Shelly Binding

Is CoIoT enabled?

Yes

I don’t want to interrupt the discussion but can anyone suggest a configuration for a dw2 sensor that does not drain the battery like crazy? I installed three of them not long ago and thought they broke after two months or so because they did not react anymore but the latest battery level was still at about 60% (which was really bad already). However it turned out that the battery was just too low to wake the device


Does it make sense to invest in another set of batteries or should I just dump them completely :sweat_smile:

Mine have longer life. I have 8 pieces DW2. This one as an example is after 1 year at 91%.

Settings (bold marked are important):

  • Tilt: enabled

  • Vibration: enabled

  • Wake Up By Lighting: disabled

  • Temperature Treshold: 1.5

  • no I/O + Sensor Actions

  • static IP address

  • current firmware v1.12.1

  • Batteries: CR123A Kraftmax Pro, 20 pieces for about 30 Euro.

1 Like

I’ll give it another try. Mine looked more like this. It died at 67%

Hi all,

my Shelly Manager doesn’t work anymore.
The screen message in the browser is:
„Exception:java.lang.NullPointerException
Check openHAB.log for details.
[Return to Overview]“

But there isn’t any information in openhab.log and restart didn’t help.

Any hint appreciated.

Which binding version are you on? I recommend dev version which is available here.
Markus might not be that present here anymore and there are definitely reasons for that (e.g. working on a new beta) but the latest dev version was created last week.

Hi,

I installed a Shelly RGBW2 yesterday to replace a Gledopto RGBW controller. The Gledopto worked nicely in conjunction with a Conbee II stick inside openHAB but it dropped off from the Zigbee network in a non-reproduceable way so I decided to go for a WiFi solution.
Now, I made some observations from which I am not sure if they are even bugs:

1. Sending HSB value whereas B=1%
When sending a command like that to the RGB channel:

val String hsb = ("29,74,1")
Farbe_Bett_RGB.sendCommand(hsb)

with the item

Color           Farbe_Bett_RGB
                "Farbe Bett RGB"
                (Bett_RGB)
                {   channel ="shelly:shellyrgbw2-color:<ID>:color#hsb",                    
                    homekit="Lighting.Hue, Lighting.Saturation, Lighting.Brightness" }

The light does not turn on although even the web page shows it is switched on:

It turns visibly on when sending a brightness value higher than 10:

val String hsb = ("29,74,11")

However, I can use the slider on the shelly web page to put the RGB channel brightness to 1% and then it works.
With deconz it was not problem using values like 1% brightness. Is there maybe an issue in the API of Shelly?

2. Reducing brightness of color channel to 0%
When I reduce the brightness of the colored light via the slider inside the homekit the color changes also and when switching on the light again it is set to a weird value:

Situation before dimming to 0% brightness in homekit


Then I put the brightness with the slider 0% and then bring it up again. This is now what I see in homekit:

The events.log shows:

2023-01-25 09:25:07.205 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Farbe_Bett_RGB' changed from 0,100,49 to 0,100,0
2023-01-25 09:25:07.231 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Farbe_Bett_RGB' received command 0,100,0
2023-01-25 09:25:07.232 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Farbe_Bett_RGB' predicted to become 0,100,0
2023-01-25 09:25:07.566 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Farbe_Bett_RGB' changed from 0,100,0 to 0,0,0
(...)
2023-01-25 09:25:26.973 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Farbe_Bett_RGB' received command 0,0,49
2023-01-25 09:25:26.974 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Farbe_Bett_RGB' predicted to become 0,0,49
2023-01-25 09:25:26.978 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Farbe_Bett_RGB' changed from 0,0,0 to 0,0,49

Why is not the previous red light?

3. When setting brightness to 0 in the white channel and the color channel was switched off, the color channel is switching on

So, when I only have the white channel switched on and I turn down the brightness to 0 sometimes the colored light switches on to maximum brightness based on the previous color.
Is this maybe due to the fact that the RGBW2 handles both channels (white and color) whithin one power channel?
In deconz both light types were handled as two different lights. A white light and an RGB light which I could also handle separately in openHAB and thus also inside homekit.
The fact that the power channel is for both lights makes the handling it a bit weird.

In case both lights are turned on, how can I turn off one without turning off the other one?
I tried some synchronization mechanism but it does not really work as expected:

Switch          Bett_LED_OnState // Shall only be switched off if both lights have been switched off
                { channel ="shelly:shellyrgbw2-color:<ID>:control#power" }

Group:Switch:OR(ON,OFF) gBett_OnState

Switch          OnState_Bett_RGB // This is used to show the state of the RGB light in homekit
                (Bett_RGB, gBett_OnState)
                { homekit="Lighting.OnState"}

Color           Farbe_Bett_RGB
                "Farbe Bett RGB"
                (Bett_RGB)
                {   channel ="shelly:shellyrgbw2-color:<ID>:color#hsb",                    
                    homekit="Lighting.Hue, Lighting.Saturation, Lighting.Brightness" }

Switch          OnState_Bett_Weiss // This is used to show the state of the white light in homekit
                (Bett_Weiss, gBett_OnState)
                { homekit="Lighting.OnState"}

And the syncing rule:

rule "Lichter-Schlafzimmer: OnState synchronisieren"
when Member of gBett_OnState changed
then
	val command = if(gBett_OnState.state == ON) ON else OFF        
        if(Bett_LED_OnState.state != command) {
                Thread::sleep(500)
                Bett_LED_OnState.sendCommand(command)
                logInfo("Lichter-Schlafzimmer: OnState synchronisieren", "gBett_Onstate changed to " + gBett_OnState.state)               
        }
end

I am using openHAB 3.4.1 Release Build and would really appreciate your support here.

Many thanks,
Oliver

