BobRak / OpenHAB-Smartthings

53 stars 54 forks source link

Slow Feedback from SmartThings Sensors To OpenHAB #4

Closed matdmiller closed 7 years ago

matdmiller commented 7 years ago

I am experiencing pretty slow feedback from the my smart things sensors back to openhab. For example motion sensor states and power meter states are taking from 5 to 45 seconds to update in openhab. Is there something I can do to improve this?

BobRak commented 7 years ago

I have the Smartthings outlet which includes a power meter. I've seen a delay as well with the power meter but I don't think it has been more than 10-15 sec. I think that is just how long the sensor is waiting to send an update to the hub. That is just my guess. But, it needs to wait a reasonable time to get a stable reading.

If you want to try to isolate where the delay is coming then I would recommend opening the log window in the Smartthings developers console and tail the openHAB logs. Then when you change the switch on the outlet you can see how long it takes for the change to show up in smartthings and in openHAB.

Please let me know what you find.

fx commented 6 years ago

Hey @BobRak, here's some more info:

I'm seeing request delays of roughly ~10s for any POST to /smartthings/state from the smartthings device. From a quick glance, it looks to me as if there is some rate limiting in effect and it's using a single queue to work through any updates. As such, updates are incredibly delayed.

It's not that the device handler's deviceNotification is blocking, it's definitely the hubAction going into a queue being walked off one by one with about 10s delay in between jobs.

They do have a rate limit of 250 events per minute, saying any events past 250 would be dropped until 60 seconds are up. Doubt that's the cause though, I'm nowhere near that number.

I don't see any information alluding to limits in HubAction or sendHubCommand ~and can't even tell at a glance how the returned HubAction gets sent.~ returned HubActions are automatically dispatched

Can you see why that is and if there's a workaround?

Edit: funny enough, I discovered this thread by someone who later got hired by SmartThings apparently about the latency of external events.

Update: I've opened https://github.com/BobRak/OpenHAB-Smartthings/pull/12 - empty body/204 response choked up the queue.