it could be but I don’t think it will do what you expect it to do…
Look at your triggers in the “on” automation. The way you have it set up now (ignoring the conditions for now) the actions will be performed in the following circumstances:
every time the sensor.netatmo_cucina_temperature state changes. it will fire every time the temp goes up or down by only 1 degree
every time the device_tracker.iphone_matteo goes into the home zone
every day at 9 am
on the first day of spring
on the first day of summer
some of those triggers seem strange to me, especially the last two. But even some of the others look strange given your conditions.
Also I do see one syntax error but that might just be a copy/paste error.
If those triggers really are what you want to happen then I would rewrite the conditions like below to fix the possible syntax errors:
automation should work only in spring and summer, only when matteo is at home, when the temperature exceeds 24 degrees. it should only work between 9:00 am and 9:00 pm and depending on the temperature the various ventilation levels should be automatically selected for speed.
I understand what you are TRYING to do. But what you have isn’t that. you have the automation TRIGGERING on those things not conditionally running based on those things.
read the automation again looking at your triggers vs conditions.
It might be easier to tell you for sure if you write out exactly how you expect it to work. list what event(s) should happen when you want it to turn on and which exact conditions need to be met.
activation is that matteo must be at home.
the condition is that the season is spring or summer and that the temperature must be higher than 24 degrees centigrade, and the activation time must be between 9 and 21 hours.
- id: 'Ventilatore_fan_on'
alias: Ventilatore_Fan On
trigger:
- platform: zone
entity_id: device_tracker.iphone_matteo
zone: zone.home
event: enter
condition:
- condition: time
after: '09:00:00'
before: '21:00:00'
- condition: numeric_state
entity_id: sensor.netatmo_cucina_temperature
above: 24
- condition: or
conditions:
- condition: state
entity_id: sensor.season
state: spring
- condition: state
entity_id: sensor.season
state: summer
action:
- service: fan.set_speed
entity_id: fan.smartmi_fan
data_template:
speed: >
{% set temp = states('sensor.netatmo_cucina_temperature')|float %}
{% if temp > 24 %} Level 1
{% elif temp > 26 %} Level 2
{% elif temp > 28 %} Level 3
{% else %} Level 4
{% endif %}
- service: notify.ios_iphone_matteo
data:
title: "Smart Home Alerts"
message: 'Ventilatore ON - temperatura {{ states("sensor.netatmo_cucina_temperature") }} C'
- data:
effect: 'WhatsApp'
entity_id: light.cucina_3
service: light.turn_on
This automation will trigger the actions only when matteo enters the home zone but only if the conditions as you specified above exist at that moment in time.
I haven’t tested it since I don’t have your entities so I would get errors. So make sure you do a config check and then report if you get any errors.
does automation still work if matteo is at home during the day and the temperature increases during the day?
that is, if at 9 o’clock the temperature is 20 degrees and at 11 o’clock the temperature reaches 25 degrees, does the automation still activate? thank you
the template looks OK. It doesn’t make any sense but it is technically OK.
The issue you will run into is it’s going to start at the first if statement to see if it’s true. If the temp is less than 24 the result is on. If not it jumps to the next if. If that’s true then the result is on. Why not just say <25 in the first if and get rid of the second one.
then also if the temp is between 25 and 26 there is no difference between that and >26 so no reason for that step either…
you forgot the action: statement. and you also need to put the entity_id under data:
- id: 'Ventilatore fan on'
alias: Ventilatore Fan On
trigger:
- platform: zone
entity_id: device_tracker.iphone_matteo
zone: zone.home
event: enter
- platform: state
entity_id: sensor.netatmo_cucina_temperature
condition:
- condition: time
after: '09:00:00'
before: '22:00:00'
- condition: numeric_state
entity_id: sensor.netatmo_cucina_temperature
above: 23
- condition: or
conditions:
- condition: state
entity_id: sensor.season
state: spring
- condition: state
entity_id: sensor.season
state: summer
action:
- service: fan.xiaomi_miio_set_natural_mode_
data_template:
speed: >
{% set temp = states('sensor.netatmo_cucina_temperature')|float %}
{% if temp < 25 %} on
{% else %} off
{% endif %}
entity_id: fan.smartmi_fan
I have a question about the design of you automation’s trigger.
As written, it triggers whenever the temperature rises or falls at two thresholds: 28 and 30.
In other words, when temperature rises above 28 to 29, it triggers, and when it rises above 30, it triggers again. Similarly, when it falls below 30 to 29, it triggers, and when it falls below 28 it triggers yet again.
I apologize for not understanding what you love you were suggesting …
what I would like to do is if the temperature is below 26 degrees the fan.xiaomi_miio_set_natural_mode_on service should be activated.
if it is higher, fan.xiaomi_miio_set_natural_mode_off.
the speed part works fine.
I wanted to add the fan.xiaomi_miio_set_natural_mode_on service by comparing it with the temperature sensor.