A few things I notice:
-
var Bath_Timer gets recreated every time the rule runs. You need to save that variable so the Timer gets preserved between runs.
this.Bath_Timer = (this.Bath_Timer === undefined) ? null: this.Bath_Timer;
-
Why are you pulling the Item from the registry just to get it’s state?
items["MotionSensorPresence_Bath1"]
will give you the Item’s state. -
You probably want to use
null
instead ofundefined
and in either case you need to use===
, not==
.