this post was submitted on 28 Sep 2023
20 points (95.5% liked)
homeassistant
12080 readers
4 users here now
Home Assistant is open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server. Available for free at home-assistant.io
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Is it possible to do this in a way that completely omits data: from the command if the variable isn't defined?
It worked the same as your suggestion above. In cases the variable is used it does works as intended but in the situation the variable is not set it's still sending data: just with a blank value.
When I tried playing with omit in the template editor I got an error about omit being undefined so probably not built in. Bummer because that would be a very elegant solution to this. I'm going to put this down for the night and try picking it back up tomorrow. I really appreciate all the suggestions. Hopefully it will lead me to a solution.
To give more context I'm working on a media control dashboard. The script or rather scripts I have to send commands to kodi is as follows
I would like to condense all of this down to a single script using "is defined" to omit the parts not needed for certain commands so something like
Problem with the above is I get "result is not a dictionary"