Is this attribute an integer, or text?

How do I tell if an attribute on any given sensor is text or an integer? I know that states are text, but attributes can be anything. Dev tools/states lists the attributes of this particular sensor as

next_date: '2021-09-01T00:00:00+12:00'
days: 1
last_collection: null
last_updated: '2021-08-31T00:00:23.358122+12:00'
holidays: ''
friendly_name: Yellow Bin
icon: mdi:delete-circle
device_class: garbage_collection__schedule

Specifically I am interesed in the days attribute. I did an automation on it that didn’t trigger, and I suspect it is because the automation editor put quotes around the trigger value, but that it shouldn’t have one.

I don’t know if this helps, but if you write {{ state_attr('sensor.your_sensor', 'days') }} in Developer Tools → Template, on the right hand side you will have Result type (number, boolean, string).

Edit: see tom_l’s post below.

Unfortunately that wont help. The template editor results are interpreted.

See Developer Tools Template Editor returning incorrect attribute type · Issue #46198 · home-assistant/core · GitHub

Instead try this template:

{{ state_attr('sensor.your_sensor', 'days') is number }}

2 Likes

Thank you @tom_l .

In the attributes I posted above, is it relevant that the days is not in quotes?

No.

OK thanks. It is a number according to your template. Will it make a difference to my automation if it is written

trigger:
  - platform: state
    entity_id: sensor.yellow_bin
    attribute: days
    to: '1'

and this

trigger:
  - platform: state
    entity_id: sensor.yellow_bin
    attribute: days
    to: 1

For states no, for attributes I’m not sure. I wouldn’t quote it just to be safe.

Yeah its for the rubbish bin. There won’t be another test until next week.