For anyone else looking at this, it took me a couple days to figure out how to make this integration work.
My requirements were this:
1) If it's after dark;
2) and there is a motion trigger
3) from any one of multiple cameras
4) then turn on the lights connected to the Shelly device for X period
5) but only if they aren't already on (could be a previous trigger OR the wall switch wired to the Shelly is already ON)
I think this cost me about 4 hours effort per line of code. But it's been a few years and the syntax here is new and unforgiving. What happened to BASIC or COBOL?
Anyway...hope this helps someone. There are likely many more applications possible to integrate Shelly and
Blue Iris. Shelly is like a Swiss Army knife for power automation.
Best Bob
-----------------
Code Snips:
Security system invokes this script if motion is sensed. Basically if the light was already On, the request gets dropped in the big bucket, otherwise it turns the light on for 300 seconds.
--- Blue Iris in camera config Alert/On Alert/Actions for each camera (only for BI night time profile):
172.22.21.79/rpc/Script.Start?id=10
172.22.21.79/rpc/Script.Stop?id=10
The IP address is the one assigned to the Shelly MAC address by my router. You could also hard assign one in the Shelly config. This is a HTTP:/ action.
--- Script 10 in Shelly Device (the Print statements only needed for debugging):
Shelly.call("Switch.GetStatus", {'id': 0}, function (chk) {
if (chk.output === false) {
print("Light was Off")
Shelly.call("Switch.set", {'id': 0, 'on': true, 'toggle_after':300})
print("Light is now On");
}
});
There probably is a more elegant way of coding this in the Shelly so that you don't need both the start and stop script commands. But this worked and I celebrated success.