In my home I have several NETATMO sensors which also measures the CO2 concentration. In addition I have several HUE lights. All are integration in Home Assistant already.
I now want to automate it in the way that everytime the Netatmo sensor measures a value above 1000 ppm the light in that room flashes once.
My sensor has the entity id sensor.netatmo_home_schlafzimmer_eltern_co2 and delivers new data every 10 minutes.
What I see now is that the lights flash exactly once (at the time netatmo delivers new data), after the automation was saved.
Does anybody has an idea how I can change the behaviour so that it flashes every 10 seconds as long as the value us above 1000 (resp. 500 in my current test-setup)?
I had to put everything in one screenshot, because new members are allowed to post only one image.
Here is the YAML file:
alias: Flash Lights in BĂĽro if CO2 is too high
description: A new measurement is done every 10 minutes
trigger:
- platform: numeric_state
entity_id: sensor.netatmo_home_schlafzimmer_eltern_co2
above: '500'
condition: []
action:
- type: flash
device_id: 77d0cdc711025d5cdaa0f70200b730e8
entity_id: light.buro_hue
domain: light
- service: notify.mobile_app_iphone_11_pro_grimm
data:
message: C02 zu hoch im BĂĽro
mode: restart
max: 10
The numeric state trigger only triggers when the value goes from below the threshold to above the threshold and then it only triggers again when the value goes below the threshold and then above the threshold again.
To flash it every time when the value is above 500, try something like this:
This trigger will not work, it’ll do the same as the numeric state trigger. It will only trigger when it changes from false to true and then only again whrn it goes to false and then to true again.
I just reread your initial post and I see that you want it to flash every 10 seconds, but this means once it goes above 500, it will flash every 10 seconds for at least 10 minutes because you only get a new reading every 10 minutes. So at minimum it will flash 60 times. Do you really want to do this??
Then use the code I posted. It will trigger every time the sensor changes value (every 10 mins) and it will only flash the light when the value is above 500.
I’ve updated my yaml file with your code and it now looks like this:
alias: Flash Lights in BĂĽro if CO2 is too high
description: A new measurement is done every 10 minutes
trigger:
- platform: state
entity_id: sensor.netatmo_home_schlafzimmer_eltern_co2
condition:
- condition: template
value_template: '{{ trigger.to_state.state > 500 }}'
action:
- service: notify.mobile_app_iphone_xxx
data:
message: C02 too high
- type: flash
device_id: 77d0cdc711025d5cdaa0f70200b730e8
entity_id: light.buro_hue
domain: light
mode: single
Unfortunately it’s never triggered although the CO2 value is above 500.
Thanks again for your input. With the last changes it works like a charm.
This is my final yaml file:
alias: Flash Lights if CO2 is too high in BĂĽro during day
description: A new measurement is done every 10 minutes
trigger:
- platform: state
entity_id: sensor.netatmo_home_schlafzimmer_eltern_co2
condition:
- condition: template
value_template: '{{ trigger.to_state.state | float > 1000 }}'
- condition: time
after: '08:00:00'
before: '23:00:00'
action:
- type: flash
device_id: 77d0cdc711025d5cdaa0f70200b730e8
entity_id: light.buro_hue
domain: light
mode: single
max: 10
Additionally I added another condition which restrict the flashing to day-time.
Honestly I don’t understand the concept of templates yet. I have to read the documentation somewhen. But I’m very happy that it works now!