Scripting versus chained triggers and actions
I just went through setting up a web-triggerable action for a dry kibble feeder for my cats. Here's what I ended up with:
- a "FeedNow" variable, set to True by the button on the control page.
- a trigger based on FeedNow changing to True, which checks if the feeder is already on and executes an action group if not
- an action group that turns on the ApplianceLinc, and uses the auto-off feature to turn it back off
- a trigger based on the ApplianceLinc turning off that resets FeedNow to False.
This feels awkward, and I don't like the fact that the logic is distributed across several places (variable, trigger, action) and a chain of different events. As a programmer, I'd much rather just embed a script in the action group and have it all in one place. In pseudocode, it's just:
- Code: Select all
if device not on:
turn device on
wait two minutes
turn device off
Is this logic that I can reasonably implement with the embedded Python scripting? I'm mostly concerned about the delay triggering some kind of watchdog timeout, but I'm also not sure if the device state changes will be reflected elsewhere (like the control page) if the script is still running.