Hello,
Sorry for the long post, I wanted to include the full context and what I already tried. But let me start with a quick summary of what I want to achieve:
TL;DR: I need help on how to save the information if my Android TV projector was playing, so that I can resume playing after doing some other actions, all in one script. I tried scenes and variables, but can’t get it to work as I want.
I have setup TTS through my Yamaha receiver. It all works very well in general. I’m saving the state of the receiver by creating a scene at the start of the script, then I make some changes if necessary (to turn on the receiver, switch the source, adjust volume), play the message, then turn on the scene to reload the previous state of the device. This works fine in general.
But the same approach does not work for my projector with Android TV on it, connected to HA with Android TV and Google Cast integrations (both are needed for different kind of control/information about the projector). Each of those integrations create a separate media player entity. I tried saving either of those entities in the scene, but it does not work as I expected. It fails at resuming the previous state. Either does nothing (Android TV one) or starts casting HA to it (the Google Cast), even though it was playing Netflix before.
I read the scenes documentation, and couldn’t really find much in terms of how this actually works technically, how does HA restore the state from the scene, and what devices are supported exactly (is it supposed to work for all integrations and devices?).
Secondly, I looked into creating a variable. This would work perfectly for my specific case, as I just need the info if the projector was playing, so I can pause it and then resume playing. I looked into variables, but it seems this approach won’t work, because variables scope is very limited, documentation says:
Variables have local scope. This means that if a variable is changed in a nested sequence block, that change will not be visible in an outer sequence block.
I don’t know if I understand this correctly, but it seems the variable I would save in the if>then block at the start of the script, would be only available in that block, and not when I try to act on it in a later sequence. Am I right?
An unrelated part of documentation, about parallel actions, seems to suggest those variables may be available to other sequence actions though, so I’m confused now:
- Variables created/modified in one parallelized action are not available in another parallelized action. Each step in a parallelized has its own scope.
Thanks in advance for any help.