How to add a time to a motion activated automation

The screenshot you have posted is for a Device Action to turn on lights with a flash effect (turn on, turn off, turn on, turn off).

FWIW, that Device Action is unrelated to the error message you posted earlier.

Please post the automation’s preformatted YAML code. Without that, we are left guessing what is the meaning of these seemingly random bits of information you are providing.

ok - let me post up whats actually saved…with regards to being left guessing…well, you and me both! :):)…as i say im not sure it works yet as the firmware is still going…

alias: Kitchen Test
description: ""
triggers:
  - trigger: sun
    event: sunset
    offset: 0
conditions:
  - condition: device
    device_id: f0938ac78ff6e4276cd0c542ad8924c9
    domain: select
    entity_id: 7ed2d59fd32b2c417462b8a99279df59
    type: selected_option
    option: medium
actions:
  - type: turn_on
    device_id: d2a4bf0ea875588e423618836a7d92aa
    entity_id: 9dbeb4892ce873c0a852994e06263ac3
    domain: light
    brightness_pct: 100
    flash: long
mode: single

Found it…it was in the cog settting…

1 Like

What that automation does:

Flash the light at sunset but only if some select entity is set to medium.

What is the purpose of this select entity you included?


Your original requirements are:

In a nutshell, you want your automation to be triggered by motion, confirm it is after sunset, then turn on the light.

In the triggers: section, you put the entity_id of your sensor
conditions: indicate when the trigger is to be considered (note: you need the Sun integration installed when using sun functions)

You can find out more about the choose: function in the docs.

conditions: in the choose: function indicates the actions (sequence: section) are to be performed.

The condtion: (note lack of ‘s’) is evaluated and if true, the sequence: is performed. In this case the condition evaluates a template. (Learning templates is a steep learning curve.) This template says, "look at the trigger, specifically, look at the state to which the the trigger switched (to_state), then look at the state of that “attribute” (state). If that evaluates to ‘on’, then the condition is true.

Note that the double quotes must be at the beginning and end. The double braces means to evaluation the equation inside the double braces. The double equals means “is equal to” (as opposed to the single = which means “set the variable to”) and, <-sarcasm font> of course it is intuitive that </sarcasm font> trigger.to_state.state is a string so on must be quoted, but not double quote, because the double quote is used outside the template, so on must be 'on'

Alas, when you create a card in your overview page which shows the state of your motion sensor, what is shown is ‘detected’ or ‘cleared’ not ‘on’ or ‘off’. <-sarcasm font> It is also intuitive that one knows to </sarcasm font> go to *Settings–>Developer Tools–>Template (a tab) and create a template such as {{ states('binary_sensor.floodlight_sensor_garage_motion_detection') }} which will tell you what the YAML will see as opposed to what is presented to you in the overview page.

@comfysofa you are at the bottom of the aforementioned steep learning curve. I am “codey” and HA is not a friendly language to learn. Start here and plow your way through very rocky soil. Not on that page, but which should be for people like you, is a link to 20 things I wished I knew when I started with Home Assistant

I really dont know…! i selected medium as i had to select something otherwise i wouldnt be able to save it…

All i want is the motion sensor to swtich the lights on when activated…when its dark…

These are the only options that are available to me…all i want is the sensor to switch the lights on…

Then you’re in good company because we also don’t know why you did that.

As far as I can tell, that select entity isn’t needed to fulfill your original requirements:

set up a motion activated hue sensor to swtich on some kitchen under cabinet lights - also Hue based but only at sunset/ when it gets dark…

Your automation needs to trigger when motion detected, then confirm it is after sunset, then turn on the light.

  • The trigger is when motion is detected.
  • The condition is it is after sunset.
  • The action is turn on the light.

You may have noticed that it is not how you designed your automation. You have it triggering at sunset. So what if sunset arrives but there’s no motion in the kitchen? Nothing happens and nothing will happen afterwards because sunset only occurs once a day. If there’s motion in the kitchen after sunset, your automation won’t detect it.

Well its a learning curve!..so ive got these the wrong way round then…?

So if i put the motion sensor at the top…which of the values are the toggle? (or the option to switch on?)

Yes.

You need it to trigger when motion is detected then check if it’s after sunset.

The one that’s highlighted (Kitchen Light Sensor Occupancy became occupied).

1 Like

Great - thanks very much for all of your help. Ill wait for the firmware to finish (56% now) no idea why its so slow but its doing it so ill leave it to finish (and get dark)

1 Like

Based on my own experience with updating the firmware of Zigbee devices, it’s normal for it to take a long time.

When you have finished revising the automation, post it here so we can review it.

Sure - no problem. Thanks again.

Ok - i think its working. Do i need to mark it as now solved… i forgot one more thing…but, i can open a new thread for that…? (id like it to shut the lights off if no one is in the room) wasnt sure if it could be added in somewhere or, i would have to create a new automation for that.

Many thanks again for filling in the blanks for me.

Have a look at these search results: Search results for 'motion lights' - Home Assistant Community
And here: Search results for '#community-guides motion lights' - Home Assistant Community

Glad to hear it’s working.

I suggest you mark my post here with the Solution tag. It will help others find answers to similar questions.

Sure, ive already been told off about that….i shall try to improve on my tardiness. :slight_smile: