Hi I am struggling with automation for closing the windows. Currently it is being triggered:
If value from CO2 sensor is less than 800
If temperature value is less than selected by input_number
Conditions:
If value from CO2 sensor is less than 800
The CO2 value often get closed to 820 but from that starts to little bit rising but the temperature in room is droping terribly (it is winter) so it get me wake up.
Is there a possibillity to make a “or” condition that will check if the CO2 values is rissing or stays on the same value for a certain period of time so to make window close?
In this specific case I do not want to set it below certain value, I need HA to recognize that the values is constant or rising, in that case to shot the trigger.
Before we get to your question, there is at least one problem with your current automation. This will not work the way you expect:
- platform: template
value_template: '{{ states(''weather.home'') == (''rainy'' or ''lightning-rainy''
or ''snowy-rainy'' or ''pouring'' or ''hail'')}}'
The right side of the == operator will evaluate to 'rainy', so the statement will only be True if the state of weather.home is rainy.
Also, you should quote the entire template with double-quote characters to make using single-quote characters inside the template string easier. And actually, since these are long templates you should probably use multi-line YAML instead.
Lastly, there’s no point in quoting the below value for the numeric_state trigger.
Now getting to your question, I suppose there is probably a way to do what you ask for, but it gets a bit involved. Why not just remove the sensor.co2 condition and let the automation turn off the switch whenever any of the triggers fire (assuming the other conditions are met)?
Also, the BEST way to get ACCURATE help is to CLEARLY define EXACTLY what you want to happen. HA absolutely can accomplish what you want - but you need to know specifically what you want it to do.
I also leverage a sensor based on the ‘gradient’ attribute of a trend sensor for some automations.
Anyhow, if you’d like to spell out exactly the scenarios you want the blinds open / closed upon - we’re happy to help - but it’s difficult w/ inaccurate and/or missing details.
Thanks Phil! I am learning to code so I will double check the guide regarding the operators.
Regarding the qoutes I am also noob however on the value, these were added when I edited the automations in Hassio. I will also google for where and how to quote.
I believe that now I can make what I need by Trend Binary Sensor as @Markus99 pointed out. Thanks Mark!
I will post the result after. Thanks guys again for your help.
Do you have idea why the template is reformated when editing in hassio? Am I banned when using this kind of formating of templates from editing in Hassio? As I am a noob I did a quick way and added state trigger in Hassio causing the reformating. I fixed the code and now it looks like this.
Opening window
- id: '1574877574417'
alias: 'Okno: Vysoká Teplota Otevři'
description: ''
trigger:
- platform: template
value_template: >
{{ states('sensor.pokoj_temperature')|float > states('input_number.noc_teplota_otevreni_okna')|float }}
- above: '1000'
entity_id: sensor.co2
platform: numeric_state
- platform: template
value_template: >
{% set last_triggered = as_timestamp(state_attr('automation.okno_vysoka_teplota_otevri', 'last_triggered')) %}
{{ last_triggered is none or (as_timestamp(now()) - last_triggered) > 60*60 }}
condition:
- condition: state
entity_id: switch.okno
state: 'off'
- condition: state
entity_id: binary_sensor.okno_fixed
state: 'on'
- condition: template
value_template: >
{{ states('weather.home') not in
('rainy', 'lightning-rainy', 'snowy-rainy', 'pouring', 'hail') }}
action:
- data:
entity_id: switch.okno
service: switch.turn_on
If by “editing in hassio” you mean using the Automation Editor in the UI, then you’re not “banned” from also directly editing the YAML files directly. But you need to be aware that the Automation Editor has its own peculiarities in the way it likes to order & format things, and doesn’t support every feature you can use by directly editing the YAML files. You should probably use one method or the other (i.e., use the Automation Editor, or directly edit YAML files), but not both, at least until you understand things more.
I would say most “advanced users” don’t use the Automation Editor, mainly because it has been very limited for most of its existence. However, I know a lot of work has been done recently to improve it. But I think it has a ways to go yet to be “fully functional.”