Shelly Binding

The was a note on Units of Measurement in the release notes you need to check, maybe this creates issues here

Thanks, yes this was the hint. And you have to disable and reenable the device to get the new setting working.

I had exactly the same problem.
Here is how i solved it.

Switch          BedroomStandingLamp_onoff                                               { channel="shelly:shellybulb:BedroomStandingLamp:control#power" }
Switch          BedroomStandingLamp_mode                                                                                     
Group:Dimmer    BedroomStandingLamp_Dimmer                      
Dimmer          BedroomStandingLamp_DimmerC                 (BedroomStandingLamp_Dimmer) { channel="shelly:shellybulb:BedroomStandingLamp:color#gain" }
Dimmer          BedroomStandingLamp_DimmerW                 (BedroomStandingLamp_Dimmer) {channel="shelly:shellybulb:BedroomStandingLamp:white#brightness"}
Color           BedroomStandingLamp_Color                                               { channel="shelly:shellybulb:BedroomStandingLamp:color#hsb" }
Dimmer          BedroomStandingLamp_ColorTemp                                           { channel="shelly:shellybulb:BedroomStandingLamp:white#temperature" }
String          BedroomStandingLamp_ColorString                                         { channel="shelly:shellybulb:BedroomStandingLamp:color#full" }

BedroomStandingLamp_mode is a dummy and NOT linked to the actual mode channel.
Also definded is a string (BedroomStandingLamp_ColorString) that takes as input {red/green/blue/white/etc}

I also created the following rule

 rule "BedroomStandingLamp_mode received command"
	when
		Item BedroomStandingLamp_mode received command
	then
		switch(receivedCommand) {
				case ON : 	BedroomStandingLamp_ColorString.sendCommand("blue")
				case OFF : 	BedroomStandingLamp_ColorString.sendCommand("white")
		}
	end

In the sitemap I have

			Text 	label="Standing Lamp" icon="light" {
			Switch item=BedroomStandingLamp_onoff label="On Off" icon="switch"
			Switch item=BedroomStandingLamp_mode label="Color" icon="switch"
			Slider item=BedroomStandingLamp_Dimmer label="Dimmer" icon="slider"
			Slider item=BedroomStandingLamp_ColorTemp label="Temperature" icon="slider"
			Colorpicker item=BedroomStandingLamp_Color label="Color" icon="colorpicker"
			}

BedroomStandingLamp_mode controls the color/white through the rule
BedroomStandingLamp_Dimmer controls both the brightness of the white and the gain/brightness of the color through the Group
I even connected it to Google Assistant and I can say “Turn on/off color” to control the bulb.
Hope this helps

I checked the API spec again

  • Gen1 devices with standard power meter report Watt/Min - kw/h = Watt/Min / 60 / 1000
  • Gen 1 EM and 3EM have a so called emeter, which reports Watt/Hour - kw/h = W/h / 1000
  • Gen2 devices like Pro 3EM report Watt (so not W/Min or W/h) - kw/h = Watt / 3600 / 1000

the binding should now normalize the values to kw/h for Gen1 http and CoAP reports as well as Gen2 WebSocket reports. I hope this fixes the issue.

@tnemrap Please verify and report device types you tested. The channels totalKWH and totalReturned should return kw/h with a precision of 3 didigts.

fyi:

  • PR for BLU support has been submitted and is in review
  • Next one will be Plus Wall Dimmer US + Wall Display
  • followed by Pro Dual Cover PM
  • and I already received 3 new devices :slight_smile:

@All Please help with testing


3.4.5-DEV Gen1/Plus/Pro | 4.0.0-DEV Gen1/Plus/Pro | README | READMEbeta
Avdanced Users - Shelly Manager - Bugs/Features - API Doc | Firmware Index - Firmware Archive


Note: The DEV build is always newer than the version in the official Distro or Milestone builds

I just set up a dimmer 2 and have 5 Shelly plug S to test. I’m on the 3.3 release. Can I help test anything?

Yes :+1: ,

  • just check the power meter values of the current things (write them down)
  • Upgrade to the latest DEV build (3.4.5-SNAPSHOT, it will also run on 3.3)
  • Check READMEbeta if you are doing this the first time
  • Check the power meter channels with the new version, they should provide similar values
  • re-check after 10min, so multiple updates via Coap and http has been processed
1 Like

@markus7017, I have a question. The Shelly devices are updating quite frequently, especially the Pro 3EM. As a matter of fact, after some time, my OS switches the filesystem to read-only because of the excessive logging. This happens with openhabian on a Pi4.

