Comparing char received from a shell_command in a light_template value_template

Hi, I have just started using Home Assistant and I have a custom controller that I would like to add.

The following configuration works perfectly:

  platform: command_line
      command_on: "/usr/bin/curl -s -o /dev/null -X GET <URL>“
      command_off: "/usr/bin/curl -s -o /dev/null -X GET <URL>”
      command_state: "/usr/bin/curl -s -X GET <URL>”
      value_template: '{{ value == "1" }}'
      friendly_name: "Room Light"

but its supposed to be a light switch so I tried replicating it using template light and I can’t figure out how to make the value_template to work. This is what I have so far and the on / off works fine its updating the current value that doesn’t.

    wib_out_3_1: "/usr/bin/curl -s -o /dev/null -X GET <URL>“
    wib_out_3_0: "/usr/bin/curl -s -o /dev/null -X GET <URL>"
    wib_out_3_t: "/usr/bin/curl -s -o /dev/null -X GET <URL>"
    wib_pin_3: "/usr/bin/curl -s -X GET <URL>"

  - platform: template
        friendly_name: "Room Light"
        value_template: '{{ shell_command.wib_pin_3 == "1" }}'
        - service: shell_command.wib_out_3_1
#          data:
#            entity_id: switch.kitchen_lights
        - service: shell_command.wib_out_3_0
#          data:
#            entity_id: switch.kitchen_lights

wib_pin_3 is supposed to return the same get request as command_state which is 1 for on and 0 for off. No JSON or anything just a single char. What am I doing wrong with the value_template?

Rather than using a Template Light, I’d suggest keeping the switch, and then turning it into a light by using a Light Switch.

Is it possible to hide the switch from the ui?

Yes. See Lovelace UI.

Is it at all possible to do it the value_template way or can you not use expressions that way?

You can, but then you’d have to create a Command Line Sensor, and then get its value from the Template Light’s value_template. You can’t invoke a shell_command from within a template like you tried to do. So, using a Template Light, in the end, you’re creating six entities – the four shell_command's, a Command Line Sensor, and finally a Template Light. But if you use my suggestion you’re only creating two entities: the Command Line Switch and the Light Switch.

It’s just that I was trying to avoid editing the UI because in its default state it manages the UI for you.

Take control of your Lovelace UI
By default Home Assistant will maintain your user interface, updating it when new entities or Lovelace components become available. If you take control we will no longer make changes automatically for you.

Are you sure you want to take control of your user interface?



I take it you can’t have it both ways?

If you just want to hide an entity from the UI you can do that from Configuration -> Customization. Select the switch from the Entity drop-down, then at the bottom where it says “Pick an attribute to override”, select “hidden”. Then check the “Hide from UI” box and click SAVE.