Must be being switched on from somewhere else, that automation won’t fire if the sensor is pending. That’s the reason I introduced the pending state so I could add the condition.
Also, even if it did skip the condition somehow, unless the sensor is ‘pump_on’ then the result will be to switch off the pump.
So, if we’re happy it definitely was ‘pending’ it was switched on by some other means. If it was on pump_on I’ll need to have another look at the template.
Can you check the logbook and see which is the case?
Seems switching on and off OK, just not off when state is pending? There are no other automations pertaining to the solar_pump. Could the broker retain message be doing anything?
automation:
- id: ID12
alias: 'Pump hot water if hotter than pool - stop if not'
initial_state: 'on'
trigger:
platform: state
entity_id: sensor.temp_diff
action:
entity_id: switch.solar_pump
service_template: >
{% if is_state ('sensor.temp_diff' , 'pump_on') %} switch.turn_on
{% else %} switch.turn_off {% endif %}
I’ve just reordered the template to make sure it double checks if it should be off before it checks if it should be on, which will hopefully get rid of any false positives (should’ve done that in the first place, sorry!)
Then I’ve removed the condition to ensure that any state change that isn’t ‘pump_on’ switches it off. The automation will fire a little more frequently, but should ensure that the pump is always off when it should be.
Here is all three sensors. Nothing changed with those.
## Pool pump status sensor as switch is hidden:
- platform: template
sensors:
pool_pump_status:
value_template: '{% if is_state("switch.pool_pump", "on") %}Running{% else %}Stopped{% endif %}'
friendly_name: 'Pool Pump Status'
## Creates a history sensor based on how long the pool pump has been in a
## status of 'running' defined in the aboved value template:
- platform: history_stats
name: Pool Pump running today
entity_id: sensor.pool_pump_status
state: 'Running'
type: time
start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'
## Look for the attribute named 'value' from the above sensor to create
## a new sensor using that attribute:
- platform: template
sensors:
pool_pump_time_on:
value_template: '{{ states.sensor.pool_pump_running_today.attributes.value }}'
friendly_name: 'Pool Pump Hours Running'
Hi. I have just started with Home Assistant and your differential temperature sensor with hysteresis is just what I am looking for. Would you be willing to share your final code with any improvement you may have added. Did you include a weekday scheduler with your final version? Thanks
Hi I am a beginner with home assistant and I am intending to build a differential temperature sensor with hysteresis to control my swimming pool solar system. I originally contacted xbmcnut and he has provided an initial response about his system but has only supplied some of the details of the setup at this stage. I see from the post that you were involved in the initial coding and wondered if you have the complete package for this project.
I would appreciate any help that you may be able to offer. Thanks