Sensor reports 0 when template availability states is not none?

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('', '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('', '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:

  - 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('', 'rows') is not none and state_attr('', '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?