Get attribute form entity

Hi,

I’m using a picture card as a floor plan to show the state of entities such as lights etc. The following is a snip from the code:

type: picture-elements
elements:
  - type: state-badge
    entity: light.living_room
    style:
      top: 80%
      left: 70%

I would like to show the temperature from one of the sensors but I can’t find the appropriate syntax to do so.

The following is from the dev tools> states (mill integration), and I’m interested in displaying current_temperature:

hvac_modes:
  - heat
  - 'off'
min_temp: 5
max_temp: 35
target_temp_step: 1
fan_modes:
  - 'on'
  - 'off'
current_temperature: 21
temperature: 16
fan_mode: 'off'
hvac_action: idle
open_window: null
heating: 0
controlled_by_tibber: 1
heater_generation: 2
room: Kontor
avg_room_temp: 22
friendly_name: Kontor
supported_features: 9

Thanks.

Use a template sensor: https://www.home-assistant.io/integrations/template/

1 Like

Try {{state_attr('ENTITY_ID', 'current_temperature') }} as your template.

2 Likes

Thanks to @Danielhiversen and @brg468. You guys are genius’s. Never used templates before, so this was new to me. Following documentation and threads helped:

https://www.home-assistant.io/integrations/template/
How to display template sensor attributes in HA home page?

The final solution ended up like this and could then be referenced like: sensor.office_temperature:

- platform: template
  sensors:
    office_temperature:
      entity_id: climate.kontor
      friendly_name: "Office temperature"
      unit_of_measurement: 'degrees'
      value_template: "{{state_attr('climate.kontor', 'current_temperature') }}"
1 Like