Been using HA for about 6 weeks now, and am really moving along nicely thanks to everyone’s help on this community.
Just got around to adding my old 4 button minimote’s. They are working quite well with this simple set of automations, but was wondering if it would be possible to combine into a single automation, or what sort of things other on here might do for something like this. I mean it works right now, just curious if there are better, smarter ways to accomplish this.
Super cool, I can see using this in a few of my other automations as well. Let me make sure I fully understand.
So for the trigger, in my automation I had a trigger for each scene ID, with your example the scene ID is not there, so I’m assuming that this means it will trigger for any scene. Then the ‘set map’ will use which ever scene ID was the underlying trigger to then map that scene id to the entity listed.
Lol! I saw you responding so I didn’t bother. Then I didn’t see a response so I jumped in. Good idea checking the scene_id and minimizing the data structure size via the divide!
Yeah, I got a call that side tracked me. Then I hit send and saw yours… lol oh well!
EDIT:
Thanks, I like lists better than dictionary maps because I hate anything verbose… It can be helpful. There are times you look back and think “WTF am I doing here” though.
Amazing to get two responses so quickly. So I better understand can you explain a little bit how the template works.
Would I list, each possible trigger
(trigger.to_state.data.scene_id - 1) // (trigger.to_state.data.scene_id - 2) // (trigger.to_state.data.scene_id - 3)// and so on
or is just the / 2 % enough for it to realize there are more options?
All this math is doing is taking 1 through 8, turning it into 0 through 3. So the first thing that needs to occur is changing the indexes from 1 through 8 to 0 through 7. So, subtract 1. Then we need to take 0 through 7 and turn it into 0 through 3 because selections (0, 1), (2,3), (4,5), (6,7) are essentially pairs. To do that, use integer divide. That will take any number and remove the remainder. So 7/2 would normally give 3.5, instead // returns 3 with the .5 chopped off.
Now how does 0 through 3 link to our list? Well all lists start with an index of 0. If we make a 4 item list, then item 1 would be index 0, item 2 would be index 1, etc.