2022-01-04 17:18:27 +01:00
|
|
|
/*
|
|
|
|
|
* dla gdańska
|
|
|
|
|
* shortest day (Dec 21): 8.04 - 15:22
|
|
|
|
|
* longest day (Jun 21): 4:10 - 21:23
|
|
|
|
|
*/
|
2018-12-10 18:44:44 +01:00
|
|
|
|
2018-07-01 21:48:20 +02:00
|
|
|
rule "Zapal stółlampkę rano"
|
|
|
|
|
when
|
|
|
|
|
Time cron "0 47 5 ? * MON-FRI *"
|
|
|
|
|
then
|
|
|
|
|
sSONOFF02.sendCommand(ON)
|
2018-12-10 18:44:44 +01:00
|
|
|
|
|
|
|
|
/* balkon */
|
2019-11-21 19:02:01 +01:00
|
|
|
sSHELLY01.sendCommand(ON)
|
2021-05-18 12:49:02 +02:00
|
|
|
|
2018-07-01 21:48:20 +02:00
|
|
|
end
|
2018-12-10 18:44:44 +01:00
|
|
|
|
2018-07-01 21:48:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
rule "Zgaś stółlampkę rano"
|
|
|
|
|
when
|
|
|
|
|
Time cron "0 30 6 * * ?"
|
|
|
|
|
then
|
|
|
|
|
sSONOFF02.sendCommand(OFF)
|
2018-12-10 18:44:44 +01:00
|
|
|
|
|
|
|
|
/* balkon */
|
2019-11-21 19:02:01 +01:00
|
|
|
sSHELLY01.sendCommand(OFF)
|
2018-07-01 21:48:20 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2021-05-18 12:49:02 +02:00
|
|
|
/* TODO: w okresie kwiecien-pazdziernik na dwie godziny przed? */
|
2018-07-01 21:48:20 +02:00
|
|
|
rule "Zapal sufitowe przed zachodem"
|
|
|
|
|
when
|
2021-05-18 12:49:02 +02:00
|
|
|
Item sSunset_Event_in_hour received update ON
|
|
|
|
|
/* Item sSunset_Event_in_twohours received update ON */
|
2018-07-01 21:48:20 +02:00
|
|
|
then
|
|
|
|
|
/* HOLIDAY */
|
2018-12-10 18:44:44 +01:00
|
|
|
|
2021-10-03 14:38:16 +02:00
|
|
|
/* drobna przerwa bo cottonballs tez sie zapalaja teraz */
|
2021-12-14 16:01:26 +01:00
|
|
|
Thread::sleep(1000)
|
2020-12-02 19:56:59 +01:00
|
|
|
sSONOFF05.sendCommand(ON)
|
2018-12-10 18:44:44 +01:00
|
|
|
|
|
|
|
|
/* balkon */
|
2021-12-14 16:01:26 +01:00
|
|
|
Thread::sleep(1000)
|
2019-11-21 19:02:01 +01:00
|
|
|
sSHELLY01.sendCommand(ON)
|
2020-12-02 19:56:59 +01:00
|
|
|
|
2018-07-01 21:48:20 +02:00
|
|
|
end
|
|
|
|
|
|
2018-12-10 18:44:44 +01:00
|
|
|
/* HOLIDAY */
|
2018-07-01 21:48:20 +02:00
|
|
|
|
2018-07-09 21:10:54 +02:00
|
|
|
rule "Zapal lampkę i kanapowe przez zmierzchem gdy pochmurno"
|
|
|
|
|
when
|
|
|
|
|
Item sSunset_Event_in_twohours received update ON
|
|
|
|
|
then
|
2021-12-14 16:02:02 +01:00
|
|
|
var Number hours = now.getHourOfDay
|
|
|
|
|
|
|
|
|
|
/* more than 90% cloud cover && not before 14:00 hour && TODO: only april-october */
|
|
|
|
|
if (wClouds.state > 90.0 && hours >= 14 && true) {
|
2020-04-18 18:20:58 +02:00
|
|
|
logInfo("stollampka", "Powyżej 90% chmur, zapalam")
|
2018-07-09 21:10:54 +02:00
|
|
|
|
2021-04-10 15:23:23 +02:00
|
|
|
/* sSONOFF02.sendCommand(ON) */
|
2018-07-09 21:10:54 +02:00
|
|
|
sSONOFF02_expected.postUpdate(ON)
|
|
|
|
|
|
2021-04-10 15:23:23 +02:00
|
|
|
sSONOFF09a.sendCommand(ON)
|
2021-05-18 12:49:02 +02:00
|
|
|
sSONOFF09b.sendCommand(ON)
|
2018-07-09 21:10:54 +02:00
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2018-07-01 21:48:20 +02:00
|
|
|
|
2018-07-09 21:10:54 +02:00
|
|
|
/* TODO: przerobic na espeasy pulse command.
|
|
|
|
|
pulse 500ms, thread sleep 1s*/
|
2018-12-10 18:44:44 +01:00
|
|
|
/* HOLIDAY */
|
|
|
|
|
|
2018-07-01 21:48:20 +02:00
|
|
|
rule "Zapal lampkę i kanapowe przed zmierzchem"
|
|
|
|
|
when
|
2020-06-28 20:13:49 +02:00
|
|
|
/* Item sSunset_Event_in_halfhour received update ON*/
|
|
|
|
|
Item sSunset_Event_in_hour received update ON
|
2018-07-01 21:48:20 +02:00
|
|
|
then
|
2021-05-18 12:49:02 +02:00
|
|
|
if (sHolidayVacancy.state == ON) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-04-18 18:20:58 +02:00
|
|
|
|
2018-07-01 21:48:20 +02:00
|
|
|
dSONOFF01LED.sendCommand(0)
|
|
|
|
|
dSONOFF02LED.sendCommand(0)
|
|
|
|
|
Thread::sleep(500)
|
|
|
|
|
dSONOFF01LED.sendCommand(1023)
|
|
|
|
|
dSONOFF02LED.sendCommand(1023)
|
|
|
|
|
Thread::sleep(500)
|
|
|
|
|
|
|
|
|
|
dSONOFF01LED.sendCommand(0)
|
|
|
|
|
dSONOFF02LED.sendCommand(0)
|
|
|
|
|
Thread::sleep(500)
|
|
|
|
|
dSONOFF01LED.sendCommand(1023)
|
|
|
|
|
dSONOFF02LED.sendCommand(1023)
|
|
|
|
|
Thread::sleep(500)
|
|
|
|
|
|
|
|
|
|
dSONOFF01LED.sendCommand(0)
|
|
|
|
|
dSONOFF02LED.sendCommand(0)
|
|
|
|
|
Thread::sleep(500)
|
|
|
|
|
dSONOFF01LED.sendCommand(1023)
|
|
|
|
|
dSONOFF02LED.sendCommand(1023)
|
|
|
|
|
Thread::sleep(500)
|
|
|
|
|
|
2021-04-10 15:23:23 +02:00
|
|
|
/* sSONOFF02.sendCommand(ON) */
|
2018-07-01 21:48:20 +02:00
|
|
|
sSONOFF02_expected.postUpdate(ON)
|
|
|
|
|
|
2021-05-18 12:49:02 +02:00
|
|
|
/* kanapa */
|
2021-12-14 16:01:26 +01:00
|
|
|
sSONOFF09b.sendCommand(ON)
|
|
|
|
|
Thread::sleep(1000)
|
2021-04-10 15:23:23 +02:00
|
|
|
sSONOFF09a.sendCommand(ON)
|
2018-07-01 21:48:20 +02:00
|
|
|
end
|
|
|
|
|
|
2018-12-10 18:44:44 +01:00
|
|
|
|
|
|
|
|
|
2018-07-01 21:48:20 +02:00
|
|
|
rule "Przedzgaś stółlampkę wieczorem"
|
|
|
|
|
when
|
|
|
|
|
Time cron "0 12 22 * * ?"
|
|
|
|
|
then
|
|
|
|
|
dSONOFF01LED.sendCommand(0)
|
|
|
|
|
dSONOFF02LED.sendCommand(0)
|
|
|
|
|
end
|
|
|
|
|
|
2019-11-21 19:02:01 +01:00
|
|
|
|
2018-09-09 16:22:11 +02:00
|
|
|
rule "Zgaś stółlampkę, sufitowe i nablatowe wieczorem"
|
2018-07-01 21:48:20 +02:00
|
|
|
when
|
|
|
|
|
Time cron "0 15 22 * * ?"
|
|
|
|
|
then
|
2020-12-02 19:56:59 +01:00
|
|
|
/* lampka nad stołem */
|
2018-07-01 21:48:20 +02:00
|
|
|
sSONOFF02.sendCommand(OFF)
|
|
|
|
|
sSONOFF02_expected.postUpdate(OFF)
|
|
|
|
|
dSONOFF02LED.sendCommand(1023)
|
|
|
|
|
|
2021-10-03 14:38:16 +02:00
|
|
|
/* sufitowe gasimy tylko jak nikogo nie ma w domu,
|
|
|
|
|
cottonbalsy tez, bo nie ma kto powiedziec goodnight */
|
2020-12-02 19:56:59 +01:00
|
|
|
if (sHolidayVacancy.state == ON) {
|
2021-10-03 14:38:16 +02:00
|
|
|
/* kanapa */
|
2020-12-02 19:56:59 +01:00
|
|
|
sSONOFF05.sendCommand(OFF)
|
2021-10-03 14:38:16 +02:00
|
|
|
/* cottonballs / krzak */
|
|
|
|
|
sOWFS01.sendCommand(OFF)
|
2020-12-02 19:56:59 +01:00
|
|
|
}
|
2021-05-18 12:49:02 +02:00
|
|
|
Thread::sleep(2000)
|
2018-12-10 18:44:44 +01:00
|
|
|
|
2020-12-02 19:56:59 +01:00
|
|
|
/* kanapowe */
|
2021-05-18 12:49:02 +02:00
|
|
|
sSONOFF09b.sendCommand(OFF)
|
|
|
|
|
Thread::sleep(2000)
|
|
|
|
|
sSONOFF09a.sendCommand(OFF)
|
|
|
|
|
Thread::sleep(2000)
|
2020-12-02 19:56:59 +01:00
|
|
|
|
2021-05-18 12:49:02 +02:00
|
|
|
/* blat */
|
|
|
|
|
sD1MINI02MOS.sendCommand(OFF)
|
2019-11-21 19:02:01 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* na wypadek rebootów sonoffa */
|
|
|
|
|
rule "Synchronizuj balkon & lampka po restarcie"
|
|
|
|
|
when
|
2021-05-18 12:49:02 +02:00
|
|
|
Item rSHELLY01 received update ON or
|
|
|
|
|
Item rSONOFF02 received update ON
|
2019-11-21 19:02:01 +01:00
|
|
|
then
|
|
|
|
|
logInfo("S02,SH01", "Reappeared, applying state balkon {}, lampka {}", sSHELLY01.state, sSONOFF02.state)
|
|
|
|
|
sSONOFF02.sendCommand(sSONOFF02.state.toString)
|
|
|
|
|
sSHELLY01.sendCommand(sSHELLY01.state.toString)
|
2018-07-01 21:48:20 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
1 Seconds
|
|
|
|
|
2 Minutes
|
|
|
|
|
3 Hours
|
|
|
|
|
4 Day-of-Month
|
|
|
|
|
5 Month
|
|
|
|
|
6 Day-of-Week
|
|
|
|
|
7 Year (optional field)
|
|
|
|
|
*/
|
2020-06-28 20:13:49 +02:00
|
|
|
|