Using mqtt to shutdown home-assistant

If aceindy’s suggestion solved your problem then it’s customary to tag aceindy’s post with the Solution tag (not your own which merely implements aceindy’s example). For more information about the Solution tag, refer to guideline 21 in the FAQ.


NOTE

There’s no need to create separate automations for each command (nor is there a need to capitalize portions of an MQTT topic) and can be done with a single automation.

- id: 'home-assistant host commands'
  mode: single
  variables:
    command: "{{ trigger.payload | lower }}"
  trigger:
    - platform: mqtt
      topic: home-assistant/cmd
  condition:
    - condition: template
      value_template: "{{ command in ['reboot', 'shutdown'] }}"
  action:
    - service: "hassio.host_{{ command }}"
      data: {}
2 Likes