finity
June 5, 2019, 8:16pm
29
No.
You didn’t specify that in your last post above. you only said you wanted it to activate if you got home during those specified conditions.
That’s why I asked you to list all of the things in the way to wanted it to come on and the conditions required.
This should do it. I think…:
- id: 'Ventilatore_fan_on'
alias: Ventilatore_Fan On
trigger:
- platform: zone
entity_id: device_tracker.iphone_matteo
zone: zone.home
event: enter
- platform: numeric_state
entity_id: sensor.netatmo_cucina_temperature
above: 24
condition:
- condition: state
entity_id: device_tracker.iphone_matteo
state: 'home'
- 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
matteos1
(Matteo)
June 5, 2019, 8:22pm
30
finity:
platform: zone entity_id: device_tracker.iphone_matteo zone: zone.home event: enter
of course it should always work when matteo is at home even if he doesn’t go out for a day. that is, always when matteo is at home
For when I’m home, as well as the trigger @finity suggested, I have this automation to change the speed.
- id: lounge_fan_speed_change
alias: Lounge Fan Speed Change
trigger:
- platform: numeric_state
entity_id: sensor.wirelesstag_lounge_temperature
below: 28
- platform: numeric_state
entity_id: sensor.wirelesstag_lounge_temperature
above: 28
- platform: numeric_state
entity_id: sensor.wirelesstag_lounge_temperature
below: 30
- platform: numeric_state
entity_id: sensor.wirelesstag_lounge_temperature
above: 30
condition:
condition: and
conditions:
- condition: numeric_state
entity_id: sensor.wirelesstag_lounge_temperature
above: 26
- condition: state
entity_id: fan.lounge_fan
state: 'on'
- condition: state
entity_id: binary_sensor.people_home
state: 'on'
action:
- service: fan.set_speed
entity_id: fan.lounge_fan
data_template:
speed: >
{% set temp = states('sensor.wirelesstag_lounge_temperature')|float %}
{% if temp < 28 %} low
{% elif temp < 30 %} medium
{% else %} high
{% endif %}
I’m sure there’s a way to make it neater and have only one automation. But, this works.
matteos1
(Matteo)
June 16, 2019, 11:10am
32
I have another question to propose:
how do i do this kind of action using date_template?
- 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
- service: fan.xiaomi_miio_set_natural_mode_
entity_id: fan.smartmi_fan
data_template:
speed: >
{% set temp = states('sensor.netatmo_cucina_temperature')|float %}
{% if temp < 24 %} on
{% elif temp < 25 %} on
{% elif temp < 26 %} off
{% else %} off
{% endif %}
fan.xiaomi_miio_set_natural_mode_ can be on or off
finity
June 16, 2019, 11:28am
33
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
matteos1
(Matteo)
June 16, 2019, 11:34am
34
could this service work?
Service fan.xiaomi_miio_set_natural_mode_on
Service fan.xiaomi_miio_set_natural_mode_off
service: fan.xiaomi_miio_set_natural_mode_
entity_id: fan.smartmi_fan
data_template:
speed: >
{% set temp = states(‘sensor.netatmo_cucina_temperature’)|float %}
{% if temp < 24 %} on
{% elif temp < 25 %} on
{% elif temp < 26 %} off
{% else %} off
{% endif %}
or i need another kind of syntax
this is complete automation
- 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.set_speed
entity_id: fan.smartmi_fan
data_template:
speed: >
{% set temp = states('sensor.netatmo_cucina_temperature')|float %}
{% if temp < 24 %} 25
{% elif temp < 25 %} 50
{% elif temp < 26 %} 75
{% else %} 100
{% endif %}
- service: fan.xiaomi_miio_set_natural_mode_
entity_id: fan.smartmi_fan
data_template:
speed: >
{% set temp = states('sensor.netatmo_cucina_temperature')|float %}
{% if temp < 24 %} on
{% elif temp < 25 %} on
{% elif temp < 26 %} off
{% else %} off
{% endif %}
i think that speed is not correct
https://github.com/syssi/xiaomi_fan
123
(Taras)
June 16, 2019, 12:23pm
35
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.
What’s the purpose of having two thresholds?
finity
June 16, 2019, 12:47pm
36
I have literally no idea what you’re trying to do.
I assumed you knew the correct service to use. Apparently you don’t.
I can’t tell you what speeds are correct. It’s your equipment. I would think you should know that.
and you completely ignored my advice on the template without explaining why I’m wrong.
matteos1
(Matteo)
June 16, 2019, 12:53pm
37
finity:
I have literally no idea what you’re trying to do.
I assumed you knew the correct service to use. Apparently you don’t.
I can’t tell you what speeds are correct. It’s your equipment. I would think you should know that.
and you completely ignored my advice on the template without explaining why I’m wrong.
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.
finity
June 17, 2019, 4:42am
39
it’s closer…
try this:
- 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.set_speed
entity_id: fan.smartmi_fan
data_template:
speed: >
{% set temp = states('sensor.netatmo_cucina_temperature')|float %}
{% if temp < 24 %} 25
{% elif temp < 25 %} 50
{% elif temp < 26 %} 75
{% else %} 100
{% endif %}
- entity_id: fan.smartmi_fan
service_template: >
{% set temp = states('sensor.netatmo_cucina_temperature')|float %}
{% if temp < 26 %}
fan.xiaomi_miio_set_natural_mode_on
{% else %}
fan.xiaomi_miio_set_natural_mode_off
{% endif %}
1 Like
@123 The trigger changes the fan speed.
123
(Taras)
June 17, 2019, 11:12am
41
Why not use a simpler trigger?
trigger:
- platform:state
entity_id: sensor.wirelesstag_lounge_temperature
condition:
condition: and
conditions:
- condition: numeric_state
entity_id: sensor.wirelesstag_lounge_temperature
above: 26
- condition: state
entity_id: fan.lounge_fan
state: 'on'
- condition: state
entity_id: binary_sensor.people_home
state: 'on'
action:
- service: fan.set_speed
entity_id: fan.lounge_fan
data_template:
speed: >
{% set temp = trigger.to_state.state | float %}
{% if temp < 28 %} low
{% elif temp < 30 %} medium
{% else %} high
{% endif %}
1 Like
I see. Any state change would trigger it. That is a simpler solution. Thanks.
Jiran
(Jiran)
November 24, 2019, 9:16pm
43
Please could anyone help? This is my automations.yaml:
- alias: fan on
initial_state: 'off'
trigger:
- platform: numeric_state
entity_id: sensor.krb_teplota
above: '45'
action:
- service: switch.turn_on
entity_id: switch.ventilator
- alias: fan off
initial_state: 'on'
trigger:
- platform: numeric_state
entity_id: sensor.krb_teplota
below: '41'
action:
- service: switch.turn_off
entity_id: switch.ventilator
but is not working. I also can´t edit his in HASS gui. Other automations run and I´m able to edit them even via GUI. Any idea?
finity
November 25, 2019, 1:25am
44
Jiran:
but is not working.
try removing the quotes from around the numbers in above: and below:
in order to make the automation editable in the ui it needs to have a unique_id included.
it can be anything as long as it’s unique and not capitalized.
- id: yghygygulfsrdrtrd765687
alias:...
Jiran
(Jiran)
November 25, 2019, 9:29pm
45
Thank you. But this is not the question. What could be wrong with this automation?
Tinkerer
(aka DubhAd on GitHub)
November 25, 2019, 9:51pm
47
Because you didn’t add an id:
line - see here
finity
November 26, 2019, 12:19am
48
yes it was…
Tinkerer:
It’s turned off
good catch. Didn’t even notice that.