Whats wrong with my value template command line switch

Hi

i have code below, but the state of my switch doesnt change, if i do a test and change the input boolean to on / off (manually) , the switch doesnt change state

from template editor, this command gives me true/false, so it seems correct

{{ is_state('input_boolean.homemode', 'on' ) }}

- platform: command_line
  switches:
    home_mode:
      friendly_name: Home Mode
      command_on: !secret home_on
      command_off: !secret home_off
      value_template: "{{ is_state('input_boolean.homemode', 'on' ) }}"

Difficult to say, as we don’t know what your commands return/

i dont have any commands to return , it doesnt even change when i manually turn on/off the input_boolean from states page
then even the switch doesnt change state

I don’t see where you change the input_boolean. If you never change it, the switch will not change. I think you better use a template switch.

for testing i am changing the input_boolean manually in the states pages
so if i turn on/off the boolean, the change for my switch should normally change

tried this, but its the same

- platform: command_line
  switches:

    home_mode:
      friendly_name: Home Mode
      command_on: !secret home_on
      command_off: !secret home_off
      value_template: "{{ states.input_boolean.homemode.state }}"

From the command_line switch docs:

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

yeah, but i dont have a command_state

eventually, i will turn on/off the boolean with an automation, and i want the switch to get the state of the boolean

Maybe it would help if you told us exactly what your end goal is.

Right now what you are trying to do won’t work.

Well, easy , when I restart hassio, I want the button to remember the state like it was before… That’s why I want to use an input Boolean… Those don’t loose state after a reboot

Ok… So you just want a “switch” that doesn’t actually do anything. That you will turn off and on with a later automation. And that you can display it’s state. But it has to remember it’s state across reboots. Is that correct?

If so then that sounds like you just need to create an input Boolean and forget about all of the rest of the extra stuff you are doing. Then just turn the Boolean off and on directly on the frontend.

indeed, thats what i am trying todo :slight_smile:
see my first post, i have an input boolean, thats my state …

when i change the state in my frontend of my boolean, the state of my switch doesnt state

i am using this also for my “template covers”, to remeber the state after reboot
the code is exactly the same…

the only difference is that my cover is a “template cover” , now my switch is a “command line switch”
maybe i need to use a “template switch” instead

offcourse my switch needs todo something :), thats my command on/off , thats working offcourse :slight_smile:

this is my code for my covers, exactly the same and working, so after a reboot i still know if my cover was open/closed

- platform: template
  covers:
    google_eetkamer:
      friendly_name: Eetkamer
      value_template: "{{ is_state('input_boolean.eetkamer', 'on' ) }}"
      open_cover:
        - service: cover.open_cover
          entity_id: cover.eetkamer
      close_cover:
        - service: cover.close_cover
          entity_id: cover.eetkamer
      stop_cover:
        - service: cover.stop_cover
          entity_id: cover.eetkamer
		  
#automations:

- alias: Screen Eetkamer omhoog
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: sensor.prog
  condition:
    - condition: template
      value_template: "{{ states.sensor.prog.state[80:82] == '01' }}"
  action:
  - service: input_boolean.turn_on
    entity_id: input_boolean.eetkamer
    
- alias: Screen Eetkamer omlaag
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: sensor.prog
  condition:
    - condition: template
      value_template: "{{ states.sensor.prog.state[82:84] == '01' }}"
  action:
  - service: input_boolean.turn_off
    entity_id: input_boolean.eetkamer

I told you already a few posts ago to use a template switch. You make it too difficult.

ow indeed, but my command on/off is actually a TCP commandline
so yes, i need to create a template switch, with the on/off command to fire my command line switch

strange that it doesnt work with a command line switch