Skip to content
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

[mynice] Binding for IT4Wifi module (Nice gate doors) #12940

Merged
merged 43 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
675e975
Initiating new binding MyNice
clinique Apr 26, 2022
7b7edf9
Saving work
clinique Apr 28, 2022
c54d711
Adding MDNS discovery participant to discover the IT4Wifi
clinique Apr 28, 2022
44590f5
Saving intermediate work
clinique Jun 4, 2022
77ac72c
Save work
clinique Jun 5, 2022
83ec6ab
Initial version
clinique Jun 15, 2022
6c4fe26
Preparing translation files
clinique Jun 15, 2022
5996cbb
Changing username to mac address.
clinique Jun 15, 2022
52eb743
Adding username to bridge configuration
clinique Jun 17, 2022
1c38a95
Spotless apply
clinique Jun 18, 2022
e15bef9
Adding keep alive mechanism
clinique Jun 20, 2022
1e663cb
Keep alive constant
clinique Jun 21, 2022
2705e2c
Handling CHANGE message
clinique Jun 21, 2022
af3ef9e
Moving to snapshot 3.4.0
clinique Jul 15, 2022
72cc8a7
Spotless apply
clinique Jul 15, 2022
96e264f
SAT warnings handling
clinique Feb 23, 2022
62c6404
Correcting potential NPE
clinique Mar 12, 2022
d9c352e
Correcting a NPE on error
clinique Mar 15, 2022
67d0a6c
Active player request falls to incorrect API version
clinique Mar 18, 2022
7708e8b
Reintroducing missing capability to send keys to player.
clinique Apr 5, 2022
12da9aa
Removing unused variable
clinique Nov 8, 2022
b7c0ef0
Removing @NonNullByDefault({}) to better handle NPE
clinique Nov 13, 2022
3309e98
Enhancing disconnection process
clinique Nov 16, 2022
0a02eb4
Enhancing NPE handling
clinique Nov 17, 2022
4fcae0f
Correction
clinique Nov 17, 2022
56ad26c
Adding handling of T4 command.
clinique Dec 22, 2022
e285e54
Properly dispose handlers
clinique Dec 22, 2022
b5e1d20
Moving to SNAPSHOT 4.0.0
clinique Dec 29, 2022
73915ff
Modifications for OH4 and ready for code review.
clinique Jan 21, 2023
717be2a
README enhancements
clinique Jan 21, 2023
6648724
Reverting wrong modification
clinique Jan 21, 2023
f357790
Correction of SAT findings
clinique Jan 21, 2023
86dc6be
Correction of addon.xml
clinique Jan 21, 2023
03d0ed6
Small modification
clinique Jan 23, 2023
f75bf9c
Pleasing Sat by updating headers
clinique Feb 24, 2023
aa5e266
Fixing the mess
clinique Feb 24, 2023
1ff63fb
Still some mixes with other bindings
clinique Feb 24, 2023
1946cc5
Yet another left
clinique Feb 24, 2023
22a4ea1
The last leftover
clinique Feb 24, 2023
d69a08a
Code review corrections
clinique Feb 25, 2023
1a97979
Some small corrections
clinique Feb 25, 2023
8e31211
Adressing code review comments from @jlaur
clinique Mar 8, 2023
cb12e2d
Clarification of obstruction.
clinique Mar 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@
/bundles/org.openhab.binding.mqtt.homie/ @davidgraeff
/bundles/org.openhab.binding.mycroft/ @dalgwen
/bundles/org.openhab.binding.mybmw/ @weymann @ntruchsess
/bundles/org.openhab.binding.mynice/ @clinique
/bundles/org.openhab.binding.myq/ @digitaldan
/bundles/org.openhab.binding.mystrom/ @pail23
/bundles/org.openhab.binding.nanoleaf/ @raepple @stefan-hoehn
Expand Down
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,11 @@
<artifactId>org.openhab.binding.mybmw</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.mynice</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.myq</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.mynice/NOTICE
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
118 changes: 118 additions & 0 deletions bundles/org.openhab.binding.mynice/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# MyNice Binding

This binding implements the support of the IT4Wifi module through the NHK protocol and enables management of Nice gates automatisms.
jlaur marked this conversation as resolved.
Show resolved Hide resolved
IT4Wifi is a bridge between the TP4 bus of your gate and your Ethernet network.

## Supported Things

- `it4wifi`: The Bridge between openHAB and your module.
- `swing`: A Thing representing a swinging (two rotating doors) gate.
- `sliding`: A Thing representing a sliding gate.

## Discovery

The binding will auto-discover (by MDNS) your module, creating the associated `it4wifi` bridge.

Once discovered, a user named “org.openhab.binding.mynice” will be created on it.
You will have to grant him permissions using the MyNice app (Android or IOS).

Once configuration of the bridge is completed, your gate(s) will also be auto-discovered and added to the Inbox.

## Binding Configuration

There is nothing to configure at binding level.

jlaur marked this conversation as resolved.
Show resolved Hide resolved
## Thing Configuration

First configuration should be done via UI discovery, this will let you get automatically the password provided by the IT4Wifi module.
Once done, you can also create your things via *.things file.

### `it4wifi` Bridge Configuration

| Name | Type | Description | Default | Required | Advanced |
|------------|------|------------------------------------------------------------------------|---------|----------|----------|
| hostname | text | Hostname or IP address of the device | N/A | yes | no |
| password | text | Password to access the device | N/A | yes | no |
| macAddress | text | The MAC address of the IT4Wifi | N/A | yes | no |
| username | text | Pairing Key needed to access the device, provided by the bridge itself | N/A | yes | no |

### Gates Thing Configuration

| Name | Type | Description | Default | Required | Advanced |
|------------|------|------------------------------------------------------------------------|---------|----------|----------|
| id | text | ID of the gate on the TP4 bus connected to the bridge | N/A | yes | no |

## Channels

There is no channel associated with the bridge.

Channels available for the gates are :

| Channel | Type | Read/Write | Description |
|-----------|--------|------------|----------------------------------------------------------|
| status | String | R | Description of the current status of the door * |
| obstruct | Switch | R | Flags an obstruction, blocking the door |
| moving | Switch | R | Indicates if the device is currently operating a command |
| command | String | W | Send a given command to the gate ** |
| t4command | String | W | Send a T4 Command to the gate |

* : can be open, closed, opening, closing, stopped.
** : must be "stop","open","close"

### T4 Commands

Depending upon your gate model, and motor capabilities, some T4 commands can be used.
jlaur marked this conversation as resolved.
Show resolved Hide resolved
The list of available commands for your model will be automatically discovered by the binding.
This information is stored in the `allowedT4` property held by the gate Thing itself.

Complete list of T4 Commands :

| Command | Action |
|---------|----------------------------|
| MDAx | Step by Step |
| MDAy | Stop (as remote control) |
| MDAz | Open (as remote control) |
| MDA0 | Close (as remote control) |
| MDA1 | Partial opening 1 |
| MDA2 | Partial opening 2 |
| MDA3 | Partial opening 3 |
| MDBi | Apartment Step by Step |
| MDBj | Step by Step high priority |
| MDBk | Open and block |
| MDBl | Close and block |
| MDBm | Block |
| MDEw | Release |
| MDEx | Courtesy ligh timer on |
| MDEy | Courtesy light on-off |
| MDEz | Step by Step master door |
| MDE0 | Open master door |
| MDE1 | Close master door |
| MDE2 | Step by Step slave door |
| MDE3 | Open slave door |
| MDE4 | Close slave door |
| MDE5 | Release and Open |
| MDFh | Release and Close |

## Full Example

### things/mynice.things

