Template issue? Lowest temperature "flickers" between the entities

Hi

I have two temperature sensors, one on the front side of the house and one of the backside. I have a template that give me the lowest reading.

    - name: "Lägsta temp utomhus"
      unique_id: lowest_outside_temp
      unit_of_measurement: "°C"
      device_class: temperature
      state: "{{ [ states('sensor.temperatur_ute_baksida')|float(0) , states('sensor.utomhus_temperatur')  |float(0)] | min | round(1) }}"

Today I saw it did not work as intended… See picture

One sensor is a 1-wire that updates every 10-minutes and one sensor is a Netatmo sensor via zigbee that updates when it feels like it. Maybe thats the problem? I can’t find any reason the template does not work…

Cheers

At first I thought it was because one of your sensors was becoming unavailable and you need an availability template. But that’s not it.

Then I thought you may not have initially had the float() filters in your template and were comparing strings. But that’s not it either.

Is this a triggered template sensor?

Can we see the full template sensor definition?

One of the hardware sensors must be doing something funky.

The blips seem to be happening about 6 times per hour, as do updates to one of the sensors, and the blips coincide with those updates.

At first, I thought that the 1-wire sensor must be doing something funky, but it could be either one of them. Take a look at the history of the states that each sensor is reporting. You could also write an automation that triggers on either sensor’s state change and reports it in the log; you can then go back and see what the value of each states was at the moment when the blip happens.

(Like tom_l, I don’t have a clear hypothesis about just what is going wrong, because if one of the sensors was dropping out at some level, the float filter should peg it to 0 on the graph. It’s interesting that the pattern does not change even as the minimum value goes above 0…)

EDIT: Actually, I’m confused by why the legend in the graph identifies the blue data as “1-wire” when you say in your post that it updates every 10 minutes. Maybe that is just an error? I’d actually expect the once-every-ten-minutes-or-so update pattern to come from a Zigbee sensor.

The only way I can explain the graph is that when an update come in from the blue sensor, there is something off about the value that the red sensor reports via states.

They are already visible in the graphs.

Not if the other sensor was below zero, which it was. But it kept doing it even when it went above zero.

Very very odd.

I’m not trusting the graphs, which is why I suggested the automation. I can’t think of a way to square the graph with the code.

It’s also odd that:

  1. The behavior seems to have stopped when the lower sensor crossed 2.5 degrees.
  2. And just before it stops, the red curve shows a period of about 10 minutes where it corresponds to neither the blue or the yellow curve.

Point 2 makes me think that there is a discrepancy between the sensors the code is looking at and the sensors graphed… which brings me back to my point at the top of this post, I suppose, that I’m not trusting the graphs.

1 Like

Okey, thank you the attention. I will monitor this problem and try to catch it when it happens next time.

Here are some more pictures regarding trusting the source data, not sure if it helps.

I was mostly curious if I wrote the template incorrectly.

If this was a one-time occurrence, we can probably close the thread.

The template is in my templates.yaml with all the other,

- sensor:
    - name: "Lägsta temp utomhus"
      unique_id: lowest_outside_temp
      unit_of_measurement: "°C"
      device_class: temperature
      state: "{{ [ states('sensor.temperatur_ute_baksida')|float(0) , states('sensor.utomhus_temperatur')  |float(0)] | min | round(1) }}"

Yeah, it’s your 1-wire sensor going unavailable. You’ll need to account for that. I assume you don’t want the minimum sensor to go unavailable when that happens so an availability template is not the right choice. You can keep the last good state like this:

- sensor:
    - name: "Lägsta temp utomhus"
      unique_id: lowest_outside_temp
      unit_of_measurement: "°C"
      device_class: temperature
      state: >
        {% if has_value('sensor.temperatur_ute_baksida') and has_value('sensor.utomhus_temperatur') %}
          {{ [ states('sensor.temperatur_ute_baksida')|float() , states('sensor.utomhus_temperatur')|float()] | min | round(1) }}
        {% else %}
          {{ this.state }}
        {% endif %}
1 Like

thanks, I will try that.