Learning: Smart Plug won't stay on

I’m learning as I go forward, so I chose a seemingly simple automation to grow from.

  • HA OS in a VM via UnRaid
  • using Innr Smart Plugs with Hue Hub
  • connected plugs to the hub via the Hue app

I know that it is something simple that I’m missing, but I’m not figuring it out based on my searches and review of the documentation. I’m not a programmer, nor do I have much experience with it. I find it fascinating though, so that’s why I’m trying to learn via practical implementations of code.

I want to have the sound machine turn on at 630p and off at 730a everyday. The config below turns it on, but it immediately turns off. Below is the yaml for the automation:

alias: Bedroom - Sound Machine Timer
description: Turns on sound machine at 630pm and off at 730am every day.
trigger:
  - platform: time
    at: '18:30:00'
condition: []
action:
  - type: turn_on
    device_id: fe691ae86e3d2bfc163cc0fcf56b6a6b
    entity_id: light.bedroom_smart_plug_soundmachine
    domain: light
  - condition: time
    after: '07:30:00'
  - type: turn_off
    device_id: fe691ae86e3d2bfc163cc0fcf56b6a6b
    entity_id: light.bedroom_smart_plug_soundmachine
    domain: light
mode: restart
initial_state: false

Thank you for any help that you can give.

At 630pm it turns the light on, then checks if it is after 7:30am. It always will be at 630pm so the light turns off.

Easiest to have 2 automations, one for turning it on at 630pm and another to turn it off at 730am

I will try that. Thank you.

if you don’t want two automations you can also do a wait action for 01:00:00.

  condition: []
  action:
  - type: turn_on
    device_id: 19ab4ba7e13b39cf3973aa61389bb230
    entity_id: switch.mechanicalroom_hot_water_pump_current_value_6
    domain: switch
  - wait_template: ''
    timeout: 00:05:30    #<-- your time here
  - type: turn_off
    device_id: 19ab4ba7e13b39cf3973aa61389bb230
    entity_id: switch.mechanicalroom_hot_water_pump_current_value_6
    domain: switch
  mode: single

Only problem is if you system is rebooted during the wait it will not turn off.

Good to know. I will try this version.

I think it’s 11 hours from 630pm to 730am. Like you say it’ll be lost on a restart.