Missing Device in action automation

Hello,
I would like to create a new automation by the web interface to turn off my light after 2 hours.
But, when I want to chose my device in the action paragraph, it’s missing while it’s present in my configuration. (It’s the Sonoff sock which works with MQTT).
Do you know why and how can I add in this device’s list ?

If you chose the light.turn_off service and your entity is a switch it wont show up. Try the switch.turn_off action.

Alternatively you can make your switch into a light using the light switch:

Thanks for your return but I used the new function of the 0.99 version, where you can use the device directly (https://www.home-assistant.io/blog/2019/09/18/release-99/).

Can you help with the function ?

Oh right. No idea sorry. Never used it.

It’s very easy to do in YAML:

automation:
- id: light_off_after_2_hours
  alias: 'Light Off After 2 Hours'
  trigger:
    platform: state
    entity_id: switch.your_switch_entity_id_here ## or light
    to: 'on'
    for: 
      hours: 2
  action:
    service: switch.turn_off ### or light.turn_off if it is a light
    entity_id: switch.your_switch_entity_id_here

You look up the entity ids in the developer tools states menu.

No problem and thank you for your help, I did it with your example.

PS : I’m a beginner on HA , and I hopened to write the automation with that. :wink: Thanks

If someone here knows they’ll hopefully reply.

I think the issue is the device option is new and does not support all types of devices yet. In the meantime, instead of selecting device in the action, select “Call service”. You’ll also need to know the “entity_id” of the device. You can find this on the States page (under Developer Tools.) Then check this out from the 0.100 release notes for an example of how to use the “Call service” action.

1 Like