Hi Everyone!
Please, help me solve the problem in ESPhome? I have a problem with the switch configuration depending on the temperature.
I want the pump to work in the temperature range, e.g. between 20 and 40 degrees.
Below 20 and above 40 the pump should be switched off.
I tried something like this:
From the docs: This trigger will only trigger when the new value is inside the range and the previous value was outside the range.
I assume you’ve allowed for this? If the system starts at e.g. 30°C the pump won’t run.
Are you certain the temperature is being read correctly and the pump operates when triggered via another method? Can you paste the boot logs, and the logs whilst transitioning from outside the 20–40°C range to inside? The dallas ID is too short: I assume you’ve cut that for brevity?
Range set to 27-31 degrees. The log looks like this:
[14:37:11][C][api:096]: Address: pump.local:6053
[14:37:51][D][dallas.sensor:148]: 'Pump Temperature': Got Temperature=30.2°C [14:37:51][D][sensor:092]: 'Pump Temperature': Sending state 30.18750 °C with 1 decimals of accuracy
[14:37:51][D][switch:021]: 'Pump_ON' Turning ON.
[14:37:51][D][switch:045]: 'Pump_ON': Sending state ON
[14:38:51][D][dallas.sensor:148]: 'Pump Temperature': Got Temperature=33.1°C
[14:38:51][D][sensor:092]: 'Pump Temperature': Sending state 33.12500 °C with 1 decimals of accuracy
[14:39:51][D][dallas.sensor:148]: 'Pump Temperature': Got Temperature=34.0°C
[14:39:51][D][sensor:092]: 'Pump Temperature': Sending state 34.00000 °C with 1 decimals of accuracy
[14:40:51][D][dallas.sensor:148]: 'Pump Temperature': Got Temperature=34.2°C
[14:40:51][D][sensor:092]: 'Pump Temperature': Sending state 34.25000 °C with 1 decimals of accuracy
[14:41:51][D][dallas.sensor:148]: 'Pump Temperature': Got Temperature=32.1°C
[14:41:51][D][sensor:092]: 'Pump Temperature': Sending state 32.12500 °C with 1 decimals of accuracy
[14:42:51][D][dallas.sensor:148]: 'Pump Temperature': Got Temperature=29.7°C
[14:42:51][D][sensor:092]: 'Pump Temperature': Sending state 29.68750 °C with 1 decimals of accuracy
[14:42:51][D][switch:021]: 'Pump_ON' Turning ON.
[14:43:51][D][dallas.sensor:148]: 'Pump Temperature': Got Temperature=27.9°C
[14:43:51][D][sensor:092]: 'Pump Temperature': Sending state 27.87500 °C with 1 decimals of accuracy
[14:44:51][D][dallas.sensor:148]: 'Pump Temperature': Got Temperature=26.4°C [14:44:51][D][sensor:092]: 'Pump Temperature': Sending state 26.37500 °C with 1 decimals of accuracy
[14:45:51][D][dallas.sensor:148]: 'Pump Temperature': Got Temperature=25.5°C
[14:45:51][D][sensor:092]: 'Pump Temperature': Sending state 25.50000 °C with 1 decimals of accuracy
[14:46:51][D][dallas.sensor:148]: 'Pump Temperature': Got Temperature=33.5°C
[14:46:51][D][sensor:092]: 'Pump Temperature': Sending state 33.50000 °C with 1 decimals of accuracy
I think there should be a condition that turns off the pump above 31 and below 27 degrees
with 0.1 space.
One more question
How to set the pump’s initial state to off?
Now when I turn on the power, I have the status on.
Even when the temperature is below 19 degrees
It will be okay?
restore_mode: ALWAYS_OFF
Adding restore_mode: ALWAYS_OFF should do the trick, yes. Default is to try to restore prior value, which may end up with the pump on even at low temperatures because “This [on_value_range] trigger will only trigger when the new value is inside the range and the previous value was outside the range.”
I set restore_mode: ALWAYS_OFF
The problem is that now when I turn on the power it flashes.
For less than 1 second it changes from on to off. Only once.
You need to select another GPIO. One that is not high on boot. You don’t mention which ESP you are using so here are two useful references, select the one appropriate to your device: