Automation with numeric state and FOR - Help please

Hi!

I need your help please.
My HA setup includes two sun sensors. With them I control my outside shutters.
Ex.

- id: '1592914276375'
  alias: Vorne runter
  description: ''
  trigger:
  - entity_id: sensor.sonnenwachter_vorne
    platform: state
  condition:
  - before: '19:29:59'
    condition: time
  - above: '65000'
    condition: numeric_state
    entity_id: sensor.sonnenwachter_vorne
  - condition: and
    conditions:
    - above: '24'
      condition: numeric_state
      entity_id: sensor.aussentemperatur
  action:
  - data:
      position: 0
    entity_id: cover.madita
    service: cover.set_cover_position

That works very good, but it acts too often when it’s heavy sunny and heavy cloudy. Shutters open and closes sometimes very often which I want to avoid.

I want now that the numeric condition must be 10 minutes above 65000 lux to close the shutters; starts service: cover.set_cover_position.

The “FOR” is not working in automations. How can I get the “FOR” working?
Is this the right way? Working with a binary sensor?

binary_sensor:
  - platform: template
    sensors:
      sonnenwaechter_vorne_65000:
        friendly_name: "Sonnenwächter Vorne > 65000"
        value_template: '{{ states.sensor.sonnenwachter_vorne | float > 65000 }}'

But how does the automation looks like?

Thank you in advance for helping!!!

Cheers

URBANsUNITED

Template binary sensors support a delay_on option, which is functionally the same as for: in your condition.

What I’ve done in a similar situation though is use multiple numeric state triggers, requiring the light level to be above a threshold for different time periods, the higher the threshold, the shorter the period. Given that you’re requiring the sensor to be above 65000, there’s no reason not to include that in the trigger.

Currently, you are triggering on every change in the sunlight sensor (which, depending in the sensor, might trigger very, very often).

Add at least one of the conditions to the trigger:

  trigger:
  - platform: numeric_state
    entity_id: sensor.sonnenwachter_vorne
    above: 65000
    for: "00:10:00"
  condition:
  - condition: time
    before: '19:29:59'
  - condition: numeric_state
    entity_id: sensor.aussentemperatur
    above: 24

1 Like

Thanks @Olen !

I always thought that I need to activate/trigger the sun sensor first for changes and then the given value.
It makes sense!
A shame that it is cloudy today so I can’t test with real life situation, but it makes sense!

Also thanks @Tinkerer for your answer!!!

Problem solved and marked :smiling_face_with_three_hearts:

Thanks alot

URBANsUNITED

If one wants or needs to use a template, say because you want to set the 6500 in a helper and use the helper value, have a look at this post.

May I ask which sensor you use, cause I am interested in one or more myself.

Yeah.
I use the following for my similar automation:

  trigger:
  - platform: template
    value_template: "{{ (states('sensor.veranda_luminance') | int ) > (states('input_number.lux_bright') | int) }}"
    for: "{{ states('input_datetime.delay_short') }}"

So I can set the limits and time in lovelace or adjust them dynamically by other automations.

I am not 100% sure, but with all the new rewrites of the templates and automations coming up in 0.115, I hope I will soon be able to change it to sometihng like

- platform: numeric_state
  entity_id: sensor.veranda_luminance
  above: input_number.lux_bright
  for: input_datetime.delay_short

@Recte
I will check your option later. Thanks!

My sensor is the Somfy sunis wirefree ii io which I use with the Tahoma Box

@Olen
How do you adjust your limits etc. dynamically? How does it look like?

Thanks

URBANsUNITED

Thanks. That extra hub/Tahoma box is what’s basically stopping mee. Hoped it was a zigbee, z-wave or WiFi sensor.

I see @Olen is replying, but I guess he updates a helper in the action of the automation. That’s at least the solution I use in another automation.

I use automations to set the values of the input_numbers and input_datetimes based on different parameters.
In the winter, the sun is not as strong, but lower in the sky, so it is more annoying at lower lux levels (shining through the windows). In the summer, I don’t need it to trigger before the level is really high, as a sun high in the sky, although brighter in lux measurements it shines less through the windows.