I'm going to try and explain as much as I can. I sorta know the problem, but am unsure how to go about troubleshooting the exact cause and fixing it.
Summary: I have an HS300 in my living room. It's an energy monitoring power strip. I have my TV and an air purifier plugged into it. I have a rule that when the TV powers on, will turn off the air purifier outlet. Since the air purifier has to be physically interacted with to turn on, I have a second rule that turns the outlet back on after a few seconds delay.
Problem: Sometimes, the outlet for the air purifier turns off and stays off.
I am using the community app/driver for the TP-Link devices. It works great. After some initial troubleshooting, I am pretty sure the issue is not there, but is somewhere in HE. Whether it's in the way an event was handled or an issue with Basic Rules, I am not sure.
We can treat the rule that turns off the outlet as a black box with an output that turns off the outlet. No need to troubleshoot that aspect. It works 100% of the time actually. Here is the rule that should turn it back on.
Super simple rule. What happens in my testing is that for the TP-Link device, using a command from the device or in a rule will immediately update the status of the device. It is a wifi device, so polling is needed to know the state. If for some reason, the states do not match when it's next polled, the device in HE is updated to reflect reality. I have mine configured to poll once a minute.
Because of this, I expected my rule to work to always make sure the outlet is on. It would go something like
- TV turns on. Sometime in less than 1 minute HE should realize this.
- Sends an off command to the Air Purifier. The device in HE should report off at this time. (this part never fails)
- The rule triggers and waits 5 seconds; sends an on command. The device in HE should now say on.
- For whatever reason, the plug didn't get the on command. When it's polled for its energy usage again, the switch in HE should revert back to off.
- This should trigger step 3 and 4 to repeat until the switch is actually on.
But this breaks down at some point. Sometimes the outlet turns off and stays off until I manually turn it back on and I'm not sure where the breakdown is occurring. When it's like this and I check in HE, it will show correctly as off.
Due to the nature of this being polled once a minute, plus I don't know when it happens until the next time I go to turn the air purifier on, which could even be the next day or two. I don't always remember to turn it back on. It makes it hard to track down the when it started.
I've got logging turned on both the device and the basic rule. but not sure where to go from there.