Skip to content

Commit 710aa76

Browse files
authored
[ahawastecollection] Initial Contribution (openhab#10387)
Signed-off-by: Sönke Küper <[email protected]>
1 parent 7fb7c65 commit 710aa76

24 files changed

+1337
-0
lines changed

CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/bundles/org.openhab.automation.jythonscripting/ @openhab/add-ons-maintainers
1010
/bundles/org.openhab.automation.pidcontroller/ @fwolter
1111
/bundles/org.openhab.binding.adorne/ @theiding
12+
/bundles/org.openhab.binding.ahawastecollection/ @soenkekueper
1213
/bundles/org.openhab.binding.airq/ @aurelio1
1314
/bundles/org.openhab.binding.airquality/ @kubawolanin
1415
/bundles/org.openhab.binding.airvisualnode/ @3cky

bom/openhab-addons/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
<artifactId>org.openhab.binding.adorne</artifactId>
3737
<version>${project.version}</version>
3838
</dependency>
39+
<dependency>
40+
<groupId>org.openhab.addons.bundles</groupId>
41+
<artifactId>org.openhab.binding.ahawastecollection</artifactId>
42+
<version>${project.version}</version>
43+
</dependency>
3944
<dependency>
4045
<groupId>org.openhab.addons.bundles</groupId>
4146
<artifactId>org.openhab.binding.airq</artifactId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
This content is produced and maintained by the openHAB project.
2+
3+
* Project home: https://www.openhab.org
4+
5+
== Declared Project Licenses
6+
7+
This program and the accompanying materials are made available under the terms
8+
of the Eclipse Public License 2.0 which is available at
9+
https://www.eclipse.org/legal/epl-2.0/.
10+
11+
== Source Code
12+
13+
https://github.com/openhab/openhab-addons
14+
15+
16+
== Third-party Content
17+
18+
jsoup
19+
* License: MIT License
20+
* Project: https://jsoup.org/
21+
* Source: https://github.com/jhy/jsoup
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# aha Waste Collection Binding
2+
3+
This binding provides information about the upcoming waste collection dates for places, that are served by aha, the waste collection company for the region of Hannover. The values are retrieved from the online aha waste collection schedule available at: [aha Abfuhrkalender](https://www.aha-region.de/abholtermine/abfuhrkalender).
4+
5+
## Supported Things
6+
7+
- **collectionSchedule:** Represents the connection to the **aha Waste Collection Schedule** with four channels for the different waste types.
8+
9+
## Discovery
10+
11+
Discovery is not possible, due some form input values from the website above are required.
12+
13+
## Thing Configuration
14+
15+
For configuration of the **collectionSchedule** thing, you need the form inputs from the aha collections schedule web page. Follow the steps below to get the required configuration parameters from the form input values.
16+
17+
18+
1. Open [aha Abfuhrkalender](https://www.aha-region.de/abholtermine/abfuhrkalender) in your favorite brower with developer-console.
19+
2. Open the developer console and switch to network tab (for example press F12 in chrome / edge / firefox).
20+
3. Fill in the form: Select your commune, Street and house number and hit "Suchen".
21+
4. Select the first request to https://www.aha-region.de/abholtermine/abfuhrkalender (see first screenshot below)
22+
5. Check the form data at the end of the request for the form values (see second screenshot below)
23+
5. Fill in the values from the form input in thing configuration (see examples below)
24+
25+
![Chrome Developer Console Top](doc/images/ChromeDevconsoleTop.png "Chrome Developer Console showing request URL")
26+
27+
*Check if you've selected the correct request, that contains the form data*
28+
29+
![Chrome Developer Console Bottom](doc/images/ChromeDevconsoleBottom.png "Chrome Developer Console showing form inputs")
30+
31+
*Grab the values for the configuration parameters from the form data section at the end of the request*
32+
33+
**collectionSchedule** parameters:
34+
35+
| Property | Default | Required | Description |
36+
|-|-|-|-|
37+
| `commune` | | Yes | The selected commune, taken from the form field `gemeinde`. |
38+
| `street` | | Yes | The selected street, taken from the form field `strasse`. This value must look like 67269@Rosmarinweg+/+Kirchhorst@Kirchhorst |
39+
| `houseNumber` | | Yes | The selected house number, taken from the form field `hausnr`. |
40+
| `houseNumberAddon` | | No | The selected house number addon, taken from the form field `hausnraddon`, may be empty. |
41+
| `collectionPlace` | | Yes | Form value for the collection place, taken from the form field `ladeort`. This value must look like 67269-0010+ |
42+
43+
## Channels
44+
45+
The thing **aha Waste Collection Schedule** provides four channels for the upcoming day of waste collection for the different waste types.
46+
47+
48+
| channel | type | description |
49+
|----------|--------|------------------------------|
50+
| generalWaste | DateTime | Next collection day for general waste |
51+
| leightweightPackaging | DateTime | Next collection day for leightweight packaging |
52+
| bioWaste | DateTime | Next collection day for bio waste |
53+
| paper | DateTime | Next collection day for paper |
54+
55+
56+
## Full Example
57+
58+
wasteCollection.things
59+
60+
```
61+
Thing ahawastecollection:collectionSchedule:wasteCollectionSchedule "aha Abfuhrkalender" [ commune="Isernhagen", street="67269@Rosmarinweg+/+Kirchhorst@Kirchhorst", houseNumber="10", houseNumberAddon="", collectionPlace="67269-0010+" ]
62+
```
63+
64+
wasteCollection.items
65+
66+
```
67+
DateTime collectionDay_generalWaste "Next general waste collection" {channel="ahawastecollection:collectionSchedule:wasteCollectionSchedule:generalWaste"}
68+
DateTime collectionDay_leightweightPackaging "Next lightweight packaging collection" {channel="ahawastecollection:collectionSchedule:wasteCollectionSchedule:leightweightPackaging"}
69+
DateTime collectionDay_bioWaste "Next bio waste collection" {channel="ahawastecollection:collectionSchedule:wasteCollectionSchedule:bioWaste"}
70+
DateTime collectionDay_paper "Next paper collection" {channel="ahawastecollection:collectionSchedule:wasteCollectionSchedule:paper"}
71+
```
72+
73+
74+
Example for rule that sends an notification with collected waste types on day before collection
75+
76+
```
77+
triggers:
78+
- id: "1"
79+
configuration:
80+
time: 18:00
81+
type: timer.TimeOfDayTrigger
82+
conditions: []
83+
actions:
84+
- inputs: {}
85+
id: "2"
86+
configuration:
87+
type: application/javascript
88+
script: >-
89+
// Determine next day with time 00:00:00
90+
var today = items['LokaleZeit_DatumundZeit'];
91+
92+
var tomorrow = today
93+
.getZonedDateTime()
94+
.plusDays(1)
95+
.withHour(0)
96+
.withMinute(0)
97+
.withSecond(0)
98+
.withNano(0);
99+
100+
// Get next collection dates from items
101+
var biomuellDate = items['collectionDay_bioWaste'].getZonedDateTime();
102+
var leichtverpackungDate = items['collectionDay_leightweightPackaging'].getZonedDateTime();
103+
var papierDate = items['collectionDay_paper'].getZonedDateTime();
104+
var restmuellDate = items['collectionDay_generalWaste'].getZonedDateTime();
105+
106+
107+
// Check which waste types are collected on the next day
108+
var biomuellCollection = biomuellDate.equals(tomorrow);
109+
var leichtverpackungCollection = leichtverpackungDate.equals(tomorrow);
110+
var papierCollection = papierDate.equals(tomorrow);
111+
var restmuellCollection = restmuellDate.equals(tomorrow);
112+
113+
// Transfer booleans to waste type names
114+
var toBeCollected = [];
115+
116+
if (biomuellCollection) {
117+
toBeCollected.push('bio waste');
118+
}
119+
120+
if (leichtverpackungCollection) {
121+
toBeCollected.push('leihtweight packaging');
122+
}
123+
124+
if (papierCollection) {
125+
toBeCollected.push('paper');
126+
}
127+
128+
if (restmuellCollection) {
129+
toBeCollected.push('general waste');
130+
}
131+
132+
133+
// Send message (or something else) if at least one waste type is collected
134+
if (toBeCollected.length > 0) {
135+
var message = "Tomorrow the following waste will be collected:\n" + toBeCollected.join(', ');
136+
events.sendCommand('SignalSmartHome_Eingabewert', message);
137+
}
138+
type: script.ScriptAction
139+
```
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>org.openhab.addons.bundles</groupId>
9+
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
10+
<version>3.1.0-SNAPSHOT</version>
11+
</parent>
12+
13+
<artifactId>org.openhab.binding.ahawastecollection</artifactId>
14+
15+
<name>openHAB Add-ons :: Bundles :: aha Waste Collection Binding</name>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>org.jsoup</groupId>
20+
<artifactId>jsoup</artifactId>
21+
<version>1.8.3</version>
22+
<scope>provided</scope>
23+
</dependency>
24+
</dependencies>
25+
26+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<features name="org.openhab.binding.ahawastecollection-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
3+
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository>
4+
5+
<feature name="openhab-binding-ahawastecollection" description="aha Waste Collection Binding" version="${project.version}">
6+
<feature>openhab-runtime-base</feature>
7+
<bundle dependency="true">mvn:org.jsoup/jsoup/1.8.3</bundle>
8+
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.ahawastecollection/${project.version}</bundle>
9+
</feature>
10+
</features>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Copyright (c) 2010-2021 Contributors to the openHAB project
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
*/
13+
package org.openhab.binding.ahawastecollection.internal;
14+
15+
import java.io.IOException;
16+
import java.util.Map;
17+
18+
import org.eclipse.jdt.annotation.NonNullByDefault;
19+
import org.openhab.binding.ahawastecollection.internal.CollectionDate.WasteType;
20+
21+
/**
22+
* Schedule that returns the next collection dates from the aha website.
23+
*
24+
* @author Sönke Küper - Initial contribution
25+
*/
26+
@NonNullByDefault
27+
public interface AhaCollectionSchedule {
28+
29+
/**
30+
* Returns the next collection dates per {@link WasteType}.
31+
*/
32+
public Map<WasteType, CollectionDate> getCollectionDates() throws IOException;
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright (c) 2010-2021 Contributors to the openHAB project
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
*/
13+
package org.openhab.binding.ahawastecollection.internal;
14+
15+
import org.eclipse.jdt.annotation.NonNullByDefault;
16+
17+
/**
18+
* Factory for creating an {@link AhaCollectionSchedule}.
19+
*
20+
* @author Sönke Küper - Initial contribution
21+
*/
22+
@NonNullByDefault
23+
public interface AhaCollectionScheduleFactory {
24+
25+
/**
26+
* Creates an new {@link AhaCollectionSchedule} for the given location.
27+
*/
28+
public AhaCollectionSchedule create(final String commune, final String street, final String houseNumber,
29+
final String houseNumberAddon, final String collectionPlace);
30+
}

0 commit comments

Comments
 (0)