Q: Can you help me create a rule in rule machine that turns on a light when a door opens, and turns it off when it closes, but doesn't turn it off if the door was already open?
ELSE IF (Door contact closed AND Private Boolean is True) THEN
Turn off light
Set Private Boolean False
END-IF
This rule uses a Private Boolean variable to keep track of whether the light was turned on by the door opening or not. If the door opens, it turns on the light and sets the Private Boolean to True. If the door closes and the Private Boolean is True, it means that the light was turned on by the door opening, so it turns off the light and sets the Private Boolean to False. If the door closes and the Private Boolean is False, it means that the light was already on before the door opened, so it does nothing.
This app uses the location.sunset() and location.sunrise() methods to determine the sunset and sunrise times for the Hubitat location, and then schedules events to turn the lights on and off at those times. The offset preference allows the user to adjust the time by a specified number of minutes.
That is awesome. Here is what Bing sent back, references to existing apps instead
I see. You want me to write some groovy code for a Hubitat app that will turn on lights at sunset and turn them off at sunrise. One possible way to do that is to use a Simple Automation Rules app12 that can create rules based on time triggers such as sunrise and sunset. You can install this app from the Hubitat built-in apps list and configure it according to your needs.
I asked ChatGPT something similar although I didn't actually test the code it generated. Even if it doesn't work as-is, the hard part is knowing what to do (and what it's called). I can figure out "how to do it" from examples and trial and error. So both of these answers are valuable and useful. I might just have to try groovy programming now rather than just writing rules.
Good point. ATM, the only one I'm considering is a combined washer/dryer handler - where it can remind me to "handle the laundry" when both the washer and the dryer are off (and at least one of them had been on), and then remind me every few minutes until I open the dryer door. It will use two current sensors in the breaker box, and a contact sensor for the door. It might be possible to do this with RuleEngine, but if I can write it in Delphi (Pascal), I should be able to get ChatGPT to translate it to groovy for me.