I’m using the Alexa media integration to pull the last command issued to my voice assistants. I have a sensor defined in my config.yaml (code taken straight from the Alexa media integration Git page).
If I paste the value template into Dev Tools\Templates, it works perfectly, but as you can see from the screenshot below, my sensor is not being updated. Furthermore, if I paste the code into a markdown card, I get some weird undefined error… what gives?! I don’t think this is an issue with the integration as the attributes are being reported to HA correctly by the integration.
Add this filter before between your existing select and selectattr filters.
selectattr('attributes.last_called', 'defined')
It confirms the selected media_player has a last_called attribute.
FWIW, the problem you encountered is an anomaly that was reported but nothing was done to correct it. The Template Editor doesn’t carp if it’s instructed to test the value of a non-existent attribute. In contrast, the same procedure performed elsewhere won’t allow it.