#How do I adjust how long my light stays up for?
1 messages Β· Page 1 of 1 (latest)
I'm trying to automate my alarm ring > LED strips turn on but I have no idea how do I adjust the duration of the LED strips
It's going to be hard to answer that
How are you turning them off? What does your current automation look like?
I have 3 steps as of now.
When alarm rings
If my phone is home
then turn LED light on
Please use a code share site to share code or logs, for example:
- https://dpaste.org/ (select YAML for the language, and consider picking a longer expiry)
- http://pastie.org/ (select YAML for the language)
- https://paste.debian.net/ (you guessed it, select YAML as the language)
Please don't use Pastebin, since it can randomly add spaces to the main view. Please also don't share text as images since it makes it harder for people to help you. Remember that others may have colour blindness, impaired vision, etc.
Ok how do I copy the YAML code for the entire automation instead of 1 by 1? Just so I know
Two options
- Look in
automations.yaml
- Edit the automation, and in the top right use the YAML option
trigger: template
value_template: >-
{{now().strftime('%a %h %d %H:%M %Z %Y') ==
(((state_attr('sensor.chris_s24ultra_next_alarm', 'Time in Milliseconds') |
int / 1000) ) | timestamp_custom('%a %h %d %H:%M %Z %Y'))}}
condition: state
entity_id: device_tracker.chris_s24ultra
state: home
action: light.turn_on
metadata: {}
data:
kelvin: 6500
brightness_pct: 100
target:
device_id: eeef4e3977ade4d9de5b2e5fe4064351
Am I doing this right?
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.
value_template: >-
{{now().strftime('%a %h %d %H:%M %Z %Y') ==
(((state_attr('sensor.chris_s24ultra_next_alarm', 'Time in Milliseconds') |
int / 1000) ) | timestamp_custom('%a %h %d %H:%M %Z %Y'))}}
condition: state
entity_id: device_tracker.chris_s24ultra
state: home
action: light.turn_on
metadata: {}
data:
kelvin: 6500
brightness_pct: 100
target:
device_id: eeef4e3977ade4d9de5b2e5fe4064351
Sorry am I doing it right T_T im real new to this
That's not right π
trigger: template
value_template: >-
{{now().strftime('%a %h %d %H:%M %Z %Y') ==
(((state_attr('sensor.chris_s24ultra_next_alarm', 'Time in Milliseconds') |
int / 1000) ) | timestamp_custom('%a %h %d %H:%M %Z %Y'))}}
condition: state
entity_id: device_tracker.chris_s24ultra
state: home
action: light.turn_on
metadata: {}
data:
kelvin: 6500
brightness_pct: 100
target:
device_id: eeef4e3977ade4d9de5b2e5fe4064351
Look at the YAML option there
Copying out the different pieces and pasting them one by one produces a mess that's broken
AHH omg that's how you do it
As I said ... top right π
mode: single
triggers:
- trigger: template
value_template: >-
{{now().strftime('%a %h %d %H:%M %Z %Y') ==
(((state_attr('sensor.chris_s24ultra_next_alarm', 'Time in Milliseconds')
| int / 1000) ) | timestamp_custom('%a %h %d %H:%M %Z %Y'))}}
conditions:
- condition: state
entity_id: device_tracker.chris_s24ultra
state: home
actions:
- action: light.turn_on
metadata: {}
data:
kelvin: 6500
brightness_pct: 100
target:
device_id: eeef4e3977ade4d9de5b2e5fe4064351
- if: []
then: []
Is this it?
That's it 
GOD damn I'm dumb
You're new to HA, that's not the same thing π
You're only dumb if you keep repeating the same mistakes
So, what's the goal for turning the lights off?
Well, I usually only need it for 45minutes before I leave home for work.
So I only want it to be on for 45minutes
Well, that's a simple delay
If you want to be fancy you can wait for you to leave home:
https://www.home-assistant.io/docs/scripts#wait-for-a-trigger
If you want to be real fancy you can add a timeout so that it turns off after 45 minutes regardless:
https://www.home-assistant.io/docs/scripts#wait-timeout
Ok sorry I do have some questions regarding the first one. Aka Delay.
How exactly does delay turns my LED strips off?
It doesn't
It does exactly what it says in the docs
It's a wait for time to pass
That's all
You put that before the action to turn off the lights...
AHHHHHHH
From the way you asked the question I'd assumed you'd worked out that the opposite of turning on a light was turning it off π
Is there any real reason why one will use wait timeout over delay?
Oh shit, sorry was trying to do what you were doing
The timeout is for a wait_for_trigger
So options are:
- Blind delay
- Turn off when you leave home, regardless of how long that takes
- Turn off when you leave home, or after 45 minutes, whichever happens first
All of which can be done in the automation that turns the lights on, or can be done in a separate automation entirely
One automation is "simple", but fragile - if you restart HA during that time then the automation dies and the lights stay on
Ok, let me first try it out with the simple delay first.
Hmmm, not working but let me try to troubleshoot first!
Light doesn't even turn on π
Ok I'm pretty lost here @ornate pollen
Am I doing anything wrong? Not very sure why does the alarm not trigger my strips.
Ahh I found out why!
- condition: state
entity_id: device_tracker.chris_s24ultra
state: home
how does this code work? how does it know if I'm "Home" or not? Do I have to indicated where's home somewhere?
Well... to be blunt, how the hell can we help if you don't share the current automation?
Look in States
Open your Home Assistant instance and show your state developer tools
That comes from location tracking on your phone. That entity is from the companion app and that controls whether or not your phone is in the home zone or not.
I got you, I shifted my Home to the correct spot. Now both my phone and my "Home" is at the same spot.
But it still doesn't trigger my strips if I have the condition in
alias: Wakeup Light
description: ""
triggers:
- trigger: template
value_template: >-
{{now().strftime('%a %h %d %H:%M %Z %Y') ==
(((state_attr('sensor.chris_s24ultra_next_alarm', 'Time in Milliseconds')
| int / 1000) ) | timestamp_custom('%a %h %d %H:%M %Z %Y'))}}
conditions:
- condition: state
entity_id: device_tracker.chris_s24ultra
state: home
actions:
- action: light.turn_on
metadata: {}
data:
kelvin: 6500
brightness_pct: 100
target:
device_id: eeef4e3977ade4d9de5b2e5fe4064351
- delay:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0
- action: light.turn_off
metadata: {}
data: {}
target:
device_id: eeef4e3977ade4d9de5b2e5fe4064351
mode: single
Does the automation run at all? What does the trace show?
To test an automation there's three stages you can follow. Testing the action, the condition and action, and the whole automation:
- Use Configuration -> Automations to find the automation and then select Run in the three dots menu. If this fails your problem is in the
action:section, and details should be found in your log file - Use Developer tools -> Services and call
automation.triggeron the automation withskip_condition: false. If the first passes but this fails then the problem is in yourcondition:block - Use Developer tools -> States to find the trigger entity, click the name, then change the state (at the top) to something that'll trigger the automation before pushing Set State. If this fails then the problem is with your
trigger:section, or the automation is turned off (you can check that in Automations, automations that are turned off will show Disabled)
You can also see this section in the docs about testing and automation traces.
It runs but it's returning not_home to me
In the "Map" settings I'm exactly at the same spot as well.
Have you actually checked?
The pretty map is just a pretty map - the only thing that matters is the state of the entity
I don't quite get this part, where do I check this? Under the entities tab?
T_T I just got this 4 hours ago, I have 0 idea what are you asking me to check.
Check "Home" under Dev>States? What am I trying to see here?
No, the device_tracker entity π
That's the one you're testing in the condition after all
Yes it's there as well.
You want to go lower, not the set state accordian, you just want to see the current state
OK I have no idea what went wrong but it's working now ( I did not change anything after the last time it failed )
Yeah I figured but I have no idea why did that happen >.<
You said you changed your Home zone location ... I'm not exactly sure if changing the coords of the zone would trigger device_tracker updates, so it very well might've just updated the location again and picked up the new zone info.
Yeah that's what I thought as well but it didn't work the first time I after I changed it haha
Apperciate the help though @ornate pollen , I just had no idea what was I supposed to click and check stuff
It's the filterable table below where you screenshotted. It's helpful to be able to see the actual state and attributes of your entities because this isn't the last time you'll be asking why something isn't working
But ... be careful pasting something like that with something that has GPS tracking, since they may have detailed GPS coords
I understand now but what are you guys looking out for? If I even have the entity/state there?
Just to understand a little more.
To confirm the state of your tracker was not_home
Then it's clearly not an automation issue, but a why is your device not reporting you at home issue
Because of #1311703248863760434 message
You thought it should be at home, so I wanted you to go and look and see for yourself that HA wasn't wrong π
I understand it now!