#How do I adjust how long my light stays up for?

1 messages Β· Page 1 of 1 (latest)

bright igloo
#

Is there any simple way to set how long it will stay up for the moment it's triggered?

#

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

ornate pollen
#

It's going to be hard to answer that

#

How are you turning them off? What does your current automation look like?

bright igloo
#

I have 3 steps as of now.

When alarm rings
If my phone is home
then turn LED light on

ember anvilBOT
#

Please use a code share site to share code or logs, for example:

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.

bright igloo
#

Ok how do I copy the YAML code for the entire automation instead of 1 by 1? Just so I know

ornate pollen
#

Two options

#
  1. Look in automations.yaml
#
  1. Edit the automation, and in the top right use the YAML option
bright igloo
#

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?

ember anvilBOT
#

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.

ornate pollen
#

Once you format it, maybe

#

Unformatted that's just a blob of unreadable text

bright igloo
#
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

ornate pollen
#

That's not right πŸ˜„

bright igloo
#
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
ornate pollen
#

Look at the YAML option there

#

Copying out the different pieces and pasting them one by one produces a mess that's broken

bright igloo
#

AHH omg that's how you do it

ornate pollen
#

As I said ... top right πŸ˜‰

bright igloo
#
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?

ornate pollen
#

That's it tada_animated

bright igloo
#

GOD damn I'm dumb

ornate pollen
#

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?

bright igloo
#

Well, I usually only need it for 45minutes before I leave home for work.

#

So I only want it to be on for 45minutes

ornate pollen
#

Well, that's a simple delay

bright igloo
#

How exactly does delay turns my LED strips off?

ornate pollen
#

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...

bright igloo
#

AHHHHHHH

ornate pollen
#

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 πŸ˜›

bright igloo
#

Is there any real reason why one will use wait timeout over delay?

#

Oh shit, sorry was trying to do what you were doing

ornate pollen
#

The timeout is for a wait_for_trigger

#

So options are:

  1. Blind delay
  2. Turn off when you leave home, regardless of how long that takes
  3. 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

bright igloo
#

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?

ornate pollen
ember anvilBOT
proven hamlet
bright igloo
#

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
ornate pollen
#

Does the automation run at all? What does the trace show?

ember anvilBOT
#

To test an automation there's three stages you can follow. Testing the action, the condition and action, and the whole automation:

  1. 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
  2. Use Developer tools -> Services and call automation.trigger on the automation with skip_condition: false. If the first passes but this fails then the problem is in your condition: block
  3. 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.

bright igloo
ornate pollen
#

That entity is not_home then

#

Have you checked?

bright igloo
#

In the "Map" settings I'm exactly at the same spot as well.

ornate pollen
#

Have you actually checked?

#

The pretty map is just a pretty map - the only thing that matters is the state of the entity

bright igloo
ornate pollen
#

Already explained there πŸ˜‰

bright igloo
#

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?

ornate pollen
#

Find the entity there

#

It'll show the current state

bright igloo
ornate pollen
#

No, the device_tracker entity πŸ˜‰

#

That's the one you're testing in the condition after all

bright igloo
#

Yes it's there as well.

ornate pollen
#

Great

#

And?

proven hamlet
#

You want to go lower, not the set state accordian, you just want to see the current state

bright igloo
#

OK I have no idea what went wrong but it's working now ( I did not change anything after the last time it failed )

ornate pollen
#

The last time your device_tracker was not_home

#

This time it's not

bright igloo
proven hamlet
#

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.

bright igloo
#

Apperciate the help though @ornate pollen , I just had no idea what was I supposed to click and check stuff

proven hamlet
#

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

bright igloo
#

Just to understand a little more.

proven hamlet
#

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

ornate pollen
bright igloo
#

AHHH

#

I see it now

ornate pollen
#

You thought it should be at home, so I wanted you to go and look and see for yourself that HA wasn't wrong πŸ˜‰