-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[broadlink] Broadlink binding #14582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6411ce8
Initial Contribution
3b634fc
Upgrade JUnit 4 to 5
33d048f
Removed deprecatad initMocks call
1cfbc2d
Override Null pointer warnings where appropiate
2bd74fc
Added warning suppression for unchecked type
b002959
Fix error in file that added multiple Suppress Annotations
0086f4e
Made requested changes for logging level as per src/main/java/org/ope…
ee7211e
Fix definition of Humidity Parameter, to get rid of warning
af18539
Bump binding version to 4.0.0-Snapshot. Update code headers to 2023
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,126 @@ | ||
| # Broadlink Binding | ||
|
|
||
| This binding supports a range of home networking devices made by (and occasionally OEM licensed from) [Broadlink](https://www.ibroadlink.com/). | ||
|
|
||
| ## Supported Things | ||
|
|
||
| | Thing ID | Description | | ||
| |------------|-------------------------------------------------------------------------| | ||
| | a1 | Broadlink A1 multi sensor | | ||
| | mp1 | Broadlink MP1 WiFi Smart Power Strip (4 sockets) | | ||
| | mp1_1k3s2u | Broadlink MP1 1K3S2U WiFi Smart Power Strip (3 sockets, 2 USB) | | ||
| | mp2 | Broadlink MP2 WiFi Smart Power Strip (3 sockets, 3 USB) | | ||
| | sp1 | Broadlink SP1 WiFi Smart Socket | | ||
| | sp2 | Broadlink SP2 WiFi Smart Socket with night light | | ||
| | sp3 | Broadlink SP3/Mini WiFi Smart Socket with night light | | ||
| | sp3s | Broadlink SP3s WiFi Smart Socket with Power Meter | | ||
| | rm2 | Broadline RM2/Pro WiFi IR/RF Transmitter with temperature sensor | | ||
| | rm3 | Broadlink RM3/Mini WiFi IR Transmitter | | ||
| | rm3q | Broadlink RM3 WiFi IR Transmitter with Firmware v44057 | | ||
| | rm4 | Broadlink RM4 WiFi IR Transmitter with temperature and humidity sensors | | ||
|
|
||
| ## Discovery | ||
|
|
||
| Devices in the above list that are set up and working in the Broadlink mobile app should be discoverable by initiating a discovery from the openHAB UI. | ||
|
|
||
| > The `Lock Device` setting must be switched off for your device via the Broadlink app to be discoverable in openHAB. | ||
|
|
||
| ## Thing Configuration | ||
|
|
||
| | Name | Type | Default | description | | ||
| |---------------------|---------|---------------|-----------------------------------------------------------------------------------| | ||
| | ipAddress | String | | Sets the IP address of the Broadlink device | | ||
| | staticIp | Boolean | true | Enabled if your broadlink device has a Static IP set | | ||
| | port | Integer | 80 | The network port for the device | | ||
| | macAddress | String | | The device's MAC Address | | ||
| | pollingInterval | Integer | 30 | The interval in seconds for polling the status of the device | | ||
| | ignoreFailedUpdates | Boolean | false | If enabled, failed status requests won't put the device `OFFLINE` | | ||
| | mapFilename | String | broadlink.map | The map file that contains remote codes to send via IR | | ||
|
|
||
| > The `mapFilename` setting is applicable to the RM series of devices only. | ||
|
|
||
| ## Channels | ||
|
|
||
| | Channel | Supported Devices | Type | Description | | ||
| |------------------|--------------------------|----------------------|-------------------------------------------------| | ||
| | powerOn | MP2, all SPx | Switch | Power on/off for switches/strips | | ||
| | nightLight | SP3 | Switch | Night light on/off | | ||
| | temperature | A1, RM2, RM4 | Number:Temperature | Temperature | | ||
| | humidity | A1, RM4 | Number:Dimensionless | Air humidity percentage | | ||
| | noise | A1 | String | Noise level: `QUIET`/`NORMAL`/`NOISY`/`EXTREME` | | ||
| | light | A1 | String | Light level: `DARK`/`DIM`/`NORMAL`/`BRIGHT` | | ||
| | air | A1 | String | Air quality: `PERFECT`/`GOOD`/`NORMAL`/`BAD` | | ||
| | s1powerOn | MP1, MP1_1k3s2u | Switch | Socket 1 power | | ||
| | s2powerOn | MP1, MP1_1k3s2u | Switch | Socket 2 power | | ||
| | s3powerOn | MP1, v_1k3s2u | Switch | Socket 3 power | | ||
| | s4powerOn | MP1 | Switch | Socket 4 power | | ||
| | usbPowerOn | MP1_1k3s2u | Switch | USB power | | ||
| | powerConsumption | MP2, SP2s,SP3s | Number:Power | Power consumption | | ||
| | command | all RMx | String | IR Command code to transmit | | ||
| | learningControl | all RMx | String | Learn mode command channel (see below) | | ||
|
|
||
| ## Map File | ||
|
|
||
| The Broadlink RM family of devices can transmit IR codes. | ||
| The map file contains a list of IR command codes to send via the device. | ||
| The file uses the [Java Properties File format](https://en.wikipedia.org/wiki/.properties) and is stored in the `<OPENHAB_CONF>/transform` folder. | ||
| By default, the file name is `broadlink.map` but can be changed using the `mapFile` setting. | ||
|
|
||
| Here is a map file example: | ||
|
|
||
| ``` | ||
| TV_POWER=26008c0092961039103a1039101510151014101510151039103a10391015101411141015101510141139101510141114101510151014103a10141139103911391037123a10391000060092961039103911391014111410151015101411391039103a101411141015101510141015103911141015101510141015101510391015103911391039103a1039103911000d05000000000000000000000000 | ||
| heatpump_off=2600760069380D0C0D0C0D290D0C0D290D0C0D0C0D0C0D290D290D0C0D0C0D0C0D290D290D0C0D0C0D0C0D0C0D0C0D0C0D0C0D0C0D0C0D0C0D0C0D0C0D0C0D290D0C0D0C0D0C0D0C0D0C0D0C0D0C0D290D0C0D0C0D0C0D0C0D290D0C0D0C0D0C0D0C0D0C0D0C0D290D0C0D290D290D290D290D290D290E0002900000 | ||
|
|
||
| ``` | ||
|
|
||
| The above codes are power on/off for Samsung TVs and Power Off for a Fujitsu heat pump. | ||
| To send either code, the string `TV_POWER` or `heatpump_off` must be sent to the `command` channel for the device. | ||
|
|
||
| ## Learning new remote codes | ||
|
|
||
| To obtain the command codes, you can get this binding to put your Broadlink RMx device into | ||
| "learn mode" and then ask it for the code it learnt. Here are the steps: | ||
|
|
||
| 1. In the openHAB web UI, navigate to your RMx Thing, and click on its *Channels* tab | ||
| 2. Find the *Remote Learning Control* channel and create an Item for it | ||
| 3. Click the item, and click the rectangular area that is marked NULL | ||
| 4. In the pop-up menu that appears, select "Enter infrared learn mode" | ||
| 5. *The LED on your RM device will illuminate solidly* | ||
| 6. Point your IR remote control at your RM device and press the button you'd like to learn | ||
| 7. *The LED on your RM device will extinguish once it has learnt the command* | ||
| 8. Now click the rectangular area again (which will now show "Enter infrared learn mode") | ||
| 9. Select the "Check last captured IR code" menu option in the pop-up menu | ||
| 10. Inspect the `openhab.log` file on your openHAB server - you should see the following: | ||
|
|
||
| ``` | ||
| [BroadlinkRemoteHandler] - BEGIN LAST LEARNT CODE (976 bytes) | ||
| [BroadlinkRemoteHandler] - 2600bc017239100d0e2b0e0f100c107f55747be51a3e1d4ff4......f5be8b3d4ff4b | ||
| 4d77c44d105fa530546becaa2bcfbd348b30145447f55747be51a3747be51a3e1d4ff4b3f4f4f......a3e1d4ff4b348 | ||
| 0145447f55747be51a3e1d4ff4b | ||
| [BroadlinkRemoteHandler] - END LAST LEARNT CODE (1944 characters) | ||
| ``` | ||
|
|
||
| 11. If you carefully copy the log line between the `BEGIN` and `END` messages, | ||
| it should have exactly the number of characters as advised in the `END` message. | ||
|
|
||
| 12. You can now paste a new entry into your `map` file, with the name of your choice; for example: | ||
|
|
||
| ``` | ||
| BLURAY_ON=2600bc017239100d0e2b0e0f100c107f55747be51a3e1d4ff4...0145447f55747be51a3e1d4ff4b | ||
| ``` | ||
|
|
||
|
|
||
| ## Full Example | ||
|
|
||
| Items file example; `sockets.items`: | ||
|
|
||
| ``` | ||
| Switch BroadlinkSP3 "Christmas Lights" [ "Lighting" ] { channel="broadlink:sp3:34-ea-34-22-44-66:powerOn" } | ||
| ``` | ||
|
|
||
| ## Credits | ||
|
|
||
| - [Cato Sognen](https://community.openhab.org/u/cato_sognen) | ||
| - [JAD](http://www.javadecompilers.com/jad) (Java Decompiler) | ||
|
|
This file contains hidden or 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,17 @@ | ||
| <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
|
||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <parent> | ||
| <groupId>org.openhab.addons.bundles</groupId> | ||
| <artifactId>org.openhab.addons.reactor.bundles</artifactId> | ||
| <version>4.0.0-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| <artifactId>org.openhab.binding.broadlink</artifactId> | ||
|
|
||
| <name>openHAB Add-ons :: Bundles :: Broadlink Binding</name> | ||
|
|
||
| </project> | ||
9 changes: 9 additions & 0 deletions
9
bundles/org.openhab.binding.broadlink/src/main/feature/feature.xml
This file contains hidden or 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,9 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <features name="org.openhab.binding.broadlink-${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-broadlink" description="Broadlink Binding" version="${project.version}"> | ||
| <feature>openhab-runtime-base</feature> | ||
| <bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.broadlink/${project.version}</bundle> | ||
| </feature> | ||
| </features> |
107 changes: 107 additions & 0 deletions
107
...ding.broadlink/src/main/java/org/openhab/binding/broadlink/BroadlinkBindingConstants.java
This file contains hidden or 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 @@ | ||
| /** | ||
| * Copyright (c) 2010-2023 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.broadlink; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| import javax.measure.Unit; | ||
| import javax.measure.quantity.Dimensionless; | ||
| import javax.measure.quantity.Power; | ||
| import javax.measure.quantity.Temperature; | ||
|
|
||
| import org.eclipse.jdt.annotation.NonNullByDefault; | ||
| import org.openhab.core.library.unit.SIUnits; | ||
| import org.openhab.core.library.unit.Units; | ||
| import org.openhab.core.thing.ThingTypeUID; | ||
|
|
||
| /** | ||
| * The {@link BroadlinkBindingConstants} class defines common constants, which are | ||
| * used across the whole binding. | ||
| * | ||
| * @author John Marshall/Cato Sognen - Initial contribution | ||
| */ | ||
| @NonNullByDefault | ||
| public class BroadlinkBindingConstants { | ||
|
|
||
| public static final ThingTypeUID THING_TYPE_RM2 = new ThingTypeUID("broadlink", "rm2"); | ||
| public static final ThingTypeUID THING_TYPE_RM3 = new ThingTypeUID("broadlink", "rm3"); | ||
| public static final ThingTypeUID THING_TYPE_RM3Q = new ThingTypeUID("broadlink", "rm3q"); | ||
| public static final ThingTypeUID THING_TYPE_RM4 = new ThingTypeUID("broadlink", "rm4"); | ||
| public static final ThingTypeUID THING_TYPE_A1 = new ThingTypeUID("broadlink", "a1"); | ||
| public static final ThingTypeUID THING_TYPE_MP1 = new ThingTypeUID("broadlink", "mp1"); | ||
| public static final ThingTypeUID THING_TYPE_MP1_1K3S2U = new ThingTypeUID("broadlink", "mp1_1k3s2u"); | ||
| public static final ThingTypeUID THING_TYPE_MP2 = new ThingTypeUID("broadlink", "mp2"); | ||
| public static final ThingTypeUID THING_TYPE_SP1 = new ThingTypeUID("broadlink", "sp1"); | ||
| public static final ThingTypeUID THING_TYPE_SP2 = new ThingTypeUID("broadlink", "sp2"); | ||
| public static final ThingTypeUID THING_TYPE_SP2S = new ThingTypeUID("broadlink", "sp2s"); | ||
| public static final ThingTypeUID THING_TYPE_SP3 = new ThingTypeUID("broadlink", "sp3"); | ||
| public static final ThingTypeUID THING_TYPE_SP3S = new ThingTypeUID("broadlink", "sp3s"); | ||
| public static final ThingTypeUID THING_TYPE_PIR = new ThingTypeUID("broadlink", "s1p"); | ||
| public static final ThingTypeUID THING_TYPE_MAGNET = new ThingTypeUID("broadlink", "s1m"); | ||
|
|
||
| public static final String RM2 = "Broadlink RM2"; | ||
| public static final String RM3 = "Broadlink RM3"; | ||
| public static final String RM3Q = "Broadlink RM3 v11057"; | ||
| public static final String RM4 = "Broadlink RM4 / RM4 Mini / RM4 Pro"; | ||
| public static final String A1 = "Broadlink A1"; | ||
| public static final String MP1 = "Broadlink MP1"; | ||
| public static final String MP1_1K3S2U = "Broadlink MP1 1K3S2U"; | ||
| public static final String MP2 = "Broadlink MP2"; | ||
|
|
||
| public static final String SP1 = "Broadlink SP1"; | ||
| public static final String SP2 = "Broadlink SP2"; | ||
| public static final String SP2S = "Broadlink SP2s"; | ||
| public static final String SP3 = "Broadlink SP3"; | ||
| public static final String SP3S = "Broadlink SP3s"; | ||
| public static final String S1P = "Smart One PIR Sensor"; | ||
| public static final String S1M = "Smart One Magnet Sensor"; | ||
|
|
||
| public static final String BROADLINK_AUTH_KEY = "097628343fe99e23765c1513accf8b02"; | ||
| public static final String BROADLINK_IV = "562e17996d093d28ddb3ba695a2e6f58"; | ||
|
|
||
| public static final String COMMAND_CHANNEL = "command"; | ||
| public static final String LEARNING_CONTROL_CHANNEL = "learningControl"; | ||
| public static final String LEARNING_CONTROL_COMMAND_LEARN = "LEARN"; | ||
| public static final String LEARNING_CONTROL_COMMAND_CHECK = "CHECK"; | ||
| public static final String CHANNEL_TEMPERATURE = "temperature"; | ||
| public static final String CHANNEL_HUMIDITY = "humidity"; | ||
| public static final String CHANNEL_POWER_CONSUMPTION = "powerConsumption"; | ||
|
|
||
| public static final String COMMAND_POWER_ON = "powerOn"; | ||
| public static final String COMMAND_NIGHTLIGHT = "nightLight"; | ||
|
|
||
| public static final Unit<Temperature> BROADLINK_TEMPERATURE_UNIT = SIUnits.CELSIUS; | ||
| public static final Unit<Dimensionless> BROADLINK_HUMIDITY_UNIT = Units.PERCENT; | ||
| public static final Unit<Power> BROADLINK_POWER_CONSUMPTION_UNIT = Units.WATT; | ||
|
|
||
| public static final Map<ThingTypeUID, String> SUPPORTED_THING_TYPES_UIDS_TO_NAME_MAP = new HashMap<>(); | ||
|
|
||
| static { | ||
| SUPPORTED_THING_TYPES_UIDS_TO_NAME_MAP.put(THING_TYPE_RM2, RM2); | ||
| SUPPORTED_THING_TYPES_UIDS_TO_NAME_MAP.put(THING_TYPE_RM3, RM3); | ||
| SUPPORTED_THING_TYPES_UIDS_TO_NAME_MAP.put(THING_TYPE_RM3Q, RM3Q); | ||
| SUPPORTED_THING_TYPES_UIDS_TO_NAME_MAP.put(THING_TYPE_RM4, RM4); | ||
| SUPPORTED_THING_TYPES_UIDS_TO_NAME_MAP.put(THING_TYPE_A1, A1); | ||
| SUPPORTED_THING_TYPES_UIDS_TO_NAME_MAP.put(THING_TYPE_MP1, MP1); | ||
| SUPPORTED_THING_TYPES_UIDS_TO_NAME_MAP.put(THING_TYPE_MP1_1K3S2U, MP1_1K3S2U); | ||
| SUPPORTED_THING_TYPES_UIDS_TO_NAME_MAP.put(THING_TYPE_MP2, MP2); | ||
| SUPPORTED_THING_TYPES_UIDS_TO_NAME_MAP.put(THING_TYPE_SP1, SP1); | ||
| SUPPORTED_THING_TYPES_UIDS_TO_NAME_MAP.put(THING_TYPE_SP2, SP2); | ||
| SUPPORTED_THING_TYPES_UIDS_TO_NAME_MAP.put(THING_TYPE_SP2S, SP2S); | ||
| SUPPORTED_THING_TYPES_UIDS_TO_NAME_MAP.put(THING_TYPE_SP3, SP3); | ||
| SUPPORTED_THING_TYPES_UIDS_TO_NAME_MAP.put(THING_TYPE_SP3S, SP3S); | ||
| SUPPORTED_THING_TYPES_UIDS_TO_NAME_MAP.put(THING_TYPE_PIR, S1P); | ||
| SUPPORTED_THING_TYPES_UIDS_TO_NAME_MAP.put(THING_TYPE_MAGNET, S1M); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.