```java
Bridge mynice:it4wifi:83eef09166 "Nice IT4WIFI" @ "portail" [
hostname="192.168.0.198",
macAddress="00:xx:zz:dd:ff:gg",
password="v***************************zU=",
username="neo_prod"] {
swing 1 "Nice POA3 Moteur Portail" @ "portail" [id="1"]
}
```

### items/mynice.items

```java
String NiceIT4WIFI_GateStatus "Gate Status" <gate> (gMyniceSwing) ["Status","Opening"] {channel="mynice:swing:83eef09166:1:status"}
String NiceIT4WIFI_Obstruction "Obstruction" <none> (gMyniceSwing) {channel="mynice:swing:83eef09166:1:obstruct"}
Switch NiceIT4WIFI_Moving "Moving" <motion> (gMyniceSwing) ["Status","Vibration"] {channel="mynice:swing:83eef09166:1:moving"}
String NiceIT4WIFI_Command "Command" <none> (gMyniceSwing) {channel="mynice:swing:83eef09166:1:command"}

```
17 changes: 17 additions & 0 deletions bundles/org.openhab.binding.mynice/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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 https://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>4.0.0-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.binding.mynice</artifactId>

<name>openHAB Add-ons :: Bundles :: MyNice Binding</name>

</project>
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.mynice-${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-mynice" description="MyNice Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.mynice/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* 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.mynice.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingTypeUID;

/**
* The {@link MyNiceBindingConstants} class defines common constants, which are used across the whole binding.
*
* @author Gaël L'hopital - Initial contribution
*/
@NonNullByDefault
public class MyNiceBindingConstants {
private static final String BINDING_ID = "mynice";

// List of all Channel ids
public static final String DOOR_STATUS = "status";
public static final String DOOR_OBSTRUCTED = "obstruct";
public static final String DOOR_MOVING = "moving";
public static final String DOOR_COMMAND = "command";
public static final String DOOR_T4_COMMAND = "t4command";

// List of all Thing Type UIDs
public static final ThingTypeUID BRIDGE_TYPE_IT4WIFI = new ThingTypeUID(BINDING_ID, "it4wifi");
public static final ThingTypeUID THING_TYPE_SWING = new ThingTypeUID(BINDING_ID, "swing");
public static final ThingTypeUID THING_TYPE_SLIDING = new ThingTypeUID(BINDING_ID, "sliding");

// Configuration element of a portal
public static final String DEVICE_ID = "id";

public static final String ALLOWED_T4 = "allowedT4";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* 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.mynice.internal;

import static org.openhab.binding.mynice.internal.MyNiceBindingConstants.*;

import java.util.Set;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.mynice.internal.handler.GateHandler;
import org.openhab.binding.mynice.internal.handler.It4WifiHandler;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.thing.binding.ThingHandlerFactory;
import org.osgi.service.component.annotations.Component;

/**
* The {@link MyNiceHandlerFactory} is responsible for creating thing handlers.
*
* @author Gaël L'hopital - Initial contribution
*/
@NonNullByDefault
@Component(configurationPid = "binding.mynice", service = ThingHandlerFactory.class)
public class MyNiceHandlerFactory extends BaseThingHandlerFactory {
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(BRIDGE_TYPE_IT4WIFI, THING_TYPE_SWING,
THING_TYPE_SLIDING);

@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
}

@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();

if (BRIDGE_TYPE_IT4WIFI.equals(thingTypeUID)) {
return new It4WifiHandler((Bridge) thing);
} else if (THING_TYPE_SWING.equals(thingTypeUID)) {
return new GateHandler(thing);
} else if (THING_TYPE_SLIDING.equals(thingTypeUID)) {
return new GateHandler(thing);
}

return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* 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.mynice.internal.config;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link It4WifiConfiguration} class contains fields mapping thing configuration parameters.
*
* @author Gaël L'hopital - Initial contribution
*/
@NonNullByDefault
public class It4WifiConfiguration {
public static final String PASSWORD = "password";
public static final String HOSTNAME = "hostname";

public String username = "";
public String hostname = "";
public String macAddress = "";
public String password = "";
}
Loading