This rule executes when the sun sets or rises.
Required devices
"devices": { "currentdatetime": { "protocol": [ "datetime" ], "id": [{ "longitude": 1.2345, "latitude": 12.3456 }], "year": 2015, "month": 1, "day": 27, "hour": 14, "minute": 37, "second": 8, "weekday": 3, "dst": 1 }, "sunrisesetdevice": { "protocol": [ "sunriseset" ], "id": [{ "longitude": 1.234567, "latitude": 12.123456 }], "sunrise": 6.40, "sunset": 18.50, "sun": "rise" }, "light": { "protocol": [ "kaku_switch" ], "id": [{ "id": 123456, "unit": 0 }], "state": "off" }
Rule
"sunset": { "rule": "IF ((sunrisesetdevice.sunset == (currentdatetime.hour + (currentdatetime.minute / 100)) AND light.state IS off) AND currentdatetime.second == 0) THEN switch DEVICE light TO on", "active": 1 }, "sunrise": { "rule": "IF ((sunrisesetdevice.sunrise == (currentdatetime.hour + (currentdatetime.minute / 100)) AND light.state IS off) AND currentdatetime.second == 0) THEN switch DEVICE light TO on", "active": 1 }
"sunset": { "rule": "IF (sunrisesetdevice.sunset == DATE_FORMAT(currentdatetime, %H.%M)) AND light.state IS off AND currentdatetime.second == 0 THEN switch DEVICE light TO on", "active": 1 }, "sunrise": { "rule": "IF (sunrisesetdevice.sunrise == DATE_FORMAT(currentdatetime, %H.%M)) AND light.state IS off AND currentdatetime.second == 0 THEN switch DEVICE light TO on", "active": 1 }
Of an hour before the sun sets:
"sunset": { "rule": "IF (sunrisesetdevice.sunset == DATE_FORMAT(DATE_ADD(currentdatetime, +1 HOUR), \"%Y-%m-%d %H:%M:%S\", %H.%M)) AND light.state IS off AND currentdatetime.second == 0 THEN switch DEVICE light TO on", "active": 1 }
Switch devices based on your IR remote buttons
Required devices
"television": { "protocol": [ "kaku_switch" ], "id": [{ "id": 123456, "unit": 0 }], "state": "off" }, "remote": { "protocol": [ "lirc" ], "id": [{ "remote": "logitech" }], "code": "000000000000e290", "repeat": 2, "button": "KEY_P" }
Rules
"remote-television-switch": { "rule": "IF remote.button IS KEY_P AND remote.repeat == 0 THEN toggle DEVICE television BETWEEN on AND off", "active": 1 }
At least one Lirc device needs to be declared in the “devices” section to be able to use the Lirc protocol within eventing rules (see rule 2):
"remote-television-switch": { "rule": "IF remote.button IS KEY_P AND remote.repeat == 0 THEN toggle DEVICE television BETWEEN on AND off", "active": 1 }, "lights-off-at-play": { "rule": "IF lirc.button IS KEY_PLAY AND lirc.repeat == 0 THEN switch DEVICE light TO off", "active": 1 }
Execute rules based on XBMC / KODI based events
Required devices
"xbmcControls": { "protocol": [ "xbmc" ], "id": [{ "server": "127.0.0.1", "port": 9090 }], "action": "home", "media": "none" }, "speakers": { "protocol": [ "kaku_switch" ], "id": [{ "id": 123456, "unit": 4 }], "state": "off" }
Rules
"speakers-on": { "rule": "IF xbmcControls.action IS play THEN switch DEVICE speakers TO on", "active": 1 }, "speakers-off": { "rule": "IF xbmcControls.action IS pause OR xbmcControls.action IS home THEN switch DEVICE speakers TO off", "active": 1 }
"speakers-on": { "rule": "IF xbmcControls.action IS play THEN switch DEVICE speakers TO on", "active": 1 }, "speakers-off": { "rule": "IF xbmcControls.action IS pause OR xbmcControls.action IS home THEN switch DEVICE speakers TO off AFTER 3 MINUTES", "active": 1 }
Trigger events based on time
Required devices
"currentdatetime": { "protocol": [ "datetime" ], "id": [{ "longitude": 1.2345, "latitude": 12.3456 }], "year": 2015, "month": 1, "day": 27, "hour": 14, "minute": 37, "second": 8, "weekday": 3, "dst": 1 }, "outsidelight": { "protocol": [ "kaku_switch" ], "id": [{ "id": 123456, "unit": 0 }], "state": "off" }
Rules
"kerstboom-off": { "rule": "IF (currentdatetime.hour == 23 AND currentdatetime.minute == 50 AND currentdatetime.second == 0 AND outsidelight.state IS on) THEN switch DEVICE outsidelight TO off", "active": 1 }
Let lights switch on and off automatically at different times every day
Required devices
"currentdatetime": { "protocol": [ "datetime" ], "id": [{ "longitude": 1.2345, "latitude": 12.3456 }], "year": 2015, "month": 1, "day": 27, "hour": 14, "minute": 37, "second": 8, "weekday": 3, "dst": 1 }, "achterkamer": { "protocol": [ "kaku_switch" ], "id": [{ "id": 123456, "unit": 0 }], "state": "off" }, "vakantie": { "protocol": [ "generic_switch" ], "id": [{ "id": 100 }], "state": "off" }
Rule
"IF vakantie.state IS on AND DATE_FORMAT(currentdatetime, %H.%M%S) == 23.0000 THEN switch DEVICE achterkamer TO on AFTER RANDOM(0, 90) MINUTE FOR RANDOM(5, 15) MINUTE"
This rule switches a light on at a random time between 23:00 and 00:30 and switches it off between 5 and 15 minutes later.
Sending a mail based on a contact device trigger including the time when it happened.
Required devices
"currentdatetime": { "protocol": [ "datetime" ], "id": [{ "longitude": 1.2345, "latitude": 12.3456 }], "year": 2015, "month": 1, "day": 27, "hour": 14, "minute": 37, "second": 8, "weekday": 3, "dst": 1 }, "frontdoor-contact": { "protocol": [ "kaku_contact" ], "id": [{ "id": 123456, "unit": 0 }], "state": "opened" }
Rules
"contact-mail": { "rule": "IF frontdoor-contact.state IS opened THEN sendmail TO foo@bar.com SUBJECT Frontdoor was opened at DATE_FORMAT(currentdatetime, %c) MESSAGE .", "active": 1 }
Send a mail when one of the computer goes offline.
Required devices
"currentdatetime": { "protocol": [ "datetime" ], "id": [{ "longitude": 1.2345, "latitude": 12.3456 }], "year": 2015, "month": 1, "day": 27, "hour": 14, "minute": 37, "second": 8, "weekday": 3, "dst": 1 }, "nasPing": { "protocol": [ "arping" ], "id": [{ "mac": "aa:bb:cc:dd:00:11" }], "ip": "192.168.1.1", "state": "connected" }
Rules
"nas-mail": { "rule": "IF nasPing.state IS disconnected THEN sendmail TO foo@bar.com SUBJECT NAS is offline since DATE_FORMAT(currentdatetime, %c) MESSAGE .", "active": 1 },