forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ahawastecollection] Initial Contribution (openhab#10387)
Signed-off-by: Sönke Küper <[email protected]>
- Loading branch information
1 parent
efc2dc8
commit 4a14e2a
Showing
24 changed files
with
1,337 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
This content is produced and maintained by the openHAB project. | ||
|
||
* Project home: https://www.openhab.org | ||
|
||
== Declared Project Licenses | ||
|
||
This program and the accompanying materials are made available under the terms | ||
of the Eclipse Public License 2.0 which is available at | ||
https://www.eclipse.org/legal/epl-2.0/. | ||
|
||
== Source Code | ||
|
||
https://github.com/openhab/openhab-addons | ||
|
||
|
||
== Third-party Content | ||
|
||
jsoup | ||
* License: MIT License | ||
* Project: https://jsoup.org/ | ||
* Source: https://github.com/jhy/jsoup |
139 changes: 139 additions & 0 deletions
139
bundles/org.openhab.binding.ahawastecollection/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
# aha Waste Collection Binding | ||
|
||
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). | ||
|
||
## Supported Things | ||
|
||
- **collectionSchedule:** Represents the connection to the **aha Waste Collection Schedule** with four channels for the different waste types. | ||
|
||
## Discovery | ||
|
||
Discovery is not possible, due some form input values from the website above are required. | ||
|
||
## Thing Configuration | ||
|
||
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. | ||
|
||
|
||
1. Open [aha Abfuhrkalender](https://www.aha-region.de/abholtermine/abfuhrkalender) in your favorite brower with developer-console. | ||
2. Open the developer console and switch to network tab (for example press F12 in chrome / edge / firefox). | ||
3. Fill in the form: Select your commune, Street and house number and hit "Suchen". | ||
4. Select the first request to https://www.aha-region.de/abholtermine/abfuhrkalender (see first screenshot below) | ||
5. Check the form data at the end of the request for the form values (see second screenshot below) | ||
5. Fill in the values from the form input in thing configuration (see examples below) | ||
|
||
![Chrome Developer Console Top](doc/images/ChromeDevconsoleTop.png "Chrome Developer Console showing request URL") | ||
|
||
*Check if you've selected the correct request, that contains the form data* | ||
|
||
![Chrome Developer Console Bottom](doc/images/ChromeDevconsoleBottom.png "Chrome Developer Console showing form inputs") | ||
|
||
*Grab the values for the configuration parameters from the form data section at the end of the request* | ||
|
||
**collectionSchedule** parameters: | ||
|
||
| Property | Default | Required | Description | | ||
|-|-|-|-| | ||
| `commune` | | Yes | The selected commune, taken from the form field `gemeinde`. | | ||
| `street` | | Yes | The selected street, taken from the form field `strasse`. This value must look like 67269@Rosmarinweg+/+Kirchhorst@Kirchhorst | | ||
| `houseNumber` | | Yes | The selected house number, taken from the form field `hausnr`. | | ||
| `houseNumberAddon` | | No | The selected house number addon, taken from the form field `hausnraddon`, may be empty. | | ||
| `collectionPlace` | | Yes | Form value for the collection place, taken from the form field `ladeort`. This value must look like 67269-0010+ | | ||
|
||
## Channels | ||
|
||
The thing **aha Waste Collection Schedule** provides four channels for the upcoming day of waste collection for the different waste types. | ||
|
||
|
||
| channel | type | description | | ||
|----------|--------|------------------------------| | ||
| generalWaste | DateTime | Next collection day for general waste | | ||
| leightweightPackaging | DateTime | Next collection day for leightweight packaging | | ||
| bioWaste | DateTime | Next collection day for bio waste | | ||
| paper | DateTime | Next collection day for paper | | ||
|
||
|
||
## Full Example | ||
|
||
wasteCollection.things | ||
|
||
``` | ||
Thing ahawastecollection:collectionSchedule:wasteCollectionSchedule "aha Abfuhrkalender" [ commune="Isernhagen", street="67269@Rosmarinweg+/+Kirchhorst@Kirchhorst", houseNumber="10", houseNumberAddon="", collectionPlace="67269-0010+" ] | ||
``` | ||
|
||
wasteCollection.items | ||
|
||
``` | ||
DateTime collectionDay_generalWaste "Next general waste collection" {channel="ahawastecollection:collectionSchedule:wasteCollectionSchedule:generalWaste"} | ||
DateTime collectionDay_leightweightPackaging "Next lightweight packaging collection" {channel="ahawastecollection:collectionSchedule:wasteCollectionSchedule:leightweightPackaging"} | ||
DateTime collectionDay_bioWaste "Next bio waste collection" {channel="ahawastecollection:collectionSchedule:wasteCollectionSchedule:bioWaste"} | ||
DateTime collectionDay_paper "Next paper collection" {channel="ahawastecollection:collectionSchedule:wasteCollectionSchedule:paper"} | ||
``` | ||
|
||
|
||
Example for rule that sends an notification with collected waste types on day before collection | ||
|
||
``` | ||
triggers: | ||
- id: "1" | ||
configuration: | ||
time: 18:00 | ||
type: timer.TimeOfDayTrigger | ||
conditions: [] | ||
actions: | ||
- inputs: {} | ||
id: "2" | ||
configuration: | ||
type: application/javascript | ||
script: >- | ||
// Determine next day with time 00:00:00 | ||
var today = items['LokaleZeit_DatumundZeit']; | ||
var tomorrow = today | ||
.getZonedDateTime() | ||
.plusDays(1) | ||
.withHour(0) | ||
.withMinute(0) | ||
.withSecond(0) | ||
.withNano(0); | ||
// Get next collection dates from items | ||
var biomuellDate = items['collectionDay_bioWaste'].getZonedDateTime(); | ||
var leichtverpackungDate = items['collectionDay_leightweightPackaging'].getZonedDateTime(); | ||
var papierDate = items['collectionDay_paper'].getZonedDateTime(); | ||
var restmuellDate = items['collectionDay_generalWaste'].getZonedDateTime(); | ||
// Check which waste types are collected on the next day | ||
var biomuellCollection = biomuellDate.equals(tomorrow); | ||
var leichtverpackungCollection = leichtverpackungDate.equals(tomorrow); | ||
var papierCollection = papierDate.equals(tomorrow); | ||
var restmuellCollection = restmuellDate.equals(tomorrow); | ||
// Transfer booleans to waste type names | ||
var toBeCollected = []; | ||
if (biomuellCollection) { | ||
toBeCollected.push('bio waste'); | ||
} | ||
if (leichtverpackungCollection) { | ||
toBeCollected.push('leihtweight packaging'); | ||
} | ||
if (papierCollection) { | ||
toBeCollected.push('paper'); | ||
} | ||
if (restmuellCollection) { | ||
toBeCollected.push('general waste'); | ||
} | ||
// Send message (or something else) if at least one waste type is collected | ||
if (toBeCollected.length > 0) { | ||
var message = "Tomorrow the following waste will be collected:\n" + toBeCollected.join(', '); | ||
events.sendCommand('SignalSmartHome_Eingabewert', message); | ||
} | ||
type: script.ScriptAction | ||
``` |
Binary file added
BIN
+178 KB
...es/org.openhab.binding.ahawastecollection/doc/images/ChromeDevconsoleBottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+187 KB
bundles/org.openhab.binding.ahawastecollection/doc/images/ChromeDevconsoleTop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.openhab.addons.bundles</groupId> | ||
<artifactId>org.openhab.addons.reactor.bundles</artifactId> | ||
<version>3.1.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>org.openhab.binding.ahawastecollection</artifactId> | ||
|
||
<name>openHAB Add-ons :: Bundles :: aha Waste Collection Binding</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jsoup</groupId> | ||
<artifactId>jsoup</artifactId> | ||
<version>1.8.3</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
10 changes: 10 additions & 0 deletions
10
bundles/org.openhab.binding.ahawastecollection/src/main/feature/feature.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<features name="org.openhab.binding.ahawastecollection-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"> | ||
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository> | ||
|
||
<feature name="openhab-binding-ahawastecollection" description="aha Waste Collection Binding" version="${project.version}"> | ||
<feature>openhab-runtime-base</feature> | ||
<bundle dependency="true">mvn:org.jsoup/jsoup/1.8.3</bundle> | ||
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.ahawastecollection/${project.version}</bundle> | ||
</feature> | ||
</features> |
33 changes: 33 additions & 0 deletions
33
.../src/main/java/org/openhab/binding/ahawastecollection/internal/AhaCollectionSchedule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Copyright (c) 2010-2021 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.ahawastecollection.internal; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.openhab.binding.ahawastecollection.internal.CollectionDate.WasteType; | ||
|
||
/** | ||
* Schedule that returns the next collection dates from the aha website. | ||
* | ||
* @author Sönke Küper - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public interface AhaCollectionSchedule { | ||
|
||
/** | ||
* Returns the next collection dates per {@link WasteType}. | ||
*/ | ||
public Map<WasteType, CollectionDate> getCollectionDates() throws IOException; | ||
} |
30 changes: 30 additions & 0 deletions
30
...in/java/org/openhab/binding/ahawastecollection/internal/AhaCollectionScheduleFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Copyright (c) 2010-2021 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.ahawastecollection.internal; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
|
||
/** | ||
* Factory for creating an {@link AhaCollectionSchedule}. | ||
* | ||
* @author Sönke Küper - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public interface AhaCollectionScheduleFactory { | ||
|
||
/** | ||
* Creates an new {@link AhaCollectionSchedule} for the given location. | ||
*/ | ||
public AhaCollectionSchedule create(final String commune, final String street, final String houseNumber, | ||
final String houseNumberAddon, final String collectionPlace); | ||
} |
Oops, something went wrong.