Happy new year cleaver people's, I almost have my smart home complete. I was working on getting my tv to turn on and turn some lights on and off when doing so aswel as my speaker system, and turn all off when the tv is turned off.
I have come up with 2 rules but they seem to interfere with each other as the speaker system often turns on and off again about 3 or 4 times before settling down is there a fix for this please.
These our the 2 rules that I come up with
I also have a contact sensor on the door here and it supposed to give a notification if the door has been left open, it works fine if the tv hasn't been turned on but if the tv is turned off and then the door has been left open it doesn't seem to work, is there a fix for this please.
It'll probably be helpful for others if you show some logs. I would make sure you have logging turned on (events, triggers, actions) for both rules. Then:
Turn on the entertainment room TV and let everything start up
Turn off the entertainment room TV and wait the 5 minutes for the rule to complete
Then open past logs on your hub in a browser and use the filter to select just those two rules, screenshot it and post that. It might highlight something.
The delayed off could cause an issue. Let's say you have the TV on and turn it off. During that 5 minutes you decide to turn it back on again. The delayed off is still active and will turn the speakers off a few minutes later when you don't want it to.
I would probably have done this with a single rule (though other more experienced will have other ideas):
Trigger - Entertainment Room TV switch 'changes'
Actions:
IF TV on
do 'on' actions
Else
wait for elapsed time 5 minutes
do 'off' actions
end if
A Wait is cancelled when the rule is re triggered unlike a delay. So in the above, each time you turn on/off the TV the rule retriggers and cancels or restarts that wait depending whether the TV was turned on or off. That prevents the issue I mention above about turning the TV back on if a delayed off is in progress.
this is the logs from turning on, and I sat n watched the sonos system switch on and off twice the cabinet lights that turn on just stay on without a glitch
It looks as though the event that triggers the rule - 'when entertainment room tv switch on' is occurring once a minute, rather than just once when you turn the TV on - there should just be one event when it turns on and one event when it turns off) That will make the rule trigger over and over. Where does the trigger come from? What physical device is 'entertainment room TV'
Ok so it looks like that is going to continually send on/off events rather than just once when it turns on/off.
As a workaround, go to devices > add devices > virtual device. Create a new virtual switch device and name it something like 'Virtual - Sony TV'. Create 2 simple rules so that the 'Virtual - Sony TV' mirrors the 'entertainment room TV'
When 'Entertainment room TV' turns ON turn ON 'Virtual - Sony TV'
When 'Entertainment room TV' turns OFF turn OFF 'Virtual - Sony TV'
Then replace your trigger for your existing rule with the 'Virtual - Sony TV'
The 'Virtual - Sony TV' will get turned on when the real TV turns on but it should ignore those repeated triggers and therefore stop the rule repeatedly triggering from the status updates.
Instead of creating a virtual device, your first action could be to turn a Private Boolean to true. Then, under Restriced Actions, that Private Boolean must be false for rule to trigger. Then, for your rule that turns off everything off, the first action would be to set that Private Boolen to false and the restriction is that the Private Boolean is currently true.
I rely on Node Red but I believe this should work as an alternative; not necessarily better just different. As usual, there are lots of ways to solve the same problem with Rule Manager.
I worked it out I went wrong with my first try at the very start think this will work, the virtual switch hasn't worked for some reason i must have made a mistake somewhere, its nicer if I can get all the rules into one like this
nothing seems to work on the tv Automation at the moment lol I will go for a system rebooting and walk the dogs thank you for your help will be back soon
Actually @stephen_nutt solution is a bit more elegant and would work without the Virtual Switches.
Rule 1 - TV ON
Required Expression - Private Boolean True
Trigger - Entertainment Room Tv turns 'On'
Actions:
Set Private Boolean False
Turn your stuff on as required (command only if off)
Wait for event - Entertainment Room TV turns 'Off'
Set Private Boolean True
Rule 2 - TV OFF
Required Expression - Private Boolean True
Trigger - Entertainment Room Tv turns 'Off'
Actions:
Set Private Boolean False
Turn your lights off as required (command only if on)
Wait for event - elapsed time 5 minutes
Turn your Sonos off as required
Set Private Boolean True
That should work but there's still issues there....When you turn off the TV a wait for 5 minutes to turn the Sonos off is in play in Rule 2. If you turn the TV back on again within that 5 minutes, the Sonos will turn off when the original 5 minutes wait expires. There will be a more complicated way of solving that little issue but it would be easiest just to do away with the 5 minutes if you can. Also the second rule won't stop the repeated Off's triggering it every minute unless you add 'Wait for event - Entertainment room TV turns On' before the final Set Private Boolean True.