Shelly Device Handlers for Hubitat

Mine is a 1pm plus. So not the 1pm.

Yes, I meant 1PM Plus.

Link is specific to your HE hub IP, device ID (ID obtained by this Shelly Plus 1PM when added to HE) and Maker API token. In my case it looks like this (bold need to be changed to your specifics):
http://192.168.1.30/apps/api/33/devices/419/refresh?access_token=xxxxxxxxxxxx

Tried applying my specifics and adding that URL to the Shelly Webhooks and HE still doesn’t refresh until I hit refresh in HE. Not sure what I’m doing wrong…

Do you have Maker api installed and this device added to it? ID of device can be obtained from link once you are on device page.

I have the Plug S and I'm wondering that you have the same problem.
My 3 plugs have the same FW but only one of them sends properly the energy property. From the HTTP response I get:
{"power":14.44,"overpower":0.00,"is_valid":true,"timestamp":0,"counters":[0.000, 0.000, 0.000],"total":0}

It should be under total key.
I'm not sure what's the problem where only one of my switches send that value properly and two others send just 0.

Someone had that kind of problem?

OK,
nvm, I had no gateway and dns configured on them and they were on an old FW. After update it's working fine.

I do have a refresh line in the code that should do this anytime you do a on/off within the dashboard or device page....

def sendSwitchCommand(action) {
    if (txtEnable) log.info "Calling ${action}"
    def params = [uri: "http://${username}:${password}@${ip}/${action}"]
try {
    httpGet(params) {
        resp -> resp.headers.each {
        logDebug "Response: ${it.name} : ${it.value}"
    }
} // End try
        
} catch (e) {
        log.error "something went wrong: $e"
    }
    runIn(2, refresh)
}

The code does not have a toggle function.

I was finally able to get this to work using poll as the action vs refresh. Thanks for the help

Sorry, toggle is the wrong word. I could get the on and off state to refresh if I was using the on and off buttons on the device page but if I turned the switch on and off when directly connected to the Shelly the state in Hubitat would not refresh until I hit the refresh or poll button on the device page.

I was able to get it to to work using Maker API and webhooks suggested by @igor.lehotan . I used the “Poll” action vice “Refresh”

Thank you for the development

Poll actually calls the refresh function -- glad you got it working but you are the first person to have this issue so far. Seems to work just fine on my end.

Just a heads up -- The plus driver for the 4Pm pro will be changing its name very soon as this code can be used for all PLUS (GEN2) devices.

1 Like

May I have a question? What is the difference in terms of nitegration of Shelly and HE compared to HomeAssistand or Homey? I noticed, that for example power metering is refreshed in HE only once the device is refreshed, but in case of HA ang Homey its instant. In case I want do to do more frequent reading in HE and do it over the refresh functionality, the single device frequent refresh (once a minute) consumes quite a significant amount of HE resources compared to the rest of the devices. Am I missing something, or I just need to get used to this?

Without being an expert, I think HA is using CoAP and HE http for the driver. CoAP is instand messaging.

Could not understand whether the Shelly 4Pm driver supports power measurement.
Can someone confirm please?
Thanks,
Amit

Yes it does, but only in given refresh intervals ot when polled manualy.

Great. Thank you. This is good enough for my needs.

Hi @Evilborg, Im playing with Shelly Plus devices (1PM Plus) and discovered one bug with 4PM driver or shelly device itself. Once I do poll device from HE, it becomes for some reason unavailable. When I go directly to device IP its unavailable for a while as well. Seems like shely cant handle this request or its overloaded with it and becomes unavailable. Same is happening on other Shelly 1PM Plus. Do you have any idea what should be wrong please?

Here is info from logs:
dev:11222022-03-29 13:42:34.962 errorsomething went wrong: org.apache.http.conn.ConnectTimeoutException: Connect to 192.168.1.90:80 [/192.168.1.90] failed: connect timed out
dev:11222022-03-29 13:42:34.962 errorsomething went wrong: org.apache.http.conn.ConnectTimeoutException: Connect to 192.168.1.90:80 [/192.168.1.90] failed: connect timed out
dev:11222022-03-29 13:42:24.942 errorsomething went wrong: java.net.SocketTimeoutException: Read timed out
dev:11222022-03-29 13:42:24.942 errorsomething went wrong: java.net.SocketTimeoutException: Read timed out
dev:11222022-03-29 13:42:14.905 infoCheck Device FW
dev:11222022-03-29 13:42:14.884 infoCheck Device FW
dev:11222022-03-29 13:42:14.389 infoCheck Device FW
dev:11222022-03-29 13:42:14.181 errorsomething went wrong: groovyx.net.http.HttpResponseException: status code: 400, reason phrase: Bad Request
dev:11222022-03-29 13:42:14.027 infoExecuting 'poll'

Has nothing to do with my driver and all about your network.

1 Like

Hi, first of all just wanted to say kudos to sgrayban for the really good work developing the drivers for these shelly devices - they have all been working brilliantly for me! :pray:

I could use some help understanding the 'shelly as a switch' notes in the readme file of the github page please.

I have enabled MakerAPI and added the shelly devices. For the next instruction "When you have the MakerAPI URL string for 'refresh'....." I'm struggling to follow. Where do I get this URL string? I can see the following at the bottom of my MakerAPI app but none of them have 'refresh' in the name:

Get Device Info (replace [Device ID] with actual subscribed device id
http://IP/apps/api/411/devices/[Device ID]?access_token=x

Get Device Event History (replace [Device ID] with actual subscribed device id
http://IP/apps/api/411/devices/[Device ID]/events?access_token=x

Get Device Commands (replace [Device ID] with actual subscribed device id
http://IP/apps/api/411/devices/[Device ID]/commands?access_token=x

Get Device Capabilities (replace [Device ID] with actual subscribed device id
http://IP/apps/api/411/devices/[Device ID]/capabilities?access_token=x

Send Device Command (replace [Device ID] with actual subscribed device id and [Command] with a supported command. Supports optional [Secondary value]
http://IP/apps/api/411/devices/[Device ID]/[Command]/[Secondary value]?access_token=x
Send POST URL (replace [URL] with actual URL to send POST to (URL encoded)
http://IP/apps/api/411/postURL/[URL]?access_token=x

Currently my switch modules are not showing their current state in HE (I can control them without issues) and I'm assuming this is because I haven't been able to complete this last step?

I also can’t seem to add the devices to a dashboard - i’ve tried using bulb, switch and relay but not of those work. Could the issue be related to not having completed the step mentioned in my post above?