Skip to content

Commit

Permalink
[enocean] Improved device discovery and added SMACK capability (#10157)
Browse files Browse the repository at this point in the history
 * Added SMACK teach in
 * Teached in devices can be teach out on a repeated teach in
 * Improved detection of RPS devices, device types can be better distinguished now
 * Bugfixes for discovery fallback to GenericThings
 * Responses to message requests are send automatically now, no need for linking SEND_COMMAND channel

Fixes #10156

Signed-off-by: Daniel Weber <uni@fruggy.de>
  • Loading branch information
fruggy83 authored Feb 20, 2021
1 parent a9f440d commit fd1c966
Show file tree
Hide file tree
Showing 58 changed files with 1,064 additions and 314 deletions.
19 changes: 18 additions & 1 deletion bundles/org.openhab.binding.enocean/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,21 @@ The corresponding channels are created dynamically, too.
If the actuator supports UTE teach-in, the corresponding thing can be created and paired automatically.
First you have to **start the discovery scan for a gateway**.
Then press the teach-in button of the actuator.
If the EEP of the actuator is known, the binding sends an UTE teach-in response with a new SenderId and creates a new thing with its channels.
If the EEP of the actuator is known, the binding sends an UTE teach-in response with a new SenderId and creates a new thing with its channels.

This binding supports so called smart acknowlegde (SMACK) devices too.
Before you can pair a SMACK device you have to configure your gateway bridge as a SMACK postmaster.
If this option is enabled you can pair up to 20 SMACK devices with your gateway.

Communication between your gateway and a SMACK device is handled through mailboxes.
A mailbox is created for each paired SMACK device and deleted after teach out.
You can see the paired SMACK devices and their mailbox index in the gateway properties.
SMACK devices send periodically status updates followed by a response request.
Whenever such a request is received a `requestAnswer` event is triggered for channel `statusRequestEvent`.
Afterwards you have 100ms time to recalculate your items states and update them.
A message with the updated item states is built, put into the corresponding mailbox and automatically sent upon request of the device.
Pairing and unpairing can be done through a discovery scan.
The corresponding thing of an unpaired device gets disabled, you have to delete it manually if you want to.

If the actuator does not support UTE teach-ins, you have to create, configure and choose the right EEP of the thing manually.
It is important to link the teach-in channel of this thing to a switch item.
Expand Down Expand Up @@ -158,6 +172,8 @@ If you change the SenderId of your thing, you have to pair again the thing with
| | espVersion | ESP Version of gateway | ESP3, ESP2 |
| | rs485 | If gateway is directly connected to a RS485 bus the BaseId is set to 0x00 | true, false
| | rs485BaseId | Override BaseId 0x00 if your bus contains a telegram duplicator (FTD14 for ex) | 4 byte hex value |
| | enableSmack | Enables SMACK pairing and handling of SMACK messages | true, false |
| | sendTeachOuts | Defines if a repeated teach in request should be answered with a learned in or teach out response | true, false |
| pushButton | receivingEEPId | EEP used for receiving msg | F6_01_01, D2_03_0A |
| | enoceanId | EnOceanId of device this thing belongs to | hex value as string |
| rockerSwitch | receivingEEPId | | F6_02_01, F6_02_02 |
Expand Down Expand Up @@ -300,6 +316,7 @@ The channels of a thing are determined automatically based on the chosen EEP.
| rssi | Number | Received Signal Strength Indication (dBm) of last received message |
| repeatCount | Number | Number of repeaters involved in the transmission of the telegram |
| lastReceived | DateTime | Date and time the last telegram was received |
| statusRequestEvent | Trigger | Emits event 'requestAnswer' |

Items linked to bi-directional actuators (actuator sends status messages back) should always disable the `autoupdate`.
This is especially true for Eltako rollershutter, as their position is calculated out of the current position and the moving time.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public class EnOceanBindingConstants {
public static final String CHANNEL_WAKEUPCYCLE = "wakeUpCycle";
public static final String CHANNEL_SERVICECOMMAND = "serviceCommand";
public static final String CHANNEL_STATUS_REQUEST_EVENT = "statusRequestEvent";
public static final String CHANNEL_SEND_COMMAND = "sendCommand";
public static final String VIRTUALCHANNEL_SEND_COMMAND = "sendCommand";

public static final String CHANNEL_VENTILATIONOPERATIONMODE = "ventilationOperationMode";
public static final String CHANNEL_FIREPLACESAFETYMODE = "fireplaceSafetyMode";
Expand Down Expand Up @@ -293,7 +293,8 @@ public class EnOceanBindingConstants {
Map.entry(CHANNEL_INDOORAIRANALYSIS,
new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_INDOORAIRANALYSIS),
CoreItemFactory.STRING)),
Map.entry(CHANNEL_SETPOINT,
Map.entry(
CHANNEL_SETPOINT,
new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_SETPOINT),
CoreItemFactory.NUMBER)),
Map.entry(CHANNEL_CONTACT,
Expand Down Expand Up @@ -444,13 +445,6 @@ public class EnOceanBindingConstants {
new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_SERVICECOMMAND),
CoreItemFactory.NUMBER)),

