Pause Dallas Temp Sensor Data Logs

My son has a saltwater fishtank with a Dallas temp sensor in it at the top measuring the water temp. He doesn’t want to install the sensor lower in the fishtank because at the top there is a good fixing point and hidden.

When he does a 20% water change roughly it lower below the sensor and the sensor reads ambient room temp before he has time to fill it up with water again.

The graph log then show a spike or massive drop and its hard to read / see the temp graph because the range on the graph is large.

He asked if it was possible to Pause (turn off / on) the logging of the temp sensor with a switch while he preforms his water changes. This way he will be able to turn off logging during his water change and then turn it back on when he is finished and the graph range should stay small and easy to read.

Would anyone know how you would do this and or if it is even possible?

You could have a template sensor that reads the temperature sensors data.
The template sensor then has a condition to only read if the a boolean is true.
Something like

{% if(states('input_boolean.temp')) %}
   states('sensor.temperature')
{% else %}
   states('sensor.template')
{% end if %}

Not sure I got the syntax correct since I’m typing on the phone.

2 Likes

You can create a gpio switch and use that pin to power the dallas sensor. Set the switch to off and it will power down the sensor. I’ve not implemented this but I assume that esphome will just pick up the sensor again when powered backup.

It will probably work but Home Assistant will probably report unknown state, meaning 0, so again a sudden spike.

Neither NaN or unavailable show up as zero not sure why unknown would be any different.