As the title says, I am looking for help setting up an automation that allows me to set a Hive Smart radiator valve to say, 15 degrees when my son’s phone leaves the house.
I have managed to create an automation that turns the valve off but I do not want it to turn off, I want to set it to a specific temperature.
I also want it to set to say 20 degrees when his phone comes back into the house.
Where’s the part where it chooses to set the temperature temperature to either 15 or 20 degrees depending on whether the tracker is home or away?
This example can do that.
alias: example
trigger:
- platform: state
entity_id: device_tracker.somebody
to:
- home
- not_home
from:
- not_home
- home
condition: []
action:
- service: climate.set_temperature
target:
entity_id: climate.hive
data:
temperature: "{{ iif(trigger.to_state.state == 'away', 15, 20) }}"
The purpose of the to and from options is to constrain the State Trigger only to the state-changes we want; we don’t want it to be triggered if the device_tracker’s state should ever change to/from unavailable.
EDIT
According to the documentation for Device Tracker, the state value not_home is used to indicate when the device is not in the home zone.
Spoke too soon. It seems if I force run the automation it works but when he comes home it doesn’t work. HA currently says his phone is home but the TRV is set as if he is away. I wonder, does anyone know how often an automation like this checks for a change of state?
the code I used has to be created in 2 automations. One for when he is away and it sets to 10 degrees and one for when he is home and it sets to 20 degrees.
The thing is, it’s not refreshing anyway. HA knows he is home yet the TRV stayed in the ‘away’ state
alias: Test on my phone
description: ""
trigger:
- platform: state
entity_id: device_tracker.iphone
from: home
condition: []
action:
- service: climate.set_temperature
data:
temperature: 10
target:
entity_id: climate.bedroom_radiator
This is the code for when I enter the house
alias: Test 2 on my phone
description: ""
trigger:
- platform: state
entity_id: device_tracker.iphone
to: home
condition: []
action:
- service: climate.set_temperature
data:
entity_id: climate.bedroom_radiator
temperature: 20
They refuse to work but when I manually run them, they do and if I manually change the state of my phone to away, or home, it works
Which integration are you using to produce the device tracker that represents the phone? Is it the mobile app? Whatever it is that creates the tracker, start there.
I created my entire HA setup on my PC and then downloaded the companion app once everything was created so I would expect it was originally produced on the PC but I cannot see anything wrong with any of it other than HA is not communicating with any of the 4 phones to say they are either home or away. From memory, when I first set up HA via my HA yellow, my iphone automatically was there on the devices list.
On the iphone app, my location history shows a background fetch every 10 minutes or so from 8am this morning. I have not left the house yet but I will see if it updates when I do.