Hi,
I try to help


  1. the Shelly RGBW2 has a RGB Channel “HSB-Type”, a color-gain channel and a white channel.
    if you want to change the brightness with HSB Command i recommend to set the gain channel at 100%.
    As I startet with openhab and Shelly I was not familiar with HSB-Type commands and linked the Gain-Channel to my “Brightness”-Slider.
    So I leave HSB-Type brightness always at 100 and change the brightness with the gain channel.
    Maybe if your gain channel is 20% and HSB brightness at 1% its too dark.

  2. I saw if I send HSB-Type brightness to 0 (i.e. “240,100,0”) the color in the webui from the shelly changes to white. If you send brightness again maybe the last color is white


  3. my powerchannel is always on in the shelly webui. I saw this, created a rule to turn power off, but it doesnt work really good. So I dont look at it anymore
 if both channels - rgb and white - are off its good for me. I dont know why it’s on although both channels are off.
    If you want to turn off a light send brightness 0 :wink:

Greets

1 Like

Brilliant! Thanks a lot for this “starter” help.
The behaviour seems to differ quite a lot from the previous controller.

I tried now

gain 100 and hsb-brightness 1 doesnt work
 it starts to light at brightness 10. then I can dim to brightness 7.
But brightness 100 and gain 1 does work. If you want it darker I would say you shorten your LED-Stripe :smiley:
I hope you get want you want.
Greets

Hehe, thanks for checking out.
I will now do it as you said: The gain channel will be handled as the brightness and the “B” in the HSB commands will always be set to “100”.

I did a quick test right now as well (thanks to MS Teams outage :-D) and it behaved much better than before!

OK, all working smoothly.
Still, I try to really switch the light off when no channel is used as the web UI constantly shows me values between 2W and 7W even when both channels have a brightness/gain of 0.

This is my attempt, it looks like it works:
The rule

rule "Lichter-Schlafzimmer: OnState synchronisieren"
when Member of gBett_OnState changed
then
	val command = if(gBett_OnState.state == ON) ON else OFF        
        if(Bett_LED_OnState.state != command) {
                Thread::sleep(500)
                Bett_LED_OnState.sendCommand(command)
                logInfo("Lichter-Schlafzimmer: OnState synchronisieren", "gBett_Onstate changed to " + gBett_OnState.state)                
        }
end

The items

Switch          Bett_LED_OnState
                { channel ="shelly:shellyrgbw2-color:<ID>:control#power" }

Group:Switch:OR(ON,OFF) gBett_OnState

Switch          OnState_Bett_Weiss
                (Bett_Weiss, gBett_OnState)
                { homekit="Lighting.OnState"}

Switch          OnState_Bett_RGB
                (Bett_RGB, gBett_OnState)
                { homekit="Lighting.OnState"}

And the rules to keep everything in sync. :smiley:

rule "Lichter-Schlafzimmer: Helligkeit weiss aktualisieren"
when Item OnState_Bett_Weiss changed
then
        logInfo("Lichter-Schlafzimmer: Helligkeit weiss aktualisieren", "OnState_Bett_Weiss changed to " + OnState_Bett_Weiss.state)

        val command = if(OnState_Bett_Weiss.state == ON) ON else OFF
        if((Helligkeit_Bett_Weiss.state as Number) == 0 || command == OFF) Helligkeit_Bett_Weiss.sendCommand(command)
end

rule "Lichter-Schlafzimmer: Status LED weiss in Homekit aktualisieren"
when Item Helligkeit_Bett_Weiss changed
then
        logInfo("Lichter-Schlafzimmer: Status LED weiss in Homekit aktualisieren", "Helligkeit_Bett_Weiss changed to " + Helligkeit_Bett_Weiss.state)

        val command = if((Helligkeit_Bett_Weiss.state as Number) > 0) ON else OFF // on liner if/else
        if(OnState_Bett_Weiss.state != command) OnState_Bett_Weiss.sendCommand(command)
end

rule "Lichter-Schlafzimmer: Helligkeit RGB aktualisieren"
when Item OnState_Bett_RGB changed
then
        logInfo("Lichter-Schlafzimmer: Helligkeit RGB aktualisieren", "OnState_Bett_RGB changed to " + OnState_Bett_RGB.state)
        val command = if(OnState_Bett_RGB.state == ON) ON else OFF
        Helligkeit_Bett_RGB.sendCommand(command)   
end

rule "Lichter-Schlafzimmer: Status LED farbig Bett in Homekit aktualisieren"
when Item Helligkeit_Bett_RGB changed
then          
        logInfo("Lichter-Schlafzimmer: Status LED farbig Bett in Homekit aktualisieren", "Farbe_Bett_RGB changed to " + Farbe_Bett_RGB.state)        
        
        val command = if((Helligkeit_Bett_RGB.state as Number) > 0) ON else OFF
        if(OnState_Bett_RGB.state != command) OnState_Bett_RGB.sendCommand(command)
end

By doing so it is ensured that the On/Off button in homekit is either up to date when brightness was changey by a rule.
Contrary to this: In case I push the On/off button in homekit the brightness gets adjusted but we avoid endless loops here by checking the current condition of the property.

The rule on top of this post makes sure that the power is switched off/on when all lights have reached brightness “0”/when at least one light has a brightness greater than “0”.

I‘m on stable release 3.4.1

fyi: I‘ll back at the weekend from vacation and will then look at all questions. I‘m glad so many peplr are benefiting from the binding😀

7 Likes

Hi,

do you know if there is already a releade available for OH 4.0.x ?

yes, there is. Just read a little bit up in my post. There you’ll find a link.

Every binding in 3.4 is available in 4.0 SNAPSHOTS.

It is very strange but the shelly manager is working again although I didn’t touch the system.

I did :wink: