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

Moderator: leecollings

Post Reply
razzle
Posts: 2
Joined: Saturday 20 June 2020 17:16
Target OS: Linux
Domoticz version:
Contact:

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

Post 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
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

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

Post 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.
razzle
Posts: 2
Joined: Saturday 20 June 2020 17:16
Target OS: Linux
Domoticz version:
Contact:

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

Post 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" ?
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

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

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest