Page 1 of 1

Best way to check the currect state of a (light) switch with PHP?

Posted: Saturday 20 June 2020 17:24
by razzle
I'm trying to make a dashboard for my light switches with PHP/jquery.
Something like Dashticz, only with just the stuff that I need.

I know how to get the currect state of an switch(idx device) with json.

But what would be the best way to monitor all these devices in my page?
Dashticz almost instantly detects when you put a light on.
How does this work? I guess I could make a script that checks the status of all devices each second, but this seems a bit a bit intents? so I'm guessing there's a better way to do this.. it would be great to get some advice on this :D

Re: Best way to check the currect state of a (light) switch with PHP?

Posted: Saturday 20 June 2020 19:04
by Egregius
Have look at my floorplan. Updates as frequently as you want. Only the changes are sent over the network. I have it set to pull 3 times each second.

Re: Best way to check the currect state of a (light) switch with PHP?

Posted: Sunday 21 June 2020 11:44
by razzle
Hi,

thanks for you're response! I've quickly looked at your code. If I'm right, you're using a cron that loops a curl request to json.htm?type=devices to get all statussen. Is this correct? How do you filter "only changes are sent over the network" ?

Re: Best way to check the currect state of a (light) switch with PHP?

Posted: Sunday 21 June 2020 12:56
by Egregius
cron.sh only checks that domoticz is running. If it does it fires some time based scripts. The actual statuses is sent in realtime from domoticz to php by the lua script.
There’s a huge topic about pass2php in this board.