Change the value of an entity via autumation

Hello,

I have a custom sensor that reads the max temp of my pool so I can see how warm if got over the day. The sesor it reads that from occasionally gets a strange spike and hits 999 deg. So I wanted to see if I can use and automation to reset that max temp back to 0 so it will get a new value from the sensor again.

I have built and automation but I cant find an action to run to change the value. Is there a service call that I can use that anyone is aware of?

Pretty much I want it to do the same as me jumping in the dev tools and manually setting it to like this:

It’s better to do this in the yaml that creates the sensor.pool_max_temp.
Post the yaml for that entity and we can help you

2 Likes

That is only a temporary change for testing purposes (e.g. testing a numeric state trigger).

You are not meant to change sensor states. You can filter them: Filter - Home Assistant

Or as Hellis says, use a template to reject the unwanted states either in the integration value_template if it supports one, or with a template sensor.

Thanks.

    sensor:
      - name: Pool Max Temp
        state: >
          {% set outt = states('sensor.shelly_pool_temperature')|float(None) %}
          {% set maxt = states('sensor.pool_max_temp')|float(None) %}
          {% if  outt != None  and (trigger.id == 'midnight' or maxt == None
            or outt > maxt) %} {{ outt }}
          {% else %} {{ maxt }} {% endif %}
        unit_of_measurement: C

This is what I have set. Anything over 75 I want it to ignore really. (Infact it shouldnt ever really go above 31 with the automations)

You could easily set if outt < 75 or 31. But you could also look at the change from previous value to current value.
Setting a hard coded value might become ans issue but if the change when you get these wrong values are always 25 → 999 then it’s quite easy to filter out.
If it was 25 → 26 → 29 and so on then it could be harder.

How is this custom sensor integrated into HA? If it’s an ESPHome device, there are built in functions to filter out values directly on the device without having to rely on HA to do the filtering.

its a custom shelly uni project I built myself that monitors my pool, solar tubes and the water return temp. Its very basic and doesnt have options like that.

    sensor:
      - name: Pool Max Temp
        state: >
          {% set outt = states('sensor.shelly_pool_temperature')|float(None) %}
          {% set maxt = states('sensor.pool_max_temp')|float(None) %}
          {% if  outt != None or outt >35 and (trigger.id == 'midnight' or maxt == None
            or outt > maxt) %} {{ outt }}
          {% else %} {{ maxt }} {% endif %}
        unit_of_measurement: C

Would that work?

That seems to say the temperature has to be above 35 or it will use the previous value.
Or maybe I’m reading it wrong?

Shouldn’t it be:

{% if  outt != None and outt < 35 and...
1 Like

I’ll give it a try, I couldnt brain it haha

Just changed it up and restarted, run some tests changing and if its anything above 35 then it doesn’t update!

Thanks for the help!