As was guessed above, this isn't how buttons work in Hubitat. The values for the "pushed," "held," and "released" attributes in Hubitat (under "Current States" on the device page, for example) will always show the last button number that generated those events. They do not get "reset" at any point after the event (the real-world event or the Hubitat event). But an event on Hubitat does get generated any time any of those real-world actions happen (regardless of whether or not the value for this attribute changes, which with only one button number it never will). It is rare that you would actually need to check the value of these attributes; what you really want is to subscribe to the event. You shouldn't need a virtual switch, though it depends on what app you're using to actually perform your automation (and if it supports buttons). If you're writing a rule or using an app like Button Controller that can handle button events, then you're good.
I cannot acess the code shared some time ago.
its possible to integrate the Shelly EM with the Hubitat Hub?
Thanks
The official Shelly USA Hubitat drivers can now be found at
Note: These are different from the Hubitat built-in drivers. Hubitat developed their own Shelly drivers, while Shelly USA's were developed by @Evilborg.
Thanks, but the EM is not supported. Right?
Yes it is. Use the shelly Switch driver.
I don't have time these days to watch this thread as I work at Amazon now. When I happen to find a spare minute I'll have a lookie but don't expect a reply. All info anyone needs is in the source code if you only look at it before commenting here.
Firts of all hi to the community, my first post here. Im connecting devices to my new HE and Im stucked woth Shelly EM3. I used Shelly Switch driver from github, but Im not able to get power reading from device. All other parameters obtained from device. Any hint how to solve this?
Show me a screenshot of your preferences please.
Yes that one... Looks good to me. Is the energy being seen in the shelly phone app?
Yes and in Homey as well. Im trying HE as a possible Homey replacement, but a lot of devices doesnt work as seamless as in Homey
Turn on all the debugging and see if there are any errors. If so paste them here
I'll bet this line is the issue:
if (state.DeviceType == "SHEM")
Doesn't seem to allow "SHEM-3" to access either of the first two meters.
Should be another line just below that...
if (state.DeviceType == "SHEM-3") {
Whole section
// Shelly EM emeters
if (state.DeviceType == "SHEM") {
if (eMeter == 0 )sendEvent(name: "power", value: obs.emeters.power[0])
if (eMeter == 0 )sendEvent(name: "voltage", value: obs.emeters.voltage[0])
if (eMeter == 0 )sendEvent(name: "reactive", value: obs.emeters.reactive[0])
if (eMeter == 0 )sendEvent(name: "energy", value: obs.emeters.total[0])
if (eMeter == 1 )sendEvent(name: "power", value: obs.emeters.power[1])
if (eMeter == 1 )sendEvent(name: "voltage", value: obs.emeters.voltage[1])
if (eMeter == 1 )sendEvent(name: "reactive", value: obs.emeters.reactive[1])
if (eMeter == 1 )sendEvent(name: "energy", value: obs.emeters.total[1])
if (state.DeviceType == "SHEM-3") {
if (eMeter == 2 )sendEvent(name: "power", value: obs.emeters.power[2])
if (eMeter == 2 )sendEvent(name: "voltage", value: obs.emeters.voltage[2])
if (eMeter == 2 )sendEvent(name: "reactive", value: obs.emeters.reactive[2])
if (eMeter == 2 )sendEvent(name: "energy", value: obs.emeters.total[2])
}
state.eMeter = eMeter
sendEvent(name: "eMeter", value: state.eMeter)
}
Current code https://raw.githubusercontent.com/ShellyUSA/Hubitat-Drivers/master/Shelly-as-a-Switch.groovy
It looks unintentionally nested -- in order to ever set eMeter 0 or 1, you have to be a SHEM, and in order to hit eMeter 2 you have to be both SHEM and SHEM-3.
I think it should be something like this, no? Or just remove the check around eMeter 0 and 1 all together.
// Shelly EM emeters
if (state.DeviceType == "SHEM" || state.DeviceType == "SHEM-3") {
if (eMeter == 0 )sendEvent(name: "power", value: obs.emeters.power[0])
if (eMeter == 0 )sendEvent(name: "voltage", value: obs.emeters.voltage[0])
if (eMeter == 0 )sendEvent(name: "reactive", value: obs.emeters.reactive[0])
if (eMeter == 0 )sendEvent(name: "energy", value: obs.emeters.total[0])
if (eMeter == 1 )sendEvent(name: "power", value: obs.emeters.power[1])
if (eMeter == 1 )sendEvent(name: "voltage", value: obs.emeters.voltage[1])
if (eMeter == 1 )sendEvent(name: "reactive", value: obs.emeters.reactive[1])
if (eMeter == 1 )sendEvent(name: "energy", value: obs.emeters.total[1])
}
if (state.DeviceType == "SHEM-3") {
if (eMeter == 2 )sendEvent(name: "power", value: obs.emeters.power[2])
if (eMeter == 2 )sendEvent(name: "voltage", value: obs.emeters.voltage[2])
if (eMeter == 2 )sendEvent(name: "reactive", value: obs.emeters.reactive[2])
if (eMeter == 2 )sendEvent(name: "energy", value: obs.emeters.total[2])
}
state.eMeter = eMeter
sendEvent(name: "eMeter", value: state.eMeter)
Opps Good catch. I'll edit the driver and post the fix this afternoon.
I haven't forgotten about this. Hopefully Wednesday or Thursday I'll fix it. I work 10 hours a day at Amazon for 4 days and 3 days off and I'm pretty whipped come Wednesday..
Works perfectly.
So you added that missing directive and its working now?
Yes.