For scripting purposes, I need to add some extra attributes to some sensors. After adding them, I noticed that if the actual device is unavailable or it’s restore state set to true, custom attributes are not set.
But for some reason, even if media_player.audio_2 is unavailable, I can see them, which is not the case for media_player.camera_1_yh_media_player.
But I believe it has something to do with restored: true but I haven’t been able to find relevant information in the doc or the forum.
I need these information as cameras are linked to plugs, which by default are not up.
Can someone tell how to have these information even if the device is unavailable? Or I need to ass an extra parameter to set the restore attribute to false?
My use case for this is that I have a generic script for play TTS on all my media players (MusicCast, MPD and Yi-Hack). All these devices are plugged on smart plugs and all these devices behave differently and need specific instructions before being able to play TTS.
Clearly not, I’ve never touch anything like that in my configuration.
The only difference I see between these 2 entities are their integration: the 1st one (audio_2) comes from MPD (configured via configuration.yaml) and doesn’t have any UI configuration while the other one comes from Yi Hack.
I also note a pattern for this restored: true: I have a Musicast integration (through the UI) and the behavior is similar. No custom attributes while it’s unavailable.
Still no success but I was wondering if it’s possible to add custom attributes using a service? Or something else?
As of now, the only workaround I found is to switch on plugs to get attributes populated for the entities I need. Would be great if someone had a better idea
BTW @123 , can you tell what is the purpose of "restored":true?
I’ve been able to make an Restful API call to add a custom attribute but weirdly, it doesn’t work for full text-based integration like MPD while it works for Musciast:
Musiccast (webUI): even if the integration is set to reload itself to test if the device is up (mine is connected to a smart plug), the custom attribute survives
MPD (text-based): the custom attribute lives for a short moment and then disappear, probably after the integration reloads
I believe it has nothing to do with webUI/text-based integration but more with some obscure internal mechanism that I will be happy to understand so that I can use the custom attributes feature without using workarounds.