#Turn light off during golden hour only when above a specified lux value

1 messages · Page 1 of 1 (latest)

pliant bronze
#

I am working on an automation that will turn a group of lights off once a specified lux value has been reached during a specific day light phase. I do not have interior sensors at the moment, so I'm using virtual sensors defined below.

I have the following integrations setup:
Sun2 - using the deCONZ daylight phase sensor. This provides various phases based on the time of day
Illuminance - using this to provide a exterior lux value.

Current logic:
Trigger: every 5 minutes
Conditions: daylight phase is in golden hour 1 and lux value is above 2850
Actions: Turn off specified interior lights and send a notification to a defined group of devices

While this automation works and does what I want it to, it obviously runs every 5 minutes and executes the actions. So I'm getting notifications every 5 minutes during golden hour 1 once the lux value is above 2850.

Is there a better way to structure the automation to continuously check the lux value while daylight phase is in golden hour 1 and once the actions are successful it stops executing. I essentially want it to continue to check until conditions are met and then execute one time. I might be over thinking this by a long shot... suggestions welcome.

dark terrace
pliant bronze
#

So, the template trigger will contain my conditions and have to satisfy true for the automation trigger to trip and execute my actions.

I'll give that a shot! Thanks

pliant bronze
dark terrace
pliant bronze
#

I was just watching a youtube video in hopes I would have gained some insight

#

Much appreciation!

pliant bronze
#

Update:
I have a similar automation that turns the same light group on in the evening, so I modified the above to be:

'''{{ is_state('sensor.home_sun_deconz_daylight', 'golden_hour_1') and states('sensor.illuminance') | float(0) <= 2850 }}'''

This did not work as expected. Developer tools evaluates to true, but the automation did not fire.

heavy phoenix
#

The trigger only fires when going from false to true. If you created the trigger while it was true, nothing will happen until it changes back to false and then back to true.

pliant bronze
#

It was created prior to it evaluating to true. It was done earlier the day when the state of sensor.home_sun_deconz_daylight was not golden_hour_2.

#

Transparency: I had a type in the prior message that I updated to reflect the appropriate state

#

I can't get the automation code to show properly

heavy phoenix
#

It’s a backtick, which is usually below the tilde (~) symbol on a US keyboard

frozen sleetBOT
#

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.

pliant bronze
#

Thank you

#

`alias: Execute Evening Scene
description: >-
This will turn lights defined in the evening scene on during the evening when
the daylight phase is in 'golden_hour_2' and the illuminance lux value outside
is below 2850.
triggers:

  • minutes: /5
    enabled: false
    id: 5_minute_frequency
    trigger: time_pattern
  • trigger: template
    value_template: >-
    {{ is_state('sensor.home_sun_deconz_daylight', 'golden_hour_2') and
    states('sensor.illuminance') | float(0) <= 2850 }}
    actions:
  • target:
    entity_id: scene.evening
    metadata: {}
    action: scene.turn_on
  • data:
    message: The evening scene has been activated and lights have been turned on.
    title: Good Evening!
    action: notify.matt
    mode: single`
#

That's the automation

heavy phoenix
#

Are there any traces in the automation that you can share?

#

I don’t see any issues, but I would supply a default value to the float filter that is larger than the number you’re comparing it to.
states('sensor.float_illuminance') | int(2851) <= 2850

That will prevent the scene from running when the sensor is unknown.

But I’m nearly fairly certain that has nothing to do with whatever issue you are having.

#

In fact I would suggest eliminating that template trigger, and replacing it with 2 triggers and 2 conditions. That will be easier to read, maintain, and debug

#
triggers:
  - trigger: state
    entity_id: sensor.home_sun_deconz_daylight
    to: golden_hour_2
  - trigger: numeric_state
    entity_id:
      - sensor.float_illuminance
    below: 2850.1
conditions:
  - condition: state
    entity_id: sensor.home_sun_deconz_daylight
    state: golden_hour_2
  - condition: numeric_state
    entity_id: sensor.float_illuminance
    below: 2850.1
pliant bronze
#

I give this a test today to see if it works. Thanks for the insight and suggestions!