import reguł

This commit is contained in:
root
2018-07-01 21:48:20 +02:00
parent 78d4c6c5e1
commit 1d85c1669f
13 changed files with 466 additions and 0 deletions

5
rules/README Normal file
View File

@@ -0,0 +1,5 @@
Put any file containing rule definitions here. They will be activated automatically.
Note: Rule definition files must have the extension '*.rules'
Demo-files can be obtained from the archive 'distribution-demo-*.zip'.

8
rules/WC.txt Normal file
View File

@@ -0,0 +1,8 @@
co minute odczyt czujnika swiatla
jesli jasno -> switch wc_occupied ON
rule wc_occupied changed to off -> psiknij (GPIO short pulse pewnie)
jakies timery, ze jesli jestesmy w domu to psikaj co godzine,
przed naszym przyjsciem, rano przy budziku

View File

@@ -0,0 +1,49 @@
rule "d1m03 przełączaj zielone"
when
Item sD1MINI03_button_green received update
then
if (sOWFS01.state == ON) {
sOWFS01.sendCommand(OFF)
} else {
sOWFS01.sendCommand(ON)
}
end
rule "d1m03 przełączaj żółte"
when
Item sD1MINI03_button_yellow received update
then
if (Mpd_quodlibet_StartStop.state == ON) {
Mpd_quodlibet_StartStop.sendCommand(OFF)
} else {
Mpd_quodlibet_StartStop.sendCommand(ON)
}
end
rule "d1m03 przełączaj czerwone"
when
Item sD1MINI03_button_red received update
then
/* if (sD1MINI04_refresh.state == ON) {
sD1MINI04_refresh.sendCommand(OFF)
} else {*/
sD1MINI04_refresh.sendCommand(ON)
/* }*/
end
rule "d1mini03 synchronizuj kolorki"
when
Item sOWFS01 received update or
Item Mpd_quodlibet_StartStop received update or
Item sD1MINI04_refresh received update
then
sD1MINI03_light_green.sendCommand(sOWFS01.state.toString())
sD1MINI03_light_yellow.sendCommand(Mpd_quodlibet_StartStop.state.toString())
sD1MINI03_light_red.sendCommand(sD1MINI04_refresh.state.toString())
end

64
rules/kuchnia.okap.rules Normal file
View File

@@ -0,0 +1,64 @@
/*
example of switch https://community.openhab.org/t/examples-of-scenes/16411/5
*/
/* 0="OFF", 1="Bieg 1", 2="Bieg 2", 3="Bieg max"]
*/
rule "Ustaw prędkość okapu"
when
Item sOKAP_speed received update
then
switch (sOKAP_speed.state) {
case 0: {
sD1MINI01_bieg1.sendCommand(OFF)
sD1MINI01_bieg2.sendCommand(OFF)
sD1MINI01_bieg3.sendCommand(OFF)
}
case 1: {
sD1MINI01_bieg1.sendCommand(ON)
sD1MINI01_bieg2.sendCommand(OFF)
sD1MINI01_bieg3.sendCommand(OFF)
}
/* 40% = 1 bieg */
case 40: {
sD1MINI01_bieg1.sendCommand(ON)
sD1MINI01_bieg2.sendCommand(OFF)
sD1MINI01_bieg3.sendCommand(OFF)
}
/* turn ON == 100% == 1 bieg */
case 100: {
sD1MINI01_bieg1.sendCommand(ON)
sD1MINI01_bieg2.sendCommand(OFF)
sD1MINI01_bieg3.sendCommand(OFF)
}
case 2: {
sD1MINI01_bieg2.sendCommand(ON)
sD1MINI01_bieg1.sendCommand(OFF)
sD1MINI01_bieg3.sendCommand(OFF)
}
/* 70% = 2 bieg */
case 70: {
sD1MINI01_bieg2.sendCommand(ON)
sD1MINI01_bieg1.sendCommand(OFF)
sD1MINI01_bieg3.sendCommand(OFF)
}
case 3: {
sD1MINI01_bieg3.sendCommand(ON)
sD1MINI01_bieg1.sendCommand(OFF)
sD1MINI01_bieg2.sendCommand(OFF)
}
default: {
logInfo("okap","incorrect state: {}", sOKAP_speed.state)
}
}
end

12
rules/kuchnia.rules Normal file
View File

@@ -0,0 +1,12 @@
rule "Kuchnia: przełącz LED"
when
Item sD1MINI02LEDS received update
then
if (sD1MINI02MOS.state == ON) {
sD1MINI02MOS.sendCommand(OFF)
/* zrobic PWM DIMM */
} else {
sD1MINI02MOS.sendCommand(ON)
}
end

53
rules/przedpokój.rules Normal file
View File

@@ -0,0 +1,53 @@
rule "Przedpokój: przełącz światło"
when
/* If there is no action the button returns 0. When you touch it it shows a state of 1 . */
Item sSONOFF06KEY received update ON or
Item sD1MINI06KEY received update
then
if (sSONOFF06.state == ON) {
sSONOFF06.sendCommand(OFF)
} else {
sSONOFF06.sendCommand(ON)
}
end
/* podswietlenie bedzie caly czas ON, ustawione jako dioda statusu */
/*rule "Przedpokój: synchronizuj podświetlenia przycisków"
when
Item sSONOFF06 received update
then
if (sSONOFF06.state == ON) {
sSONOFF06LED.sendCommand(OFF)
sD1MINI03_light_red.sendCommand(OFF)
} else {
sSONOFF06LED.sendCommand(ON)
sD1MINI03_light_red.sendCommand(ON)
}
end*/
/* jak się urwie od internetu przyciskowi, zsynchronizuj stan światła na OFF */
when
Item rSONOFF06 received update OFF
then
sSONOFF06.postUpdate(OFF)
end
rule "Przedpokój: zapal rano"
when
Time cron "0 50 5 ? * MON-FRI *"
then
sSONOFF06.sendCommand(ON)
end
rule "Przedpokój: zgaś rano"
when
Time cron "0 50 6 ? * MON-FRI *"
then
sSONOFF06.sendCommand(OFF)
end

View File

@@ -0,0 +1,51 @@
rule "Zapal cottonballs, kanapowe i blat rano"
when
Time cron "0 45 5 ? * MON-FRI *"
then
sOWFS01.sendCommand(ON)
/* sSONOFF01.sendCommand(ON) */
sD1MINI02MOS.sendCommand(ON)
end
rule "Zgaś cottonballs, kanapowe i blat rano"
when
Time cron "0 35 6 * * ?"
then
sOWFS01.sendCommand(OFF)
sSONOFF01.sendCommand(OFF)
sD1MINI02MOS.sendCommand(OFF)
end
/* kanapowe zmierzchowe sterowane z lampki stolowej */
rule "Zapal cottonballsy i blat przed zmierzchem"
when
Item sSunset_Event_in_hour received update ON
then
sOWFS01.sendCommand(ON)
sOWFS01_expected.postUpdate(ON)
/* HOLIDAY */
D1MINI02MOS.sendCommand(ON)
end
rule "Zgaś cottonballsy wieczorem"
when
Time cron "0 20 22 * * ?"
then
sOWFS01.sendCommand(OFF)
sOWFS01_expected.postUpdate(OFF)
end
/*
1 Seconds
2 Minutes
3 Hours
4 Day-of-Month
5 Month
6 Day-of-Week
7 Year (optional field)
*/

45
rules/salon.kodi.rules Normal file
View File

@@ -0,0 +1,45 @@
rule "Gramy!"
when
Item Kodi_State changed to Play
then
sOWFS01.sendCommand(OFF)
Mpd_quodlibet_StartStop_expected.postUpdate(Mpd_quodlibet_StartStop.state)
Mpd_quodlibet_StartStop.sendCommand(OFF)
end
rule "Nie gramy"
when
Item Kodi_State changed to Stop or
Item Kodi_State changed to Pause
then
/* bezpośrednie odwoływanie się do tych zmiennych powoduje jakieś nulle */
var preCB = sOWFS01_expected.state.toString()
/* ponizsze generuje w linijce z ifem: The name '<XFeatureCallImplCustom> == <XFeatureCallImplCustom>' cannot be resolved to an item or type.
var OnOffType preQL = Mpd_quodlibet_StartStop_expected.state */
var preQL = Mpd_quodlibet_StartStop_expected.state.toString()
logInfo("niegramy", "Restore QL to {}", preQL)
/* Mpd_quodlibet_StartStop.sendCommand(preQL.toString())*/
/* nie działa: preQL as StringType
preQL.toString()
*/
if (preQL == "ON") {
sendCommand(Mpd_quodlibet_StartStop, ON)
} else {
// logInfo("niegramy", "Did not restore QL. why?")
}
logInfo("niegramy", "Restore sOWFS01 to {}", preCB)
/* sOWFS01.sendCommand(preCB) */
/* sOWFS01.sendCommand(sOWFS01_expected.state.toString()) zakomentowane, bo null instance */
/* sendCommand(sOWFS01, preCB) */
if (preCB == "ON") {
sendCommand(sOWFS01, ON)
}
end

