OH as proxy for 12 LED Panel by MDT

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.

BR Lars

Post all your relevant items, LEDS, dates…
I’ll try to point you in the right direction

1 Like

hi,
sorry it’s been a while. - with a lot more understanding.
ok.
Here are my “Things”

    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"

and here the itmes muell (waste)

    /* Müllkalender */

    String CalDav_Muelltonne "Tonne [%s]" <calendar> { caldavPersonal="calendar:Muellkalender type:EVENT eventNr:1 value:NAME" }

    DateTime CalDav_Date "Datum der Abholung [%1$td.%1$tm.%1$tY]" <calendar> { caldavPersonal="calendar:Muellkalender type:EVENT eventNr:1 value:START" }

    String CalDav_Muelltonne_2 "Tonne [%s]" <calendar> { caldavPersonal="calendar:Muellkalender type:EVENT eventNr:2 value:NAME" }

    DateTime CalDav_Date_2 "Datum der Abholung [%1$td.%1$tm.%1$tY]" <calendar> { caldavPersonal="calendar:Muellkalender type:EVENT eventNr:2 value:START" }

    String CalDav_Muelltonne_3 "Tonne [%s]" <calendar> { caldavPersonal="calendar:Muellkalender type:EVENT eventNr:3 value:NAME" }

    DateTime CalDav_Date_3 "Datum der Abholung [%1$td.%1$tm.%1$tY]" <calendar> { caldavPersonal="calendar:Muellkalender type:EVENT eventNr:3 value:START" }

    String CalDav_Muelltonne_4 "Tonne [%s]" <calendar> { caldavPersonal="calendar:Muellkalender type:EVENT eventNr:4 value:NAME" }

    DateTime CalDav_Date_4 "Datum der Abholung [%1$td.%1$tm.%1$tY]" <calendar> { caldavPersonal="calendar:Muellkalender type:EVENT eventNr:4 value:START" }

    DateTime date_today "Heute [%1$td.%1$tm.%1$tY]" <calendar> { channel="ntp:ntp:local:dateTime" }

and here my sitemap

    	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.

Thank you

BR
lars

Please remove the dropdowns and use the codes fences, thanks

ok, done

Ok, thanks, I see what you want to do.
I am not able to do that tonight. Ping me tomorrw

1 Like

What are the LED items?
and what command to send them for different colors, please?
I have the time check working, I need to light up the leds

First change you items as follow:

Group gCalDav_Muelltonne
Group gCalDav_Date
String CalDav_Muelltonne_1 "Tonne [%s]" <calendar> (gCalDav_Muelltonne) { caldavPersonal="calendar:Muellkalender type:EVENT eventNr:1 value:NAME" }
DateTime CalDav_Date_1 "Datum der Abholung [%1$td.%1$tm.%1$tY]" <calendar> (gCalDav_Date) { caldavPersonal="calendar:Muellkalender type:EVENT eventNr:1 value:START" }
String CalDav_Muelltonne_2 "Tonne [%s]" <calendar> (gCalDav_Muelltonne) { caldavPersonal="calendar:Muellkalender type:EVENT eventNr:2 value:NAME" }
DateTime CalDav_Date_2 "Datum der Abholung [%1$td.%1$tm.%1$tY]" <calendar>  (gCalDav_Date){ caldavPersonal="calendar:Muellkalender type:EVENT eventNr:2 value:START" }
String CalDav_Muelltonne_3 "Tonne [%s]" <calendar> (gCalDav_Muelltonne) { caldavPersonal="calendar:Muellkalender type:EVENT eventNr:3 value:NAME" }
DateTime CalDav_Date_3 "Datum der Abholung [%1$td.%1$tm.%1$tY]" <calendar>  (gCalDav_Date){ caldavPersonal="calendar:Muellkalender type:EVENT eventNr:3 value:START" }
String CalDav_Muelltonne_4 "Tonne [%s]" <calendar> (gCalDav_Muelltonne) { caldavPersonal="calendar:Muellkalender type:EVENT eventNr:4 value:NAME" }
DateTime CalDav_Date_4 "Datum der Abholung [%1$td.%1$tm.%1$tY]" <calendar>  (gCalDav_Date){ caldavPersonal="calendar:Muellkalender type:EVENT eventNr:4 value:START" }
DateTime date_today "Heute [%1$td.%1$tm.%1$tY]" <calendar> { channel="ntp:ntp:local:dateTime" }

Then the rules:

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

2 Likes
        // 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

You want the LED to be either GREEN or RED but the items are switch only
How do you get them to change colour?

My code would switch ON the LED on the day of waste collection and OFF otherwise

The Color can be Change bei the KNX when I send a new knx telegram to GA [ ga=“0/2/60” ]

I Setup some new Thnings

        // 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.

Thank you so far!

BR
Lars

Cool then your rule is:

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! :wink:

BR
Lars

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

1 Like

uff as suspected, the calendar entries are the following ( Uper Case and Gelber Sack with a blank)
Papiermuell
Gelber Sack
Biotonne
Papiertonne

Can this be solved by transformation?

File: muell.map

Papiermuell=papiermuell
Gelber Sack=gelbersack
Biotonne=biotonne
Papiertonne=papiertonne

Yes of cousre, you may need to escape the space

Then change the line:

        val wasteType = wasteItem.state.toString

to:

        val wasteType = transform("MAP", "muell.map", wasteItem.state.toString)

OR

Without transformation:

        val wasteType = wasteItem.state.toString.replace(" ", "").toLowerCase()

That is because your items CalDav_Muelltonne_X still have values in them from their last update

Check the item file it the other items exist then these should too.

1 Like