Routines triggering on their own

Hi … since the loss of the garden hue app that could be used to change led strip colours I decided to use several routines to turn off and on virtual switches which in turns sets the rgb controller to various colours. It’s initial trigger is from the power meter above 15watts on a smart plug that powers the tv and another routine to switch off when power is below 5watts . (Tested those figures and they work well for switching the rgb controller on/off) my problem is the virtual switches (created from the labs in the android version) switch on and of randomly even when the initial trigger clearly doesn’t meet the switch on criteria . Each virtual switch is turned on by a routine that also sets the rgb colour and turns off the previously used routine . This way it loops nicely. When switched on it works very well but when powered off I get these random switching on/off of the virtual switches … anyone know why this might be happening please ? Thank you Andy

you may want to post screenshots of the Routines.

1 Like

These are the routines… ( there are 6 virtual switches called colour 1 to colour 6 ) The sequence is Started with TV Initial Colour routine that switches on the RGB controller if the TV smart plug is above 15W thus indicating TV is powered on and not on standby . This then calls Colour 1 routine after 20 seconds and so on until they loop back from colour 6 to colour 1. You will see each of the routines called colour 1 to 6 , set a colour, turn on the next virtual switch thus associated routine after 20 seconds to initiate the colour change and then turn of the previous virtual switch ready for the next loop. Hence why colour 1 then turns off colour 6 virtual switch as it loops. As I say when working it works fine, just that when TV is switched off and power reduces to 0 Watts the TV lights do power off but after about 20 seconds a random virtual switch will switch on and start firing the next one and so on thus the TV lights come on again. If I disable the colour routines and just leave the TV Initial colour routine this works well. There is a routine called TV Off which says if power on TV smart plug is equal or below 5W then turn off TV lights and turn off all the Colour 1 to 6 virtual switches. This also works fine … Its just the random nature of the virtual switches initialising when not commanded. Anyone seen this before ? Many thanks Andy

Is it actually ‘random’ and ‘after about 20 seconds’ or is it actually the sequence continuing regardless, so the next colour and up to 20 seconds? I think I’d expect the latter as when you turn the TV off there will already be a routine running that is in a 20 second wait so you haven’t broken the loop.

I think the Routines in your colour light loop probably need to test for the TV Lights being on as a precondition so the loop can be broken and you probably need to delay the turning off of all the lights at the end to allow the loop to terminate. I think that means by 20-and-a-few seconds. Something like that anyway.

I haven’t thought too deeply about a race condition if you turned off the TV just as a routine was about to run. It might be that using a separate switch to control whether the loop is active would be a better idea.

1 Like

Thanks that’s a really good idea as it could be just that. I thought by turning off each virtual switch as I went would help with this and also there is another routine that senses the lack of power draw and then turns off all virtual switches and tv lights. But I reckon a check condition would help … will look at that . thank you

Just as an update. I added a precondition on each of the routines and that seems to have worked well. Will keep an eye on it over the next few days/weeks.

Bit of a shame I had to fudge it this way and there is not an easier way to script something like this. Maybe a future feature ?

Thanks for the help thou… Regards Andy

I don’t think it’s a “fudge” and I think you would have this problem in any scripting or programming language unless you built in a way to discontinue the delay period of an already triggered Routine based on some condition. While possible, I’m fairly certain it would be fairly complex code.