Command line switch + statecmd

Can somebody tell me what this exactly means ?

statecmd (Optional): If given, this command will be run. Returning a result code 0 will indicate that the switch is on.

My switch is always ON :disappointed:

my switch runs a curl command to a php script . How would my php return 0 or 1 for states

please help !!!

The return code of the script your running will define the state of your command line switch.
In your case it’s a php script so start by looking at the exit function
How your going to get curl to return that code is beyond on the other hand.

thanks for your help //

i made a bash script to curl and return exit 1 or exit 0 based on curl output

thanks :slight_smile:

I didn’t think of that. Good solution.
Would you mind making a sanitized version of it and sharing it with the rest of the community? Maybe under the Share your projects category.

Just a note that you can also use the value_template to return true or false for your statecmd instead of fussing with the return code.

absolutely i will share my findings :slight_smile: thx !!

hi there …

Can you give me an example … ? thanks a lot !