DanielOgorchock / OmniThing

OmniThing turns your ESP32, ESP8266, Raspberry Pi, Linux Computer, or Windows Computer into a SmartThings composite Device. It is being developed as a cross-platform successor to ST_Anything.
GNU General Public License v3.0
64 stars 16 forks source link

Speed of actioning an ST operation #15

Open sfalvey opened 5 years ago

sfalvey commented 5 years ago

I have 24 devices configured using commands. I have optimised my code so that they return in < 1second providing the status of the device being controlled. This means that the entire polling loop is taking up to 30 seconds. I have the polling interval at 180 seconds with a 5 second gap between each device.

But, the devices are being polled for their status continuously in a loop. So its can take up to 1 minute (2x30 seconds) for an on/off action to be actioned by omnithing and up to 2 minutes for the status to appear in the ST app. I also have everything set to multithread switched on.

  1. Is it possible to decouple the actioning of ST commands from the status updates?
  2. is it possible to return the result of the command back to ST immediately?
  3. why is my config running the polling loop continuously rather than every 3 minutes?
DanielOgorchock commented 5 years ago

That's an interesting problem. I haven't tried adding more than a couple commands at a time. The contact sensor actually has a constantPoll option that you can disable if you only want to poll on your triggers. I assume you're using the Switch device type though. I'll add a new input type that will run another input in a background thread. That shouldn't take long for me to implement.

A hacky, temporary solution you could use is have a separate script running on your machine that loops polling all the data you need. It can then write the outputs to files on your filesystem. The omnithing commands can just read those files then which should be really fast.

I'll try to add the asynchronous input type tonight or tomorrow.

sfalvey commented 5 years ago

Good idea, ST is not the only thing that could use the current status values so using a status file would be useful elsewhere.