Command_line switch only takes value_template with command_state

Hi there!

I am playing around a bit with HA to automate my sunscreens. These can be controlled using the command_line switch. However, since they don’t have a command_state feedback, but feedback from a mqtt binary switch I set up the configuration as follows:"

- platform: command_line
  switches:
    screen_x:
      friendly_name: "Screen x"
      value_template: "{{ is_state('binary_sensor.screen_x', 'on') }}"
      command_on: "command"
      command_off: "command"

However, the switch in the frontend shows up as 2 flashes instead of the on/off switch (first vs. second in the picture below)
2020-10-12_15h54_59

When I add a dummy command_state as in the code below, the binary_sensor in value_template is evaluated and the switch shows up as a toggle switch.

- platform: command_line
  switches:
    screen_x:
      friendly_name: "Screen x"
      command_state: ""
      value_template: "{{ is_state('binary_sensor.screen_x', 'on') }}"
      command_on: "command"
      command_off: "command"

Am I missing the logic behind the necessity of adding the command_state, or is it a bug?

By the way the documentation is stating the command_state is optional (https://www.home-assistant.io/integrations/switch.command_line/)

I think command_state is only optional if you want the switch to be optimistic, i.e. assumed state and ‘two flashes’ for control.

That’s an interesting work around.