From 715eb4836bdeefaccd5f1983e5b5a3d9f209b310 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 9 Jul 2018 21:10:54 +0200 Subject: [PATCH] lampki w salonie: zapalanie wczesniej (2h przed zachodem) gdy pochmurno --- items/astro.items | 1 + items/pogoda.items | 2 +- rules/salon.lampka-stolowa.rules | 18 ++++++++++++++++++ sitemaps/tech.sitemap | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/items/astro.items b/items/astro.items index addae0f..ca77cc3 100644 --- a/items/astro.items +++ b/items/astro.items @@ -4,4 +4,5 @@ DateTime dtSunset_Time "Zachód Słońca [%1$tH:%1$tM]" {astro="planet= Switch sSunset_Event { astro="planet=sun, type=set, property=end"} Switch sSunset_Event_in_halfhour { astro="planet=sun, type=set, property=end, offset=-30"} Switch sSunset_Event_in_hour { astro="planet=sun, type=set, property=end, offset=-60"} +Switch sSunset_Event_in_twohours { astro="planet=sun, type=set, property=end, offset=-120"} diff --git a/items/pogoda.items b/items/pogoda.items index f19f970..f2e581f 100644 --- a/items/pogoda.items +++ b/items/pogoda.items @@ -1,5 +1,5 @@ /* https://github.com/openhab/openhab1-addons/wiki/weather-binding */ -Number wClouds "Clouds [%.0f %%]" {weather="locationId=domek, type=clouds, property=percent"} +Number wClouds "Clouds [%.0f %%]" {weather="locationId=domek, type=clouds, property=percent"} diff --git a/rules/salon.lampka-stolowa.rules b/rules/salon.lampka-stolowa.rules index 34ab9b1..f4533ab 100644 --- a/rules/salon.lampka-stolowa.rules +++ b/rules/salon.lampka-stolowa.rules @@ -27,7 +27,25 @@ then end +rule "Zapal lampkę i kanapowe przez zmierzchem gdy pochmurno" +when + Item sSunset_Event_in_twohours received update ON +then + /* more than 60% cloud cover */ + if (wClouds.state > 60.0) { + logInfo("stollampka", "Powyżej 60% chmur, zapalam") + sSONOFF02.sendCommand(ON) + sSONOFF02_expected.postUpdate(ON) + + sSONOFF01.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 diff --git a/sitemaps/tech.sitemap b/sitemaps/tech.sitemap index eee20ae..202d598 100644 --- a/sitemaps/tech.sitemap +++ b/sitemaps/tech.sitemap @@ -2,6 +2,7 @@ sitemap pbrk label="Szczegóły techniczne" { Frame { Text item=dtSunset_Time + Text item=wClouds } Group label="Łączność" {