Problem after command_line changes

Simple one I hope, I just can’t see it.
I have a switch that calls a command to turn my media PC off
I have a switch that used WOL to turn my media PC on
I have a switch template that combines these to give a nice user friendly on-off switch in the UI

Since reformating the YAML to new command_line the template will not switch on the media PC. the WOL switch works fine, just seems my template switch is not calling it.

Heres where I am:

command_line:
  - sensor:
      name: CPU Temperature
      command: "cat /sys/class/thermal/thermal_zone0/temp"
      # If errors occur, make sure configuration file is encoded as UTF-8
      unit_of_measurement: "°C"
      value_template: "{{ value | multiply(0.001) | round(1) }}"

  #Red Dwarf Control - Switch off command line
  - switch:
      name: REDDWARF_OFF
      #template calls this switch as toggle, so same action if on or off
      command_on: >
        curl http://192.168.50.87:8000/?action=System.Shutdown
      command_off: >
        curl http://192.168.50.87:8000/?action=System.Shutdown

switch:
  #Red Dwarf Control - switch for wake on LAN
  - platform: wake_on_lan
    #name: REDDWARF_ON (name does not seem to be working)
    mac: 10:7B:44:17:C5:EF

  #Red Dwarf Control - Switch template to show in UI. combines
  - platform: template
    switches:
      reddwarf:
        unique_id: RedDwarf_User_Switch
        value_template: "{{ states.binary_sensor.reddwarfiii_status.state }}"
        turn_on:
          - service: switch.turn_on
            target:
              entity_id: switch.wake_on_lan #should be switch.REDDWARF_ON?
        turn_off:
          - service: switch.toggle
            target:
              entity_id: switch.REDDWARF_OFF

Case matters in linux/python.
I don’t think there’s such an entity_id. Take a look in Dev Tools/states.
Try switch.reddwarf_off

That bit works though, but I agree case seems unusual.

Will try changing tomorrow.

OK Stupid me. Turned out to be a hardware issue that must have occurred at exactly the same time as I started modifying my YAML.
So my YAML is good - while turn-off did work I think best practice is lower-case as VDRainer suggested
if anyone is interested this works on a windows 10 machine using Airytec Switch Off. Thats what accepts the CURL

binary_sensor:
  #RedDwarf Control - RedDwarf is online
  - platform: ping
    host: 192.168.50.87
    scan_interval: 30
    count: 4
    name: "RedDwarfIII Status"

template:
  #RedDwarf Control - set state (there is a delay during boot/shutdown)
  - sensor:
      - name: "Red Dwarf III Status"
        icon: mdi:desktopclassic
        state: >
          {% if is_state('binary_sensor.reddwarfiii_status', 'on') %}
            Switched On
          {% else %}
            Switched Off
          {% endif %}

command_line:
  #Red Dwarf Control - Switch off command line
  - switch:
      name: RedDwarf_Off
      #template calls this switch as toggle, so same action if on or off
      command_on: >
        curl http://192.168.50.87:8000/?action=System.Shutdown
      command_off: >
        curl http://192.168.50.87:8000/?action=System.Shutdown

switch:
  #RedDwarf Control - switch for wake on LAN
  - platform: wake_on_lan
    name: RedDwarf_On
    mac: 10:7B:44:17:C5:EF

  #RedDwarf Control - Switch template to show in UI. combines
  - platform: template
    switches:
      reddwarf:
        unique_id: RedDwarf_User_Switch
        value_template: "{{ states.binary_sensor.reddwarfiii_status.state }}"
        turn_on:
          - service: switch.turn_on
            target:
              entity_id: switch.wake_on_lan #RedDwarf_On
        turn_off:
          - service: switch.toggle
            target:
              entity_id: switch.reddwarf_off

image

I probably don’t need the sensor and the switch but I find it useful to identify if information HA has is out of sync

1 Like