Hi there,
I’m new to HA and especially ESPHome.
I’ve set up an wemos d1 mini to measure temperatures of my heating system. I want to capture the Temperature quite fast and calculate the temperature change with a derivative helper in HA. That works fine sofar.
But I am thinking of reducing wifi traffic by doing the calculation of the temperature change on the ESP and only send an update if the value changes, to avoid unnecessarily wifi traffic. Currently I’m sending the values every second.
Can anyone help me with the code?
Here is the current code:
If you manage to stop sending values if there’s no change, then beware that the HA derivative sensor will not work well because of it. The derivative will only calculate on new data. If there is no change, the derivative should go to zero. But it won’t, if you don’t send the duplicate value. So you will need to find a way to get around that until it is fixed.
My goal is not to use the derivative sensor in HA, and do the calculation on the ESP instead.
Current situation: ESP sends temperatures every second to HA and there I use the derivative sensor to detect changes.
Plan: detect the temperature change on the ESP and only send a value if its greater than a certain value.
According to the docs, you can set the temp sensor to internal to prevent sending the data to HA:
internal (Optional, boolean): Mark this component as internal. Internal components will not be exposed to the frontend (like Home Assistant). Only specifying an id without a name will implicitly set this to true. Sensor Component — ESPHome
A simple version of a derivative can be calculated using this description:
However, I doubt that will work well on temperatures, a better one will be harder, maybe by calculating an average using a filter (see also the filter docs I mention in the next point).
And if you want to only send the derivative if its value is above a certain value, a delta filter would help you avoid sending smaller values:
But remember, if you only send the derivative if it is high, how would you react to it changing from small to big or vice versa? Or is it that you only want to sent the temperature if the derivative is high? That would be weird because the temperature in HA would not change after a long gradual rise or fall.
Reducing wifi traffic and by limiting the frequency of a sensor value? Did your wifi router come free when you signed signed up with AOL and bought a 56k dial-up modem by chance??