How can I send a notification of a state attributes of an entity

Tags: #<Tag:0x00007f325ace5cc8>

Hi,
I would like to send a notification of one of the state attributes of an entity. Basically the below is the entity and I would like to send the daily_yield value in a message.

Tried the below but it didn’t work.

message: ’ {{ states(sensor.sun2000_3_68ktl_l1.attributes[“daily_yield”] }}’

Regards,
Et

Please try this in template

message: '{{state_attr('sensor.sun2000_3_68ktl_l1.attributes', 'daily_yield')}}'

Its being marked red not letting me save as if there is something wrong in syntax. See attached

Capture

You can always test templates in the HA dev tools, to easily spot errors.

Anyway, this would be the correct template to get the attribute:

{{ state_attr("sensor.sun2000_3_68ktl_l1", "daily_yield") }}

You need to either use double quotes outside the curly brackets and single quotes inside or vice versa. And the .attributes part is incorrect.

message: "{{ state_attr('sensor.sun2000_3_68ktl_l1', 'daily_yield') }}"