#sun controlled automation failed to run

54 messages · Page 1 of 1 (latest)

swift sentinel
#

I have two basic home automations to control turning on and off a set of lights via a smart plug. One to turn them on at sundown, one to turn off at sunrise.

Tonight, the sundown version seemed to not have run for some reason, and nothing showed in the logs.

How do I look further into this?

Is it possible to run a check to ensure that the automations eventually do run, after the default automation fails?

cosmic swallow
#

Hi @swift sentinel,
You can look for a trace to see if it triggered or not or what happened.
Beyond that sharing the YAML code is the only way anyone can help you here.

tawdry oarBOT
#

@swift sentinel To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

swift sentinel
swift sentinel
#

SO it looks like that the device may not have been seen by HA somehow? On the days prior, I see the outlet but in the failed trigger, the outlet is missing in the trace timeline.

#

`alias: Holiday Lights On
description: ""
trigger:

  • platform: sun
    event: sunset
    offset: 0
    condition: []
    action:
  • type: turn_on
    device_id: 17248ee75cb97b46a677456953ab10c0
    entity_id: 8d0ce77a10738e971573fbea809e0c93
    domain: switch
    mode: single`
#

This is the failed attempt:

#

Day prior's successful attempt:

#

What I would like to do is build a way to ensure that the lights go on properly automatically should the first attempt fail

#

But, I am unsure how to go about that in HA

#

It looks like my device controlling the lights somehow dissappeared from the network for 12 hours too

#

It's possible that someone turned off the switch somehow during that time

#

Chekcing my cameras, yep, that's what happens. So, I would like to build a automation that checks every half hour after the sunset time to make sure that the switch is in the on position in case the switch goes offline due to cut power, and once power comes back it can turn the lights on at some point

last agate
#

Trigger on the switch turning off
Conditions to check if the sun has set
Action to turn the light on

#
trigger:
- platform: state
  entity_id: switch.whale
  to: 'off'
condition:
- platform: state
  entity_id: sun.sun
  state: 'below_horizon'
action:
- service: switch.turn_on
  data:
    entity_id: switch.whale
boreal moth
last agate
#

-# I'm waiting for 2024.10 before I update all the YAML in my head 😛

wispy mural
#

Need to keep the sunset trigger also, to retain the intended functionality of the automation.

swift sentinel
last agate
#

Well, sort of

#

It's triggered by the switch turning off

#

Then it check to see if the sun has set

tawdry oarBOT
#

There are three sections to an automation:

  • trigger: When any one of these becomes true the automation starts processing. Only one trigger is ever responsible for starting an automation, if you make a condition that checks for more than one having started the automation then the condition can never be true.
  • condition: These are checked after a trigger starts the processing, and must be true for the automation to continue.
  • action: This is the part that does something, and can also include further conditions.
swift sentinel
#

Ah, so the idea was that if the automation "failed" because someone turned off the manual dumb switch that controls this "smart" outlet, that when the switch goes back on (thus powering the smart outlet), an automation will see this change and then turn the lights on

last agate
#

Ah, that the problem was a dumb switch wasn't clear

#

You can still solve that, it's just more complex

#

Does the (smart) switch go unavailable when the power is off?

#

How does the light feature in all of this?

swift sentinel
#

So, to try and paint the best picture.. the power order goes like this

Dumb switch > Light socket > smart outlet > dumb lights

Dumb switch sends power to the socket which has a bulb socket and 2 three prong outlets, one of which the "smart" outlet is plugged into.

#

Dumb switch

#

Socket with "smart" outlet on it

last agate
#

Does the (smart) switch go unavailable when the power is off?

swift sentinel
#

Where do I go to see that so I can check?

tawdry oarBOT
swift sentinel
#

No, it just says off

last agate
#

And was it on or off before the power was cut?

swift sentinel
#

It was also off

#

Power was cut during the day after sunrise, when I have an automation that turns off the lights then

#

Then my kid turned the dumb switch off

last agate
#

Then there's no way to tell when that happens

swift sentinel
#

Ah okay

last agate
#

Some integrations handle that and will report unavailable

#

Whatever you're using doesn't

#

(or that hasn't been enabled)

swift sentinel
#

It's the wyze integration and probably doesn't support it I think

#

Some older devices I had seem to show this, so maybe it does, idk

#

Maybe the check takes time to show as unavailable

last agate
#

Give it ten mins and see

swift sentinel
#

Ok

swift sentinel
#

Okay I am back. It went "Unavailable" after 9 minutes, so that's good

#

So the yaml code above, I can basically throw that in my sunset automation for it and it will do what I am looking for?

#

just change from 'off' to 'unavailable'?

#

or just leave it as 'off' as that will be the state the device will be in when power is returned?

#

I made this automation