Hello, everybody,
in my current environment i use OH release 2.4 via openHabian - runs great!
I’ve implemented the CaldDav script by Thomas Schwarz and have my sitemap show me the rebuttal dates.
I have now extended the script and it shows dates for the whole week, because there are 2-3 redirection dates / day and another 4th one in the week is possible.
In short, I want my 12 LED panel from MDT to show what is due, but I must be able to achieve that OH gives something back to the BUS. At this point I can’t get any further as I completely lack the approach I should be looking for.
For example, I would like to have the waste type residual waste displayed one day in advance, LED=blue and LED=red on the day of collection.
In addition I would like to control 4 LED to 4 types of waste also.
Excuse me, maybe I just don’t know how to ask my question better and maybe I have already asked this question before.
Frame label="LED Müll" {
Switch item=restmuell // waste type
Switch item=papier // waste type
Switch item=gelbersack // waste type
Switch item=Biotonne // waste type
With This Setup of Course I’m able to let the LED of the MDT LED Panel turn on/off - solved.
The next step I tried is to create a rule
here is what I got
rule "muell_licht"
when
Time cron "0 0/1 * * * ?"
//Time cron "0 15 17 * * ?"
//Item date_today changed
then
var String dMuell1
var String dMuell2
var String dMuell3
var String dMuell4
var String muell1
var String muell2
var String muell3
var String muell4
dMuell1 = CalDav_Date.state.format("%1$td.%1$tm.%1$tY")
dMuell2 = CalDav_Date_2.state.format("%1$td.%1$tm.%1$tY")
dMuell3 = CalDav_Date_3.state.format("%1$td.%1$tm.%1$tY")
dMuell4 = CalDav_Date_4.state.format("%1$td.%1$tm.%1$tY")
muell1 = CalDav_Muelltonne.state.toString
muell2 = CalDav_Muelltonne_2.state.toString
muell3 = CalDav_Muelltonne_3.state.toString
muell4 = CalDav_Muelltonne_4.state.toString
logInfo("Log meiner Müll-Rule", "Müll 1= " + muell1 + dMuell1)
logInfo("Log meiner Müll-Rule", "Müll 2= " + muell2 + dMuell2)
logInfo("Log meiner Müll-Rule", "Müll 3= " + muell3 + dMuell3)
logInfo("Log meiner Müll-Rule", "Müll 4= " + muell4 + dMuell4)
if (muell1=="Biotonne")
prüfe ob item.LED Biotonne = ON
Else sendCommand(item=biotonne, ON)
if (muell1=="Restmuell")
if (muell1=="Gruenabfall")
if (muell1=="Gelbersack")
{
lampe = "biotonne"
} else if (abfallart.substring(0,4)=="Gelb") {
lampe = "gelbersack"
} else if (abfallart.substring(0,4)=="Rest") {
lampe = "restmuell"
} else if (abfallart.substring(0,6)=="Papier") {
lampe = "papier"
}
if (now.isBefore(new DateTime((CalDav_Date.state as DateTimeType).getCalendar().getTime ()).plusHours(24)) &&
now.isAfter(new DateTime((CalDav_Date.state as DateTimeType).getCalendar().getTime()))) {
}
end
From the principle I would like to know whether today is the day of the collection or whether it is the advance information.
e.g.
on 14.01.2019 the paper waste will be collected.
Today is the 13.12.2019
First of all I would like to see the LED “Papiermuell” on red today. And at midnight the same LED on (paper waste) jumps to green.
The same should happen with the other types of waste.
With us it can be that 4 garbage per day are fetched. - therefore the repeating variables garbage1- garbage4
The Code is a “Status quo” from different Sources and only the first part till the first “if” is my.
import org.eclipse.smarthome.model.script.ScriptServiceUtil
rule "muell_licht"
when
Time cron "1 30 2 ? * * " //02:30 in the morning (enough time for the CalDav binding to update and avoid winter/summer time changes)
then
gCalDav_Date.members.forEach[ i |
val wasteDate = new DateTime(i.state.toString)
val String wasteItemName = "CalDav_Muelltonne_" + i.name.toString.split("_").get(2)
val wasteItem = ScriptServiceUtil.getItemRegistry.getItem(wasteItemName)
val wasteType = wasteItem.state.toString
if (wasteDate.isBefore(now.withTimeAtStartOfDay.plusDays(1))) { // If Muell1 time is before tomorrow 00:00 ie: is today
sendCommand(wasteType, "ON")
} else { //is tomorrow
sendCommand(wasteType, "OFF")
}
]
end
This will switch the lights ON or OFF if the waste collection is today
But I don’t have enough info about the items or what command to send the LEDs to turn them GREEN or RED
This will only work if the String in the calendar EXACTLY matches the item names for the lights:
i.e.: restmuell, papier, gelbersack and Biotonne
// LED Anzeigen Flur
Type switch : restmuell "restmuell" [ ga="0/2/50" ] // GA für das //
Type switch : papier "papier" [ ga="0/2/51" ]
Type switch : gelbersack "gelbersack" [ ga="0/2/52" ]
Type switch : biotonne "biotonne" [ ga="0/2/53" ]
The LED Panel from MDT has got for each LED a GA
}
Frame label="LED Müll" {
Switch item=restmuell
Switch item=papier
Switch item=gelbersack
Switch item=biotonne
}
In the ETS I can assign a group address to an LED light.
And if I want I can specify in the ETS what should happen as priority action for the same light.
Your code would “switch on” the GA for light red the day before.
And on the day of collection, switch the GA to priority for the same LED.
Was that what your question meant? Or should I attach a photo of the LED panel from MDT
// LED Waste day befor
Type switch : restmuell "restmuell" [ ga="0/2/50" ]
Type switch : papier "papier" [ ga="0/2/51" ]
Type switch : gelbersack "gelbersack" [ ga="0/2/52" ]
Type switch : biotonne "biotonne" [ ga="0/2/53" ]
// LED Wast today
Type switch : restmuell_today "restmuell" [ ga="0/2/60" ]
Type switch : papier_today "papier" [ ga="0/2/61" ]
Type switch : gelbersack_today "gelbersack" [ ga="0/2/62" ]
Type switch : biotonne_today "biotonne" [ ga="0/2/63" ]
``
```csv
and of Course the ITEMS
Switch restmuell "LED Restmüll [%s]" <light> { channel="knx:device:bridge:generic:restmuell" }
Switch papier "LED Papiermüll [%s]" <light> { channel="knx:device:bridge:generic:papier" }
Switch gelbersack "LED Gelber Sack [%s]" <light> { channel="knx:device:bridge:generic:gelbersack" }
Switch biotonne "LED Biotonne [%s]" <light> { channel="knx:device:bridge:generic:biotonne" }
Switch restmuell_today "LED Restmüll heute [%s]" <light> { channel="knx:device:bridge:generic:restmuell_today" }
Switch papier_today "LED Papiermüll heute [%s]" <light> { channel="knx:device:bridge:generic:papier_today" }
Switch gelbersack_today "LED Gelber Sack heute [%s]" <light> { channel="knx:device:bridge:generic:gelbersack_today" }
Switch biotonne_today "LED Biotonne heute [%s]" <light> { channel="knx:device:bridge:generic:biotonne_today" }
In the LED panel I can switch on the LED via [ ga=“0/2/50” ]. This happens the day before the pick-up.
On the day of the collection [ ga=“0/2/60” ] should be switched on again. ( with it the color of the LED changes from color 1 to color 2) - in the ETS I have simulated this and it works.
When the collection day is over (at 14 o’clock - 2 pm.)
Item restmuell_today == OFF AND THEN Item restmuell == OFF
The Order of switching is nessesary.
This is a very very great case for many People with the same MDT 12 LED Panel.
import org.eclipse.smarthome.model.script.ScriptServiceUtil
rule "muell_licht"
when
Time cron "1 30 2 ? * * " //02:30 in the morning (enough time for the CalDav binding to update and avoid winter/summer time changes)
then
gCalDav_Date.members.forEach[ i |
val wasteDate = new DateTime(i.state.toString)
val String wasteItemName = "CalDav_Muelltonne_" + i.name.toString.split("_").get(2)
val wasteItem = ScriptServiceUtil.getItemRegistry.getItem(wasteItemName)
val wasteType = wasteItem.state.toString
if (wasteDate.isBefore(now.withTimeAtStartOfDay.plusDays(1))) { // If Muell1 time is before tomorrow 00:00 ie: is today
sendCommand(wasteType, "OFF")
sendCommand(wasteType + "_today", "ON")
} else { //is tomorrow or after
sendCommand(wasteType + "_today", "OFF")
sendCommand(wasteType, "ON")
}
]
end
Thank you.
for a better understandig - where do you get the Information about what is the item?
You never use the real item name like “restmuell” or “biotonne”
I’ll give final a Feedback when the Lights go on and off!
You are sending that information with the CalDav binding
There:
rule "muell_licht"
when
Time cron "1 30 2 ? * * " //02:30 in the morning (enough time for the CalDav binding to update and avoid winter/summer time changes)
then
// For each item
gCalDav_Date.members.forEach[ i |
// Let's say CalDav_Date_1
val wasteDate = new DateTime(i.state.toString)
// COMMENT: wasteDate = 15/01/2018
val String wasteItemName = "CalDav_Muelltonne_" + i.name.toString.split("_").get(2)
// COMMENT: wasteItemName = "CalDavmuelltonne_" + "1" = CalDavMuelltonne_1
val wasteItem = ScriptServiceUtil.getItemRegistry.getItem(wasteItemName)
// COMMENT: wasteItem = CalDavMuelltonne_1
val wasteType = wasteItem.state.toString
// COMMENT: wasteType = "biotonne" (Information in the calendar)
if (wasteDate.isBefore(now.withTimeAtStartOfDay.plusDays(1))) { // If Muell1 time is before tomorrow 00:00 ie: is today
sendCommand(wasteType, "OFF")
sendCommand(wasteType + "_today", "ON")
} else { //is tomorrow or after
sendCommand(wasteType + "_today", "OFF")
sendCommand(wasteType, "ON")
}
]
end
That’s why I said that the info in the calendar MUST exactly match you item names