Problems with command line switch status update

I have a smart plug connected via zwave to a toon thermostat. I can control this via a command line switch. Turning the thing on and off works. But getting the status is the hard part.

When calling http://toon-ip:10080/hdrv_zwave?action=GetBasic&nodeID=5
the thermostat returns a json:

{
"value":"0xFF",
"nodeId":"5"
,"result":"ok"
}

where the value changes from 0x00 to 0xFF when turned on.

Based on the documentation found i put this in the configurations.yaml to control the smart plug and reads its status:

switch:
  platform: command_line
  switches:
    neo_coolcam_lampjes:
      command_on: '/usr/bin/curl "http://toon-ip:10080/hdrv_zwave?action=basicCommand&nodeID=5&state=1"'
      command_off: '/usr/bin/curl "http://toon-ip:10080/hdrv_zwave?action=basicCommand&nodeID=5&state=0"'
      command_state: '/usr/bin/curl "http://toon-ip:10080/hdrv_zwave?action=GetBasic&nodeID=5"'
      value_template: '{"value":"0xFF","nodeId":"5","result":"ok"}'

But the command state doesn’t ever change the switch to on.
Because there is no error (not even in debug) I don’t know what’s going on.

Where am I going wrong?

Try this in your value_template:

{% if value_json.value == "0xFF" %}
  on
{% else %}
  off
{% endif %}

Thanks for the input. I implemented this way:

  command_on: '/usr/bin/curl "http://toon-ip:10080/hdrv_zwave?action=basicCommand&nodeID=6&state=1"'
  command_off: '/usr/bin/curl "http://toon-ip:10080/hdrv_zwave?action=basicCommand&nodeID=6&state=0"'
  command_state: '/usr/bin/curl "http://toon-ip:10080/hdrv_zwave?action=GetBasic&nodeID=6"'
  value_template: >
   {% if value_json.value == "0xFF" %}
     on
   {% else %}
     off
   {% endif %}

Unfortunately no change. I can switch the switch, but the status isn’t updated.

What is the result of the “command_state” command if you just run that when it is on?

Also I just looked in the docs and it looks like I led you wrong on the value_template.

Try this instead:

value_template: '{{ value_json.value == "0xFF" }}'

1 Like

That’s it!

Thanks!

It’s a bit slow to update, but that’s ok.