Run Automation with Scene Trigger

Hi All,

I have an mqtt fan which I need to control with my HA Scene. I couldn’t find a way to trigger the fan control using HA Scenes, so I thought to build an automation that detects the scene trigger and sends mqtt payload to control the fan off. Below is my automation code so far. When I trigger the scene adios I want the following automation to be run which will then publish mqtt to off my fan. So far this is not working.

- id: '1573695194342'
  alias: New Automation
  description: ''
  trigger:
  - entity_id: scene.adios
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      data:
        payload: '0'
        topic: sonoff_fan/cmnd/FanSpeed
    service: mqtt.publish

Spaces and indentation is very important in YAML. Here is an example from the online documentation.

automation:
  trigger:
    platform: state
    entity_id: device_tracker.paulus, device_tracker.anne_therese
    # Optional
    from: "not_home"
    # Optional
    to: "home"

    # If given, will trigger when state has been the to state for X time.
    for: "01:10:05"

scene does not have a state on or of, it is always ‘scening’. You trigger will not work like this.

even though you can active a scene using the service scene.turn_on it would still be scening. you can’t turn_off a scene: https://www.home-assistant.io/integrations/scene/

you could probably write a small script with the service scene.turn_on: scene.adios, and trigger from the scripts last_triggered state.