Easy creation of sensors from attributes

By today you have to create a template sensor to extract values from devices attribute e.g. Current Consumption of a wall plug

It´d be great to just click a button an get this done without touching a yaml file again?


Actually you don’t.

State and numeric state triggers and conditions have been updated to use attributes. So have some Dashboard cards.

Particularly useful for when you want long term statistics from some attributes.


Seems that History Graph does not support Attributes, or documentation is not correct? My intention is more of a long term stats view.

So you don’t want to create a sensor you just want the History Graph to support attributes?

Can you edit your post and title to say that please.

Think having an easy way to create a template sensor will make it usable in a variety of cases. Another case was the deutsche_bahn integration

  - platform: deutsche_bahn
    from: Sauerlach
    to: MuenchenOst
    offset: 00:02:00
    only_direct: true
  - platform: template
        value_template: "{{ states.sensor.sauerlach_to_muenchenost.attributes.next }}"
        friendly_name: "Nächste Sbahn nach München"
  - platform: template
        value_template: "{{ states.sensor.sauerlach_to_muenchenost.attributes.delay }}"
        friendly_name: "Verspätung nach München"
        unit_of_measurement: "min"

making template sensors easier to create it gets way more accessible to less experienced people out there.


Yes but what are you doing with those sensors?

I you are just displaying the next train on your dashboard the entities card supports that, so no need for a template sensor.

Also just FYI, you should use state_attr() for your template to prevent errors.



I´m using it in an automation sending a notification to my mobile so it´s not sufficient to display the attribute on a dashboard. Thank you for the hint!

1 Like

You can put the template in the message data.

Having a first-class sensor instead of just an attribute is useful for all kinds of reasons, even if there were some support for seeing history etc of attributes.

Lots of stuff in HA works based on entities with attributes being an afterthought. So either we’d have to clean up all those places, or add this one feature.


I’d like to use a attribute in statistics graph, now it doesn’t see it.

There’s a HACS integration:

A little easier than templates, though not as easy as just clicking a button, but thought it was worth a mention!

1 Like

Thank you for mentioning it. Still I could imagine that it´d be way more comfy to get things done Way easier when it be directly integrated to get attributes addressable more easily all around HA.
Or like having an “automated” way to apply sum integrals to an attribute via UI and directly show results.

Yeah, something like a helper seems like it would be appropriate here. I like your idea about having a button right next to the attribute, though not sure how that would smoothly fit into the existing UI design.

it works perfectly thank you so much Cannot get data from entity · Issue #35 · pilotak/homeassistant-attributes · GitHub

1 Like