Icon for my entities

Hi, I take some sleeps data with my smartwatch api and I show that on dashboard.

entity = ‘sensor.lightsleepduration’
self.set_state(entity, state = last_night_lightsleepduration)

entity = ‘sensor.sleep_time’
self.set_state(entity, state = last_night_sleep_time)

entity = ‘sensor.hr_average’
self.set_state(entity, state = last_night_hr_average)

entity = ‘sensor.hr_max’
self.set_state(entity, state = last_night_hr_max)

This work but i want to change the icon of each entity but I don’t know what to do, I’m using appDaemon and I try to set attributes inside the set state but don’t work.

To set the attributes of an entity, use the following code:

        attr = {}
        attr['icon'] = 'mdi:security'
        self.set_state("input_boolean.my_entity", state="on", attributes=attr)

The attributes are not persistent so you need to set the attributes in each set_state call, i.e. you can not just change the state.

Thank you very match. Now work!!