Garbage Collection

Yes this script is meant to sort the dates. I do not use it yet but you can see that it relies on custom Item metadata. This would be the ideal solution in my opinion (at least in theory) but since the support for custom metadata is still pretty limited in main ui I haven’t really used this feature.

As DrRSatzteil (netter Name btw. :smiley:) already wrote the script is meant to sort the dates. On my setup the script gets called everytime a garbage items changes. Color and name are set as custom namespace on each item. These are used to beautify the list.

Can you please tell me how to use it ? I am just now try to migrate my oh2 to oh3 and all these metadata confuse me.

Sure. Got to your item list and select the appropriate item. Click on the “Add Metadata” button and select “Enter custom namespace”. Enter e.g. “color” and finally you should end with something like this

value: yellow
config: {}

thanks for your reply but i am think its too difficult for me :disappointed_relieved: i have all Ready put the custom metadata like you told me, when i run the script i get this error:
Script execution of rule with UID ‘4c3bed8d7f’ failed: TypeError: Cannot get property “value” of null in at line number 23
next question is how to use the “SortedGarbageDateItems” item to the garbage widget??

Try this one
footer: =items[loop.item.name].displayState

Wauw, this is indeeed working! thanks!!! I will use this in several other widgets as well.

I’m a bit of an OpenHAB beginner and definitely new to widgets, but I’m trying to get this to work. I got the widget and it works statically, with some missing items, but I’m not sure how to make and populate the items:

  1. So it’s easy enough to create the item “items.garbage_collection_garbage” and I assume I’ll need to write a script to populate SOMETHING in the item so that “displayState” is some value, but what type IS the item? I see references in the messages here to meta data, but I’ve never used it before. How do I set it up so “items.garbage_collection_garbage.displayState” returns what’s necessary?
  2. Once I get that item working, I obviously need an item “items.local_dateweekday”. Where does that come from? Do I need another script to populate that? Another script?

I think I understand the rest, but I need to get over this hurdle first. Any help?

Thanks!

Hi Ian,

Let me try to help you explain what you need:

  1. For every line that should be shown in the widget list you will need an item of type DateTime. To get a human readable displayState from this item you will need to apply the state description metadata (Open the item in Main Ui and click ‚Add metadata‘ → select ‚State Description‘. Then fill in the pattern value something like: ‚ %1$tA %1$td.%1$tm.%1$tY‘ and check out the resulting display in the main UI. Please search the forums and/or documentation if you need more help on the pattern syntax. I think there should be plenty of helpful resources around.

  2. I should have updated the first post, sorry for not doing so. Please use the garbage_list_v1 version of the widget that I posted on Jan 26. there is no need for this item anymore. I will update the first post when I find some more time.

I hope this will help you to get on the right track. Please let me know if you got it working!

Haven’t had much time yet over the holidays, but I’ll let you know - I think I understand it so it should be workable! Thanks for the help!

Got it working fine! Thanks very much. I’ll come back in a few days and post exactly what I had to do (for us newbies).

Now I just need to write a script to update the date items and I’m golden - thanks very much for your help!

1 Like

Updated the first post with the latest code and improved explanations.

Great work. Thank you.

First, thanks. Great widget.
I’m new to openHab, and it took me some time to understand, what is required.

For every other newbie, a short summary using the web interface to maybe speed them up :slight_smile:

My assumption for the reader:

  • You are familiar with CalDav,
  • You have a calendar with at least two meeting series, named “paper” and “glass”
  • You installed the widget “Garbage Collection”

To get this widget running, you have to follow this step

  1. Install icalendar
  2. Add a icalendar configuration for your calender
  3. Add an event filter
    3.1 for each type you like to display (e.g. two event filter in case of paper and glass to be displayed)
    3.2 with max event == 1
    3.4 with a text based filter, e.g. using the subject
    3.5 provide the proper subject of the calender entry, e.g. paper or glass
    3.6 set Start to 0, as shown here Garbage Collection - #36 by DrRSatzteil
  4. Add an item for each event filter
    4.1 Each item is of type DateTime
    4.2 Every item is linked to one event filter only
    4.3 The used channel is “result_0#begin”
    4.4 Adjust the meta description of each item to “%1$tA %1$td.%1$tm.%1$tY” like written here Garbage Collection - #32 by DrRSatzteil. Otherwise, the date in the footer for each type is missing, like here: Garbage Collection - #27 by wars

Now all pre-conditions should be fulfilled, so that the widget can be easily configured as described here Garbage Collection

7 Likes

Hi,

@Panji
I tried your guide by creating a local calender.ics and save it to the openhab pi. ICalender Binding URL has a local address.

Following your points I end up that all my channel filter items are “UNDEF”.

Regarding search subject i tried the blank name of the event as well as “SUMMARY:Eventname”. ← why this : see an extract of my .ics file:
I also tried both types of the search expression.

SUMMARY:Gelber Sack
DTSTART;TZID=Europe/Berlin:20220125T070000
DTEND;TZID=Europe/Berlin:20220125T080000
TRANSP:OPAQUE
SEQUENCE:3
X-MOZ-GENERATION:3
END:VEVENT
END:VCALENDAR

My local time is proper set .

What do I miss?
Thanks for your help

Phil

Sorry, but I have no idea.

General hints would be:

  1. Check the openhab log files
  2. Check the permission, if the file can be reached via web from localhost

But because this issue is not related to this widget, I would also recommend to create a new topic :slight_smile:

  1. There werent any logs regarding calender binding or event filter.
  2. Permissons are granted and location is reachable (same folder like OpenHAB UI images)
  3. A reboot always helpts :see_no_evil:

I did a reboot because of other reasons and left all my calendar settings. After reboot everything works fine.

Thanks anyway for your hints

Hi i am still trying to make this work but i am stuck with the new item that have the sorted items. i have put all the metadata name and color, i have create a new item (SortedGarbageDateItems) as string?? my question is how to use the new item (SortedGarbageDateItems) in the widget ??

Thanks
Nikos

You should simply use this as the datearray parameter in the widget.

can you be more specific please :slight_smile:

so its look like my item now