From 8e051fd17c85b1b52803bb39e6b5c6e8d3c42ff6 Mon Sep 17 00:00:00 2001 From: Tomasz Torcz Date: Thu, 21 Nov 2019 19:02:01 +0100 Subject: [PATCH] balkon: zamiana sterowania lampkami z sonoffa na shelly --- items/wifi.items | 19 ++++++++++++++----- rules/salon.lampka-stolowa.rules | 21 +++++++++++++++++---- sitemaps/default.sitemap | 2 +- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/items/wifi.items b/items/wifi.items index c833124..abe7903 100644 --- a/items/wifi.items +++ b/items/wifi.items @@ -15,7 +15,7 @@ sonoff01 sonoff02 - lampka stół sonoff03 - łazienka wiatrak sonoff04 - -sonoff05 - lampki balkonowe +sonoff05 - sonoff06 - przedpokój touch przy drzwiach sonoff07 - wc wiatrak d1mini01 - okap @@ -24,6 +24,7 @@ d1mini03 - prototyp / pilot na kanapie d1mini04 - odświeżacz d1mini05 - wskazówka interneu d1mini06 - schodowy przy salonie +shelly01 - oświetlenie balkonu */ /* moc sygnalu */ @@ -50,9 +51,8 @@ Number wSONOFF03 "Wifi s03 wiatrak [%d dB]" (wifi) { mqtt="<[motherqtt:/s Switch rSONOFF03 "Conn s03 [%s]" { mqtt="<[motherqtt:/sonoff03/status:state:MAP(espeasy_lwt.map)]" } -/* lampki balkonowe */ -Switch sSONOFF05 "Lampki balkonowe" { mqtt=">[motherqtt:/sonoff05/gpio/12:command:ON:1],>[motherqtt:/sonoff05/gpio/12:command:OFF:0]" } -Number wSONOFF05 "Wifi s05 balkon [%d dB]" (wifi) { mqtt="<[motherqtt:/sonoff05/sysinfo/wifi:state:default]" } +Switch sSONOFF05 "sonoff5" { mqtt=">[motherqtt:/sonoff05/gpio/12:command:ON:1],>[motherqtt:/sonoff05/gpio/12:command:OFF:0]" } +Number wSONOFF05 "Wifi s05 [%d dB]" (wifi) { mqtt="<[motherqtt:/sonoff05/sysinfo/wifi:state:default]" } Switch rSONOFF05 "Conn s05 [%s]" { mqtt="<[motherqtt:/sonoff05/lwt:state:MAP(espeasy_lwt.map)]" } /* przedpokój - sonoff przy drzwiach wejściowych */ @@ -79,7 +79,7 @@ Switch rSONOFF07 "Conn s07 [%s]" { mqtt="<[motherqtt:/sonoff07/lwt:state:MAP(esp relay 2 gpio5 */ Switch sSONOFF08a "Sypialnia cottonballs" { mqtt=">[motherqtt:/sonoff08/gpio/12:command:ON:1],>[motherqtt:/sonoff08/gpio/12:command:OFF:0]" } -Switch sSONOFF08b "Sypialnia lampeczki" { mqtt=">[motherqtt:/sonoff08/gpio/5:command:ON:1],>[motherqtt:/sonoff08/gpio/5:command:OFF:0]" } +Switch sSONOFF08b "Sypialnia nawilżacz" { mqtt=">[motherqtt:/sonoff08/gpio/5:command:ON:1],>[motherqtt:/sonoff08/gpio/5:command:OFF:0]" } Switch sSONOFF08_ext "Sypialnia przycisk" { mqtt="<[motherqtt:/sonoff08/button/ext:state:MAP(espeasy_onoff.map)]" } Number wSONOFF08 "Wifi s08 dual [%d dB]" (wifi) { mqtt="<[motherqtt:/sonoff08/sysinfo/wifi:state:default]" } Switch rSONOFF08 "Conn s08 [%s]" { mqtt="<[motherqtt:/sonoff08/lwt:state:MAP(espeasy_lwt.map)]" } @@ -146,3 +146,12 @@ Switch sD1MINI06LED "Przedpokój LED" { mqtt=">[motherqtt:/d1mini06/gpi Switch sD1MINI06KEY "Włącznik hall przy salonie [%s]" { mqtt="<[motherqtt:/d1mini06/salon/switch:state:MAP(espeasy_onoff.map)]" } /* GPIO14 */ Number wD1MINI06 "Wifi d1m06 przedpokój [%d dB]" (wifi) { mqtt="<[motherqtt:/d1mini06/wifi/:state:default]" } Switch rD1MINI06 "Conn d1m06 [%s]" { mqtt="<[motherqtt:/d1mini06/lwt:state:MAP(espeasy_lwt.map)]" } + + +/* lampki balkonowe */ +Switch sSHELLY01 "Lampki balkonowe" { mqtt=">[motherqtt:/shelly01/gpio/4:command:ON:1],>[motherqtt:/shelly01/gpio/4:command:OFF:0]" } +/*Switch sSHELLY01KEY "Włącznik hall przy drzwiach wejściowych [%s]" { mqtt="<[motherqtt:/shelly01/gpio/5:state:MAP(espeasy_onoff.map)]" }*/ +Number wSHELLY01 "Wifi sh01 balkon [%d dB]" (wifi) { mqtt="<[motherqtt:/shelly01/wifi/:state:default]" } +Switch rSHELLY01 "Conn sh01 [%s]" { mqtt="<[motherqtt:/shelly01/lwt:state:MAP(espeasy_lwt.map)]" } + + diff --git a/rules/salon.lampka-stolowa.rules b/rules/salon.lampka-stolowa.rules index 8e28764..d0efc39 100644 --- a/rules/salon.lampka-stolowa.rules +++ b/rules/salon.lampka-stolowa.rules @@ -7,7 +7,7 @@ then sSONOFF02.sendCommand(ON) /* balkon */ - sSONOFF05.sendCommand(OFF) + sSHELLY01.sendCommand(ON) end @@ -19,7 +19,7 @@ then sSONOFF02.sendCommand(OFF) /* balkon */ - sSONOFF05.sendCommand(OFF) + sSHELLY01.sendCommand(OFF) end @@ -33,7 +33,7 @@ then sD1MINI01_lampki_sufitowe.sendCommand(ON) /* balkon */ - sSONOFF05.sendCommand(ON) + sSHELLY01.sendCommand(ON) end /* HOLIDAY */ @@ -100,6 +100,7 @@ then dSONOFF02LED.sendCommand(0) end + rule "Zgaś stółlampkę, sufitowe i nablatowe wieczorem" when Time cron "0 15 22 * * ?" @@ -113,7 +114,19 @@ then sD1MINI02MOS.sendCommand(OFF) /* balkon */ - sSONOFF05.sendCommand(OFF) + sSHELLY01.sendCommand(OFF) +end + + +/* na wypadek rebootów sonoffa */ +rule "Synchronizuj balkon & lampka po restarcie" +when + Item rSHELLY01 changed to ON or + Item rSONOFF02 changed to ON +then + logInfo("S02,SH01", "Reappeared, applying state balkon {}, lampka {}", sSHELLY01.state, sSONOFF02.state) + sSONOFF02.sendCommand(sSONOFF02.state.toString) + sSHELLY01.sendCommand(sSHELLY01.state.toString) end /* diff --git a/sitemaps/default.sitemap b/sitemaps/default.sitemap index 08b7698..7c19bf6 100644 --- a/sitemaps/default.sitemap +++ b/sitemaps/default.sitemap @@ -20,7 +20,7 @@ sitemap pbrk label="Domek" Switch item=sD1MINI01_lampki_sufitowe Switch item=sSONOFF01 Switch item=sSONOFF06 - Switch item=sSONOFF05 + Switch item=sSHELLY01 }