Sensor reports 0 when template availability states is not none?

Hi,
I don’t understand the availability in my template sensor.
How come that the sensor still reports 0 in a few moments (see the screenshot below), when the availability in the template states that it should not report when it’s 0?

      availability: >-
        {{ state_attr('sensor.data', 'rows')['impressions'] is not none }}

Am I’m doing something wrong?

none is different to 0.

none means there is no state value (“null”).

Try this:

      availability: >
        {{ state_attr('sensor.data', 'rows')['impressions']|float(0) != 0 }}

with your example somehow I get this message:
UndefinedError: 'list object' has no attribute 'impressions'
but when I look up the sensor in question, the result is:

rows:
  - keys:
      - test1
    clicks: 0
    impressions: 34
    ctr: 0
    position: 55

so the template is correctly used I think, it looks at right attributes

if rows is none, you have to account for that.

  {{ state_attr('sensor.data', 'rows') is not none and state_attr('sensor.data', 'rows').impressions is not none }}

Hi Petro this improves the null availability part but not yet the 0 result, right?

I just looked at your last error message and I noticed rows was a list. Is it always populated or is it sometimes empty? Are you always getting the first item in the list?