View File

@@ -0,0 +1,90 @@
/*
rule "Zapal stółlampkę rano"
when
Time cron "0 47 5 ? * MON-FRI *"
then
sSONOFF02.sendCommand(ON)
end
*/
rule "Zgaś stółlampkę rano"
when
Time cron "0 30 6 * * ?"
then
sSONOFF02.sendCommand(OFF)
end
rule "Zapal sufitowe przed zachodem"
when
Item sSunset_Event_in_hour received update ON
then
/* HOLIDAY */
sD1MINI01_lampki_sufitowe.sendCommand(ON)
end
rule "Zapal lampkę i kanapowe przed zmierzchem"
when
Item sSunset_Event_in_halfhour received update ON
then
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)
sSONOFF02.sendCommand(ON)
sSONOFF02_expected.postUpdate(ON)
sSONOFF01.sendCommand(ON)
end
rule "Przedzgaś stółlampkę wieczorem"
when
Time cron "0 12 22 * * ?"
then
dSONOFF01LED.sendCommand(0)
dSONOFF02LED.sendCommand(0)
end
rule "Zgaś stółlampkę i kanapowe wieczorem"
when
Time cron "0 15 22 * * ?"
then
sSONOFF02.sendCommand(OFF)
sSONOFF02_expected.postUpdate(OFF)
dSONOFF02LED.sendCommand(1023)
sSONOFF01.sendCommand(OFF)
dSONOFF01LED.sendCommand(1023)
end
/*
1 Seconds
2 Minutes
3 Hours
4 Day-of-Month
5 Month
6 Day-of-Week
7 Year (optional field)
*/

View File

@@ -0,0 +1,7 @@
rule "mpd-concat"
when
Item Mpd_CurrentTrack received update or
Item Mpd_CurrentArtist received update
the
Mpd_ConcatInfo.postUpdate(Mpd_CurrentTrack.state.toString + " / " + Mpd_CurrentArtist.state.toString)
end

View File

@@ -0,0 +1,27 @@
rule "Zapal lampkę rano"
when
Time cron "0 39 5 ? * MON-FRI *"
then
sOWFS02.sendCommand(ON)
end
rule "Zgaś lampkę rano"
when
Time cron "0 20 6 * * ?"
then
sOWFS02.sendCommand(OFF)
end
/*
1 Seconds
2 Minutes
3 Hours
4 Day-of-Month
5 Month
6 Day-of-Week
7 Year (optional field)
*/

26
rules/wc.rules Normal file
View File

@@ -0,0 +1,26 @@
rule "Sprawdzaj zajętość WC"
when
Item lWC_lux received update
then
if (lWC_lux.state > 3) {
sWC_occupied.postUpdate(ON)
} else {
sWC_occupied.postUpdate(OFF)
}
end
/* HOLIDAY */
rule "Psikaj w WC"
when
Item sWC_occupied changed from ON to OFF or
Time cron "0 50 05 * * ?" or
Time cron "0 20 15 ? * MON-FRI" or
Time cron "0 10/20 15-21 ? * MON-FRI" or
Time cron "0 0,20,40 8-22 ? * SAT,SUN"
then
sD1MINI04_refresh.sendCommand(ON)
end

29
rules/łazienka.rules Normal file
View File

@@ -0,0 +1,29 @@
val int h_low = 55
val int h_high = 65
rule "Włącz wiatrak przy dużej wilgotności"
when
Item h_lazienka received update
then
if (h_lazienka.state > h_high) {
/* wlaczyc wiatrak i diodke */
sSONOFF03.sendCommand(ON)
dSONOFF03LED.sendCommand(0)
else if (h_lazienka.state < h_low) {
sSONOFF03.sendCommand(OFF)
dSONOFF03LED.sendCommand(1023)
else {
/* pomiedzy 55 a 65 */
val h_lazienka_int = h_lazienka.state as Number
var led_pwm = (h_high - h_lazienka_int) * ( 1023 / (h_high - h_low) )
if (led_pwm < 0) { led_pwm = 0 }
dSONOFF03LED.sendCommand(led_pwm)
}
end
/* if dzien roboczy 7-15, wlacz wiatrak */