Shelly Plus H&T driver not providing device units on dashboards

I am looking for some help adding or changing the driver code so that it provides device units (IE a % sign on battery & humidity and °F on temperature) on the dashboards.

I am just not seeing where or what I might need to change it seems the the driver should be using default units but it does not.

I did also ask the developer, but thought someone in the help area might be able to point me in the right direction.

MY other post is here with screenshots:

Here is the driver Hubitat-Drivers/WebhookWebsocket/ShellyPlusH&T.groovy at master · ShellyUSA/Hubitat-Drivers · GitHub

Thanks

The developer Daniel hasn't posted on this community in many months so not sure he is still actively developing these drivers.

I took a look at the driver code and it leverages a central Library file for all the event processing so you will need to navigate to Developer tools \ Libraries Code and open the ShellyUSA.ShellyUSA_Driver_Library file.

Once you have that open, click into the code and search for "sendEvent" as those are the commands to log an event for the device. I see that none of them include a unit, here is the correct syntax to include it from HE Docs:

sendEvent(name: "colorTemperature", value: 2700, unit: "K")

Around line 1300 I see battery, 1305 I see Humidity, and lines 1309-1322 I see temperature. To add unit, taking line 1305 as an example change the code to:

getDevice().sendEvent(name: 'humidity', value: percent.setScale(1, BigDecimal.ROUND_HALF_UP), unit: '%')

ritchierich thanks for the assistance, what you provided worked for Temperature and Humidity but I have been unable to get the battery to show the % sign.

Here is line 1300 with the unit added
getDevice().sendEvent(name: 'battery', value: percent, unit: '%')

What am I missing?

Thanks

I am glad that worked on most of your attributes. I don't use this driver so not sure why it is not working for battery.

I was able to get it working by changing the type to Device, clearing the current states and then going back to the Shelly Webhook driver.

One other question is there an easy way to have the temp and humidity show as 73 instead of 73.6?

Thanks

1 Like

You can disregard that last question I figured it out, just needed to change the setScale to 0

getDevice().sendEvent(name: 'humidity', value: percent.setScale(0, BigDecimal.ROUND_HALF_UP), unit: '%')

Thanks again for the help, its been a while since I had to mess with Hubitat Drivers

1 Like

@ritchierich @XLR8ED @daniel.winks I was trying to get this to work and appreciate the work you all put in here!

For others as unfamiliar as myself with webhooks and drivers:

  • It appears that Outbound Websockets needs to be enabled through the app on the Shelly H&T 3rd gen and then rebooted, specifically it will need an entry for websockets like this: "ws://192.168.1.XXX:8123/api/shelly/ws"
  • The Shelly Driver Library needs to be loaded and the Driver (Shelly Plus H&T works for the 3rd Gen) needs to be installed, both as described above
  • The units need updating in the Library code as per above (unclear if we use " or ' )

@XLR8ED What type and where does it need to be set to "Device"?

I did not have to do any of the above, this is what I have done with the 4 H&T's I have setup: power the H&T via usb, connect to the device with the android app, install all firmware updates, and then set a static IP address. Next create the new device in Hubitat, input the IP address but do not press the save preferences button yet, next press the button on the H&T to put into programming, now in Hubitat press save preferences and then press initialize. Wait a bit for it to create the webhooks and then refresh the page, you should see the the current states populate.

Install from Hubitat Package Manager, it will allow you to choose which drivers to install and will automatically install the other necessary items.

You simply change to Device in the Type box and press save device
image

Once you do refresh the page and you will see the button to clear the current states, once done change back to the H&T Webhook in the Type box and again press save device.

Thanks for the clarifications!

  • I tried the HPM but ended up with the MQTT drivers only - I did not dig deeper for other drivers though, hence the manual load.
  • The initializing sequence may reflect what I inadvertently did. However at some point I removed the websocket part and it stopped updating. Not sure if it is a timing fluke or not.

Just do a fast search for Shelly in HPM