Automation challenges: 'homeassistant.core.State object' has no attribute

hi all,
I’m a few weeks into my home assistant journey… in some ways far supiour to openhab… in others, quite frustrating… one is the error messaging that I’m still trying to get my head around…
in this case, I have 2 apparent attributes of a thermostat (hive) which look the same through the developer tools, but only one of which works as expected…
it appears to have attributes “temperature” and “current_temperature”:

however, when I try to put an automation in place… it only works for “temperature”. what is the difference for the attribute “current_temperature”? how can I retrieve its value?

thanks!
R.

automation script…

      - alias: test temperature increase
    trigger:
      platform: template
      value_template: '{{ states.climate.downstairs_heating.attributes.temperature > 18 }}'
    action:
      - service: notify.pushover_notify
        data:
          message: "works when set point is put above 18"
  - alias: test current_temperature increase
    trigger:
      platform: template
      value_template: '{{ states.climate.downstairs_heating.attributes.current_temperature > 18 }}'
    action:
      - service: notify.pushover_notify
        data:
          message: "never executes.. no attribute current_temperature"

Hi @230delphi, what’s shown in Developer Tools/Templates if you insert:

{{ states.climate.downstairs_heating.attributes }}

thanks for the help @VDRainer! very much appreciated.
lots to learn… useful dev tool!

output from that command shows current temp:

{'aux_heat': 'off', 'supported_features': 2177, 'current_temperature': 19.9, 'operation_mode': 'auto', 'unit_of_measurement': '°C', 'min_temp': 5, 'max_temp': 32, 'friendly_name': 'Downstairs Heating', 'operation_list': ['auto', 'heat', 'off'], 'temperature': 20}

I should also add version: 0.62.1

So if

{{ states.climate.downstairs_heating.attributes.current_temperature }}

shows the right value, your template trigger should work.

But i would try to use the numeric_state instead of the template trigger for this.
From the docs:

Template triggers work by evaluating a template on every state change for all of the recognized entities.

1 Like

@VDRainer thanks again. that solved it… although I’m not clear on the significance of the doc snippet - is it that its not a recognised entity?
as my automations get more complex, feels like I need to move towards native python scripts (or applications?).
I guess that is what most of the power users end up with?

for any beginners… the solution looks like:

  - alias: test current_temperature increase
    trigger:
      platform: numeric_state
      entity_id: climate.downstairs_heating
      value_template: '{{state.attributes.current_temperature}}'
      above: 17
      below: 20
    action:
      - service: notify.pushover_notify
        data:
          message: "test temp increase check!"

I’m also not clear about this, but i think the template trigger gets evaluated on every change of every entity. I’ve seen this on other topics that i can’t find now.

Then take a look at Appdaemon

Here’s an easy tutorial by @ReneTode

2 Likes