-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pilight] Pilight Binding migration to OHv3 + add discovery
Also-by: Stefan Roellin [email protected] Signed-off-by: Niklas Dörfler <[email protected]>
- Loading branch information
1 parent
1cc6577
commit 40448a7
Showing
42 changed files
with
3,010 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,13 @@ | ||
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 |
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,107 @@ | ||
# pilight Binding | ||
|
||
The pilight binding allows openHAB to communicate with a [pilight](http://www.pilight.org/) instance running pilight version 6.0 or greater. | ||
|
||
> pilight is a free open source full fledge domotica solution that runs on a Raspberry Pi, HummingBoard, BananaPi, Radxa, but also on *BSD and various linuxes (tested on Arch, Ubuntu and Debian). It's open source and freely available for anyone. pilight works with a great deal of devices and is frequency independent. Therefor, it can control devices working at 315Mhz, 433Mhz, 868Mhz etc. Support for these devices are dependent on community, because we as developers don't own them all. | ||
pilight is a cheap way to control 'Click On Click Off' devices. It started as an application for the Raspberry Pi (using the GPIO interface) but it's also possible now to connect it to any other PC using an Arduino Nano. You will need a cheap 433Mhz transceiver in both cases. See the [Pilight manual](https://manual.pilight.org/electronics/wiring.html) for more information. | ||
|
||
## Supported Things | ||
|
||
| Thing | Type | Description | | ||
|-----------|--------|----------------------------------------------------------------------------| | ||
| `bridge` | Bridge | Pilight bridge required for the communication with the pilight daemon. | | ||
| `contact` | Thing | Pilight contact (read-only). | | ||
| `dimmer` | Thing | Pilight dimmer. | | ||
| `switch` | Thing | Pilight switch. | | ||
| `generic` | Thing | Pilight generic device for which you have to add the channels dynamically. | | ||
|
||
## Binding Configuration | ||
|
||
Things can be configured using Paper UI, or using a `.things` file. | ||
The configuration in this documentation explains the `.things` file, although you can find the same parameters from the Paper UI. | ||
|
||
### `bridge` Thing | ||
|
||
A `bridge` is required for the communication with a pilight daemon. Multiple pilight instances are supported by creating different pilight `bridge` things. | ||
|
||
The `bridge` requires the following configuration parameters: | ||
|
||
| Parameter Label | Parameter ID | Description | Required | | ||
|-----------------|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| | ||
| IP Address | ipAddress | Host name or IP address of the pilight daemon | yes | | ||
| Port | port | Port number on which the pilight daemon is listening. Default: 5000 | yes | | ||
| Delay | delay | Delay (in millisecond) between consecutive commands. Recommended value without band pass filter: 1000. Recommended value with band pass filter: somewhere between 200-500. Default: 500 | no | | ||
|
||
Important: you must explicitly configure the port in the pilight daemon config or otherwise a random port will be used and the binding will not be able to connect. | ||
|
||
|
||
### `contact`, `dimmer`, `switch`, `generic` Things | ||
|
||
These things have alle one required parameter: | ||
|
||
| Parameter Label | Parameter ID | Description | Required | | ||
|-----------------|--------------|------------------------|----------| | ||
| Name | name | Name of pilight device | yes | | ||
|
||
|
||
## Channels | ||
|
||
The `bridge` thing has no channels. | ||
|
||
The `contact`, `dimmer` and `switch` things all have one channel: | ||
|
||
| Thing | Channel | Type | Description | | ||
|-----------|----------|---------|-------------------------| | ||
| `contact` | state | Contact | State of the contact | | ||
| `dimmer` | dimlevel | Dimmer | Dim level of the dimmer | | ||
| `switch` | state | Switch | State of the switch | | ||
|
||
The `generic` thing has no fixed channels and you have to add them manually. Currently, only String and Number channels are supported. | ||
|
||
## Auto Discovery | ||
|
||
### Bridge Auto Discovery | ||
|
||
The pilight daemon implements a SSDP interface, which can be used to search for running pilight daemon instances by sending a SSDP request via multicast udp (this mechanism may only work if the [standalone mode](https://manual.pilight.org/configuration/settings.html#standalone) in the pilight daemon is disabled. | ||
After loading the binding this bridge discovery is automatically run and scheduled to scan for bridges every 10 minutes. | ||
|
||
### Device Auto Discovery | ||
After a `bridge` thing has been configured in openHAB, it automatically establishes a connection between pilight daemon and openHAB. | ||
As soon as the bridge is connected, the devices configured in the pilight daemon are automatically found via autodiscovery in background (or via a manually triggered discovery) and are displayed in the inbox to easily create things from them. | ||
|
||
## Examples | ||
|
||
things/pilight.things | ||
|
||
``` | ||
Bridge pilight:bridge:raspi "Pilight Daemon raspi" [ ipAddress="192.168.1.1", port=5000 ] { | ||
Thing switch office "Office" [ name="office" ] | ||
Thing dimmer piano "Piano" [ name="piano" ] | ||
Thing generic weather "Weather" [ name="weather" ] { | ||
Channels: | ||
State Number : temperature [ property="temperature"] | ||
State Number : humidity [ property="humidity"] | ||
} | ||
} | ||
``` | ||
|
||
items/pilight.items | ||
|
||
``` | ||
Switch office_switch "Büro" { channel="pilight:switch:raspi:office:state" } | ||
Dimmer piano_light "Klavier [%.0f %%]" { channel="pilight:dimmer:raspi:piano:dimlevel" } | ||
Number weather_temperature "Aussentemperatur [%.1f °C]" <temperature> { channel="pilight:generic:raspi:weather:temperature" } | ||
Number weather_humidity "Feuchtigkeit [%.0f %%]" <humidity> { channel="pilight:generic:raspi:weather:humidity" } | ||
``` | ||
|
||
sitemaps/fragment.sitemap | ||
|
||
``` | ||
Switch item=office_switch | ||
Slider item=piano_light | ||
Text item=weather_temperature | ||
Text item=weather_humidity | ||
``` | ||
|
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,35 @@ | ||
<?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.pilight</artifactId> | ||
|
||
<name>openHAB Add-ons :: Bundles :: Pilight Binding</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>2.10.4</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-annotations</artifactId> | ||
<version>2.10.4</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-core</artifactId> | ||
<version>2.10.4</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
23 changes: 23 additions & 0 deletions
23
bundles/org.openhab.binding.pilight/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,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2010-2020 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 | ||
--> | ||
<features name="org.openhab.binding.pilight-${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-pilight" description="Pilight Binding" version="${project.version}"> | ||
<feature>openhab-runtime-base</feature> | ||
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.pilight/${project.version}</bundle> | ||
</feature> | ||
</features> |
64 changes: 64 additions & 0 deletions
64
....binding.pilight/src/main/java/org/openhab/binding/pilight/internal/IPilightCallback.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,64 @@ | ||
/** | ||
* Copyright (c) 2010-2020 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.pilight.internal; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
import org.openhab.binding.pilight.internal.dto.Config; | ||
import org.openhab.binding.pilight.internal.dto.Status; | ||
import org.openhab.binding.pilight.internal.dto.Version; | ||
import org.openhab.core.thing.ThingStatus; | ||
import org.openhab.core.thing.ThingStatusDetail; | ||
|
||
/** | ||
* Callback interface to signal any listeners that an update was received from pilight | ||
* | ||
* @author Jeroen Idserda - Initial contribution | ||
* @author Stefan Röllin - Port to openHAB 2 pilight binding | ||
* @author Niklas Dörfler - Port pilight binding to openHAB 3 + add device discovery | ||
*/ | ||
@NonNullByDefault | ||
public interface IPilightCallback { | ||
|
||
/** | ||
* Update thing status | ||
* | ||
* @param status status of thing | ||
* @param statusDetail status detail of thing | ||
* @param description description of thing status | ||
*/ | ||
void updateThingStatus(ThingStatus status, ThingStatusDetail statusDetail, @Nullable String description); | ||
|
||
/** | ||
* Update for one or more device received. | ||
* | ||
* @param allStatus list of Object containing list of devices that were updated and their current state | ||
*/ | ||
void statusReceived(List<Status> allStatus); | ||
|
||
/** | ||
* Configuration received. | ||
* | ||
* @param config Object containing configuration of pilight | ||
*/ | ||
void configReceived(Config config); | ||
|
||
/** | ||
* Version information received. | ||
* | ||
* @param version Object containing software version information of pilight daemon | ||
*/ | ||
void versionReceived(Version version); | ||
} |
Oops, something went wrong.