I have a small automation I’m trying to switch from Smartthings and MQTT to the new Smartthings component.
I’ve made the necessary changes to configuration.yaml to remove the MQTT switch entry and added a light entry for the switch. These are visible in the front end and in the dev tools. Where I’m having my problem is the automation to turn it on or off.
MQTT version (that works):
- id: '1542223087645'
alias: Bedroom Switch
trigger:
- platform: mqtt
topic: smartthings/Bedroom Switch/switch
action:
entity_id: light.b_room
service_template: >
{% if trigger.payload == 'on' %}
light.turn_on
{%- else -%}
light.turn_off
{% endif %}
New version (that doesn’t work):
- id: '1542223087645'
alias: Bedroom Switch
trigger:
- entity_id: switch.bedroom_switch
platform: state
to: 'on'
- entity_id: switch.bedroom_switch
platform: state
to: 'off'
action:
entity_id: light.b_room
service_template: >
{% if trigger.to_state == 'on' %}
light.turn_on
{%- else -%}
light.turn_off
{% endif %}
I know it has to be using the trigger.to_state, trigger_payload is for MQTT only.
Any suggestions?
Thanks!