I’m guessing this has been done many times before but I can’t find an example piston of this so I’m looking for some help to simplify what I’m trying to do. I’d like to create a piston for a Simulated Dimmer in ST that will control a room full of hue lights. I’d like to use this simulated dimmer as a tile in ActionTiles. I want this to be easily repeatable using some variables at the top of the piston so that I can make a tile for each room of my house. In addition, I have built automated windows that ST see as a dimmable switch that I’d like to use the same way. I want a tile that will set the percentage of all the windows in one room at the same time. This should be the exact same piston concept as the lights as far as I can see. I created a piston to the best of my ability and it does accomplish what I want but it’s very long and complicated and I am hoping there is a far simpler way to accomplish this. This piston is for a 2-Window bay in my living room. I have 10 other rooms with windows and lights for a total of 20 more pistons. I’d actually love to do all the Switches in just one piston but I’m not sure if that’s possible. I tried to use two local dynamic variables for % and on/off status but I didn’t use them anywhere because I couldn’t wrap my mind around how this would be useful. I essentially repeated a reverse version of the piston at the bottom to achieve reciprocity between my actiontiles reading and the actual reading in case I control the lights/windows from a source other than actiontiles. Without this section, my simulated dimmer switch does not accurately reflect the lights/window % if I set it from the remote control or Alexa or any other source. So, with no further rambling, here’s my piston:
Simulated Dimmer to control entire room?
I went back and changed all my devices to variables and defined them at the top so this should make it simpler to repeat the piston by just changing the device variables. Is there a way to use the currentState and currentLevel dynamic variables to my advantage? Currently I just have them in the piston but they aren’t being used. They are showing the correct readings upon changes but it works without them. I’d like to somehow use them to avoid the reciprocity portion of the piston. Also, is there a clever way to combine the on/off status into one if/then statement instead of doing one for On and one for Off? Here’s my updated piston with the device variables:
If I understand what you’re trying to do, I think this will do it?
I forgot to do it but you can get rid of the currentLevel and currentState variables with this piston, too. But as you said, they were more for evaluation and not function, anyway.
You also need to consider keeping the simulated switch in sync if the bulbs are turned off by some other method… you would want AT to show the correct state at all times.
Doable with webCoRE but this one might be best solved using a well established smartapp built for the purpose…
Here’s the template I use for all my lights. I have one for virtual switches, one with an override say for a bedroom, and one variant for a virtual switch.