Get the state value

How do I get the current state of the led( in : true or false ) and store it in a variable in a php page so that I can check if the current state of the led is on or off ?

Hi, did you check out the API explorer for a connected device? Best.

Yes, it is connected to the dashboard and works perfectly on thinger.

I have deployed the thinger on my own server and I’m using my own toggle button to switch on and off an led. I’m using the following code to achieve this:

I am able to control my device in my custom dashboard, however, if I switch on the device and refresh the page, the toggle button will be off when actually the led is on.

Is there a way to fix this? How do I GET the current state of the device?

Thank you.


you can issue a GET request over the same URL you are issuing the POST, ending with /api. If the resource is correctly implemented, i.e., via macro digitalPin, it will return the current device state. It is always useful to open the Google Chrome developer console to see the HTTP requests the web client is doing over the REST api.

Hope it helps!

1 Like

Could you please share the code?