Bibabutzi
(Sebastian)
December 28, 2020, 4:16pm
1
Hello everyone. I wanted to ‘extract’ an attribute from a switch and use it as separate device.
I searched a bit in the forum but I am not sure what is wrong here:
sensor:
platform: template
sensors:
solar_erzeugt:
value_template: '{{ states.switch.solaranlage.attributes.current_power_w }}'
unit_of_measurement: 'kWh'
That is the entry of my template configuration.yaml
Thank you for your help
Best regards,
Sebastian
Have you tested your template in the dev-tools?
I use the following template for that. With “state_attr” you don’t get an error when the enity isn’t available.
{{ state_attr('switch.solaranlage', 'current_power_w') | float }}
Bibabutzi
(Sebastian)
December 28, 2020, 4:28pm
3
Never usedthe dev tools. I am new with home assistant. Where can I finde them?
Develpoer tools in the left menu and then template tab. Just paste your template code there and check if you have the correct result.
Bibabutzi
(Sebastian)
December 28, 2020, 4:47pm
5
A sorry. Was in germa mode. Have changed it now. Much easier with documentation and so on.
Works in the dev tools and also the sensor is there.
Tank you