How often is the command line switch command_state executed

In the example command-line switch the command state is retrieved. How often is this state command executed?

The reason for the question is that the web service that I’m querying only allows a few requests per minute.

# Example configuration.yaml entry
switch:
  - platform: command_line
    switches:
      arest_pin_four:
        command_on: "/usr/bin/curl -X GET http://192.168.1.10/digital/4/1"
        command_off: "/usr/bin/curl -X GET http://192.168.1.10/digital/4/0"
        command_state: "/usr/bin/curl -X GET http://192.168.1.10/digital/4"
        value_template: '{{ value == "1" }}'
        friendly_name: Kitchen Lightswitch

It polls twice per minute (every 30 seconds).

1 Like

How can you test what string or output is being received from the command_state CURL?
I tried various syntax options and my command line switch is not updating the correct state.

      light205:
        friendly_name: "Utility wall lights"
        command_on: /usr/bin/curl -X POST 'http://192.168.1.3/luminaries.php?light=205&state=1'
        command_off: /usr/bin/curl -X POST 'http://192.168.1.3/luminaries.php?light=205&state=15'
        command_state: curl http://192.168.1.3/hass/binary.php

if I check with SSH I do get back 1 or 0 corresponding to off and on, but the state of the switch isn’t correctly changing
ssh

one thing I have noticed is the following:

if binary.php changes its output from 0 to 1 then the state of the switch will not change from “on” to “off”

if binary.php changes from 1 to 0, then the switch WILL change from “off” to “on”