I installed one of these on my paddle-style low-voltage switch for our fireplace:
My purpose was to (1) limit the time the fireplace could be ON, and (2) allow Alexa voice control over turning the fireplace OFF (but not ON, I'm averse to using voice control for activating a potential hazard unawares).
My Rule for purpose 1 is immediately below (change the local variable vTimeOutHours to set the max time the fireplace can be ON, unless trumped by closeness to midnight). Most of the commands are just to determine how many seconds exist between the trigger time and midnight. The Rule then picks the lesser of that number of seconds or 7200 seconds (2 hrs) to delay the OFF command in the last line.
For purpose 2, I created a virtual switch (e.g., "VS Fireplace") and the rule below (which is dead simple). The trick to make this work properly with Alexa is to use the "Virtual Switch uDTH Lite" driver (search this forum) and set its preferences to "Force State Update" [ON] and "Enable Auto-Off" [1 sec]. Even if the VS is OFF, asking Alexa to turn it OFF will still trigger the rule below (and of course I have no other rule that is triggered by saying "Alexa, turn on the fireplace"). Note: make sure the trigger event is the VS turning OFF, not "changed" -- "changed" just doesn't work with the selected driver.
EDIT: changed rule to include midnight as a trigger.
I'm open to suggestions for making this even more robust!