New Helper: Entity from attribute

It is quite common to want to turn an attribute of an entity into it’s own entity: E.g Sun elevation for automations. Temperature from the weather entity. Etc etc. This makes automations easier and also gives other advantages such as state history.

This is often done with templates

  - sensor:
    - name: sun_elevation
      state: "{{ state_attr('sun.sun', 'elevation') }}"
      unique_id: c0b35ff264f5d00dfbcf135fd560e375
      unit_of_measurement: '°'
#      state_class: measurement
    - name: boiler_target_temp
      state: "{{ state_attr('climate.hive_boiler_thermostat', 'temperature') }}"
      unique_id: f3ba759359840932bac93ba1928c63c4
      unit_of_measurement: '°C'

It would be great if these could be set in the helper UI.

+1 and also remembering that the attribute can be ‘deep’, such as x.y.z.

Commonly - weather forecast related:


For example to check if the forecast low temperature might warrant a frost warning, or:


To generate 2 sensors that can be added together to issue a warning if the 48 hour precipitation forecast might cause local flooding.

I think this is a great idea and will build it.
Probably plenty of templates which are no longer needed then for a lot of people as still there is a lot of data in attributes still.


Awesome, link to the PR when you make it. And would be happy to contribute.

We might even be able to use regex to detect YAML entries in the style of "{{ state_attr('x', 'y') }}" and {{states.x.attributes.y}} and suggest migration using the new repairs UI.

1 Like

As this was not approved to have within core I have released it finally as a custom component if someone finds it here and is interested.
At time of writing not yet available in HACS default.