Is there a way to restrict shelly logs to warnings or change the default log level to verbose to reduce the amount of events that are logged?

Thanks,
Florian

@Ltty you have already answered the question in the topic you’ve created Extensive logging of binding turns filesystem to read-only :slight_smile:

Hi there,

I’ve got a new Shelly Motion 2 but OH 3.4.4 and also OH 4.0.0.M3 does only discover a shellymotion (Gen1). There is no channel for the vibration-sensor available, and the motion-channel stays “off” when I move in front of the device (the Web UI shows a motion-alarm!).
If I try to create the thing manually, I can’t see any thing-type “shellymotion2” in the list as described in the OH-docs

Can anyone help me? Thanks!

you could go to the OH console and enter
log:set WARNING org.openhab.binding.shelly

There is also a way to filter log output, so you could suspress messages based on an regex expression. Search for log filter or stthg liked that. I know there is a post from me, but I didn’t bookmarked it. Let me know if you can’t find it

It’s even easier: RTFM

Search for Log optimization

The last PR to add Shelly BLU support is merged.

I updated calculation of consumption values for relays (Gen1+2) devices. In addition OH4 framework does stricter checking on the item unites and the binding has some issues in the channel definitions. Several other bugs has also been fixed (thanks @igi for testing).

I need help to verify that updating the relay energy channel works, show the correct values and units.
Please help!!

  • Gen 1: 1PM, 2.5, 4Pro, EM, 3EM
  • Gen 2: Plus 1PM, 2PM, Pro 1PM, Pro 2PM, Pro 3EM

Important: You need to delete and re-discover the things


3.4.5-DEV Gen1/Plus/Pro | 4.0.0-DEV Gen1/Plus/Pro | README | READMEbeta
Avdanced Users - Shelly Manager - Bugs/Features - API Doc | Firmware Index - Firmware Archive


Note: The DEV build is always newer than the version in the official Distro or Milestone builds

1 Like

I’ve tried the current DEV version (from yesterday) with a brand new OH 4.0.0.m3 installation, but there is no way to add a shelly-motion2. It is discovered as a shellymotion (gen1) and the motion-channel doesn’t change when I move in front of the device (the WebUI of the device shows a motion-alarm and the mqtt-state changes).
How do I add a shelly motion gen2 correctly?

I tested my 2.5 and it fits. 20 watts on channel 1 according to WebUI of the device, 20.41 watts in OH. Channel 2 is not in use atm but the accumulate watts value was 20.41 too.

OH 4.0.0.M3
Binding DEV-Ver. 4.0.0.202306272109

Hi Markus,

I think the calculations for the totalkWh on Gen2 - I’m using a Plus 1PM - is wrong. Per API documentation the aenergy.total object is returning Watt-hours which matches my observations. So you may need to change the calculations from:

sm.total = emeter.total = rs.aenergy.total / 3600;

to

sm.total = emeter.total = rs.aenergy.total / 1000;

to report kWh values in that channel.

Thanks!

Hmm, documentation says “In Watt”

apower

number

Last measured instantaneous active power (in Watts) delivered to the attached load (shown if applicable)

that was the reasons why I used / 3600 (which is also wrong)

I created an updated build with / 1000, please verify (relevant for all Gen2 devices with power meter, not Gen1)

fyi: Tonight is a Allterco/Shelly live presentation of new devices and updates
https://www.facebook.com/hashtag/newshellydevices

356659699_572009165139006_3180194852472831434_n

Hi Markus,

apower is the momentary Power drawn. You shall look at aenergy.total for totalkWh.

Will try it anyway



 ok, we are getting there. Now the item reports 1/1000th of what I’d expect. Might be a UoM thing, not sure where the gratuitous 1000 scaling is coming from.

Hi Markus.

when turning on DEBUG log mode, I see the following line:

2023-06-29 15:12:36.662 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellyplus1pm-84cca8770384: Channel meter#totalKWH updated with 0.055 kWh (type class org.openhab.core.library.types.QuantityType).

I’d expect to see ~55kWh as I see from the raw data which reports aenergy.total in Wh:

2023-06-29 15:12:36.661 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplus1pm-84cca8770384: NotifyStatus update received: {"src":"shellyplus1pm-84cca8770384","dst":"shellyplus1pm-84cca8770384","method":"NotifyStatus","params":{"ts":1.68804438064E9,"switch:0":{"id":0,"aenergy":{"total":54505.852,"by_minute":[9156.128,9218.711,9203.785],"minute_ts":1688044379}}}}

So I think you shall remove the " / 1000" all together:

sm.total = emeter.total = rs.aenergy.total;

Thanks!