- alias: Sync Set Thermo Value
trigger:
platform: state
entity_id: sensor.desiredtemp
action:
- condition: and
conditions:
- condition: template
value_template: '{{ states.sensor.desiredtemp.state != states.input_number.thermo_slider.state }}'
- service: input_number.set_value
data_template:
entity_id: input_number.thermo_slider
value: "{{ states.sensor.desiredtemp.state }}"
- alias: Set Thermo Value from HASS
trigger:
platform: state
entity_id: input_number.thermo_slider
action:
- service: shell_command.set_thermo_value
- condition: and
conditions:
- condition: template
value_template: '{{ states.input_number.thermo_slider.state != states.sensor.desiredtemp.state }}'
Something is wrong with Sync Thermo Value, because if I comment it out this doesn’t happen.
This is controlling yet another controllers virtual thermostat. Here I have two automations. One to set the foreign virtual thermostat to the sliders value. The other updates the slider based on the sensor value.
For some reason I can’t figure out, often times the result of changing the set temp either via HASS or the foreign controller, my desired temp gets set to a weird value of “-0.100000038” - and not just hass. It tries to set the foreign thermostat to that as well.
If I leave the “Sync Thermo Value” automation out - this doesn’t occur.
If you have conditions in actions the list is executed in order. Actions progress down the list until a condition is not met then the automation exits. So the condition in your second automation does nothing as it is after the service call. It needs to be before the service call. Also you don’t need the and statement. Conditions are and by default and you only have one condition.
So, like this:
- alias: Set Thermo Value from HASS
trigger:
platform: state
entity_id: input_number.thermo_slider
action:
- condition: template
value_template: '{{ states.input_number.thermo_slider.state != states.sensor.desiredtemp.state }}'
- service: shell_command.set_thermo_value
or like this as the only action is conditional for the whole automation:
- alias: Set Thermo Value from HASS
trigger:
platform: state
entity_id: input_number.thermo_slider
condition: template
value_template: '{{ states.input_number.thermo_slider.state != states.sensor.desiredtemp.state }}'
action:
- service: shell_command.set_thermo_value
Your second option resulted in: 2018-11-30 01:47:51 ERROR (Thread-2) [homeassistant.util.yaml] mapping values are not allowed here
in “/home/homeassistant/.homeassistant/configuration.yaml”, line 210, column 21
The first option still exhibits the problem.
Adding a delay to “Set Thermo Value” of 3 seconds seems to have helped.