Converting Smartthings switch from MQTT to new SmartThings component

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!

Not sure I follow this part. You shouldn’t need to create anything in configuration.yaml for the SmartThings entities. If you set it up via the Integrations section the switch should be in your entity registry already.

I wanted to keep the same switch name, so I remove the switch from the MQTT section. Was thinking I had to have

light:
  - platform: switch
    entity_id: switch.bedroom_switch

To use the new switch.

Not tried it but don’t you need this:

trigger.to_state

To be:

trigger.to_state.state

That got it! I needed the trigger.to_state.state

Thank you so much!