Map.entry(CHANNEL_STATUS_REQUEST_EVENT,
new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_STATUS_REQUEST_EVENT), null,
"", false, true)),
Map.entry(CHANNEL_SEND_COMMAND,
new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_SEND_COMMAND),
CoreItemFactory.SWITCH)),

Map.entry(CHANNEL_VENTILATIONOPERATIONMODE,
new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_VENTILATIONOPERATIONMODE),
CoreItemFactory.STRING)),
Expand Down Expand Up @@ -527,6 +521,10 @@ public class EnOceanBindingConstants {
CoreItemFactory.NUMBER + ItemUtil.EXTENSION_SEPARATOR
+ Dimensionless.class.getSimpleName())),

Map.entry(CHANNEL_STATUS_REQUEST_EVENT,
new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_STATUS_REQUEST_EVENT), null,
"", false, true)),

Map.entry(CHANNEL_REPEATERMODE, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_REPEATERMODE), CoreItemFactory.STRING)));

Expand All @@ -536,11 +534,8 @@ public class EnOceanBindingConstants {
public static final String REPEATERMODE_LEVEL_2 = "LEVEL2";

// Bridge config properties
public static final String SENDERID = "senderId";
public static final String PATH = "path";
public static final String HOST = "host";
public static final String RS485 = "rs485";
public static final String NEXTSENDERID = "nextSenderId";
public static final String PARAMETER_NEXT_SENDERID = "nextSenderId";

// Bridge properties
public static final String PROPERTY_BASE_ID = "Base ID";
Expand All @@ -551,13 +546,12 @@ public class EnOceanBindingConstants {
public static final String PROPERTY_DESCRIPTION = "Description";

// Thing properties
public static final String PROPERTY_ENOCEAN_ID = "enoceanId";
public static final String PROPERTY_SENDINGENOCEAN_ID = "SendingEnoceanId";

// Thing config parameter
public static final String PARAMETER_SENDERIDOFFSET = "senderIdOffset";
public static final String PARAMETER_SENDINGEEPID = "sendingEEPId";
public static final String PARAMETER_RECEIVINGEEPID = "receivingEEPId";
public static final String PARAMETER_EEPID = "eepId";

public static final String PARAMETER_BROADCASTMESSAGES = "broadcastMessages";
public static final String PARAMETER_ENOCEANID = "enoceanId";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.openhab.core.io.transport.serial.SerialPortManager;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingManager;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.ThingUID;
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
Expand Down Expand Up @@ -60,6 +61,9 @@ public class EnOceanHandlerFactory extends BaseThingHandlerFactory {
@Reference
ItemChannelLinkRegistry itemChannelLinkRegistry;

@Reference
ThingManager thingManager;

@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
Expand Down Expand Up @@ -96,7 +100,7 @@ protected void removeHandler(ThingHandler thingHandler) {
}

private void registerDeviceDiscoveryService(EnOceanBridgeHandler handler) {
EnOceanDeviceDiscoveryService discoveryService = new EnOceanDeviceDiscoveryService(handler);
EnOceanDeviceDiscoveryService discoveryService = new EnOceanDeviceDiscoveryService(handler, thingManager);
discoveryService.activate();
this.discoveryServiceRegs.put(handler.getThing().getUID(),
bundleContext.registerService(DiscoveryService.class.getName(), discoveryService, new Hashtable<>()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public class EnOceanActuatorConfig extends EnOceanBaseConfig {

public int channel;
public int senderIdOffset = -1;
public Integer senderIdOffset = null;
public String manufacturerId;
public String teachInType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,23 @@
import java.util.ArrayList;
import java.util.List;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.util.HexUtils;

/**
*
* @author Daniel Weber - Initial contribution
*/
@NonNullByDefault
public class EnOceanBaseConfig {
/**
* EnOceanId of the physical device
*/
public String enoceanId;

/**
* EEP used/send by physical device
*/
public List<String> receivingEEPId = new ArrayList<>();
public boolean receivingSIGEEP = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,16 @@ public static ESPVersion getESPVersion(String espVersion) {
public boolean rs485;
public String rs485BaseId;

public int nextSenderId = 0;
public Integer nextSenderId;

public boolean enableSmack;
public boolean sendTeachOuts;

public EnOceanBridgeConfig() {
espVersion = "ESP3";
sendTeachOuts = false;
enableSmack = true;
nextSenderId = null;
}

public ESPVersion getESPVersion() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@
*/
package org.openhab.binding.enocean.internal.config;

import org.openhab.core.config.core.Configuration;

/**
*
* @author Daniel Weber - Initial contribution
*/
public class EnOceanChannelTransformationConfig {
public class EnOceanChannelTransformationConfig extends Configuration {

public String transformationType;
public String transformationFunction;

public EnOceanChannelTransformationConfig() {
put("transformationType", "");
put("transformationFunction", "");
}
}
Loading

0 comments on commit fd1c966

Please sign in to comment.