Files
openhab/rules/salon.lampka-stolowa.rules
Tomasz Torcz 4af668cb9d SHELLY02 w lampce stołowej, w zamian za SONOFF02 który zdechł
SHELLY nie ma osobnej kontrolki LED, więc wywalone.
2023-11-18 16:24:08 +01:00

149 lines
3.0 KiB
Plaintext

/*
* dla gdańska
* shortest day (Dec 21): 8.04 - 15:22
* longest day (Jun 21): 4:10 - 21:23
*/
rule "Zapal stółlampkę rano"
when
Time cron "0 47 5 ? * MON-FRI *"
/* Time cron "0 33 6 ? * MON-FRI *" */
then
sSHELLY02.sendCommand(ON)
/* balkon */
sSHELLY01.sendCommand(ON)
end
rule "Zgaś stółlampkę rano"
when
Time cron "0 50 6 * * ?"
then
sSHELLY02.sendCommand(OFF)
/* balkon */
sSHELLY01.sendCommand(OFF)
end
/* TODO: w okresie kwiecien-pazdziernik na dwie godziny przed? */
rule "Zapal sufitowe przed zachodem"
when
Item sSunset_Event_in_hour received update ON
/* Item sSunset_Event_in_twohours received update ON */
then
if (sHolidayVacancy.state == ON) {
return;
}
/* drobna przerwa bo cottonballs tez sie zapalaja teraz */
Thread::sleep(1000)
sSONOFF05.sendCommand(ON)
/* balkon */
Thread::sleep(1000)
sSHELLY01.sendCommand(ON)
end
rule "Zapal lampkę i kanapowe przez zmierzchem gdy pochmurno"
when
Item sSunset_Event_in_twohours received update ON
then
var Number hours = now.getHourOfDay
if (sHolidayVacancy.state == ON) {
return;
}
/* more than 90% cloud cover && not before 14:00 hour && TODO: only april-october */
/* na razie zawsze wlaczaj, bo juz ciemno sie robi, a pogodynka chwilowo nie dziala *.
if (true || wClouds.state > 90.0 && hours >= 14 && true) {
logInfo("stollampka", "Powyżej 90% chmur, zapalam")
sSHELLY02.sendCommand(ON)
sSHELLY02_expected.postUpdate(ON)
sSONOFF09a.sendCommand(ON)
sSONOFF09b.sendCommand(ON)
}
end
/* TODO: przerobic na espeasy pulse command.
pulse 500ms, thread sleep 1s*/
rule "Zapal lampkę i kanapowe przed zmierzchem"
when
/* Item sSunset_Event_in_halfhour received update ON*/
Item sSunset_Event_in_hour received update ON
then
if (sHolidayVacancy.state == ON) {
return;
}
sSHELLY02.sendCommand(ON) */
sSHELLY02_expected.postUpdate(ON)
/* kanapa */
if ( Kodi_State.state == "Play" ) {
sSONOFF09b_expected.postUpdate(ON)
} else {
/* zapalamy tylko jeśli kodi nic nie gra */
sSONOFF09b.sendCommand(ON)
Thread::sleep(1000)
}
sSONOFF09a.sendCommand(ON)
end
rule "Zgaś stółlampkę, sufitowe i nablatowe wieczorem"
when
Time cron "0 15 22 * * ?"
then
if (sHolidayVacancy.state != ON && sSONOFF09a.state == ON) {
/* zapalmy w przedpokoju (o ile kanapa jeszcze nie zgaszona) - droga do łóżka */
sSONOFF06.sendCommand(ON)
}
/* lampka nad stołem */
sSHELLY02.sendCommand(OFF)
sSHELLY02_expected.postUpdate(OFF)
/* sufitowe gasimy tylko jak nikogo nie ma w domu,
cottonbalsy tez, bo nie ma kto powiedziec goodnight */
if (sHolidayVacancy.state == ON) {
/* kanapa */
sSONOFF05.sendCommand(OFF)
/* cottonballs / krzak */
sOWFS01.sendCommand(OFF)
}
Thread::sleep(2000)
/* kanapowe */
sSONOFF09b.sendCommand(OFF)
Thread::sleep(2000)
sSONOFF09a.sendCommand(OFF)
Thread::sleep(2000)
/* blat */
sD1MINI02MOS.sendCommand(OFF)
end
/*
1 Seconds
2 Minutes
3 Hours
4 Day-of-Month
5 Month
6 Day-of-Week
7 Year (optional field)
*/