added migrated 2.x add-ons

Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
Kai Kreuzer
2020-09-21 01:58:32 +02:00
parent bbf1a7fd29
commit 6df6783b60
11662 changed files with 1302875 additions and 11 deletions

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.enocean-${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-enocean" description="EnOcean Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<feature>openhab-transport-serial</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.enocean/${project.version}</bundle>
</feature>
</features>

View File

@@ -0,0 +1,437 @@
/**
* 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.enocean.internal;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.measure.quantity.Angle;
import javax.measure.quantity.ElectricPotential;
import javax.measure.quantity.Energy;
import javax.measure.quantity.Illuminance;
import javax.measure.quantity.Power;
import javax.measure.quantity.Speed;
import javax.measure.quantity.Temperature;
import javax.measure.quantity.Time;
import javax.measure.quantity.Volume;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.items.ItemUtil;
import org.openhab.core.library.CoreItemFactory;
import org.openhab.core.library.dimension.VolumetricFlowRate;
import org.openhab.core.thing.DefaultSystemChannelTypeProvider;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.type.ChannelTypeUID;
/**
* The {@link EnOceanBinding} class defines common constants, which are
* used across the whole binding.
*
* @author Daniel Weber - Initial contribution
*/
@NonNullByDefault
public class EnOceanBindingConstants {
public static final String BINDING_ID = "enocean";
// bridge
public static final ThingTypeUID THING_TYPE_BRIDGE = new ThingTypeUID(BINDING_ID, "bridge");
// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_PUSHBUTTON = new ThingTypeUID(BINDING_ID, "pushButton");
public static final ThingTypeUID THING_TYPE_ROCKERSWITCH = new ThingTypeUID(BINDING_ID, "rockerSwitch");
public static final ThingTypeUID THING_TYPE_CLASSICDEVICE = new ThingTypeUID(BINDING_ID, "classicDevice");
public static final ThingTypeUID THING_TYPE_CENTRALCOMMAND = new ThingTypeUID(BINDING_ID, "centralCommand");
public static final ThingTypeUID THING_TYPE_ROOMOPERATINGPANEL = new ThingTypeUID(BINDING_ID, "roomOperatingPanel");
public static final ThingTypeUID THING_TYPE_MECHANICALHANDLE = new ThingTypeUID(BINDING_ID, "mechanicalHandle");
public static final ThingTypeUID THING_TYPE_CONTACT = new ThingTypeUID(BINDING_ID, "contact");
public static final ThingTypeUID THING_TYPE_MEASUREMENTSWITCH = new ThingTypeUID(BINDING_ID, "measurementSwitch");
public static final ThingTypeUID THING_TYPE_TEMPERATURESENSOR = new ThingTypeUID(BINDING_ID, "temperatureSensor");
public static final ThingTypeUID THING_TYPE_TEMPERATUREHUMIDITYSENSOR = new ThingTypeUID(BINDING_ID,
"temperatureHumiditySensor");
public static final ThingTypeUID THING_TYPE_AUTOMATEDMETERSENSOR = new ThingTypeUID(BINDING_ID,
"automatedMeterSensor");
public static final ThingTypeUID THING_TYPE_THERMOSTAT = new ThingTypeUID(BINDING_ID, "thermostat");
public static final ThingTypeUID THING_TYPE_OCCUPANCYSENSOR = new ThingTypeUID(BINDING_ID, "occupancySensor");
public static final ThingTypeUID THING_TYPE_LIGHTTEMPERATUREOCCUPANCYSENSOR = new ThingTypeUID(BINDING_ID,
"lightTemperatureOccupancySensor");
public static final ThingTypeUID THING_TYPE_LIGHTSENSOR = new ThingTypeUID(BINDING_ID, "lightSensor");
public static final ThingTypeUID THING_TYPE_ENVIRONMENTALSENSOR = new ThingTypeUID(BINDING_ID,
"environmentalSensor");
public static final ThingTypeUID THING_TYPE_GENERICTHING = new ThingTypeUID(BINDING_ID, "genericThing");
public static final ThingTypeUID THING_TYPE_ROLLERSHUTTER = new ThingTypeUID(BINDING_ID, "rollershutter");
public static final ThingTypeUID THING_TYPE_MULTFUNCTIONSMOKEDETECTOR = new ThingTypeUID(BINDING_ID,
"multiFunctionSmokeDetector");
public static final Set<ThingTypeUID> SUPPORTED_DEVICE_THING_TYPES_UIDS = new HashSet<>(Arrays.asList(
THING_TYPE_PUSHBUTTON, THING_TYPE_ROCKERSWITCH, THING_TYPE_CLASSICDEVICE, THING_TYPE_CENTRALCOMMAND,
THING_TYPE_ROOMOPERATINGPANEL, THING_TYPE_MECHANICALHANDLE, THING_TYPE_CONTACT,
THING_TYPE_MEASUREMENTSWITCH, THING_TYPE_TEMPERATURESENSOR, THING_TYPE_TEMPERATUREHUMIDITYSENSOR,
THING_TYPE_GENERICTHING, THING_TYPE_ROLLERSHUTTER, THING_TYPE_OCCUPANCYSENSOR,
THING_TYPE_LIGHTTEMPERATUREOCCUPANCYSENSOR, THING_TYPE_LIGHTSENSOR, THING_TYPE_ENVIRONMENTALSENSOR,
THING_TYPE_AUTOMATEDMETERSENSOR, THING_TYPE_THERMOSTAT, THING_TYPE_MULTFUNCTIONSMOKEDETECTOR));
// List of all Channel Type Ids, these type ids are also used as channel ids during dynamic creation of channels
// this makes it a lot easier as we do not have to manage a type id and an id, drawback long channel names
public static final String CHANNEL_REPEATERMODE = "repeaterMode";
public static final String CHANNEL_SETBASEID = "setBaseId";
public static final String CHANNEL_GENERAL_SWITCHING = "generalSwitch";
public static final String CHANNEL_GENERAL_SWITCHINGA = "generalSwitchA"; // used for D2-01-12 EEP
public static final String CHANNEL_GENERAL_SWITCHINGB = "generalSwitchB"; // used for D2-01-12 EEP
public static final String CHANNEL_DIMMER = "dimmer";
public static final String CHANNEL_ROLLERSHUTTER = "rollershutter";
public static final String CHANNEL_ANGLE = "angle";
public static final String CHANNEL_TEMPERATURE = "temperature";
public static final String CHANNEL_HUMIDITY = "humidity";
public static final String CHANNEL_SETPOINT = "setPoint";
public static final String CHANNEL_FANSPEEDSTAGE = "fanSpeedStage";
public static final String CHANNEL_OCCUPANCY = "occupancy";
public static final String CHANNEL_MOTIONDETECTION = "motionDetection";
public static final String CHANNEL_VIBRATION = "vibration";
public static final String CHANNEL_ILLUMINATION = "illumination";
public static final String CHANNEL_ILLUMINATIONWEST = "illuminationWest";
public static final String CHANNEL_ILLUMINATIONSOUTHNORTH = "illuminationSouthNorth";
public static final String CHANNEL_ILLUMINATIONEAST = "illuminationEast";
public static final String CHANNEL_WINDSPEED = "windspeed";
public static final String CHANNEL_RAINSTATUS = "rainStatus";
public static final String CHANNEL_COUNTER = "counter";
public static final String CHANNEL_CURRENTNUMBER = "currentNumber";
public static final String CHANNEL_SMOKEDETECTION = "smokeDetection";
public static final String CHANNEL_SENSORFAULT = "sensorFault";
public static final String CHANNEL_MAINTENANCESTATUS = "maintenanceStatus";
public static final String CHANNEL_SENSORANALYSISHUMIDITYRANGE = "saHumidityRange";
public static final String CHANNEL_SENSORANALYSISTEMPERATURRANGE = "saTemperatureRange";
public static final String CHANNEL_TIMESINCELASTMAINTENANCE = "timeSinceLastMaintenance";
public static final String CHANNEL_REMAININGPLT = "remainingPLT";
public static final String CHANNEL_HYGROCOMFORTINDEX = "hygroComfortIndex";
public static final String CHANNEL_INDOORAIRANALYSIS = "indoorAirAnalysis";
public static final String CHANNEL_PUSHBUTTON = "pushButton";
public static final String CHANNEL_DOUBLEPRESS = "doublePress";
public static final String CHANNEL_LONGPRESS = "longPress";
public static final String CHANNEL_ROCKERSWITCH_CHANNELA = "rockerswitchA";
public static final String CHANNEL_ROCKERSWITCH_CHANNELB = "rockerswitchB";
public static final String CHANNEL_VIRTUALSWITCHA = "virtualSwitchA";
public static final String CHANNEL_VIRTUALROLLERSHUTTERA = "virtualRollershutterA";
public static final String CHANNEL_VIRTUALROCKERSWITCHB = "virtualRockerswitchB";
public static final String CHANNEL_ROCKERSWITCHLISTENERSWITCH = "rockerswitchListenerSwitch";
public static final String CHANNEL_ROCKERSWITCHLISTENERROLLERSHUTTER = "rockerswitchListenerRollershutter";
public static final String CHANNEL_ROCKERSWITCHLISTENER_START = "rockerswitchListener";
public static final String CHANNEL_WINDOWHANDLESTATE = "windowHandleState";
public static final String CHANNEL_CONTACT = "contact";
public static final String CHANNEL_TEACHINCMD = "teachInCMD";
public static final String CHANNEL_INSTANTPOWER = "instantpower";
public static final String CHANNEL_TOTALUSAGE = "totalusage";
public static final String CHANNEL_CURRENTFLOW = "currentFlow";
public static final String CHANNEL_CUMULATIVEVALUE = "cumulativeValue";
public static final String CHANNEL_BATTERY_VOLTAGE = "batteryVoltage";
public static final String CHANNEL_ENERGY_STORAGE = "energyStorage";
public static final String CHANNEL_BATTERY_LEVEL = "batteryLevel";
public static final String CHANNEL_BATTERYLOW = "batteryLow";
public static final String CHANNEL_AUTOOFF = "autoOFF";
public static final String CHANNEL_DELAYRADIOOFF = "delayRadioOFF";
public static final String CHANNEL_EXTERNALINTERFACEMODE = "externalInterfaceMode";
public static final String CHANNEL_TWOSTATESWITCH = "twoStateSwitch";
public static final String CHANNEL_ECOMODE = "ecoMode";
public static final String CHANNEL_RSSI = "rssi";
public static final String CHANNEL_REPEATCOUNT = "repeatCount";
public static final String CHANNEL_LASTRECEIVED = "lastReceived";
public static final String CHANNEL_GENERIC_SWITCH = "genericSwitch";
public static final String CHANNEL_GENERIC_ROLLERSHUTTER = "genericRollershutter";
public static final String CHANNEL_GENERIC_DIMMER = "genericDimmer";
public static final String CHANNEL_GENERIC_NUMBER = "genericNumber";
public static final String CHANNEL_GENERIC_STRING = "genericString";
public static final String CHANNEL_GENERIC_COLOR = "genericColor";
public static final String CHANNEL_GENERIC_TEACHINCMD = "genericTeachInCMD";
public static final String CHANNEL_VALVE_POSITION = "valvePosition";
public static final String CHANNEL_BUTTON_LOCK = "buttonLock";
public static final String CHANNEL_DISPLAY_ORIENTATION = "displayOrientation";
public static final String CHANNEL_TEMPERATURE_SETPOINT = "temperatureSetPoint";
public static final String CHANNEL_FEED_TEMPERATURE = "feedTemperature";
public static final String CHANNEL_MEASUREMENT_CONTROL = "measurementControl";
public static final String CHANNEL_FAILURE_CODE = "failureCode";
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 Map<String, EnOceanChannelDescription> CHANNELID2CHANNELDESCRIPTION = Collections
.unmodifiableMap(new HashMap<String, EnOceanChannelDescription>() {
private static final long serialVersionUID = 1L;
{
put(CHANNEL_GENERAL_SWITCHING, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_GENERAL_SWITCHING), CoreItemFactory.SWITCH));
put(CHANNEL_GENERAL_SWITCHINGA, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_GENERAL_SWITCHINGA), CoreItemFactory.SWITCH));
put(CHANNEL_GENERAL_SWITCHINGB, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_GENERAL_SWITCHINGB), CoreItemFactory.SWITCH));
put(CHANNEL_DIMMER, new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_DIMMER),
CoreItemFactory.DIMMER));
put(CHANNEL_ROLLERSHUTTER, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_ROLLERSHUTTER), CoreItemFactory.ROLLERSHUTTER));
put(CHANNEL_ANGLE, new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_ANGLE),
CoreItemFactory.NUMBER + ItemUtil.EXTENSION_SEPARATOR + Angle.class.getSimpleName()));
put(CHANNEL_TEMPERATURE, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_TEMPERATURE),
CoreItemFactory.NUMBER + ItemUtil.EXTENSION_SEPARATOR + Temperature.class.getSimpleName()));
put(CHANNEL_HUMIDITY, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_HUMIDITY), CoreItemFactory.NUMBER));
put(CHANNEL_FANSPEEDSTAGE, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_FANSPEEDSTAGE), CoreItemFactory.STRING));
put(CHANNEL_OCCUPANCY, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_OCCUPANCY), CoreItemFactory.SWITCH));
put(CHANNEL_MOTIONDETECTION, new EnOceanChannelDescription(
DefaultSystemChannelTypeProvider.SYSTEM_MOTION.getUID(), CoreItemFactory.SWITCH));
put(CHANNEL_VIBRATION, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_VIBRATION), CoreItemFactory.SWITCH));
put(CHANNEL_ILLUMINATION, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_ILLUMINATION),
CoreItemFactory.NUMBER + ItemUtil.EXTENSION_SEPARATOR + Illuminance.class.getSimpleName()));
put(CHANNEL_ILLUMINATIONWEST, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_ILLUMINATIONWEST),
CoreItemFactory.NUMBER + ItemUtil.EXTENSION_SEPARATOR + Illuminance.class.getSimpleName()));
put(CHANNEL_ILLUMINATIONSOUTHNORTH, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_ILLUMINATIONSOUTHNORTH),
CoreItemFactory.NUMBER + ItemUtil.EXTENSION_SEPARATOR + Illuminance.class.getSimpleName()));
put(CHANNEL_ILLUMINATIONEAST, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_ILLUMINATIONEAST),
CoreItemFactory.NUMBER + ItemUtil.EXTENSION_SEPARATOR + Illuminance.class.getSimpleName()));
put(CHANNEL_WINDSPEED, new EnOceanChannelDescription(
DefaultSystemChannelTypeProvider.SYSTEM_WIND_SPEED.getUID(),
CoreItemFactory.NUMBER + ItemUtil.EXTENSION_SEPARATOR + Speed.class.getSimpleName()));
put(CHANNEL_RAINSTATUS, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_RAINSTATUS), CoreItemFactory.SWITCH));
put(CHANNEL_COUNTER, new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_COUNTER),
CoreItemFactory.NUMBER));
put(CHANNEL_CURRENTNUMBER, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_CURRENTNUMBER), CoreItemFactory.NUMBER));
put(CHANNEL_SMOKEDETECTION, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_SMOKEDETECTION), CoreItemFactory.SWITCH));
put(CHANNEL_SENSORFAULT, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_SENSORFAULT), CoreItemFactory.SWITCH));
put(CHANNEL_MAINTENANCESTATUS, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_SENSORFAULT), CoreItemFactory.SWITCH));
put(CHANNEL_SENSORANALYSISHUMIDITYRANGE, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_SENSORFAULT), CoreItemFactory.SWITCH));
put(CHANNEL_SENSORANALYSISTEMPERATURRANGE, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_SENSORFAULT), CoreItemFactory.SWITCH));
put(CHANNEL_TIMESINCELASTMAINTENANCE, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_TIMESINCELASTMAINTENANCE),
CoreItemFactory.NUMBER + ItemUtil.EXTENSION_SEPARATOR + Time.class.getSimpleName()));
put(CHANNEL_REMAININGPLT, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_REMAININGPLT),
CoreItemFactory.NUMBER + ItemUtil.EXTENSION_SEPARATOR + Time.class.getSimpleName()));
put(CHANNEL_HYGROCOMFORTINDEX, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_HYGROCOMFORTINDEX), CoreItemFactory.STRING));
put(CHANNEL_INDOORAIRANALYSIS, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_INDOORAIRANALYSIS), CoreItemFactory.STRING));
put(CHANNEL_SETPOINT, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_SETPOINT), CoreItemFactory.NUMBER));
put(CHANNEL_CONTACT, new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_CONTACT),
CoreItemFactory.CONTACT));
put(CHANNEL_WINDOWHANDLESTATE, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_WINDOWHANDLESTATE), CoreItemFactory.STRING));
put(CHANNEL_BATTERY_VOLTAGE,
new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_BATTERY_VOLTAGE),
CoreItemFactory.NUMBER + ItemUtil.EXTENSION_SEPARATOR
+ ElectricPotential.class.getSimpleName()));
put(CHANNEL_ENERGY_STORAGE,
new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_ENERGY_STORAGE),
CoreItemFactory.NUMBER + ItemUtil.EXTENSION_SEPARATOR
+ ElectricPotential.class.getSimpleName()));
put(CHANNEL_BATTERY_LEVEL,
new EnOceanChannelDescription(
DefaultSystemChannelTypeProvider.SYSTEM_CHANNEL_BATTERY_LEVEL.getUID(),
CoreItemFactory.NUMBER));
put(CHANNEL_BATTERYLOW,
new EnOceanChannelDescription(
DefaultSystemChannelTypeProvider.SYSTEM_CHANNEL_LOW_BATTERY.getUID(),
CoreItemFactory.SWITCH));
put(CHANNEL_TEACHINCMD, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_TEACHINCMD), CoreItemFactory.SWITCH));
put(CHANNEL_PUSHBUTTON,
new EnOceanChannelDescription(DefaultSystemChannelTypeProvider.SYSTEM_RAWBUTTON.getUID(),
null, "Push button", false, true));
put(CHANNEL_DOUBLEPRESS,
new EnOceanChannelDescription(DefaultSystemChannelTypeProvider.SYSTEM_RAWBUTTON.getUID(),
null, "Double press", false, true));
put(CHANNEL_LONGPRESS,
new EnOceanChannelDescription(DefaultSystemChannelTypeProvider.SYSTEM_RAWBUTTON.getUID(),
null, "Long press", false, true));
put(CHANNEL_ROCKERSWITCH_CHANNELA,
new EnOceanChannelDescription(DefaultSystemChannelTypeProvider.SYSTEM_RAWROCKER.getUID(),
null, "Rocker Switch - Channel A", false, false));
put(CHANNEL_ROCKERSWITCH_CHANNELB,
new EnOceanChannelDescription(DefaultSystemChannelTypeProvider.SYSTEM_RAWROCKER.getUID(),
null, "Rocker Switch - Channel B", false, false));
put(CHANNEL_VIRTUALSWITCHA,
new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_VIRTUALSWITCHA),
CoreItemFactory.SWITCH, "", true, false));
put(CHANNEL_VIRTUALROLLERSHUTTERA,
new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_VIRTUALROLLERSHUTTERA),
CoreItemFactory.ROLLERSHUTTER, "", true, false));
put(CHANNEL_VIRTUALROCKERSWITCHB,
new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_VIRTUALROCKERSWITCHB),
CoreItemFactory.STRING, "Rocker Switch - Channel B", true, false));
put(CHANNEL_ROCKERSWITCHLISTENERSWITCH,
new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_ROCKERSWITCHLISTENERSWITCH),
CoreItemFactory.SWITCH, "Rocker Switch Listener (Switch)", true, false));
put(CHANNEL_ROCKERSWITCHLISTENERROLLERSHUTTER, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_ROCKERSWITCHLISTENERROLLERSHUTTER),
CoreItemFactory.ROLLERSHUTTER, "Rocker Switch Listener (Rollershutter)", true, false));
put(CHANNEL_INSTANTPOWER, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_INSTANTPOWER),
CoreItemFactory.NUMBER + ItemUtil.EXTENSION_SEPARATOR + Power.class.getSimpleName()));
put(CHANNEL_TOTALUSAGE, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_TOTALUSAGE),
CoreItemFactory.NUMBER + ItemUtil.EXTENSION_SEPARATOR + Energy.class.getSimpleName()));
put(CHANNEL_CURRENTFLOW,
new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_CURRENTFLOW),
CoreItemFactory.NUMBER + ItemUtil.EXTENSION_SEPARATOR
+ VolumetricFlowRate.class.getSimpleName()));
put(CHANNEL_CUMULATIVEVALUE, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_CUMULATIVEVALUE),
CoreItemFactory.NUMBER + ItemUtil.EXTENSION_SEPARATOR + Volume.class.getSimpleName()));
put(CHANNEL_AUTOOFF, new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_AUTOOFF),
CoreItemFactory.NUMBER));
put(CHANNEL_DELAYRADIOOFF, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_DELAYRADIOOFF), CoreItemFactory.NUMBER));
put(CHANNEL_EXTERNALINTERFACEMODE, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_EXTERNALINTERFACEMODE), CoreItemFactory.STRING));
put(CHANNEL_TWOSTATESWITCH, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_TWOSTATESWITCH), CoreItemFactory.SWITCH));
put(CHANNEL_ECOMODE, new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_ECOMODE),
CoreItemFactory.SWITCH));
put(CHANNEL_RSSI, new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_RSSI),
CoreItemFactory.NUMBER));
put(CHANNEL_REPEATCOUNT, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_REPEATCOUNT), CoreItemFactory.NUMBER));
put(CHANNEL_LASTRECEIVED, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_LASTRECEIVED), CoreItemFactory.DATETIME));
put(CHANNEL_GENERIC_SWITCH, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_GENERIC_SWITCH), CoreItemFactory.SWITCH));
put(CHANNEL_GENERIC_ROLLERSHUTTER,
new EnOceanChannelDescription(new ChannelTypeUID(BINDING_ID, CHANNEL_GENERIC_ROLLERSHUTTER),
CoreItemFactory.ROLLERSHUTTER));
put(CHANNEL_GENERIC_DIMMER, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_GENERIC_DIMMER), CoreItemFactory.DIMMER));
put(CHANNEL_GENERIC_NUMBER, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_GENERIC_NUMBER), CoreItemFactory.NUMBER));
put(CHANNEL_GENERIC_STRING, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_GENERIC_STRING), CoreItemFactory.STRING));
put(CHANNEL_GENERIC_COLOR, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_GENERIC_COLOR), CoreItemFactory.COLOR));
put(CHANNEL_GENERIC_TEACHINCMD, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_GENERIC_TEACHINCMD), CoreItemFactory.SWITCH));
put(CHANNEL_VALVE_POSITION, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_VALVE_POSITION), CoreItemFactory.NUMBER));
put(CHANNEL_BUTTON_LOCK, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_BUTTON_LOCK), CoreItemFactory.SWITCH));
put(CHANNEL_DISPLAY_ORIENTATION, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_DISPLAY_ORIENTATION), CoreItemFactory.NUMBER));
put(CHANNEL_TEMPERATURE_SETPOINT, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_TEMPERATURE_SETPOINT),
CoreItemFactory.NUMBER + ItemUtil.EXTENSION_SEPARATOR + Temperature.class.getSimpleName()));
put(CHANNEL_FEED_TEMPERATURE, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_FEED_TEMPERATURE),
CoreItemFactory.NUMBER + ItemUtil.EXTENSION_SEPARATOR + Temperature.class.getSimpleName()));
put(CHANNEL_MEASUREMENT_CONTROL, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_MEASUREMENT_CONTROL), CoreItemFactory.SWITCH));
put(CHANNEL_FAILURE_CODE, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_FAILURE_CODE), CoreItemFactory.NUMBER));
put(CHANNEL_WAKEUPCYCLE, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_WAKEUPCYCLE), CoreItemFactory.NUMBER));
put(CHANNEL_SERVICECOMMAND, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_SERVICECOMMAND), CoreItemFactory.NUMBER));
put(CHANNEL_STATUS_REQUEST_EVENT, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_STATUS_REQUEST_EVENT), null, "", false, true));
put(CHANNEL_SEND_COMMAND, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_SEND_COMMAND), CoreItemFactory.SWITCH));
put(CHANNEL_REPEATERMODE, new EnOceanChannelDescription(
new ChannelTypeUID(BINDING_ID, CHANNEL_REPEATERMODE), CoreItemFactory.STRING));
}
});
// List of all repeater mode states
public static final String REPEATERMODE_OFF = "OFF";
public static final String REPEATERMODE_LEVEL_1 = "LEVEL1";
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";
// Bridge properties
public static final String PROPERTY_BASE_ID = "Base ID";
public static final String PROPERTY_REMAINING_WRITE_CYCLES_Base_ID = "Remaining Base ID Write Cycles";
public static final String PROPERTY_APP_VERSION = "APP Version";
public static final String PROPERTY_API_VERSION = "API Version";
public static final String PROPERTY_CHIP_ID = "Chip ID";
public static final String PROPERTY_DESCRIPTION = "Description";
// Thing properties
public static final String PROPERTY_ENOCEAN_ID = "enoceanId";
// 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";
// Channel config parameter
public static final String PARAMETER_CHANNEL_TeachInMSG = "teachInMSG";
public static final String PARAMETER_CHANNEL_Duration = "duration";
public static final String PARAMETER_CHANNEL_SwitchMode = "switchMode";
// Manufacturer Ids - used to recognize special EEPs during auto discovery
public static final int ELTAKOID = 0x00d;
public static final int NODONID = 0x046; // NodOn devices are designed by ID-RF hence use their ID
public static final int PERMUNDOID = 0x033;
public static final String EMPTYENOCEANID = "00000000";
public static final byte ZERO = (byte) 0;
}

View File

@@ -0,0 +1,65 @@
/**
* 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.enocean.internal;
import org.eclipse.jdt.annotation.NonNull;
import org.openhab.core.thing.type.ChannelTypeUID;
/**
*
* @author Daniel Weber - Initial contribution
* This class holds information for creating a channel of an EnOcean thing like acceptedItemType and
* channelTypeUID
*/
public class EnOceanChannelDescription {
public final ChannelTypeUID channelTypeUID;
public final String acceptedItemType;
@NonNull
public final String label;
public final boolean isStateChannel;
public final boolean autoCreate;
/**
* Ctor for an EnOceanChannelDescription
*
* @param channelTypeUID ChannelTypeUID of channel
* @param acceptedItemType AcceptedItemType of channel like Switch, Dimmer or null if we accept everything
*/
public EnOceanChannelDescription(ChannelTypeUID channelTypeUID, String itemType) {
this(channelTypeUID, itemType, "", true, true);
}
/**
* Ctor for an EnOceanChannelDescription with detailed information
*
* @param channelTypeUID ChannelTypeUID of channel
* @param acceptedItemType ItemType of channel like Switch, Dimmer
* @param label of created channel
* @param isStateChannel otherwise created channel is a trigger channel
* @param autoCreate create channel during thing initialization, otherwise channel is created
* manually/predefined
*/
public EnOceanChannelDescription(ChannelTypeUID channelTypeUID, String itemType, String label,
boolean isStateChannel, boolean autoCreate) {
this.channelTypeUID = channelTypeUID;
this.acceptedItemType = itemType;
if (label != null) {
this.label = label;
} else {
this.label = "";
}
this.isStateChannel = isStateChannel;
this.autoCreate = autoCreate;
}
}

