Command_line switch without dummy calling of command_state

at first I thought it was bug but, then I found in some replies a mention of using a dummy command (like “echo”) and even for me it was the only way to get the correct switch states according to what the values are in the sensor.

Is there any reason why this configuration does not taking state from value_template?

  - switch:
      name: Kotel topení
      unique_id: kotel_topeni
      command_on: "python3 /config/inels/ SET Kotel_Topeni 1"
      command_off: "python3 /config/inels/ SET Kotel_Topeni 0"
      scan_interval: 1
      value_template: "{{ state_attr('sensor.topeni', 'Kotel_Topeni') }}"

until I add command_state to the configuration (even with a broken command)

# i am usinng empty echo, becase i don't have any better idea
command_state: echo

If there is a way to remove this dependency, it will definitely simplify the code and life for many others.

If there is no other option, please provide different wording in the documentation to make it clear that command_state must be used even if it returns no value.

Thank you for your work.


That’s not a feature request.
If you want the documentation to be clarified you can self-service that :wink: