This is a large update to Gene's Smart Lights C# code. This code will control a module with a motion sensor. If the controlled module is a light (on/off light) or dimmer (dimmable light), it can also be optionally controlled by a wall switch transmitter. If the module is a siren, it will treat it as a notification chime.
Day/night is handled via jkUtils though Weather Underground is possible too with minimal modifications to the code.
There is an option for triggering the timer when motion is initially detected (on received) or after motion has stopped (off received).
The wall switch control has an advanced functionality beyond simply turning on and off the light module. If a double on is received, it will turn the light on and enable the timer. If a double off is received with the timer running, it will override and turn off the light immediately. If a single off is received and the timer is on, it will not turn the light off. In order to use this advanced switch control, it's also necessary to add the Last Event code. This will allow HG to properly track duplicated on or off commands which is not possible by default.
The final code that is available is a stuck module check. This is useful if you have a module that does not transmit properly every time or, more likely, the signal is not received consistently. In this case, the stuck module check code will use a timer to turn the module off after a user specified timeout period.
I've spent a lot of time debugging, so hopefully everything works 100%. If bugs are located, please let me know. Enjoy!