View File

@@ -0,0 +1,33 @@
/**
* 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.enocean.internal;
/**
*
* @author Daniel Weber - Initial contribution
*/
public enum EnOceanConfigStatusMessage {
PORT_MISSING("missing-port-configuration"),
SENDERID_MISSING("missing-senderId-configuration"),
SENDERID_MALFORMED("malformed-senderId-configuration");
private String messageKey;
private EnOceanConfigStatusMessage(String messageKey) {
this.messageKey = messageKey;
}
public String getMessageKey() {
return messageKey;
}
}

View File

@@ -0,0 +1,29 @@
/**
* 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.enocean.internal;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class EnOceanException extends Exception {
/**
*
*/
private static final long serialVersionUID = 1L;
public EnOceanException(String msg) {
super(msg);
}
}

View File

@@ -0,0 +1,104 @@
/**
* 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.enocean.internal;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.openhab.binding.enocean.internal.discovery.EnOceanDeviceDiscoveryService;
import org.openhab.binding.enocean.internal.handler.EnOceanBaseActuatorHandler;
import org.openhab.binding.enocean.internal.handler.EnOceanBaseSensorHandler;
import org.openhab.binding.enocean.internal.handler.EnOceanBridgeHandler;
import org.openhab.binding.enocean.internal.handler.EnOceanClassicDeviceHandler;
import org.openhab.core.config.discovery.DiscoveryService;
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.ThingTypeUID;
import org.openhab.core.thing.ThingUID;
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.thing.binding.ThingHandlerFactory;
import org.openhab.core.thing.link.ItemChannelLinkRegistry;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
/**
* The {@link EnOceanHandlerFactory} is responsible for creating things and thing
* handlers.
*
* @author Daniel Weber - Initial contribution
*/
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.enocean")
public class EnOceanHandlerFactory extends BaseThingHandlerFactory {
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Stream
.concat(EnOceanBridgeHandler.SUPPORTED_THING_TYPES.stream(),
EnOceanBindingConstants.SUPPORTED_DEVICE_THING_TYPES_UIDS.stream())
.collect(Collectors.toSet());
private Map<ThingUID, ServiceRegistration<?>> discoveryServiceRegs = new HashMap<>();
@Reference
SerialPortManager serialPortManager;
@Reference
ItemChannelLinkRegistry itemChannelLinkRegistry;
@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
}
@Override
protected ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (EnOceanBridgeHandler.SUPPORTED_THING_TYPES.contains(thingTypeUID)) {
EnOceanBridgeHandler bridgeHandler = new EnOceanBridgeHandler((Bridge) thing, serialPortManager);
registerDeviceDiscoveryService(bridgeHandler);
return bridgeHandler;
} else if (EnOceanBaseActuatorHandler.SUPPORTED_THING_TYPES.contains(thingTypeUID)) {
return new EnOceanBaseActuatorHandler(thing, itemChannelLinkRegistry);
} else if (EnOceanBaseSensorHandler.SUPPORTED_THING_TYPES.contains(thingTypeUID)) {
return new EnOceanBaseSensorHandler(thing, itemChannelLinkRegistry);
} else if (EnOceanClassicDeviceHandler.SUPPORTED_THING_TYPES.contains(thingTypeUID)) {
return new EnOceanClassicDeviceHandler(thing, itemChannelLinkRegistry);
}
return null;
}
@Override
protected void removeHandler(ThingHandler thingHandler) {
if (this.discoveryServiceRegs != null) {
ServiceRegistration<?> serviceReg = this.discoveryServiceRegs.get(thingHandler.getThing().getUID());
if (serviceReg != null) {
serviceReg.unregister();
discoveryServiceRegs.remove(thingHandler.getThing().getUID());
}
}
}
private void registerDeviceDiscoveryService(EnOceanBridgeHandler handler) {
EnOceanDeviceDiscoveryService discoveryService = new EnOceanDeviceDiscoveryService(handler);
discoveryService.activate();
this.discoveryServiceRegs.put(handler.getThing().getUID(),
bundleContext.registerService(DiscoveryService.class.getName(), discoveryService, new Hashtable<>()));
}
}

View File

@@ -0,0 +1,45 @@
/**
* 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.enocean.internal;
import java.util.Arrays;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class Helper {
public static byte[] concatAll(byte[] a, byte[]... rest) {
if (rest == null) {
return a;
}
int totalLength = a.length;
for (byte[] b : rest) {
if (b != null) {
totalLength += b.length;
}
}
byte[] result = Arrays.copyOf(a, totalLength);
int offset = a.length;
for (byte[] array : rest) {
if (array != null) {
System.arraycopy(array, 0, result, offset, array.length);
offset += array.length;
}
}
return result;
}
}

View File

@@ -0,0 +1,33 @@
/**
* 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.enocean.internal.config;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class EnOceanActuatorConfig extends EnOceanBaseConfig {
public int channel;
public int senderIdOffset = -1;
public String manufacturerId;
public String teachInType;
public String sendingEEPId;
public int pollingInterval;
public boolean broadcastMessages;
public boolean suppressRepeating;
}

View File

@@ -0,0 +1,39 @@
/**
* 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.enocean.internal.config;
import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.EMPTYENOCEANID;
import java.util.ArrayList;
import java.util.List;
import org.openhab.core.util.HexUtils;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class EnOceanBaseConfig {
public String enoceanId;
public List<String> receivingEEPId = new ArrayList<>();
public boolean receivingSIGEEP = false;
public EnOceanBaseConfig() {
enoceanId = EMPTYENOCEANID;
}
public byte[] getEnOceanId() {
return HexUtils.hexToBytes(enoceanId);
}
}

View File

@@ -0,0 +1,58 @@
/**
* 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.enocean.internal.config;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class EnOceanBridgeConfig {
public enum ESPVersion {
UNKNOWN("unknown"),
ESP3("ESP3"),
ESP2("ESP2");
private String version;
ESPVersion(String version) {
this.version = version;
}
public static ESPVersion getESPVersion(String espVersion) {
for (ESPVersion version : values()) {
if (version.version.equalsIgnoreCase(espVersion)) {
return version;
}
}
return ESPVersion.UNKNOWN;
}
}
public String path;
public String espVersion;
public boolean rs485;
public String rs485BaseId;
public int nextSenderId = 0;
public EnOceanBridgeConfig() {
espVersion = "ESP3";
}
public ESPVersion getESPVersion() {
return ESPVersion.getESPVersion(espVersion);
}
}

View File

@@ -0,0 +1,23 @@
/**
* 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.enocean.internal.config;
/**
*
* @author Holger Englert - Initial contribution
*/
public class EnOceanChannelContactConfig {
// Swap Open/Closed value, e.g.
// Eltako FPE-1: false, Eltako FPE-2: true
public boolean inverted = false;
}

View File

@@ -0,0 +1,24 @@
/**
* 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.enocean.internal.config;
/**
*
* @author Dominik Krickl-Vorreiter - Initial contribution
*/
public class EnOceanChannelDimmerConfig {
public int rampingTime = 0;
public boolean eltakoDimmer = true;
public boolean storeValue = false;
}

View File

@@ -0,0 +1,95 @@
/**
* 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.enocean.internal.config;
import java.security.InvalidParameterException;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class EnOceanChannelRockerSwitchConfigBase {
public String switchMode;
public String channel;
public enum SwitchMode {
Unkown(""),
RockerSwitch("rockerSwitch"),
ToggleDir1("toggleButtonDir1"),
ToggleDir2("toggleButtonDir2");
private String value;
SwitchMode(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public static SwitchMode getSwitchMode(String value) {
if (value == null) {
return SwitchMode.Unkown;
}
for (SwitchMode t : SwitchMode.values()) {
if (t.value.equals(value)) {
return t;
}
}
throw new InvalidParameterException("Unknown SwitchMode");
}
}
public enum Channel {
Unkown(""),
ChannelA("channelA"),
ChannelB("channelB");
private String value;
Channel(String value) {
this.value = value;
}
public static Channel getChannel(String value) {
if (value == null) {
return Channel.Unkown;
}
for (Channel t : Channel.values()) {
if (t.value.equals(value)) {
return t;
}
}
throw new InvalidParameterException("Unknown Channel");
}
}
public EnOceanChannelRockerSwitchConfigBase() {
switchMode = "rockerSwitch";
channel = "channelA";
}
public SwitchMode getSwitchMode() {
return SwitchMode.getSwitchMode(switchMode);
}
public Channel getChannel() {
return Channel.getChannel(channel);
}
}

View File

@@ -0,0 +1,27 @@
/**
* 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.enocean.internal.config;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class EnOceanChannelRockerSwitchListenerConfig extends EnOceanChannelRockerSwitchConfigBase {
public String enoceanId;
public EnOceanChannelRockerSwitchListenerConfig() {
super();
enoceanId = null;
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.config;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class EnOceanChannelRollershutterConfig {
public int shutTime;
public EnOceanChannelRollershutterConfig() {
shutTime = 255;
}
}

View File

@@ -0,0 +1,23 @@
/**
* 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.enocean.internal.config;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class EnOceanChannelTeachInConfig {
public String teachInMSG;
public String manufacturerId;
}

View File

@@ -0,0 +1,21 @@
/**
* 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.enocean.internal.config;
/**
*
* @author Dominik Vorreiter - Initial contribution
*/
public class EnOceanChannelTotalusageConfig {
public boolean validateValue = false;
}

View File

@@ -0,0 +1,23 @@
/**
* 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.enocean.internal.config;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class EnOceanChannelTransformationConfig {
public String transformationType;
public String transformationFunction;
}

View File

@@ -0,0 +1,27 @@
/**
* 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.enocean.internal.config;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class EnOceanChannelVirtualRockerSwitchConfig extends EnOceanChannelRockerSwitchConfigBase {
public Integer duration;
public EnOceanChannelVirtualRockerSwitchConfig() {
super();
duration = 350;
}
}

View File

@@ -0,0 +1,174 @@
/**
* 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.enocean.internal.discovery;
import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
import org.openhab.binding.enocean.internal.eep.Base.UTEResponse;
import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
import org.openhab.binding.enocean.internal.eep.EEP;
import org.openhab.binding.enocean.internal.eep.EEPFactory;
import org.openhab.binding.enocean.internal.handler.EnOceanBridgeHandler;
import org.openhab.binding.enocean.internal.messages.BasePacket;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.binding.enocean.internal.messages.ERP1Message.RORG;
import org.openhab.binding.enocean.internal.transceiver.PacketListener;
import org.openhab.core.config.discovery.AbstractDiscoveryService;
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.ThingUID;
import org.openhab.core.util.HexUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The {@link EnOceanDeviceDiscoveryService} is used to discover Enocean devices and to accept teach in requests.
*
* @author Daniel Weber - Initial contribution
*/
public class EnOceanDeviceDiscoveryService extends AbstractDiscoveryService implements PacketListener {
private final Logger logger = LoggerFactory.getLogger(EnOceanDeviceDiscoveryService.class);
private EnOceanBridgeHandler bridgeHandler;
public EnOceanDeviceDiscoveryService(EnOceanBridgeHandler bridgeHandler) {
super(null, 60, false);
this.bridgeHandler = bridgeHandler;
}
/**
* Called on component activation.
*/
public void activate() {
super.activate(null);
}
@Override
public void deactivate() {
super.deactivate();
}
@Override
protected void startScan() {
if (bridgeHandler == null) {
return;
}
logger.info("Starting EnOcean discovery and accepting teach in requests");
bridgeHandler.startDiscovery(this);
}
@Override
public synchronized void stopScan() {
if (bridgeHandler == null) {
return;
}
logger.info("Stopping EnOcean discovery scan");
bridgeHandler.stopDiscovery();
super.stopScan();
}
@Override
public Set<@NonNull ThingTypeUID> getSupportedThingTypes() {
return SUPPORTED_DEVICE_THING_TYPES_UIDS;
}
@Override
public void packetReceived(BasePacket packet) {
ERP1Message msg = (ERP1Message) packet;
logger.info("EnOcean Package discovered, RORG {}, payload {}, additional {}", msg.getRORG().name(),
HexUtils.bytesToHex(msg.getPayload()), HexUtils.bytesToHex(msg.getOptionalPayload()));
EEP eep = EEPFactory.buildEEPFromTeachInERP1(msg);
if (eep == null) {
logger.debug("Could not build EEP for received package");
return;
}
String enoceanId = HexUtils.bytesToHex(eep.getSenderId());
ThingTypeUID thingTypeUID = eep.getThingTypeUID();
ThingUID thingUID = new ThingUID(thingTypeUID, bridgeHandler.getThing().getUID(), enoceanId);
int senderIdOffset = 0;
boolean broadcastMessages = true;
// check for bidirectional communication => do not use broadcast in this case
if (msg.getRORG() == RORG.UTE && (msg.getPayload(1, 1)[0]
& UTEResponse.CommunicationType_MASK) == UTEResponse.CommunicationType_MASK) {
broadcastMessages = false;
}
// if ute => send response if needed
if (msg.getRORG() == RORG.UTE && (msg.getPayload(1, 1)[0] & UTEResponse.ResponseNeeded_MASK) == 0) {
logger.info("Sending UTE response to {}", enoceanId);
senderIdOffset = sendTeachInResponse(msg, enoceanId);
}
// if 4BS teach in variation 3 => send response
if ((eep instanceof _4BSMessage) && ((_4BSMessage) eep).isTeachInVariation3Supported()) {
logger.info("Sending 4BS teach in variation 3 response to {}", enoceanId);
senderIdOffset = sendTeachInResponse(msg, enoceanId);
}
DiscoveryResultBuilder discoveryResultBuilder = DiscoveryResultBuilder.create(thingUID)
.withRepresentationProperty(enoceanId).withBridge(bridgeHandler.getThing().getUID());
eep.addConfigPropertiesTo(discoveryResultBuilder);
discoveryResultBuilder.withProperty(PARAMETER_BROADCASTMESSAGES, broadcastMessages);
discoveryResultBuilder.withProperty(PARAMETER_ENOCEANID, enoceanId);
if (senderIdOffset > 0) {
// advance config with new device id
discoveryResultBuilder.withProperty(PARAMETER_SENDERIDOFFSET, senderIdOffset);
}
thingDiscovered(discoveryResultBuilder.build());
// As we only support sensors to be teached in, we do not need to send a teach in response => 4bs
// bidirectional teach in proc is not supported yet
// this is true except for UTE teach in => we always have to send a response here
}
private int sendTeachInResponse(ERP1Message msg, String enoceanId) {
int offset;
// get new sender Id
offset = bridgeHandler.getNextSenderId(enoceanId);
if (offset > 0) {
byte[] newSenderId = bridgeHandler.getBaseId();
newSenderId[3] += offset;
// send response
EEP response = EEPFactory.buildResponseEEPFromTeachInERP1(msg, newSenderId);
if (response != null) {
bridgeHandler.sendMessage(response.getERP1Message(), null);
logger.info("Teach in response for {} with new senderId {} (= offset {}) sent", enoceanId,
HexUtils.bytesToHex(newSenderId), offset);
} else {
logger.warn("Teach in response for enoceanId {} not supported!", enoceanId);
}
}
return offset;
}
@Override
public long getSenderIdToListenTo() {
// we just want teach in msg, so return zero here
return 0;
}
}

View File

@@ -0,0 +1,102 @@
/**
* 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.enocean.internal.discovery;
import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.config.discovery.DiscoveryResult;
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
import org.openhab.core.config.discovery.usbserial.UsbSerialDeviceInformation;
import org.openhab.core.config.discovery.usbserial.UsbSerialDiscoveryParticipant;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.ThingUID;
import org.osgi.service.component.annotations.Component;
/**
* Discovery for Enocean USB dongles, integrated in Eclipse SmartHome's USB-serial discovery by implementing
* a component of type {@link UsbSerialDiscoveryParticipant}.
* <p/>
* Currently, this {@link UsbSerialDiscoveryParticipant} supports the Enocean USB300 dongles.
*
* @author Aitor Iturrioz - initial contribution
*/
@Component(service = UsbSerialDiscoveryParticipant.class)
public class EnOceanUsbSerialDiscoveryParticipant implements UsbSerialDiscoveryParticipant {
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = new HashSet<>(Arrays.asList(THING_TYPE_BRIDGE));
public static final int ENOCEAN_USB300_DONGLE_VENDOR_ID = 0x0403;
public static final int ENOCEAN_USB300_DONGLE_PRODUCT_ID = 0x6001;
public static final String ENOCEAN_USB300_DONGLE_MANUFACTURER = "EnOcean GmbH";
public static final String ENOCEAN_USB300_DONGLE_PRODUCT = "usb 300";
public static final String ENOCEAN_USB300_DONGLE_DEFAULT_LABEL = "Enocean USB300 Dongle";
@Override
public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
return SUPPORTED_THING_TYPES;
}
@Override
public @Nullable DiscoveryResult createResult(UsbSerialDeviceInformation deviceInformation) {
if (isEnoceanUSB300Dongle(deviceInformation)) {
return DiscoveryResultBuilder.create(createBridgeThingType(deviceInformation))
.withLabel(createEnoceanUSB300DongleLabel(deviceInformation)).withRepresentationProperty(PATH)
.withProperty(PATH, deviceInformation.getSerialPort()).build();
} else {
return null;
}
}
@Override
public @Nullable ThingUID getThingUID(UsbSerialDeviceInformation deviceInformation) {
if (isEnoceanUSB300Dongle(deviceInformation)) {
return createBridgeThingType(deviceInformation);
} else {
return null;
}
}
private ThingUID createBridgeThingType(UsbSerialDeviceInformation deviceInformation) {
String serialNumber = deviceInformation.getSerialNumber();
if (serialNumber != null) {
return new ThingUID(THING_TYPE_BRIDGE, serialNumber);
} else {
return new ThingUID(THING_TYPE_BRIDGE, String.valueOf(deviceInformation.getProductId()));
}
}
private boolean isEnoceanUSB300Dongle(UsbSerialDeviceInformation deviceInformation) {
String manufacturer = deviceInformation.getManufacturer();
String product = deviceInformation.getProduct();
return deviceInformation.getVendorId() == ENOCEAN_USB300_DONGLE_VENDOR_ID
&& deviceInformation.getProductId() == ENOCEAN_USB300_DONGLE_PRODUCT_ID && manufacturer != null
&& manufacturer.equalsIgnoreCase(ENOCEAN_USB300_DONGLE_MANUFACTURER) && product != null
&& product.toLowerCase().contains(ENOCEAN_USB300_DONGLE_PRODUCT);
}
private @Nullable String createEnoceanUSB300DongleLabel(UsbSerialDeviceInformation deviceInformation) {
String serialNumber = deviceInformation.getSerialNumber();
if (serialNumber != null && !serialNumber.isEmpty()) {
return String.format("%s (%s)", ENOCEAN_USB300_DONGLE_DEFAULT_LABEL, serialNumber);
} else {
return ENOCEAN_USB300_DONGLE_DEFAULT_LABEL;
}
}
}

View File

@@ -0,0 +1,63 @@
/**
* 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.enocean.internal.eep.A5_02;
import java.util.function.Function;
import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SIUnits;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
/**
*
* @author Daniel Weber - Initial contribution
*/
public abstract class A5_02 extends _4BSMessage {
public A5_02(ERP1Message packet) {
super(packet);
}
protected double getUnscaledMin() {
return 255;
}
protected double getUnscaledMax() {
return 0;
}
protected abstract double getScaledMin();
protected abstract double getScaledMax();
protected int getUnscaledTemperatureValue() {
return getDB_1Value();
}
@Override
protected State convertToStateImpl(String channelId, String channelTypeId,
Function<String, State> getCurrentStateFunc, Configuration config) {
if (!isValid()) {
return UnDefType.UNDEF;
}
double scaledTemp = getScaledMin()
- (((getUnscaledMin() - getUnscaledTemperatureValue()) * (getScaledMin() - getScaledMax()))
/ getUnscaledMin());
return new QuantityType<>(scaledTemp, SIUnits.CELSIUS);
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_01 extends A5_02 {
public A5_02_01(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return -40;
}
@Override
protected double getScaledMax() {
return 0;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_02 extends A5_02 {
public A5_02_02(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return -30;
}
@Override
protected double getScaledMax() {
return 10;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_03 extends A5_02 {
public A5_02_03(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return -20;
}
@Override
protected double getScaledMax() {
return 20;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_04 extends A5_02 {
public A5_02_04(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return -10;
}
@Override
protected double getScaledMax() {
return 30;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_05 extends A5_02 {
public A5_02_05(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return 0;
}
@Override
protected double getScaledMax() {
return 40;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_06 extends A5_02 {
public A5_02_06(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return 10;
}
@Override
protected double getScaledMax() {
return 50;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_07 extends A5_02 {
public A5_02_07(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return 20;
}
@Override
protected double getScaledMax() {
return 60;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_08 extends A5_02 {
public A5_02_08(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return 30;
}
@Override
protected double getScaledMax() {
return 70;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_09 extends A5_02 {
public A5_02_09(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return 40;
}
@Override
protected double getScaledMax() {
return 80;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_0A extends A5_02 {
public A5_02_0A(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return 50;
}
@Override
protected double getScaledMax() {
return 90;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_0B extends A5_02 {
public A5_02_0B(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return 60;
}
@Override
protected double getScaledMax() {
return 100;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_10 extends A5_02 {
public A5_02_10(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return -60;
}
@Override
protected double getScaledMax() {
return 20;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_11 extends A5_02 {
public A5_02_11(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return -50;
}
@Override
protected double getScaledMax() {
return 30;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_12 extends A5_02 {
public A5_02_12(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return -40;
}
@Override
protected double getScaledMax() {
return 40;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_13 extends A5_02 {
public A5_02_13(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return -30;
}
@Override
protected double getScaledMax() {
return 50;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_14 extends A5_02 {
public A5_02_14(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return -20;
}
@Override
protected double getScaledMax() {
return 60;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_15 extends A5_02 {
public A5_02_15(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return -10;
}
@Override
protected double getScaledMax() {
return 70;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_16 extends A5_02 {
public A5_02_16(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return 0;
}
@Override
protected double getScaledMax() {
return 80;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_17 extends A5_02 {
public A5_02_17(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return 10;
}
@Override
protected double getScaledMax() {
return 90;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_18 extends A5_02 {
public A5_02_18(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return 20;
}
@Override
protected double getScaledMax() {
return 100;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_19 extends A5_02 {
public A5_02_19(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return 30;
}
@Override
protected double getScaledMax() {
return 110;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_1A extends A5_02 {
public A5_02_1A(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return 40;
}
@Override
protected double getScaledMax() {
return 120;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_1B extends A5_02 {
public A5_02_1B(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return 50;
}
@Override
protected double getScaledMax() {
return 130;
}
}

View File

@@ -0,0 +1,51 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_20 extends A5_02 {
public A5_02_20(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return -10;
}
@Override
protected double getScaledMax() {
return 41.2;
}
@Override
protected double getUnscaledMin() {
return 1023;
}
@Override
protected double getUnscaledMax() {
return 0;
}
@Override
protected int getUnscaledTemperatureValue() {
return getDB_1Value() + ((getDB_2Value() & 0b11) << 8);
}
}

View File

@@ -0,0 +1,51 @@
/**
* 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.enocean.internal.eep.A5_02;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_02_30 extends A5_02 {
public A5_02_30(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledMin() {
return -40;
}
@Override
protected double getScaledMax() {
return 62.3;
}
@Override
protected double getUnscaledMin() {
return 1023;
}
@Override
protected double getUnscaledMax() {
return 0;
}
@Override
protected int getUnscaledTemperatureValue() {
return getDB_1Value() + ((getDB_2Value() & 0b11) << 8);
}
}

View File

@@ -0,0 +1,80 @@
/**
* 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.enocean.internal.eep.A5_04;
import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
import java.util.function.Function;
import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SIUnits;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
/**
*
* @author Daniel Weber - Initial contribution
*/
public abstract class A5_04 extends _4BSMessage {
public A5_04(ERP1Message packet) {
super(packet);
}
protected double getUnscaledTemperatureMin() {
return 0;
}
protected double getUnscaledTemperatureMax() {
return 250;
}
protected abstract double getScaledTemperatureMin();
protected abstract double getScaledTemperatureMax();
protected int getUnscaledTemperatureValue() {
return getDB_1Value();
}
protected double getUnscaledHumidityMax() {
return 250;
}
protected int getUnscaledHumidityValue() {
return getDB_2Value();
}
@Override
protected State convertToStateImpl(String channelId, String channelTypeId,
Function<String, State> getCurrentStateFunc, Configuration config) {
if (!isValid()) {
return UnDefType.UNDEF;
}
if (channelId.equals(CHANNEL_TEMPERATURE)) {
double scaledTemp = getScaledTemperatureMin()
+ ((getUnscaledTemperatureValue() * (getScaledTemperatureMax() - getScaledTemperatureMin()))
/ (getUnscaledTemperatureMax() - getUnscaledTemperatureMin()));
return new QuantityType<>(scaledTemp, SIUnits.CELSIUS);
} else if (channelId.equals(CHANNEL_HUMIDITY)) {
return new DecimalType((getUnscaledHumidityValue() * 100.0) / getUnscaledHumidityMax());
}
return UnDefType.UNDEF;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_04;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_04_01 extends A5_04 {
public A5_04_01(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledTemperatureMin() {
return 0;
}
@Override
protected double getScaledTemperatureMax() {
return 40;
}
}

View File

@@ -0,0 +1,36 @@
/**
* 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.enocean.internal.eep.A5_04;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_04_02 extends A5_04 {
public A5_04_02(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledTemperatureMin() {
return -20;
}
@Override
protected double getScaledTemperatureMax() {
return 60;
}
}

View File

@@ -0,0 +1,45 @@
/**
* 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.enocean.internal.eep.A5_04;
import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.CHANNEL_BATTERY_VOLTAGE;
import java.util.function.Function;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.types.State;
/**
*
* @author Dominik Krickl-Vorreiter - Initial contribution
*/
public class A5_04_02_Eltako extends A5_04_02 {
public A5_04_02_Eltako(ERP1Message packet) {
super(packet);
}
@Override
protected State convertToStateImpl(String channelId, String channelTypeId,
Function<String, State> getCurrentStateFunc, Configuration config) {
if (channelId.equals(CHANNEL_BATTERY_VOLTAGE)) {
double voltage = getDB_3Value() * 6.58 / 255.0; // not sure if this is right
return new QuantityType<>(voltage, SmartHomeUnits.VOLT);
}
return super.convertToStateImpl(channelId, channelTypeId, getCurrentStateFunc, config);
}
}

View File

@@ -0,0 +1,56 @@
/**
* 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.enocean.internal.eep.A5_04;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_04_03 extends A5_04 {
public A5_04_03(ERP1Message packet) {
super(packet);
}
@Override
protected double getUnscaledTemperatureMax() {
return 1023;
}
@Override
protected double getScaledTemperatureMin() {
return -20;
}
@Override
protected double getScaledTemperatureMax() {
return 60;
}
@Override
protected int getUnscaledTemperatureValue() {
return getDB_1Value() + ((getDB_2Value() & 0b11) << 8);
}
@Override
protected double getUnscaledHumidityMax() {
return 255;
}
@Override
protected int getUnscaledHumidityValue() {
return getDB_3Value();
}
}

View File

@@ -0,0 +1,65 @@
/**
* 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.enocean.internal.eep.A5_06;
import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
import java.util.function.Function;
import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
/**
*
* @author Dominik Krickl-Vorreiter - Initial contribution
*/
public class A5_06_01 extends _4BSMessage {
public A5_06_01(ERP1Message packet) {
super(packet);
}
private State getBatteryVoltage() {
int db3 = getDB_3Value();
double voltage = db3 / 50.0; // 0..255 = 0.0..5.1V
return new QuantityType<>(voltage, SmartHomeUnits.VOLT);
}
private State getIllumination() {
boolean rs = getBit(getDB_0(), 0);
double illumination = rs ? getDB_2Value() * 116.48 + 300.0 : getDB_1Value() * 232.94 + 600.0;
return new QuantityType<>(illumination, SmartHomeUnits.LUX);
}
@Override
protected State convertToStateImpl(String channelId, String channelTypeId,
Function<String, State> getCurrentStateFunc, Configuration config) {
switch (channelId) {
case CHANNEL_BATTERY_VOLTAGE:
return getBatteryVoltage();
case CHANNEL_ILLUMINATION:
return getIllumination();
}
return UnDefType.UNDEF;
}
}

View File

@@ -0,0 +1,58 @@
/**
* 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.enocean.internal.eep.A5_06;
import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.CHANNEL_ILLUMINATION;
import java.util.function.Function;
import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
/**
*
* @author Dominik Krickl-Vorreiter - Initial contribution
*/
public class A5_06_01_ELTAKO extends _4BSMessage {
public A5_06_01_ELTAKO(ERP1Message packet) {
super(packet);
}
private State getIllumination() {
int db2 = getDB_2Value();
if (db2 == 0) {
int db3 = getDB_3Value();
return new QuantityType<>(db3 * 0.5, SmartHomeUnits.LUX);
} else {
return new QuantityType<>(db2 * 116.48 + 300.0, SmartHomeUnits.LUX);
}
}
@Override
protected State convertToStateImpl(String channelId, String channelTypeId,
Function<String, State> getCurrentStateFunc, Configuration config) {
switch (channelId) {
case CHANNEL_ILLUMINATION:
return getIllumination();
}
return UnDefType.UNDEF;
}
}

View File

@@ -0,0 +1,70 @@
/**
* 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.enocean.internal.eep.A5_07;
import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
import java.util.function.Function;
import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
/**
*
* @author Daniel Weber - Initial contribution
*/
public abstract class A5_07 extends _4BSMessage {
public A5_07(ERP1Message packet) {
super(packet);
}
protected abstract State getIllumination();
protected abstract State getMotion();
protected abstract State getSupplyVoltage();
protected State getSupplyVoltage(int value) {
if (value > 250) {
logger.warn("EEP A5-07 error code {}", value);
return UnDefType.UNDEF;
}
double voltage = value / 50.0; // 0..250 = 0.0..5.0V
return new QuantityType<>(voltage, SmartHomeUnits.VOLT);
}
@Override
protected State convertToStateImpl(String channelId, String channelTypeId,
Function<String, State> getCurrentStateFunc, Configuration config) {
if (!isValid()) {
return UnDefType.UNDEF;
}
if (channelId.equals(CHANNEL_ILLUMINATION)) {
return getIllumination();
} else if (channelId.equals(CHANNEL_MOTIONDETECTION)) {
return getMotion();
} else if (channelId.equals(CHANNEL_BATTERY_VOLTAGE)) {
return getSupplyVoltage();
}
return UnDefType.UNDEF;
}
}

View File

@@ -0,0 +1,50 @@
/**
* 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.enocean.internal.eep.A5_07;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_07_01 extends A5_07 {
private final int PIR_OFF = 0x7f;
public A5_07_01(ERP1Message packet) {
super(packet);
}
@Override
protected State getIllumination() {
return UnDefType.UNDEF;
}
@Override
protected State getMotion() {
return getDB_1Value() <= PIR_OFF ? OnOffType.OFF : OnOffType.ON;
}
@Override
protected State getSupplyVoltage() {
if (!getBit(getDB_0Value(), 0)) {
return UnDefType.UNDEF;
}
return getSupplyVoltage(getDB_3Value());
}
}

View File

@@ -0,0 +1,44 @@
/**
* 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.enocean.internal.eep.A5_07;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_07_02 extends A5_07 {
public A5_07_02(ERP1Message packet) {
super(packet);
}
@Override
protected State getIllumination() {
return UnDefType.UNDEF;
}
@Override
protected State getMotion() {
return getBit(getDB_0Value(), 7) ? OnOffType.ON : OnOffType.OFF;
}
@Override
protected State getSupplyVoltage() {
return getSupplyVoltage(getDB_3Value());
}
}

View File

@@ -0,0 +1,34 @@
/**
* 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.enocean.internal.eep.A5_07;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.types.State;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_07_03 extends A5_07_02 {
public A5_07_03(ERP1Message packet) {
super(packet);
}
@Override
protected State getIllumination() {
return new QuantityType<>((getDB_2Value() << 8) + ((getDB_1Value() & 0b11000000) >>> 6), SmartHomeUnits.LUX);
}
}

View File

@@ -0,0 +1,96 @@
/**
* 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.enocean.internal.eep.A5_08;
import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
import java.util.function.Function;
import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SIUnits;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
/**
*
* @author Daniel Weber - Initial contribution
*/
public abstract class A5_08 extends _4BSMessage {
public A5_08(ERP1Message packet) {
super(packet);
}
protected double getUnscaledTemperatureMin() {
return 0;
}
protected double getUnscaledTemperatureMax() {
return 255;
}
protected double getUnscaledIlluminationMin() {
return 0;
}
protected double getUnscaledIlluminationMax() {
return 255;
}
protected abstract double getScaledTemperatureMin();
protected abstract double getScaledTemperatureMax();
protected abstract double getScaledIlluminationMin();
protected abstract double getScaledIlluminationMax();
protected int getUnscaledTemperatureValue() {
return getDB_1Value();
}
protected int getUnscaledIlluminationValue() {
return getDB_2Value();
}
@Override
protected State convertToStateImpl(String channelId, String channelTypeId,
Function<String, State> getCurrentStateFunc, Configuration config) {
if (!isValid()) {
return UnDefType.UNDEF;
}
if (channelId.equals(CHANNEL_TEMPERATURE)) {
double scaledTemp = getScaledTemperatureMin()
+ ((getUnscaledTemperatureValue() * (getScaledTemperatureMax() - getScaledTemperatureMin()))
/ (getUnscaledTemperatureMax() - getUnscaledTemperatureMin()));
return new QuantityType<>(scaledTemp, SIUnits.CELSIUS);
} else if (channelId.equals(CHANNEL_ILLUMINATION)) {
double scaledIllumination = getScaledIlluminationMin()
+ ((getUnscaledIlluminationValue() * (getScaledIlluminationMax() - getScaledIlluminationMin()))
/ (getUnscaledIlluminationMax() - getUnscaledIlluminationMin()));
return new QuantityType<>(scaledIllumination, SmartHomeUnits.LUX);
} else if (channelId.equals(CHANNEL_MOTIONDETECTION)) {
return getBit(getDB_0(), 1) ? OnOffType.OFF : OnOffType.ON;
} else if (channelId.equals(CHANNEL_OCCUPANCY)) {
return getBit(getDB_0(), 0) ? OnOffType.OFF : OnOffType.ON;
}
return UnDefType.UNDEF;
}
}

View File

@@ -0,0 +1,46 @@
/**
* 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.enocean.internal.eep.A5_08;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_08_01 extends A5_08 {
public A5_08_01(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledTemperatureMin() {
return 0;
}
@Override
protected double getScaledTemperatureMax() {
return 51;
}
@Override
protected double getScaledIlluminationMin() {
return 0;
}
@Override
protected double getScaledIlluminationMax() {
return 510;
}
}

View File

@@ -0,0 +1,46 @@
/**
* 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.enocean.internal.eep.A5_08;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_08_01_FXBH extends A5_08 {
public A5_08_01_FXBH(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledTemperatureMin() {
return 0;
}
@Override
protected double getScaledTemperatureMax() {
return 1;
}
@Override
protected double getScaledIlluminationMin() {
return 0;
}
@Override
protected double getScaledIlluminationMax() {
return 2048;
}
}

View File

@@ -0,0 +1,46 @@
/**
* 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.enocean.internal.eep.A5_08;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_08_02 extends A5_08 {
public A5_08_02(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledTemperatureMin() {
return 0;
}
@Override
protected double getScaledTemperatureMax() {
return 51;
}
@Override
protected double getScaledIlluminationMin() {
return 0;
}
@Override
protected double getScaledIlluminationMax() {
return 1020;
}
}

View File

@@ -0,0 +1,46 @@
/**
* 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.enocean.internal.eep.A5_08;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_08_03 extends A5_08 {
public A5_08_03(ERP1Message packet) {
super(packet);
}
@Override
protected double getScaledTemperatureMin() {
return -30;
}
@Override
protected double getScaledTemperatureMax() {
return 50;
}
@Override
protected double getScaledIlluminationMin() {
return 0;
}
@Override
protected double getScaledIlluminationMax() {
return 1530;
}
}

View File

@@ -0,0 +1,74 @@
/**
* 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.enocean.internal.eep.A5_10;
import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
import java.util.function.Function;
import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.library.unit.SIUnits;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
/**
*
* @author Daniel Weber - Initial contribution
*/
public abstract class A5_10 extends _4BSMessage {
public A5_10(ERP1Message packet) {
super(packet);
}
@Override
protected State convertToStateImpl(String channelId, String channelTypeId,
Function<String, State> getCurrentStateFunc, Configuration config) {
if (!isValid()) {
return UnDefType.UNDEF;
}
switch (channelId) {
case CHANNEL_FANSPEEDSTAGE:
if (getDB_3Value() > 209) {
return new StringType("-1");
} else if (getDB_3Value() > 189) {
return new StringType("0");
} else if (getDB_3Value() > 164) {
return new StringType("1");
} else if (getDB_3Value() > 144) {
return new StringType("2");
} else {
return new StringType("3");
}
case CHANNEL_SETPOINT:
return new DecimalType(getDB_2Value());
case CHANNEL_TEMPERATURE:
double temp = (getDB_1Value() - 255) / -6.375;
return new QuantityType<>(temp, SIUnits.CELSIUS);
case CHANNEL_OCCUPANCY:
return getBit(getDB_0(), 0) ? OnOffType.OFF : OnOffType.ON;
}
return UnDefType.UNDEF;
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_01 extends A5_10 {
public A5_10_01(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_02 extends A5_10 {
public A5_10_02(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_03 extends A5_10 {
public A5_10_03(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_04 extends A5_10 {
public A5_10_04(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_05 extends A5_10 {
public A5_10_05(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_06 extends A5_10 {
public A5_10_06(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_07 extends A5_10 {
public A5_10_07(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_08 extends A5_10 {
public A5_10_08(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_09 extends A5_10 {
public A5_10_09(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_0A extends A5_10 {
public A5_10_0A(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_0B extends A5_10 {
public A5_10_0B(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_0C extends A5_10 {
public A5_10_0C(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_0D extends A5_10 {
public A5_10_0D(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_10 extends A5_10 {
public A5_10_10(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_11 extends A5_10 {
public A5_10_11(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_12 extends A5_10 {
public A5_10_12(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_13 extends A5_10 {
public A5_10_13(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_14 extends A5_10 {
public A5_10_14(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_15 extends A5_10 {
public A5_10_15(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_16 extends A5_10 {
public A5_10_16(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_17 extends A5_10 {
public A5_10_17(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_18 extends A5_10 {
public A5_10_18(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_19 extends A5_10 {
public A5_10_19(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_1A extends A5_10 {
public A5_10_1A(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_1B extends A5_10 {
public A5_10_1B(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_1C extends A5_10 {
public A5_10_1C(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_1D extends A5_10 {
public A5_10_1D(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_1E extends A5_10 {
public A5_10_1E(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_1F extends A5_10 {
public A5_10_1F(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_20 extends A5_10 {
public A5_10_20(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_21 extends A5_10 {
public A5_10_21(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_22 extends A5_10 {
public A5_10_22(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,26 @@
/**
* 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.enocean.internal.eep.A5_10;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
/**
*
* @author Daniel Weber - Initial contribution
*/
public class A5_10_23 extends A5_10 {
public A5_10_23(ERP1Message packet) {
super(packet);
}
}

View File

@@ -0,0 +1,103 @@
/**
* 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.enocean.internal.eep.A5_11;
import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
import java.util.function.Function;
import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.PercentType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
/**
*
* @author Dominik Krickl-Vorreiter - Initial contribution
*/
public class A5_11_03 extends _4BSMessage {
public A5_11_03(ERP1Message packet) {
super(packet);
}
protected boolean isErrorState() {
byte db1 = getDB_1();
int state = (db1 >> 4) & 0x03;
if (state != 0) {
// TODO: display error state on thing
return true;
} else {
return false;
}
}
protected State getPositionData() {
byte db1 = getDB_1();
boolean pvf = getBit(db1, 7);
if (pvf) {
byte db0 = getDB_0();
boolean motp = getBit(db0, 6);
int bsp = getDB_3Value();
if ((bsp >= 0) && (bsp <= 100)) {
return new PercentType(motp ? 100 - bsp : bsp);
}
}
return UnDefType.UNDEF;
}
protected State getAngleData() {
byte db1 = getDB_1();
boolean avf = getBit(db1, 6);
if (avf) {
byte db2 = getDB_2();
boolean as = getBit(db2, 7);
int an = (db2 & 0x7F) * 2;
if ((an >= 0) && (an <= 180)) {
return new QuantityType<>(as ? an * -1 : an, SmartHomeUnits.DEGREE_ANGLE);
}
}
return UnDefType.UNDEF;
}
@Override
protected State convertToStateImpl(String channelId, String channelTypeId,
Function<String, State> getCurrentStateFunc, Configuration config) {
if (isErrorState()) {
return UnDefType.UNDEF;
}
switch (channelId) {
case CHANNEL_ROLLERSHUTTER:
return getPositionData();
case CHANNEL_ANGLE:
return getAngleData();
}
return UnDefType.UNDEF;
}
}

View File

@@ -0,0 +1,205 @@
/**
* 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.enocean.internal.eep.A5_11;
import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
import java.util.function.Function;
import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
import org.openhab.binding.enocean.internal.eep.EEPHelper;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.PercentType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
import org.openhab.core.util.HexUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Vincent Bakker - Initial contribution
*/
public class A5_11_04 extends _4BSMessage {
private enum Error {
NO_ERROR_PRESENT,
LAMP_FAILURE,
INTERNAL_FAILURE,
FAILURE_ON_THE_EXTERNAL_PERIPHERY
}
private enum ParameterMode {
EIGHT_BIT_DIMMER_VALUE_AND_LAMP_OPERATING_HOURS,
RGB_VALUE,
ENERGY_METERING_VALUE,
NOT_USED
}
public enum EnergyUnit {
MILLIWATT,
WATT,
KILOWATT,
MEGAWATT,
WATTHOUR,
KILOWATTHOUR,
MEGAWATTHOUR,
GIGAWATTHOUR,
NOT_SUPPORTED
}
private static Logger logger = LoggerFactory.getLogger(A5_11_04.class);
public A5_11_04(ERP1Message packet) {
super(packet);
}
protected boolean isErrorState() {
byte db0 = getDB_0();
int state = (db0 >> 4) & 0x03;
if (state != 0) {
// TODO: display error state on thing
logger.warn("Received error {}: {}", state, Error.values()[state]);
return true;
} else {
return false;
}
}
protected ParameterMode getParameterMode() {
int pm = (getDB_0() >> 1) & 0x03;
return ParameterMode.values()[pm];
}
protected EnergyUnit getEnergyUnit() {
int unit = getDB_1();
if (unit < 8) {
return EnergyUnit.values()[unit];
}
return EnergyUnit.NOT_SUPPORTED;
}
protected State getLightingStatus() {
byte db0 = getDB_0();
boolean lightOn = getBit(db0, 0);
return lightOn ? OnOffType.ON : OnOffType.OFF;
}
protected State getDimmerStatus() {
if (getParameterMode() == ParameterMode.EIGHT_BIT_DIMMER_VALUE_AND_LAMP_OPERATING_HOURS) {
return new PercentType(getDB_3Value() * 100 / 255);
}
return UnDefType.UNDEF;
}
protected State getEnergyMeasurementData() {
if (getParameterMode() == ParameterMode.ENERGY_METERING_VALUE) {
EnergyUnit unit = getEnergyUnit();
float factor = 1;
switch (unit) {
case WATTHOUR:
factor /= 1000;
break;
case KILOWATTHOUR:
factor = 1;
break;
case GIGAWATTHOUR:
factor *= 1000;
case MEGAWATTHOUR:
factor *= 1000;
break;
default:
return UnDefType.UNDEF;
}
return new QuantityType<>(
Long.parseLong(HexUtils.bytesToHex(new byte[] { getDB_3(), getDB_2() }), 16) * factor,
SmartHomeUnits.KILOWATT_HOUR);
}
return UnDefType.UNDEF;
}
protected State getPowerMeasurementData() {
if (getParameterMode() == ParameterMode.ENERGY_METERING_VALUE) {
EnergyUnit unit = getEnergyUnit();
float factor = 1;
switch (unit) {
case MILLIWATT:
factor /= 1000;
break;
case WATT:
factor = 1;
break;
case MEGAWATT:
factor *= 1000;
case KILOWATT:
factor *= 1000;
break;
default:
return UnDefType.UNDEF;
}
return new QuantityType<>(
Long.parseLong(HexUtils.bytesToHex(new byte[] { getDB_3(), getDB_2() }), 16) * factor,
SmartHomeUnits.WATT);
}
return UnDefType.UNDEF;
}
protected State getOperatingHours() {
if (getParameterMode() == ParameterMode.EIGHT_BIT_DIMMER_VALUE_AND_LAMP_OPERATING_HOURS) {
return new DecimalType(getDB_2Value() << 8 + getDB_1Value());
}
return UnDefType.UNDEF;
}
@Override
protected State convertToStateImpl(String channelId, String channelTypeId,
Function<String, State> getCurrentStateFunc, Configuration config) {
if (isErrorState()) {
return UnDefType.UNDEF;
}
switch (channelId) {
case CHANNEL_GENERAL_SWITCHING:
return getLightingStatus();
case CHANNEL_DIMMER:
return getDimmerStatus();
case CHANNEL_INSTANTPOWER:
return getPowerMeasurementData();
case CHANNEL_TOTALUSAGE:
State value = getEnergyMeasurementData();
State currentState = getCurrentStateFunc.apply(channelId);
return EEPHelper.validateTotalUsage(value, currentState, config);
case CHANNEL_COUNTER:
return getOperatingHours();
}
return UnDefType.UNDEF;
}
}

View File

@@ -0,0 +1,134 @@
/**
* 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.enocean.internal.eep.A5_12;
import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
import java.util.function.Function;
import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
import org.openhab.binding.enocean.internal.eep.EEPHelper;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
import org.openhab.core.util.HexUtils;
/**
*
* @author Dominik Krickl-Vorreiter - Initial contribution
*/
public abstract class A5_12 extends _4BSMessage {
public A5_12(ERP1Message packet) {
super(packet);
}
protected State calcCumulativeValue(float value) {
return new QuantityType<>(value, SmartHomeUnits.ONE);
}
protected State calcCurrentValue(float value) {
return new QuantityType<>(value, SmartHomeUnits.ONE);
}
protected State getCumulativeValue() {
byte db0 = getDB_0();
boolean dt = getBit(db0, 2);
if (!dt) {
byte div = (byte) (db0 & 0x03);
float factor = 1;
switch (div) {
case 0:
factor = 1;
break;
case 1:
factor /= 10;
break;
case 2:
factor /= 100;
break;
case 3:
factor /= 1000;
break;
default:
return UnDefType.UNDEF;
}
float cumulativeValue = Long.parseLong(HexUtils.bytesToHex(new byte[] { getDB_3(), getDB_2(), getDB_1() }),
16) * factor;
return calcCumulativeValue(cumulativeValue);
}
return UnDefType.UNDEF;
}
protected State getCurrentValue() {
byte db0 = getDB_0();
boolean dt = getBit(db0, 2);
if (dt) {
byte div = (byte) (db0 & 0x03);
float factor = 1;
switch (div) {
case 0:
factor = 1;
break;
case 1:
factor /= 10;
break;
case 2:
factor /= 100;
break;
case 3:
factor /= 1000;
break;
default:
return UnDefType.UNDEF;
}
float currentValue = Long.parseLong(HexUtils.bytesToHex(new byte[] { getDB_3(), getDB_2(), getDB_1() }), 16)
* factor;
return calcCurrentValue(currentValue);
}
return UnDefType.UNDEF;
}
@Override
protected State convertToStateImpl(String channelId, String channelTypeId,
Function<String, State> getCurrentStateFunc, Configuration config) {
switch (channelId) {
case CHANNEL_INSTANTPOWER:
case CHANNEL_CURRENTFLOW:
case CHANNEL_CURRENTNUMBER:
return getCurrentValue();
case CHANNEL_TOTALUSAGE:
State value = getCumulativeValue();
State currentState = getCurrentStateFunc.apply(channelId);
return EEPHelper.validateTotalUsage(value, currentState, config);
case CHANNEL_CUMULATIVEVALUE:
case CHANNEL_COUNTER:
return getCumulativeValue();
}
return UnDefType.UNDEF;
}
}

Some files were not shown because too many files have changed in this diff Show More