From 059ad2d5dba39626cfddc77af35027c420fd7610 Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 22 Mar 2017 14:06:52 +0100 Subject: [PATCH 1/9] Refactoring of the MySensors binding (#74) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Initial commit of the refactored binding from @andreacioni * mvn license:format execution * mvn license:format execution (2) * mvn clean install -P check --> corrections * Changes to apply OpenHAB coding guidelines Signed-off-by: Tim Oberföll --- .../org.openhab.binding.mysensors/.classpath | 9 + .../org.openhab.binding.mysensors/.gitignore | 1 + .../org.openhab.binding.mysensors/.project | 33 + .../.settings/org.eclipse.jdt.core.prefs | 7 + .../ESH-INF/binding/binding.xml | 11 + .../ESH-INF/thing/thing-types.xml | 2389 +++++++++++++++++ .../META-INF/MANIFEST.MF | 34 + .../OSGI-INF/MySensorsDiscovery.xml | 17 + .../OSGI-INF/MySensorsHandlerFactory.xml | 19 + .../org.openhab.binding.mysensors/README.md | 7 + .../org.openhab.binding.mysensors/about.html | 28 + .../build.properties | 7 + .../org.openhab.binding.mysensors/pom.xml | 33 + .../mysensors/MySensorsBindingConstants.java | 381 +++ .../config/MySensorsBridgeConfiguration.java | 41 + .../config/MySensorsSensorConfiguration.java | 66 + .../MySensorsDecimalTypeConverter.java | 26 + .../MySensorsOnOffTypeConverter.java | 49 + .../MySensorsOpenCloseTypeConverter.java | 49 + .../MySensorsPercentTypeConverter.java | 26 + .../MySensorsStringTypeConverter.java | 27 + .../converter/MySensorsTypeConverter.java | 67 + .../MySensorsUpDownTypeConverter.java | 94 + .../discovery/MySensorsDiscoveryService.java | 110 + .../factory/MySensorsCacheFactory.java | 138 + .../factory/MySensorsHandlerFactory.java | 54 + .../handler/MySensorsBridgeHandler.java | 238 ++ .../handler/MySensorsThingHandler.java | 396 +++ .../binding/mysensors/internal/Mergeable.java | 28 + .../mysensors/internal/MySensorsUtility.java | 83 + .../internal/event/EventRegister.java | 102 + .../event/MySensorsEventRegister.java | 163 ++ .../event/MySensorsGatewayEventListener.java | 85 + .../event/MySensorsNodeUpdateEventType.java | 15 + .../mysensors/internal/event/Register.java | 55 + .../internal/exception/MergeException.java | 30 + .../internal/exception/NoAckException.java | 31 + .../exception/NoContentException.java | 30 + .../exception/NoMoreIdsException.java | 24 + .../exception/NotInitializedException.java | 30 + .../RevertVariableStateException.java | 24 + .../internal/gateway/MySensorsGateway.java | 735 +++++ .../gateway/MySensorsGatewayConfig.java | 202 ++ .../gateway/MySensorsGatewayType.java | 14 + .../MySensorsNetworkSanityChecker.java | 268 ++ .../protocol/MySensorsAbstractConnection.java | 750 ++++++ .../protocol/ip/MySensorsIpConnection.java | 97 + .../protocol/message/MySensorsMessage.java | 665 +++++ .../serial/MySensorsSerialConnection.java | 163 ++ .../internal/sensors/MySensorsChild.java | 371 +++ .../sensors/MySensorsChildConfig.java | 90 + .../internal/sensors/MySensorsNode.java | 342 +++ .../internal/sensors/MySensorsNodeConfig.java | 69 + .../internal/sensors/MySensorsVariable.java | 121 + .../child/MySensorsChildSAirQuality.java | 38 + .../child/MySensorsChildSArduinoNode.java | 29 + .../MySensorsChildSArduinoRepeaterNode.java | 30 + .../sensors/child/MySensorsChildSBaro.java | 38 + .../sensors/child/MySensorsChildSBinary.java | 38 + .../child/MySensorsChildSColorSensor.java | 36 + .../sensors/child/MySensorsChildSCover.java | 42 + .../sensors/child/MySensorsChildSCustom.java | 29 + .../sensors/child/MySensorsChildSDimmer.java | 40 + .../child/MySensorsChildSDistance.java | 38 + .../sensors/child/MySensorsChildSDoor.java | 38 + .../sensors/child/MySensorsChildSDust.java | 38 + .../sensors/child/MySensorsChildSGas.java | 38 + .../sensors/child/MySensorsChildSGps.java | 36 + .../sensors/child/MySensorsChildSHeater.java | 42 + .../sensors/child/MySensorsChildSHum.java | 36 + .../sensors/child/MySensorsChildSHvac.java | 48 + .../sensors/child/MySensorsChildSInfo.java | 36 + .../sensors/child/MySensorsChildSIr.java | 40 + .../child/MySensorsChildSLightLevel.java | 38 + .../sensors/child/MySensorsChildSLock.java | 36 + .../child/MySensorsChildSMoisture.java | 40 + .../sensors/child/MySensorsChildSMotion.java | 38 + .../child/MySensorsChildSMultimeter.java | 40 + .../sensors/child/MySensorsChildSPower.java | 44 + .../sensors/child/MySensorsChildSRain.java | 38 + .../child/MySensorsChildSRgbLight.java | 38 + .../child/MySensorsChildSRgbwLight.java | 38 + .../child/MySensorsChildSSceneController.java | 38 + .../sensors/child/MySensorsChildSSmoke.java | 38 + .../sensors/child/MySensorsChildSSound.java | 40 + .../child/MySensorsChildSSprinkler.java | 38 + .../sensors/child/MySensorsChildSTemp.java | 38 + .../sensors/child/MySensorsChildSUv.java | 36 + .../child/MySensorsChildSVibration.java | 40 + .../sensors/child/MySensorsChildSWater.java | 38 + .../child/MySensorsChildSWaterLeak.java | 38 + .../child/MySensorsChildSWaterQuality.java | 44 + .../sensors/child/MySensorsChildSWeight.java | 38 + .../sensors/child/MySensorsChildSWind.java | 40 + .../variable/MySensorsVariableVArmed.java | 28 + .../variable/MySensorsVariableVCurrent.java | 28 + .../variable/MySensorsVariableVCustom.java | 28 + .../variable/MySensorsVariableVDirection.java | 28 + .../variable/MySensorsVariableVDistance.java | 28 + .../variable/MySensorsVariableVDown.java | 28 + .../variable/MySensorsVariableVEc.java | 28 + .../variable/MySensorsVariableVFlow.java | 28 + .../variable/MySensorsVariableVForecast.java | 28 + .../variable/MySensorsVariableVGust.java | 28 + .../variable/MySensorsVariableVHum.java | 28 + .../MySensorsVariableVHvacFlowMode.java | 28 + .../MySensorsVariableVHvacFlowState.java | 28 + .../MySensorsVariableVHvacSetpointCool.java | 28 + .../MySensorsVariableVHvacSetpointHeat.java | 28 + .../variable/MySensorsVariableVHvacSpeed.java | 28 + .../variable/MySensorsVariableVId.java | 28 + .../variable/MySensorsVariableVImpedance.java | 28 + .../variable/MySensorsVariableVIrReceive.java | 28 + .../variable/MySensorsVariableVIrRecord.java | 28 + .../variable/MySensorsVariableVIrSend.java | 28 + .../variable/MySensorsVariableVKwh.java | 28 + .../variable/MySensorsVariableVLevel.java | 28 + .../MySensorsVariableVLightLevel.java | 28 + .../MySensorsVariableVLockStatus.java | 28 + .../variable/MySensorsVariableVOrp.java | 28 + .../MySensorsVariableVPercentage.java | 28 + .../variable/MySensorsVariableVPh.java | 28 + .../variable/MySensorsVariableVPosition.java | 28 + .../MySensorsVariableVPowerFactor.java | 28 + .../variable/MySensorsVariableVPressure.java | 28 + .../variable/MySensorsVariableVRain.java | 28 + .../variable/MySensorsVariableVRainrate.java | 28 + .../variable/MySensorsVariableVRgb.java | 28 + .../variable/MySensorsVariableVRgbw.java | 28 + .../variable/MySensorsVariableVSceneOff.java | 28 + .../variable/MySensorsVariableVSceneOn.java | 28 + .../variable/MySensorsVariableVStatus.java | 28 + .../variable/MySensorsVariableVStop.java | 28 + .../variable/MySensorsVariableVTemp.java | 28 + .../variable/MySensorsVariableVText.java | 28 + .../variable/MySensorsVariableVTripped.java | 28 + .../MySensorsVariableVUnitPrefix.java | 28 + .../variable/MySensorsVariableVUp.java | 28 + .../variable/MySensorsVariableVUv.java | 28 + .../variable/MySensorsVariableVVa.java | 28 + .../variable/MySensorsVariableVVar.java | 28 + .../variable/MySensorsVariableVVar1.java | 28 + .../variable/MySensorsVariableVVar2.java | 28 + .../variable/MySensorsVariableVVar3.java | 28 + .../variable/MySensorsVariableVVar4.java | 28 + .../variable/MySensorsVariableVVar5.java | 28 + .../variable/MySensorsVariableVVoltage.java | 28 + .../variable/MySensorsVariableVVolume.java | 28 + .../variable/MySensorsVariableVWatt.java | 28 + .../variable/MySensorsVariableVWeight.java | 28 + .../variable/MySensorsVariableVWind.java | 28 + .../binding/mysensors/test/CacheTest.java | 56 + .../mysensors/test/DiscoveryServiceTest.java | 32 + .../binding/mysensors/test/MessageTest.java | 52 + .../mysensors/test/MySensorsUtilityTest.java | 103 + .../binding/mysensors/test/NodeChildTest.java | 37 + .../binding/mysensors/test/VariableTest.java | 53 + .../test/iVersionMessage.sh | 5 + .../test/smartSleepTest.sh | 12 + .../test/testscript.sh | 211 ++ addons/binding/pom.xml | 3 +- 161 files changed, 12629 insertions(+), 1 deletion(-) create mode 100644 addons/binding/org.openhab.binding.mysensors/.classpath create mode 100644 addons/binding/org.openhab.binding.mysensors/.gitignore create mode 100644 addons/binding/org.openhab.binding.mysensors/.project create mode 100644 addons/binding/org.openhab.binding.mysensors/.settings/org.eclipse.jdt.core.prefs create mode 100644 addons/binding/org.openhab.binding.mysensors/ESH-INF/binding/binding.xml create mode 100644 addons/binding/org.openhab.binding.mysensors/ESH-INF/thing/thing-types.xml create mode 100644 addons/binding/org.openhab.binding.mysensors/META-INF/MANIFEST.MF create mode 100644 addons/binding/org.openhab.binding.mysensors/OSGI-INF/MySensorsDiscovery.xml create mode 100644 addons/binding/org.openhab.binding.mysensors/OSGI-INF/MySensorsHandlerFactory.xml create mode 100644 addons/binding/org.openhab.binding.mysensors/README.md create mode 100644 addons/binding/org.openhab.binding.mysensors/about.html create mode 100644 addons/binding/org.openhab.binding.mysensors/build.properties create mode 100644 addons/binding/org.openhab.binding.mysensors/pom.xml create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/MySensorsBindingConstants.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/config/MySensorsBridgeConfiguration.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/config/MySensorsSensorConfiguration.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsDecimalTypeConverter.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsOnOffTypeConverter.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsOpenCloseTypeConverter.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsPercentTypeConverter.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsStringTypeConverter.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsTypeConverter.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsUpDownTypeConverter.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/discovery/MySensorsDiscoveryService.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/factory/MySensorsCacheFactory.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/factory/MySensorsHandlerFactory.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/handler/MySensorsBridgeHandler.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/handler/MySensorsThingHandler.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/Mergeable.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/MySensorsUtility.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/event/EventRegister.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/event/MySensorsEventRegister.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/event/MySensorsGatewayEventListener.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/event/MySensorsNodeUpdateEventType.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/event/Register.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/MergeException.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/NoAckException.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/NoContentException.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/NoMoreIdsException.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/NotInitializedException.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/RevertVariableStateException.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/gateway/MySensorsGateway.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/gateway/MySensorsGatewayConfig.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/gateway/MySensorsGatewayType.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/gateway/MySensorsNetworkSanityChecker.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/protocol/MySensorsAbstractConnection.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/protocol/ip/MySensorsIpConnection.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/protocol/message/MySensorsMessage.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/protocol/serial/MySensorsSerialConnection.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/MySensorsChild.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/MySensorsChildConfig.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/MySensorsNode.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/MySensorsNodeConfig.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/MySensorsVariable.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSAirQuality.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSArduinoNode.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSArduinoRepeaterNode.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSBaro.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSBinary.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSColorSensor.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSCover.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSCustom.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSDimmer.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSDistance.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSDoor.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSDust.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSGas.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSGps.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSHeater.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSHum.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSHvac.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSInfo.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSIr.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSLightLevel.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSLock.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSMoisture.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSMotion.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSMultimeter.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSPower.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSRain.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSRgbLight.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSRgbwLight.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSSceneController.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSSmoke.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSSound.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSSprinkler.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSTemp.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSUv.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSVibration.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSWater.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSWaterLeak.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSWaterQuality.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSWeight.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSWind.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVArmed.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVCurrent.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVCustom.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVDirection.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVDistance.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVDown.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVEc.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVFlow.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVForecast.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVGust.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHum.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHvacFlowMode.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHvacFlowState.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHvacSetpointCool.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHvacSetpointHeat.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHvacSpeed.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVId.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVImpedance.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVIrReceive.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVIrRecord.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVIrSend.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVKwh.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVLevel.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVLightLevel.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVLockStatus.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVOrp.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVPercentage.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVPh.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVPosition.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVPowerFactor.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVPressure.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVRain.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVRainrate.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVRgb.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVRgbw.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVSceneOff.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVSceneOn.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVStatus.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVStop.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVTemp.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVText.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVTripped.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVUnitPrefix.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVUp.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVUv.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVa.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar1.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar2.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar3.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar4.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar5.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVoltage.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVolume.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVWatt.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVWeight.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVWind.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/CacheTest.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/DiscoveryServiceTest.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/MessageTest.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/MySensorsUtilityTest.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/NodeChildTest.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/VariableTest.java create mode 100755 addons/binding/org.openhab.binding.mysensors/test/iVersionMessage.sh create mode 100755 addons/binding/org.openhab.binding.mysensors/test/smartSleepTest.sh create mode 100755 addons/binding/org.openhab.binding.mysensors/test/testscript.sh diff --git a/addons/binding/org.openhab.binding.mysensors/.classpath b/addons/binding/org.openhab.binding.mysensors/.classpath new file mode 100644 index 000000000000..1ff253c6199b --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/addons/binding/org.openhab.binding.mysensors/.gitignore b/addons/binding/org.openhab.binding.mysensors/.gitignore new file mode 100644 index 000000000000..6fac264911ec --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/.gitignore @@ -0,0 +1 @@ +/*.cached diff --git a/addons/binding/org.openhab.binding.mysensors/.project b/addons/binding/org.openhab.binding.mysensors/.project new file mode 100644 index 000000000000..2f1535aa83d5 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/.project @@ -0,0 +1,33 @@ + + + org.openhab.binding.mysensors + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.pde.ds.core.builder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/addons/binding/org.openhab.binding.mysensors/.settings/org.eclipse.jdt.core.prefs b/addons/binding/org.openhab.binding.mysensors/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..0c68a61dca86 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/addons/binding/org.openhab.binding.mysensors/ESH-INF/binding/binding.xml b/addons/binding/org.openhab.binding.mysensors/ESH-INF/binding/binding.xml new file mode 100644 index 000000000000..38d25ff13cb3 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/ESH-INF/binding/binding.xml @@ -0,0 +1,11 @@ + + + + MySensors Binding + This is the binding for MySensors. + Tim Oberföll + + diff --git a/addons/binding/org.openhab.binding.mysensors/ESH-INF/thing/thing-types.xml b/addons/binding/org.openhab.binding.mysensors/ESH-INF/thing/thing-types.xml new file mode 100644 index 000000000000..cf2f3bc327b1 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/ESH-INF/thing/thing-types.xml @@ -0,0 +1,2389 @@ + + + + + + + + MySensors Gateway connected via serial port + + + + + The serial port the MySensors Gateway is connected to + + + + + Baudrate for serial port + + 115200 + + + + + + + The delay between messages send to the gateway + + 100 + + + + Allow the user to bypass the I_VERSION check on startup + false + + + + Metric answer with imperial instead of metric + false + + + + Network sanity check periodically unsure that gateway is up and running + false + + + + Network sanity check periodically unsure that gateway is up and running + 3 + + + + When gateway not respond, you could configure how many retry, sanity check, will do + 3 + + + + When network sanity checker run, send heartbeat to all nodes + false + + + + When nodes not respond to heartbeat, you could configure how many retry, sanity check, will do before + disconnecting them + + 10 + + + + + + + + + + + MySensors Gateway connected via ethernet/IP + + + + + The IP Address the MySensors Gateway uses + + + + + The TCP Port the MySensors Gateway uses (usually 5003) + + 5003 + + + + + + + The delay between messages send to the gateway + + 100 + + + + Allow the user to bypass the I_VERSION check on startup + false + + + + Metric answer with imperial instead of metric + false + + + + Network sanity check periodically unsure that gateway is up and running + false + + + + Network sanity check periodically unsure that gateway is up and running + 3 + + + + When gateway not respond, you could configure how many retry, sanity check, will do before + disconnecting it + + 3 + + + + When network sanity checker run, send heartbeat to all nodes + false + + + + When nodes not respond to heartbeat, you could configure how many retry, sanity check, will do before + disconnecting them + + 10 + + + + + + + + + + + + + + + + + + Humidity sensor + + + + + + + + + + + NodeId + + The ID of the node in the MySensors network + + + + ChildId + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + + Temperature sensor + + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + + Multimeter sensor + + + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Light + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Power-Sensor + + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the first child, displaying watt, of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Barometer + + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Door + + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Motion detection + + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Smoke detection + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Dimmer + + + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + RollerShutter + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Wind + + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Rain + + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + UV + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Weight + + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Distance + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Light level + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Thermostat + + + + + + + + + + + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Water flow meter + + + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Custom Sensor with VAR1 - VAR5 channels -> Values are also transmitted to the sensor + + + + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Lock sensor + + + + + + + + + + NodeId + + The ID of the node in the MySensors network + + + + ChildId + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Level sensor + + + + + + + + + + + + NodeId + + The ID of the node in the MySensors network + + + + ChildId + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + RGB light sensor + + + + + + + + + + + + + NodeId + + The ID of the node in the MySensors network + + + + ChildId + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + RGBW light sensor + + + + + + + + + + + + + + NodeId + + The ID of the node in the MySensors network + + + + ChildId + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + PH meter sensor + + + + + + + + + + + + + NodeId + + The ID of the node in the MySensors network + + + + ChildId + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + Shows the complete MySensors Message + + + + + + + + + NodeId + + The ID of the node in the MySensors network + + 999 + + + ChildId + + The ID of the child of a node in the MySensors network + + 999 + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + V_TEXT + + + + + + + + + NodeId + + The ID of the node in the MySensors network + + 999 + + + ChildId + + The ID of the child of a node in the MySensors network + + 999 + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Receive IR codes + + + + + + + + + + NodeId + + The ID of the node in the MySensors network + + 999 + + + ChildId + + The ID of the child of a node in the MySensors network + + 999 + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Air Quality Meter + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Dust Meter + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + + + + + Color Sensor + + + + + + + + + + + The ID of the node in the MySensors network + + + + + The ID of the child of a node in the MySensors network + + + + + Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + + -1 + + + + Minutes after, if no message received, thing will be set to OFFLINE + -1 + + + + If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with + same node ID will be set OFFLINE. + false + + + + Request ACK from Actuator + false + + + + Revert state if no Ack received + true + + + + Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + false + + + + + + + + Number + + MySensors Humidity Channel + Humidity + + + + Number + + MySensors Temperature Channel + Temperature + + + + Number + + MySensors Volt Channel + Energy + + + + Number + + MySensors Current Channel + Energy + + + + Switch + + Status + Light + + + + Number + + MySensors Watt Channel + Energy + + + + Number + + MySensors KWH Channel + Energy + + + + Number + + MySensors Pressure Channel + Weather + + + String + + MySensors Forecast Channel + Weather + + + Contact + + Tripped Status + + + + Switch + + Armed Status + + + Dimmer + + Dimmer + LightVolume + + + + Rollershutter + + Cover + Blinds + + + Number + + Wind speed + Wind + + + Number + + Wind gust + Wind + + + Number + + Amount of rain + Rain + + + Number + + Rain rate + Rain + + + Number + + UV + Light + + + Number + + Weight + + + Number + + Impedance + + + Number + + Distance + + + Number + + Light level + + + Number + + MySensors Version + + + Number + + MySensors Battery Channel + Energy + + + + DateTime + + MySensors Last Update + + + + Number + + MySensors Set point Heat Channel + Heating + + + Number + + MySensors Set point Cool Channel + Heating + + + String + + MySensors HVAC Flow State Channel + Heating + + + String + + MySensors HVAC Speed Channel + Heating + + + String + + MySensors HVAC Flow Mode Channel + Heating + + + Number + + MySensors var1 Channel + Variable + + + Number + + MySensors var2 Channel + Variable + + + Number + + MySensors var3 Channel + Variable + + + Number + + MySensors var4 Channel + Variable + + + Number + + MySensors var5 Channel + Variable + + + Number + + MySensors Water Flow Channel + + + Number + + MySensors Water Volume Channel + + + Status + + MySensors Lock Channel + + + + Number + + MySensors Level Channel + + + + Number + + MySensors PH Meter Channel + + + + Number + + MySensors Water ORP Channel + + + + Number + + MySensors Water Electric Condictivity Channel + + + + String + + MySensors Message Channel + + + + String + + MySensors Text Channel + Variable + + + String + + MySensors IR Send Channel + Variable + + + String + + MySensors IR Receive Channel + Variable + + + String + + MySensors RGB Channel + Variable + + diff --git a/addons/binding/org.openhab.binding.mysensors/META-INF/MANIFEST.MF b/addons/binding/org.openhab.binding.mysensors/META-INF/MANIFEST.MF new file mode 100644 index 000000000000..7f6cb434e0a0 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/META-INF/MANIFEST.MF @@ -0,0 +1,34 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: MySensors Binding +Bundle-SymbolicName: org.openhab.binding.mysensors;singleton:=true +Bundle-Vendor: openHAB +Bundle-Version: 2.1.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Bundle-ClassPath: . +Import-Package: + com.google.common.base, + com.google.common.collect, + com.google.gson, + com.google.gson.reflect, + com.google.gson.stream, + gnu.io, + org.apache.commons.lang, + org.eclipse.smarthome.config.core, + org.eclipse.smarthome.config.discovery, + org.eclipse.smarthome.core.common.registry, + org.eclipse.smarthome.core.library.types, + org.eclipse.smarthome.core.thing, + org.eclipse.smarthome.core.thing.binding, + org.eclipse.smarthome.core.thing.binding.builder, + org.eclipse.smarthome.core.thing.type, + org.eclipse.smarthome.core.types, + org.openhab.binding.mysensors, + org.openhab.binding.mysensors.handler, + org.osgi.framework, + org.osgi.service.cm, + org.osgi.service.component, + org.slf4j +Service-Component: OSGI-INF/*.xml +Export-Package: org.openhab.binding.mysensors, + org.openhab.binding.mysensors.handler diff --git a/addons/binding/org.openhab.binding.mysensors/OSGI-INF/MySensorsDiscovery.xml b/addons/binding/org.openhab.binding.mysensors/OSGI-INF/MySensorsDiscovery.xml new file mode 100644 index 000000000000..df498775bc43 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/OSGI-INF/MySensorsDiscovery.xml @@ -0,0 +1,17 @@ + + + + + + + + diff --git a/addons/binding/org.openhab.binding.mysensors/OSGI-INF/MySensorsHandlerFactory.xml b/addons/binding/org.openhab.binding.mysensors/OSGI-INF/MySensorsHandlerFactory.xml new file mode 100644 index 000000000000..77d01b826a4d --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/OSGI-INF/MySensorsHandlerFactory.xml @@ -0,0 +1,19 @@ + + + + + + + + + + diff --git a/addons/binding/org.openhab.binding.mysensors/README.md b/addons/binding/org.openhab.binding.mysensors/README.md new file mode 100644 index 000000000000..8d58527e717b --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/README.md @@ -0,0 +1,7 @@ +# MySensors OpenHAB 2.x Binding + +Binding for OpenHAB 2.x to MySensors (https://www.mysensors.org) + +For more information on the features take a look at the summary at https://www.mysensors.org/controller + +Installation, configuration and examples are described in the wiki https://github.com/tobof/openhab2-addons/wiki diff --git a/addons/binding/org.openhab.binding.mysensors/about.html b/addons/binding/org.openhab.binding.mysensors/about.html new file mode 100644 index 000000000000..d0e7ae81be96 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/about.html @@ -0,0 +1,28 @@ + + + + +About + + +

About This Content

+ +

January 4, 2017

+

License

+ +

The openHAB community makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the openHAB community, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at openhab.org.

+ + + \ No newline at end of file diff --git a/addons/binding/org.openhab.binding.mysensors/build.properties b/addons/binding/org.openhab.binding.mysensors/build.properties new file mode 100644 index 000000000000..276bfe92d2e1 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/build.properties @@ -0,0 +1,7 @@ +source.. = src/main/java/ +output.. = target/classes +bin.includes = META-INF/,\ + .,\ + OSGI-INF/,\ + ESH-INF/ +src.excludes = src/main/test/ diff --git a/addons/binding/org.openhab.binding.mysensors/pom.xml b/addons/binding/org.openhab.binding.mysensors/pom.xml new file mode 100644 index 000000000000..df199e823f08 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/pom.xml @@ -0,0 +1,33 @@ + + + + 4.0.0 + + + org.openhab.binding + pom + 2.1.0-SNAPSHOT + + + org.openhab.binding.mysensors + + MySensors Binding + eclipse-plugin + + + + + ${tycho-groupid} + tycho-compiler-plugin + ${tycho-version} + + UTF-8 + 1.8 + 1.8 + + + + + + + diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/MySensorsBindingConstants.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/MySensorsBindingConstants.java new file mode 100644 index 000000000000..583ca65f7a7d --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/MySensorsBindingConstants.java @@ -0,0 +1,381 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors; + +import static org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage.*; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.eclipse.smarthome.core.thing.ThingTypeUID; +import org.openhab.binding.mysensors.converter.MySensorsDecimalTypeConverter; +import org.openhab.binding.mysensors.converter.MySensorsOnOffTypeConverter; +import org.openhab.binding.mysensors.converter.MySensorsOpenCloseTypeConverter; +import org.openhab.binding.mysensors.converter.MySensorsPercentTypeConverter; +import org.openhab.binding.mysensors.converter.MySensorsStringTypeConverter; +import org.openhab.binding.mysensors.converter.MySensorsTypeConverter; +import org.openhab.binding.mysensors.converter.MySensorsUpDownTypeConverter; +import org.openhab.binding.mysensors.internal.MySensorsUtility; + +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; + +/** + * The {@link MySensorsBinding} class defines common constants, which are + * used across the whole binding. + * + * @author Tim Oberföll + */ +public class MySensorsBindingConstants { + + public static final String BINDING_ID = "mysensors"; + + // parameters / fields of a MySensors message + public static final String PARAMETER_NODEID = "nodeId"; + public static final String PARAMETER_CHILDID = "childId"; + public static final String PARAMETER_IPADDRESS = "ipAddress"; + public static final String PRAMETER_TCPPORT = "tcpPort"; + public static final String PARAMETER_SENDDELAY = "sendDelay"; + public static final String PARAMETER_BAUDRATE = "baudRate"; + public static final String PARAMETER_REQUESTACK = "requestack"; + + /** + * All knowing thing. A node with nodeId 999 and childId 999 receives all messages + * received from the MySensors bridge/gateway. Useful for debugging and for implementation + * of features not covered by the binding (for example with rules) + */ + public static final int MYSENSORS_NODE_ID_ALL_KNOWING = 999; + public static final int MYSENSORS_CHILD_ID_ALL_KNOWING = 999; + + // List of all Thing Type UIDs + public final static ThingTypeUID THING_TYPE_HUMIDITY = new ThingTypeUID(BINDING_ID, "humidity"); + public final static ThingTypeUID THING_TYPE_TEMPERATURE = new ThingTypeUID(BINDING_ID, "temperature"); + public final static ThingTypeUID THING_TYPE_MULTIMETER = new ThingTypeUID(BINDING_ID, "multimeter"); + public final static ThingTypeUID THING_TYPE_LIGHT = new ThingTypeUID(BINDING_ID, "light"); + public final static ThingTypeUID THING_TYPE_POWER = new ThingTypeUID(BINDING_ID, "power"); + public final static ThingTypeUID THING_TYPE_BARO = new ThingTypeUID(BINDING_ID, "baro"); + public final static ThingTypeUID THING_TYPE_DOOR = new ThingTypeUID(BINDING_ID, "door"); + public final static ThingTypeUID THING_TYPE_MOTION = new ThingTypeUID(BINDING_ID, "motion"); + public final static ThingTypeUID THING_TYPE_SMOKE = new ThingTypeUID(BINDING_ID, "smoke"); + public final static ThingTypeUID THING_TYPE_DIMMER = new ThingTypeUID(BINDING_ID, "dimmer"); + public final static ThingTypeUID THING_TYPE_COVER = new ThingTypeUID(BINDING_ID, "cover"); + public final static ThingTypeUID THING_TYPE_WIND = new ThingTypeUID(BINDING_ID, "wind"); + public final static ThingTypeUID THING_TYPE_RAIN = new ThingTypeUID(BINDING_ID, "rain"); + public final static ThingTypeUID THING_TYPE_UV = new ThingTypeUID(BINDING_ID, "uv"); + public final static ThingTypeUID THING_TYPE_WEIGHT = new ThingTypeUID(BINDING_ID, "weight"); + public final static ThingTypeUID THING_TYPE_DISTANCE = new ThingTypeUID(BINDING_ID, "distance"); + public final static ThingTypeUID THING_TYPE_LIGHT_LEVEL = new ThingTypeUID(BINDING_ID, "light-level"); + public final static ThingTypeUID THING_TYPE_WATER = new ThingTypeUID(BINDING_ID, "waterMeter"); + public final static ThingTypeUID THING_TYPE_CUSTOM = new ThingTypeUID(BINDING_ID, "customSensor"); + public final static ThingTypeUID THING_TYPE_HVAC = new ThingTypeUID(BINDING_ID, "hvacThermostat"); + public final static ThingTypeUID THING_TYPE_LOCK = new ThingTypeUID(BINDING_ID, "lock"); + public final static ThingTypeUID THING_TYPE_SOUND = new ThingTypeUID(BINDING_ID, "sound"); + public final static ThingTypeUID THING_TYPE_RGB_LIGHT = new ThingTypeUID(BINDING_ID, "rgbLight"); + public final static ThingTypeUID THING_TYPE_RGBW_LIGHT = new ThingTypeUID(BINDING_ID, "rgbwLight"); + public final static ThingTypeUID THING_TYPE_WATER_QUALITY = new ThingTypeUID(BINDING_ID, "waterQuality"); + public final static ThingTypeUID THING_TYPE_MYSENSORS_MESSAGE = new ThingTypeUID(BINDING_ID, "mySensorsMessage"); + public final static ThingTypeUID THING_TYPE_TEXT = new ThingTypeUID(BINDING_ID, "text"); + public final static ThingTypeUID THING_TYPE_IR = new ThingTypeUID(BINDING_ID, "ir"); + public final static ThingTypeUID THING_TYPE_AIR_QUALITY = new ThingTypeUID(BINDING_ID, "airQuality"); + public final static ThingTypeUID THING_TYPE_DUST = new ThingTypeUID(BINDING_ID, "dust"); + public final static ThingTypeUID THING_TYPE_COLOR_SENSOR = new ThingTypeUID(BINDING_ID, "colorSensor"); + + // List of bridges + public final static ThingTypeUID THING_TYPE_BRIDGE_SER = new ThingTypeUID(BINDING_ID, "bridge-ser"); + public final static ThingTypeUID THING_TYPE_BRIDGE_ETH = new ThingTypeUID(BINDING_ID, "bridge-eth"); + + // List of all Channel ids + public final static String CHANNEL_HUM = "hum"; + public final static String CHANNEL_TEMP = "temp"; + public final static String CHANNEL_VOLT = "volt"; + public final static String CHANNEL_WATT = "watt"; + public final static String CHANNEL_KWH = "kwh"; + public final static String CHANNEL_STATUS = "status"; + public final static String CHANNEL_PRESSURE = "pressure"; + public final static String CHANNEL_BARO = "baro"; + public final static String CHANNEL_TRIPPED = "tripped"; + public final static String CHANNEL_ARMED = "armed"; + public final static String CHANNEL_DIMMER = "dimmer"; + public final static String CHANNEL_COVER = "cover"; + public final static String CHANNEL_WIND = "wind"; + public final static String CHANNEL_GUST = "gust"; + public final static String CHANNEL_RAIN = "rain"; + public final static String CHANNEL_RAINRATE = "rainrate"; + public final static String CHANNEL_UV = "uv"; + public final static String CHANNEL_WEIGHT = "weight"; + public final static String CHANNEL_IMPEDANCE = "impedance"; + public final static String CHANNEL_CURRENT = "current"; + public final static String CHANNEL_DISTANCE = "distance"; + public final static String CHANNEL_LIGHT_LEVEL = "light-level"; + public final static String CHANNEL_VERSION = "version"; + public final static String CHANNEL_BATTERY = "battery"; + public final static String CHANNEL_HVAC_FLOW_STATE = "hvac-flow-state"; + public final static String CHANNEL_HVAC_FLOW_MODE = "hvac-flow-mode"; + public final static String CHANNEL_HVAC_SETPOINT_HEAT = "hvac-setPoint-heat"; + public final static String CHANNEL_HVAC_SETPOINT_COOL = "hvac-setPoint-cool"; + public final static String CHANNEL_HVAC_SPEED = "hvac-speed"; + public final static String CHANNEL_VAR1 = "var1"; + public final static String CHANNEL_VAR2 = "var2"; + public final static String CHANNEL_VAR3 = "var3"; + public final static String CHANNEL_VAR4 = "var4"; + public final static String CHANNEL_VAR5 = "var5"; + public final static String CHANNEL_FLOW = "flow"; + public final static String CHANNEL_VOLUME = "volume"; + public final static String CHANNEL_LOCK_STATUS = "lock-status"; + public final static String CHANNEL_LEVEL = "level"; + public final static String CHANNEL_RGB = "rgb"; + public final static String CHANNEL_RGBW = "rgbw"; + public final static String CHANNEL_ID = "id"; + public final static String CHANNEL_UNIT_PREFIX = "unit-prefix"; + public final static String CHANNEL_TEXT = "text"; + public final static String CHANNEL_CUSTOM = "custom"; + public final static String CHANNEL_POSITION = "position"; + public final static String CHANNEL_IR_RECORD = "ir-record"; + public final static String CHANNEL_PH = "ph"; + public final static String CHANNEL_ORP = "orp"; + public final static String CHANNEL_EC = "ec"; + public final static String CHANNEL_VAR = "var"; + public final static String CHANNEL_VA = "va"; + public final static String CHANNEL_POWER_FACTOR = "power-factor"; + public final static String CHANNEL_IR_SEND = "irSend"; + public final static String CHANNEL_IR_RECEIVE = "irReceive"; + + // Extra channel names for non-standard MySensors channels + public final static String CHANNEL_MYSENSORS_MESSAGE = "mySensorsMessage"; + public final static String CHANNEL_LAST_UPDATE = "lastupdate"; + + /** + * Mapping MySensors message type/subtypes to channels. + */ + public final static Map CHANNEL_MAP = new HashMap() { + /** + * + */ + private static final long serialVersionUID = -7970323220036599380L; + + { + put(MYSENSORS_SUBTYPE_V_TEMP, CHANNEL_TEMP); + put(MYSENSORS_SUBTYPE_V_HUM, CHANNEL_HUM); + put(MYSENSORS_SUBTYPE_V_STATUS, CHANNEL_STATUS); + put(MYSENSORS_SUBTYPE_V_VOLTAGE, CHANNEL_VOLT); + put(MYSENSORS_SUBTYPE_V_WATT, CHANNEL_WATT); + put(MYSENSORS_SUBTYPE_V_KWH, CHANNEL_KWH); + put(MYSENSORS_SUBTYPE_V_PRESSURE, CHANNEL_PRESSURE); + put(MYSENSORS_SUBTYPE_V_FORECAST, CHANNEL_BARO); + put(MYSENSORS_SUBTYPE_V_TRIPPED, CHANNEL_TRIPPED); + put(MYSENSORS_SUBTYPE_V_ARMED, CHANNEL_ARMED); + put(MYSENSORS_SUBTYPE_V_PERCENTAGE, CHANNEL_DIMMER); + put(MYSENSORS_SUBTYPE_V_UP, CHANNEL_COVER); + put(MYSENSORS_SUBTYPE_V_DOWN, CHANNEL_COVER); + put(MYSENSORS_SUBTYPE_V_STOP, CHANNEL_COVER); + put(MYSENSORS_SUBTYPE_V_WIND, CHANNEL_WIND); + put(MYSENSORS_SUBTYPE_V_GUST, CHANNEL_GUST); + put(MYSENSORS_SUBTYPE_V_RAIN, CHANNEL_RAIN); + put(MYSENSORS_SUBTYPE_V_RAINRATE, CHANNEL_RAINRATE); + put(MYSENSORS_SUBTYPE_V_UV, CHANNEL_UV); + put(MYSENSORS_SUBTYPE_V_WEIGHT, CHANNEL_WEIGHT); + put(MYSENSORS_SUBTYPE_V_IMPEDANCE, CHANNEL_IMPEDANCE); + put(MYSENSORS_SUBTYPE_V_DISTANCE, CHANNEL_DISTANCE); + put(MYSENSORS_SUBTYPE_V_LIGHT_LEVEL, CHANNEL_LIGHT_LEVEL); + put(MYSENSORS_SUBTYPE_V_CURRENT, CHANNEL_CURRENT); + put(MYSENSORS_SUBTYPE_V_HVAC_FLOW_STATE, CHANNEL_HVAC_FLOW_STATE); + put(MYSENSORS_SUBTYPE_V_HVAC_SPEED, CHANNEL_HVAC_SPEED); + put(MYSENSORS_SUBTYPE_V_HVAC_SETPOINT_COOL, CHANNEL_HVAC_SETPOINT_COOL); + put(MYSENSORS_SUBTYPE_V_HVAC_SETPOINT_HEAT, CHANNEL_HVAC_SETPOINT_HEAT); + put(MYSENSORS_SUBTYPE_V_HVAC_FLOW_MODE, CHANNEL_HVAC_FLOW_MODE); + put(MYSENSORS_SUBTYPE_V_VAR1, CHANNEL_VAR1); + put(MYSENSORS_SUBTYPE_V_VAR2, CHANNEL_VAR2); + put(MYSENSORS_SUBTYPE_V_VAR3, CHANNEL_VAR3); + put(MYSENSORS_SUBTYPE_V_VAR4, CHANNEL_VAR4); + put(MYSENSORS_SUBTYPE_V_VAR5, CHANNEL_VAR5); + put(MYSENSORS_SUBTYPE_V_FLOW, CHANNEL_FLOW); + put(MYSENSORS_SUBTYPE_V_VOLUME, CHANNEL_VOLUME); + put(MYSENSORS_SUBTYPE_V_LOCK_STATUS, CHANNEL_LOCK_STATUS); + put(MYSENSORS_SUBTYPE_V_LEVEL, CHANNEL_LEVEL); + put(MYSENSORS_SUBTYPE_V_RGB, CHANNEL_RGB); + put(MYSENSORS_SUBTYPE_V_RGBW, CHANNEL_RGBW); + put(MYSENSORS_SUBTYPE_V_ID, CHANNEL_ID); + put(MYSENSORS_SUBTYPE_V_UNIT_PREFIX, CHANNEL_UNIT_PREFIX); + put(MYSENSORS_SUBTYPE_V_TEXT, CHANNEL_TEXT); + put(MYSENSORS_SUBTYPE_V_CUSTOM, CHANNEL_CUSTOM); + put(MYSENSORS_SUBTYPE_V_POSITION, CHANNEL_POSITION); + put(MYSENSORS_SUBTYPE_V_IR_RECORD, CHANNEL_IR_RECORD); + put(MYSENSORS_SUBTYPE_V_PH, CHANNEL_PH); + put(MYSENSORS_SUBTYPE_V_ORP, CHANNEL_ORP); + put(MYSENSORS_SUBTYPE_V_EC, CHANNEL_EC); + put(MYSENSORS_SUBTYPE_V_VAR, CHANNEL_VAR); + put(MYSENSORS_SUBTYPE_V_VA, CHANNEL_VA); + put(MYSENSORS_SUBTYPE_V_POWER_FACTOR, CHANNEL_POWER_FACTOR); + put(MYSENSORS_SUBTYPE_V_TEXT, CHANNEL_TEXT); + put(MYSENSORS_SUBTYPE_V_IR_SEND, CHANNEL_IR_SEND); + put(MYSENSORS_SUBTYPE_V_IR_RECEIVE, CHANNEL_IR_RECEIVE); + } + }; + + /** + * Inverse of the CHANNEL_MAP, duplicate allowed (see also Converters here below) + */ + public final static Map INVERSE_CHANNEL_MAP = MySensorsUtility.invertMap(CHANNEL_MAP, true); + + /** + * Converters will be used to map values from OH to/from MySensors Variables + */ + public static final MySensorsDecimalTypeConverter DECIMAL_TYPE_CONVERTER = new MySensorsDecimalTypeConverter(); + public static final MySensorsPercentTypeConverter PERCENT_TYPE_CONVERTER = new MySensorsPercentTypeConverter(); + public static final MySensorsOnOffTypeConverter ONOFF_TYPE_CONVERTER = new MySensorsOnOffTypeConverter(); + public static final MySensorsOpenCloseTypeConverter OPENCLOSE_TYPE_CONVERTER = new MySensorsOpenCloseTypeConverter(); + public static final MySensorsUpDownTypeConverter UPDOWN_TYPE_CONVERTER = new MySensorsUpDownTypeConverter(); + public static final MySensorsStringTypeConverter STRING_TYPE_CONVERTER = new MySensorsStringTypeConverter(); + + /** + * Mappings between ChannelUID and class that represents the type of the channel + */ + public final static Map TYPE_MAP = new HashMap() { + + /** + * + */ + private static final long serialVersionUID = 6273187523631143905L; + { + put(CHANNEL_TEMP, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_HUM, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_STATUS, ONOFF_TYPE_CONVERTER); + put(CHANNEL_VOLT, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_WATT, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_KWH, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_PRESSURE, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_BARO, STRING_TYPE_CONVERTER); + put(CHANNEL_TRIPPED, OPENCLOSE_TYPE_CONVERTER); + put(CHANNEL_ARMED, ONOFF_TYPE_CONVERTER); + put(CHANNEL_DIMMER, PERCENT_TYPE_CONVERTER); + put(CHANNEL_COVER, UPDOWN_TYPE_CONVERTER); + put(CHANNEL_COVER, UPDOWN_TYPE_CONVERTER); // ! + put(CHANNEL_COVER, UPDOWN_TYPE_CONVERTER); // ! + put(CHANNEL_WIND, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_GUST, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_RAIN, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_RAINRATE, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_UV, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_WEIGHT, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_IMPEDANCE, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_DISTANCE, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_LIGHT_LEVEL, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_CURRENT, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_HVAC_FLOW_STATE, STRING_TYPE_CONVERTER); + put(CHANNEL_HVAC_SPEED, STRING_TYPE_CONVERTER); + put(CHANNEL_HVAC_SETPOINT_COOL, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_HVAC_SETPOINT_HEAT, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_HVAC_FLOW_MODE, STRING_TYPE_CONVERTER); + put(CHANNEL_VAR1, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_VAR2, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_VAR3, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_VAR4, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_VAR5, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_FLOW, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_VOLUME, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_LOCK_STATUS, ONOFF_TYPE_CONVERTER); + put(CHANNEL_LEVEL, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_RGB, STRING_TYPE_CONVERTER); + put(CHANNEL_RGBW, STRING_TYPE_CONVERTER); + put(CHANNEL_ID, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_UNIT_PREFIX, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_TEXT, STRING_TYPE_CONVERTER); + put(CHANNEL_CUSTOM, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_POSITION, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_IR_RECORD, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_PH, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_ORP, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_EC, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_VAR, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_VA, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_POWER_FACTOR, DECIMAL_TYPE_CONVERTER); + put(CHANNEL_TEXT, STRING_TYPE_CONVERTER); + put(CHANNEL_IR_SEND, STRING_TYPE_CONVERTER); + put(CHANNEL_IR_RECEIVE, STRING_TYPE_CONVERTER); + + // Internal + put(CHANNEL_VERSION, STRING_TYPE_CONVERTER); + put(CHANNEL_BATTERY, DECIMAL_TYPE_CONVERTER); + } + }; + + /** + * Used in DiscoveryService to map subtype of a presentation message to thing type + */ + public final static Map THING_UID_MAP = new HashMap() { + + /** + * + */ + private static final long serialVersionUID = -2042537863671385026L; + { + put(MYSENSORS_SUBTYPE_S_HUM, THING_TYPE_HUMIDITY); + put(MYSENSORS_SUBTYPE_S_TEMP, THING_TYPE_TEMPERATURE); + put(MYSENSORS_SUBTYPE_S_MULTIMETER, THING_TYPE_MULTIMETER); + put(MYSENSORS_SUBTYPE_S_LIGHT, THING_TYPE_LIGHT); + put(MYSENSORS_SUBTYPE_S_POWER, THING_TYPE_POWER); + put(MYSENSORS_SUBTYPE_S_BARO, THING_TYPE_BARO); + put(MYSENSORS_SUBTYPE_S_DOOR, THING_TYPE_DOOR); + put(MYSENSORS_SUBTYPE_S_MOTION, THING_TYPE_MOTION); + put(MYSENSORS_SUBTYPE_S_SMOKE, THING_TYPE_SMOKE); + put(MYSENSORS_SUBTYPE_S_DIMMER, THING_TYPE_DIMMER); + put(MYSENSORS_SUBTYPE_S_COVER, THING_TYPE_COVER); + put(MYSENSORS_SUBTYPE_S_WIND, THING_TYPE_WIND); + put(MYSENSORS_SUBTYPE_S_RAIN, THING_TYPE_RAIN); + put(MYSENSORS_SUBTYPE_S_UV, THING_TYPE_UV); + put(MYSENSORS_SUBTYPE_S_WEIGHT, THING_TYPE_WEIGHT); + put(MYSENSORS_SUBTYPE_S_DISTANCE, THING_TYPE_DISTANCE); + put(MYSENSORS_SUBTYPE_S_LIGHT_LEVEL, THING_TYPE_LIGHT_LEVEL); + put(MYSENSORS_SUBTYPE_S_WATER, THING_TYPE_WATER); + put(MYSENSORS_SUBTYPE_S_CUSTOM, THING_TYPE_CUSTOM); + put(MYSENSORS_SUBTYPE_S_HVAC, THING_TYPE_HVAC); + put(MYSENSORS_SUBTYPE_S_LOCK, THING_TYPE_LOCK); + put(MYSENSORS_SUBTYPE_S_SOUND, THING_TYPE_SOUND); + put(MYSENSORS_SUBTYPE_S_RGB_LIGHT, THING_TYPE_RGB_LIGHT); + put(MYSENSORS_SUBTYPE_S_RGBW_LIGHT, THING_TYPE_RGBW_LIGHT); + put(MYSENSORS_SUBTYPE_S_WATER_QUALITY, THING_TYPE_WATER_QUALITY); + put(MYSENSORS_SUBTYPE_S_INFO, THING_TYPE_TEXT); + put(MYSENSORS_SUBTYPE_S_IR, THING_TYPE_IR); + put(MYSENSORS_SUBTYPE_S_AIR_QUALITY, THING_TYPE_AIR_QUALITY); + put(MYSENSORS_SUBTYPE_S_DUST, THING_TYPE_DUST); + put(MYSENSORS_SUBTYPE_S_COLOR_SENSOR, THING_TYPE_COLOR_SENSOR); + } + + }; + + /** + * Inverse of the THING_UID_MAP, helps on building child for every thing type + */ + public final static Map INVERSE_THING_UID_MAP = MySensorsUtility.invertMap(THING_UID_MAP, + true); + + /** Supported Things without bridge */ + public final static Set SUPPORTED_THING_TYPES_UIDS = ImmutableSet.of(THING_TYPE_HUMIDITY, + THING_TYPE_TEMPERATURE, THING_TYPE_LIGHT, THING_TYPE_MULTIMETER, THING_TYPE_POWER, THING_TYPE_BARO, + THING_TYPE_DOOR, THING_TYPE_MOTION, THING_TYPE_SMOKE, THING_TYPE_DIMMER, THING_TYPE_COVER, THING_TYPE_WIND, + THING_TYPE_RAIN, THING_TYPE_UV, THING_TYPE_WEIGHT, THING_TYPE_DISTANCE, THING_TYPE_LIGHT_LEVEL, + THING_TYPE_HVAC, THING_TYPE_WATER, THING_TYPE_CUSTOM, THING_TYPE_LOCK, THING_TYPE_SOUND, + THING_TYPE_RGB_LIGHT, THING_TYPE_RGBW_LIGHT, THING_TYPE_WATER_QUALITY, THING_TYPE_MYSENSORS_MESSAGE, + THING_TYPE_TEXT, THING_TYPE_IR, THING_TYPE_AIR_QUALITY, THING_TYPE_DUST, THING_TYPE_COLOR_SENSOR); + /** Supported bridges */ + public final static Set SUPPORTED_BRIDGE_THING_TYPES_UIDS = ImmutableSet.of(THING_TYPE_BRIDGE_SER, + THING_TYPE_BRIDGE_ETH); + + /** Supported devices (things + brdiges) */ + public final static Collection SUPPORTED_DEVICE_TYPES_UIDS = Lists.newArrayList(THING_TYPE_HUMIDITY, + THING_TYPE_TEMPERATURE, THING_TYPE_LIGHT, THING_TYPE_MULTIMETER, THING_TYPE_POWER, THING_TYPE_BARO, + THING_TYPE_DOOR, THING_TYPE_MOTION, THING_TYPE_SMOKE, THING_TYPE_DIMMER, THING_TYPE_COVER, THING_TYPE_WIND, + THING_TYPE_RAIN, THING_TYPE_UV, THING_TYPE_WEIGHT, THING_TYPE_DISTANCE, THING_TYPE_LIGHT_LEVEL, + THING_TYPE_HVAC, THING_TYPE_WATER, THING_TYPE_CUSTOM, THING_TYPE_LOCK, THING_TYPE_SOUND, + THING_TYPE_RGB_LIGHT, THING_TYPE_RGBW_LIGHT, THING_TYPE_WATER_QUALITY, THING_TYPE_MYSENSORS_MESSAGE, + THING_TYPE_TEXT, THING_TYPE_IR, THING_TYPE_AIR_QUALITY, THING_TYPE_DUST, THING_TYPE_COLOR_SENSOR, + THING_TYPE_BRIDGE_SER, THING_TYPE_BRIDGE_ETH); +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/config/MySensorsBridgeConfiguration.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/config/MySensorsBridgeConfiguration.java new file mode 100644 index 000000000000..922bfcb41482 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/config/MySensorsBridgeConfiguration.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.config; + +/** + * Parameters used for bridge configuration. + * + * @author Tim Oberföll + * + */ +public class MySensorsBridgeConfiguration { + public String serialPort; // serial port the gateway is attached to + public String ipAddress; // ip address the gateway is attached to + public Integer tcpPort; // tcp port the gateway is running at + public Integer sendDelay; // delay at which messages are send from the internal queue to the MySensors network + public Integer baudRate; // baud rate used to connect the serial port + public Boolean imperial; // should nodes send imperial or metric values? + public Boolean skipStartupCheck; // should the startup check of the bridge at boot skipped? + public Boolean enableNetworkSanCheck; // network sanity check enabled? + public Integer sanityCheckerInterval; // determines interval to start NetworkSanityCheck + public Integer sanCheckConnectionFailAttempts; // connection will wait this number of attempts before disconnecting + public boolean sanCheckSendHeartbeat; // network sanity checker will also send heartbeats to all known nodes + public Integer sanCheckSendHeartbeatFailAttempts; // disconnect nodes that fail to answer to heartbeat request + + @Override + public String toString() { + return "MySensorsBridgeConfiguration [serialPort=" + serialPort + ", ipAddress=" + ipAddress + ", tcpPort=" + + tcpPort + ", sendDelay=" + sendDelay + ", baudRate=" + baudRate + ", imperial=" + imperial + + ", skipStartupCheck=" + skipStartupCheck + ", enableNetworkSanCheck=" + enableNetworkSanCheck + + ", sanityCheckerInterval=" + sanityCheckerInterval + ", sanCheckConnectionFailAttempts=" + + sanCheckConnectionFailAttempts + ", sanCheckSendHeartbeat=" + sanCheckSendHeartbeat + + ", sanCheckSendHeartbeatFailAttempts=" + sanCheckSendHeartbeatFailAttempts + "]"; + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/config/MySensorsSensorConfiguration.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/config/MySensorsSensorConfiguration.java new file mode 100644 index 000000000000..262061b321b0 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/config/MySensorsSensorConfiguration.java @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.config; + +/** + * Parameters used for node / thing configuration. + * + * @author toberfoe + * + */ +public class MySensorsSensorConfiguration { + /** + * Node ID in the MySensors network + */ + public String nodeId; + + /** + * Child ID in the MySensors network + */ + public String childId; + + /** + * Should a message request an ACK? + */ + public boolean requestAck; + + /** + * If no ACK was received after the defined retries, should the state of the item get reverted? + */ + public boolean revertState; + + /** + * Does this node support Smartsleep? A message to the node is only send in response to a heartbeat! + */ + public boolean smartSleep; + + /** + * Minutes after, if no message received, thing will be set to OFFLINE + */ + public int childUpdateTimeout; + + /** + * Minutes after, if no message received, ALL things with same node ID will be set to OFFLINE + */ + public int nodeUpdateTimeout; + + /** + * If no heartbeat received and no attempts left (see: sanCheckSendHeartbeatFailAttempts) ALL thing with same node + * ID will be set OFFLINE. + */ + public boolean requestHeartbeatResponse; + + @Override + public String toString() { + return "MySensorsSensorConfiguration [nodeId=" + nodeId + ", childId=" + childId + ", requestAck=" + requestAck + + ", revertState=" + revertState + ", smartSleep=" + smartSleep + ", childUpdateTimeout=" + + childUpdateTimeout + ", nodeUpdateTimeout=" + nodeUpdateTimeout + ", requestHeartbeatResponse=" + + requestHeartbeatResponse + "]"; + } +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsDecimalTypeConverter.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsDecimalTypeConverter.java new file mode 100644 index 000000000000..65eebc9c9265 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsDecimalTypeConverter.java @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.converter; + +import org.eclipse.smarthome.core.library.types.DecimalType; +import org.eclipse.smarthome.core.types.State; + +/** + * Used to convert a String from an incoming MySensors message to a DecimalType + * + * @author Andrea Cioni + * + */ +public class MySensorsDecimalTypeConverter implements MySensorsTypeConverter { + + @Override + public State fromString(String s) { + return new DecimalType(s); + } +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsOnOffTypeConverter.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsOnOffTypeConverter.java new file mode 100644 index 000000000000..9f04cfe78bea --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsOnOffTypeConverter.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.converter; + +import org.eclipse.smarthome.core.library.types.OnOffType; +import org.eclipse.smarthome.core.types.Command; +import org.eclipse.smarthome.core.types.State; + +/** + * Used to convert a String from an incoming MySensors message to an OnOffType + * + * @author Andrea Cioni + * + */ +public class MySensorsOnOffTypeConverter implements MySensorsTypeConverter { + + @Override + public State fromString(String s) { + if ("0".equals(s)) { + return OnOffType.OFF; + } else if ("1".equals(s)) { + return OnOffType.ON; + } else { + throw new IllegalArgumentException("String: " + s + ", could not be used as OnOff state"); + } + } + + @Override + public String fromCommand(Command value) { + if (value instanceof OnOffType) { + if (value == OnOffType.OFF) { + return "0"; + } else if (value == OnOffType.ON) { + return "1"; + } else { + throw new IllegalArgumentException("Passed command is not On/Off"); + } + } else { + throw new IllegalArgumentException("Passed command: " + value + " is not an OnOff command"); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsOpenCloseTypeConverter.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsOpenCloseTypeConverter.java new file mode 100644 index 000000000000..fe440037c2ca --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsOpenCloseTypeConverter.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.converter; + +import org.eclipse.smarthome.core.library.types.OnOffType; +import org.eclipse.smarthome.core.library.types.OpenClosedType; +import org.eclipse.smarthome.core.types.Command; +import org.eclipse.smarthome.core.types.State; + +/** + * Used to convert a String from an incoming MySensors message to an OpenCloseType + * + * @author Andrea Cioni + * + */ +public class MySensorsOpenCloseTypeConverter implements MySensorsTypeConverter { + @Override + public State fromString(String s) { + if ("0".equals(s)) { + return OpenClosedType.CLOSED; + } else if ("1".equals(s)) { + return OpenClosedType.OPEN; + } else { + throw new IllegalArgumentException("String: " + s + ", could not be used as OpenClose state"); + } + } + + @Override + public String fromCommand(Command value) { + if (value instanceof OnOffType) { + if (value == OpenClosedType.CLOSED) { + return "0"; + } else if (value == OpenClosedType.OPEN) { + return "1"; + } else { + throw new IllegalArgumentException("Passed command is not Open/Closed"); + } + } else { + throw new IllegalArgumentException("Passed command: " + value + " is not an OpenClose command"); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsPercentTypeConverter.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsPercentTypeConverter.java new file mode 100644 index 000000000000..bd000feb2867 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsPercentTypeConverter.java @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.converter; + +import org.eclipse.smarthome.core.library.types.PercentType; +import org.eclipse.smarthome.core.types.State; + +/** + * Used to convert a String from an incoming MySensors message to a PercentType + * + * @author Andrea Cioni + * + */ +public class MySensorsPercentTypeConverter implements MySensorsTypeConverter { + + @Override + public State fromString(String s) { + return new PercentType(s); + } +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsStringTypeConverter.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsStringTypeConverter.java new file mode 100644 index 000000000000..0358b6b8a391 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsStringTypeConverter.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.converter; + +import org.eclipse.smarthome.core.library.types.StringType; +import org.eclipse.smarthome.core.types.State; + +/** + * Used to convert a String from an incoming MySensors message to a StringType + * + * @author Andrea Cioni + * + */ +public class MySensorsStringTypeConverter implements MySensorsTypeConverter { + + @Override + public State fromString(String s) { + return new StringType(s); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsTypeConverter.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsTypeConverter.java new file mode 100644 index 000000000000..b459524d7841 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsTypeConverter.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.converter; + +import org.eclipse.smarthome.core.types.Command; +import org.eclipse.smarthome.core.types.State; +import org.openhab.binding.mysensors.MySensorsBindingConstants; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * Converter to adapt state of OpenHab to MySensors and vice versa + * + * @author Andrea Cioni + * + */ +public interface MySensorsTypeConverter { + + /** + * Convert a value from MySensors variable to OH state + * + * @param value non-null that should be converted + * + * @return the state from a variable + */ + default public State stateFromChannel(MySensorsVariable value) { + return fromString(value.getValue()); + } + + /** + * Given a payload string, build an OpenHab state + * + * @param string the payload to process + * + * @return an equivalent state for OpenHab + */ + public State fromString(String string); + + /** + * Get a string from an OpenHab command. + * + * @param command, the command from OpenHab environment + * + * @return the payload string + */ + default public String fromCommand(Command command) { + return command.toString(); + } + + /** + * Sometimes payload is not sufficient to build a message for MySensors (see S_COVER: V_UP,V_DOWN,V_STOP). + * In most cases default implementation is enough. + * + * @param channel of the thing that receive an update + * @param command the command received + * + * @return the variable number + */ + default Integer typeFromChannelCommand(String channel, Command command) { + return MySensorsBindingConstants.INVERSE_CHANNEL_MAP.get(channel); + } +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsUpDownTypeConverter.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsUpDownTypeConverter.java new file mode 100644 index 000000000000..be1f5f2cd8e7 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/converter/MySensorsUpDownTypeConverter.java @@ -0,0 +1,94 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.converter; + +import org.eclipse.smarthome.core.library.types.PercentType; +import org.eclipse.smarthome.core.library.types.StopMoveType; +import org.eclipse.smarthome.core.library.types.UpDownType; +import org.eclipse.smarthome.core.types.Command; +import org.eclipse.smarthome.core.types.State; +import org.openhab.binding.mysensors.MySensorsBindingConstants; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * Used to convert a String from an incoming MySensors message to a UpDownType + * + * @author Andrea Cioni + * + */ +public class MySensorsUpDownTypeConverter implements MySensorsTypeConverter { + + @Override + public Integer typeFromChannelCommand(String channel, Command command) { + if (channel.equals(MySensorsBindingConstants.CHANNEL_COVER)) { + if (command instanceof UpDownType) { + if (command.equals(UpDownType.UP)) { + return MySensorsMessage.MYSENSORS_SUBTYPE_V_UP; + } else if (command.equals(UpDownType.DOWN)) { + return MySensorsMessage.MYSENSORS_SUBTYPE_V_DOWN; + } else { + throw new IllegalArgumentException("Invalid command of type UpDownType: " + command); + } + } else if (command instanceof StopMoveType) { + if (command.equals(StopMoveType.STOP)) { + return MySensorsMessage.MYSENSORS_SUBTYPE_V_STOP; + } else { + throw new IllegalArgumentException("Invalid command of type StopMoveType"); + } + } else if (command instanceof PercentType) { + return MySensorsMessage.MYSENSORS_SUBTYPE_V_PERCENTAGE; + } else { + throw new IllegalArgumentException("Invalid command (" + command + ") passed to UpDown adapter"); + + } + } else { + throw new IllegalArgumentException("Invalid channel(" + channel + ") passed to UpDown adapter"); + } + } + + @Override + public State stateFromChannel(MySensorsVariable value) { + if (value.getType() == MySensorsMessage.MYSENSORS_SUBTYPE_V_DOWN) { + return UpDownType.DOWN; + } else if (value.getType() == MySensorsMessage.MYSENSORS_SUBTYPE_V_UP) { + return UpDownType.UP; + } else if (value.getType() == MySensorsMessage.MYSENSORS_SUBTYPE_V_PERCENTAGE) { + return new PercentType(value.getValue()); + } else { + throw new IllegalArgumentException("Variable " + value.getType() + " is not up/down or percent type"); + } + } + + @Override + public String fromCommand(Command state) { + if (state instanceof UpDownType) { + if (state == UpDownType.DOWN || state == UpDownType.UP) { + return "1"; + } else { + throw new IllegalStateException("Invalid UpDown state: " + state); + } + } else if (state instanceof StopMoveType) { + return "1"; + } else if (state instanceof PercentType) { + return state.toFullString(); + } else { + throw new IllegalStateException( + "UpDown/Percent command are the only one command allowed by this adapter, passed: " + state + "(" + + (state != null ? state.getClass() : "") + ")"); + } + } + + @Override + public State fromString(String string) { + throw new IllegalStateException( + "UpDown type state could not determinateted from a string, use stateFromChannel"); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/discovery/MySensorsDiscoveryService.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/discovery/MySensorsDiscoveryService.java new file mode 100644 index 000000000000..31135cbb8efe --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/discovery/MySensorsDiscoveryService.java @@ -0,0 +1,110 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.discovery; + +import static org.openhab.binding.mysensors.MySensorsBindingConstants.*; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.smarthome.config.discovery.AbstractDiscoveryService; +import org.eclipse.smarthome.config.discovery.DiscoveryResult; +import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; +import org.eclipse.smarthome.core.thing.ThingTypeUID; +import org.eclipse.smarthome.core.thing.ThingUID; +import org.openhab.binding.mysensors.handler.MySensorsBridgeHandler; +import org.openhab.binding.mysensors.internal.event.MySensorsGatewayEventListener; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.MySensorsNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Discovery service for MySensors devices. Starts DiscoveryThread to listen for + * new things / nodes. + * + * @author Tim Oberföll + * + */ +public class MySensorsDiscoveryService extends AbstractDiscoveryService implements MySensorsGatewayEventListener { + + private Logger logger = LoggerFactory.getLogger(MySensorsDiscoveryService.class); + + private MySensorsBridgeHandler bridgeHandler = null; + + public MySensorsDiscoveryService(MySensorsBridgeHandler bridgeHandler) { + super(SUPPORTED_THING_TYPES_UIDS, 0, true); + this.bridgeHandler = bridgeHandler; + } + + @Override + protected void startScan() { + logger.debug("Starting MySensors discovery scan"); + bridgeHandler.getMySensorsGateway().addEventListener(this); + } + + public void activate() { + startScan(); + } + + @Override + public void deactivate() { + stopScan(); + } + + @Override + protected void stopScan() { + logger.debug("Stopping MySensors discovery scan"); + bridgeHandler.getMySensorsGateway().removeEventListener(this); + } + + /** + * Gets called if message from the MySensors network was received. + * Distinguishes if a new thing was discovered. + * + * @param msg + * MySensors message received from the bridge / gateway. + */ + public void newDevicePresented(MySensorsNode node, MySensorsChild child) { + /* + * If a message was received from a not known node, which issn't a + * presentation message, we don't do anything! + */ + if (child != null) { + // uid must not contains dots + ThingTypeUID thingUid = THING_UID_MAP.get(child.getPresentationCode()); + + if (thingUid != null) { + logger.debug("Preparing new thing for inbox: {}", thingUid); + + ThingUID uid = new ThingUID(thingUid, bridgeHandler.getThing().getUID(), + thingUid.getId().toLowerCase() + "_" + node.getNodeId() + "_" + child.getChildId()); + + Map properties = new HashMap<>(2); + properties.put(PARAMETER_NODEID, "" + node.getNodeId()); + properties.put(PARAMETER_CHILDID, "" + child.getChildId()); + DiscoveryResult result = DiscoveryResultBuilder.create(uid).withProperties(properties) + .withLabel("MySensors Device (" + node.getNodeId() + ";" + child.getChildId() + ")") + .withBridge(bridgeHandler.getThing().getUID()).build(); + thingDiscovered(result); + + logger.debug("Discovered device submitted"); + } else { + logger.warn("Cannot automatic discover thing node: {}, child: {} please insert it manually", + node.getNodeId(), child.getChildId()); + } + } + } + + @Override + public void newNodeDiscovered(MySensorsNode node, MySensorsChild child) throws Exception { + newDevicePresented(node, child); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/factory/MySensorsCacheFactory.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/factory/MySensorsCacheFactory.java new file mode 100644 index 000000000000..b1414f8c6251 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/factory/MySensorsCacheFactory.java @@ -0,0 +1,138 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.factory; + +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.lang.reflect.Type; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.gson.Gson; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Cache may be used to store information across restart of MySensors connection. + * + * @author Andrea Cioni + * + */ +public class MySensorsCacheFactory { + private Logger logger = LoggerFactory.getLogger(getClass()); + + private static final String CACHE_BASE_PATH = "./mysensors/cache"; + private static final String CACHE_FILE_SUFFIX = ".cached"; + + public static final String GIVEN_IDS_CACHE_FILE = "given_ids"; + + private Gson gson = null; + + public MySensorsCacheFactory() { + gson = new Gson(); + initializeCacheDir(); + } + + private void initializeCacheDir() { + File f = new File(CACHE_BASE_PATH); + if (!f.exists()) { + logger.debug("Creating cache directory..."); + f.mkdirs(); + } + } + + /** + * Read the cache file. + */ + public T readCache(String cacheName, T defaulT, Type clasz) { + return jsonFromFile(cacheName, defaulT, clasz); + } + + /** + * Write the cache file. + */ + public void writeCache(String cacheName, T obj, Type clasz) { + jsonToFile(cacheName, obj, clasz); + } + + /** + * Read the cache file. + */ + private synchronized T jsonFromFile(String fileName, T def, Type clasz) { + + T ret = def; + + try { + File f = new File(CACHE_BASE_PATH + "/" + GIVEN_IDS_CACHE_FILE + CACHE_FILE_SUFFIX); + + if (f.exists()) { + logger.debug("Cache file: {} exist.", GIVEN_IDS_CACHE_FILE + CACHE_FILE_SUFFIX); + JsonReader jReader = new JsonReader(new FileReader(f)); + ret = gson.fromJson(jReader, clasz); + } else { + logger.debug("Cache file: {} not exist.", GIVEN_IDS_CACHE_FILE + CACHE_FILE_SUFFIX); + if (def != null) { + logger.debug("Cache file: {} not exist. Default passed, creating it...", + GIVEN_IDS_CACHE_FILE + CACHE_FILE_SUFFIX); + jsonToFile(fileName, def, clasz); + } else { + logger.warn("Cache file: {} not exist. Default NOT passed, cache won't be created!", + GIVEN_IDS_CACHE_FILE + CACHE_FILE_SUFFIX); + } + } + } catch (Exception e) { + logger.error("Cache reading throws an exception, cause: {} ({})", e.getClass(), e.getMessage()); + } + + logger.debug("Cache ({}) content: {}", GIVEN_IDS_CACHE_FILE, ret); + return ret; + } + + /** + * Write the cache file. + */ + private synchronized void jsonToFile(String fileName, T obj, Type clasz) { + JsonWriter jsonWriter = null; + try { + File f = new File(CACHE_BASE_PATH + "/" + GIVEN_IDS_CACHE_FILE + CACHE_FILE_SUFFIX); + + jsonWriter = new JsonWriter(new FileWriter(f)); + + logger.debug("Writing on cache {}, content: {}", GIVEN_IDS_CACHE_FILE, gson.toJson(obj, clasz)); + gson.toJson(obj, clasz, jsonWriter); + } catch (Exception e) { + logger.error("Cache writing throws an exception, cause: {} ({})", e.getClass(), e.getMessage()); + } finally { + if (jsonWriter != null) { + try { + jsonWriter.close(); + } catch (IOException e) { + logger.error("Cannot close Json writer"); + } + } + } + } + + public void deleteCache(String cacheId) { + File f = new File(CACHE_BASE_PATH + "/" + cacheId + CACHE_FILE_SUFFIX); + if (f.exists()) { + if (f.delete()) { + logger.debug("Cache {} file deleted", cacheId); + } else { + logger.error("Cannot delete cache {}", cacheId); + } + } else { + logger.warn("Cache {} not exist", cacheId); + } + + } +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/factory/MySensorsHandlerFactory.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/factory/MySensorsHandlerFactory.java new file mode 100644 index 000000000000..6b2b6cdd18fb --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/factory/MySensorsHandlerFactory.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.factory; + +import static org.openhab.binding.mysensors.MySensorsBindingConstants.*; + +import org.eclipse.smarthome.core.thing.Bridge; +import org.eclipse.smarthome.core.thing.Thing; +import org.eclipse.smarthome.core.thing.ThingTypeUID; +import org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory; +import org.eclipse.smarthome.core.thing.binding.ThingHandler; +import org.openhab.binding.mysensors.handler.MySensorsBridgeHandler; +import org.openhab.binding.mysensors.handler.MySensorsThingHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The {@link MySensorsHandlerFactory} is responsible for creating things and thing + * handlers. + * + * @author Tim Oberföll + */ +public class MySensorsHandlerFactory extends BaseThingHandlerFactory { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Override + public boolean supportsThingType(ThingTypeUID thingTypeUID) { + return SUPPORTED_DEVICE_TYPES_UIDS.contains(thingTypeUID); + } + + @Override + protected ThingHandler createHandler(Thing thing) { + logger.trace("Creating handler for thing: {}", thing.getUID()); + ThingTypeUID thingTypeUID = thing.getThingTypeUID(); + ThingHandler handler = null; + + if (SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID)) { + handler = new MySensorsThingHandler(thing); + } else if (thingTypeUID.equals(THING_TYPE_BRIDGE_SER) || thingTypeUID.equals(THING_TYPE_BRIDGE_ETH)) { + handler = new MySensorsBridgeHandler((Bridge) thing); + } else { + logger.error("Thing {} cannot be configured, is this thing supported by the binding?", thingTypeUID); + } + + return handler; + } +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/handler/MySensorsBridgeHandler.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/handler/MySensorsBridgeHandler.java new file mode 100644 index 000000000000..9691bb6e006a --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/handler/MySensorsBridgeHandler.java @@ -0,0 +1,238 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.handler; + +import static org.openhab.binding.mysensors.MySensorsBindingConstants.*; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; + +import org.eclipse.smarthome.config.discovery.DiscoveryService; +import org.eclipse.smarthome.core.thing.Bridge; +import org.eclipse.smarthome.core.thing.ChannelUID; +import org.eclipse.smarthome.core.thing.ThingStatus; +import org.eclipse.smarthome.core.thing.ThingTypeUID; +import org.eclipse.smarthome.core.thing.binding.BaseBridgeHandler; +import org.eclipse.smarthome.core.types.Command; +import org.openhab.binding.mysensors.config.MySensorsBridgeConfiguration; +import org.openhab.binding.mysensors.discovery.MySensorsDiscoveryService; +import org.openhab.binding.mysensors.factory.MySensorsCacheFactory; +import org.openhab.binding.mysensors.internal.event.MySensorsGatewayEventListener; +import org.openhab.binding.mysensors.internal.gateway.MySensorsGateway; +import org.openhab.binding.mysensors.internal.gateway.MySensorsGatewayConfig; +import org.openhab.binding.mysensors.internal.gateway.MySensorsGatewayType; +import org.openhab.binding.mysensors.internal.protocol.MySensorsAbstractConnection; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.MySensorsNode; +import org.osgi.framework.ServiceRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.gson.reflect.TypeToken; + +/** + * MySensorsBridgeHandler is used to initialize a new bridge (in MySensors: Gateway) + * The sensors are connected via the gateway/bridge to the controller + * + * @author Tim Oberföll + * + */ +public class MySensorsBridgeHandler extends BaseBridgeHandler implements MySensorsGatewayEventListener { + + private Logger logger = LoggerFactory.getLogger(MySensorsBridgeHandler.class); + + // Gateway instance + private MySensorsGateway myGateway; + + // Configuration from thing file + private MySensorsBridgeConfiguration myBridgeConfiguration; + + // Service discovery registration + private ServiceRegistration discoveryServiceRegistration; + + // Discovery service + private MySensorsDiscoveryService discoveryService; + + private MySensorsCacheFactory cacheFactory = new MySensorsCacheFactory(); + + public MySensorsBridgeHandler(Bridge bridge) { + super(bridge); + } + + @Override + public void initialize() { + logger.debug("Initialization of the MySensors bridge"); + + myBridgeConfiguration = getConfigAs(MySensorsBridgeConfiguration.class); + + myGateway = new MySensorsGateway(loadCacheFile()); + + if (myGateway.setup(openhabToMySensorsGatewayConfig(myBridgeConfiguration, getThing().getThingTypeUID()))) { + myGateway.startup(); + + myGateway.addEventListener(this); + + registerDeviceDiscoveryService(); + // reloadSensors(); + + logger.debug("Initialization of the MySensors bridge DONE!"); + } else { + logger.error("Failed to initialize MySensors bridge"); + } + + } + + @Override + public void dispose() { + logger.debug("Disposing of the MySensors bridge"); + + unregisterDeviceDiscoveryService(); + + if (myGateway != null) { + myGateway.removeEventListener(this); + myGateway.shutdown(); + } + + super.dispose(); + } + + @Override + public void handleCommand(ChannelUID channelUID, Command command) { + + } + + /** + * Getter for the configuration of the bridge. + * + * @return Configuration of the MySensors bridge. + */ + public MySensorsBridgeConfiguration getBridgeConfiguration() { + return myBridgeConfiguration; + } + + /** + * Getter for the connection to the MySensors bridge / gateway. + * Used for receiving (register handler) and sending of messages. + * + * @return Connection to the MySensors bridge / gateway. + */ + public MySensorsGateway getMySensorsGateway() { + return myGateway; + } + + @Override + public void connectionStatusUpdate(MySensorsAbstractConnection connection, boolean connected) throws Exception { + if (connected) { + updateStatus(ThingStatus.ONLINE); + } else { + updateStatus(ThingStatus.OFFLINE); + } + + updateCacheFile(); + } + + @Override + public void nodeIdReservationDone(Integer reservedId) throws Exception { + updateCacheFile(); + } + + @Override + public void newNodeDiscovered(MySensorsNode node, MySensorsChild child) throws Exception { + updateCacheFile(); + } + + @Override + public void handleConfigurationUpdate(Map configurationParameters) { + logger.debug("Configuation update for bridge: {}", configurationParameters); + super.handleConfigurationUpdate(configurationParameters); + } + + private void updateCacheFile() { + + List givenIds = myGateway.getGivenIds(); + + cacheFactory.writeCache(MySensorsCacheFactory.GIVEN_IDS_CACHE_FILE, givenIds.toArray(new Integer[] {}), + Integer[].class); + } + + private Map loadCacheFile() { + Map nodes = new HashMap(); + + List givenIds = cacheFactory.readCache(MySensorsCacheFactory.GIVEN_IDS_CACHE_FILE, + new ArrayList(), new TypeToken>() { + }.getType()); + + for (Integer i : givenIds) { + if (i != null) { + nodes.put(i, new MySensorsNode(i)); + } + } + + return nodes; + } + + private MySensorsGatewayConfig openhabToMySensorsGatewayConfig(MySensorsBridgeConfiguration conf, + ThingTypeUID bridgeuid) { + MySensorsGatewayConfig ret = new MySensorsGatewayConfig(); + + if (bridgeuid.equals(THING_TYPE_BRIDGE_SER)) { + ret.setGatewayType(MySensorsGatewayType.SERIAL); + ret.setBaudRate(conf.baudRate); + ret.setSerialPort(conf.serialPort); + } else if (bridgeuid.equals(THING_TYPE_BRIDGE_ETH)) { + ret.setGatewayType(MySensorsGatewayType.IP); + ret.setIpAddress(conf.ipAddress); + ret.setTcpPort(conf.tcpPort); + } else { + throw new IllegalArgumentException("BridgeUID is unkonown: " + bridgeuid); + } + + ret.setSendDelay(conf.sendDelay); + ret.setEnableNetworkSanCheck(conf.enableNetworkSanCheck); + ret.setImperial(conf.imperial); + ret.setSkipStartupCheck(conf.skipStartupCheck); + ret.setSanityCheckerInterval(conf.sanityCheckerInterval); + ret.setSanCheckConnectionFailAttempts(conf.sanCheckConnectionFailAttempts); + ret.setSanCheckSendHeartbeat(conf.sanCheckSendHeartbeat); + ret.setSanCheckSendHeartbeatFailAttempts(conf.sanCheckSendHeartbeatFailAttempts); + + return ret; + } + + private void registerDeviceDiscoveryService() { + if (bundleContext != null) { + logger.trace("Registering MySensorsDiscoveryService for bridge '{}'", getThing().getUID().getId()); + discoveryService = new MySensorsDiscoveryService(this); + discoveryServiceRegistration = bundleContext.registerService(DiscoveryService.class.getName(), + discoveryService, new Hashtable()); + discoveryService.activate(); + } + } + + private void unregisterDeviceDiscoveryService() { + if (discoveryServiceRegistration != null && discoveryService != null) { + logger.trace("Unregistering MySensorsDiscoveryService for bridge '{}'", getThing().getUID().getId()); + + discoveryService.deactivate(); + + discoveryServiceRegistration.unregister(); + discoveryServiceRegistration = null; + discoveryService = null; + } + } + + @Override + public String toString() { + return "MySensorsBridgeHandler []"; + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/handler/MySensorsThingHandler.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/handler/MySensorsThingHandler.java new file mode 100644 index 000000000000..45aa96b9c38b --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/handler/MySensorsThingHandler.java @@ -0,0 +1,396 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.handler; + +import static org.openhab.binding.mysensors.MySensorsBindingConstants.*; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Map; + +import org.eclipse.smarthome.core.library.types.DateTimeType; +import org.eclipse.smarthome.core.library.types.DecimalType; +import org.eclipse.smarthome.core.library.types.StringType; +import org.eclipse.smarthome.core.thing.Bridge; +import org.eclipse.smarthome.core.thing.ChannelUID; +import org.eclipse.smarthome.core.thing.Thing; +import org.eclipse.smarthome.core.thing.ThingStatus; +import org.eclipse.smarthome.core.thing.ThingStatusDetail; +import org.eclipse.smarthome.core.thing.ThingStatusInfo; +import org.eclipse.smarthome.core.thing.binding.BaseThingHandler; +import org.eclipse.smarthome.core.types.Command; +import org.eclipse.smarthome.core.types.RefreshType; +import org.eclipse.smarthome.core.types.State; +import org.openhab.binding.mysensors.MySensorsBindingConstants; +import org.openhab.binding.mysensors.config.MySensorsSensorConfiguration; +import org.openhab.binding.mysensors.converter.MySensorsTypeConverter; +import org.openhab.binding.mysensors.internal.event.MySensorsGatewayEventListener; +import org.openhab.binding.mysensors.internal.event.MySensorsNodeUpdateEventType; +import org.openhab.binding.mysensors.internal.gateway.MySensorsGateway; +import org.openhab.binding.mysensors.internal.protocol.MySensorsAbstractConnection; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChildConfig; +import org.openhab.binding.mysensors.internal.sensors.MySensorsNode; +import org.openhab.binding.mysensors.internal.sensors.MySensorsNodeConfig; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The {@link MySensorsThingHandler} is responsible for handling commands, which are + * sent to one of the channels and messages received via the MySensors network. + * + * @author Tim Oberföll + */ +public class MySensorsThingHandler extends BaseThingHandler implements MySensorsGatewayEventListener { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + private MySensorsSensorConfiguration configuration = null; + + private int nodeId = 0; + private int childId = 0; + private boolean requestAck = false; + private boolean revertState = true; + + private boolean smartSleep = false; + + private int expectUpdateTimeout = -1; + + private DateTimeType lastUpdate = null; + + private MySensorsGateway myGateway; + + public MySensorsThingHandler(Thing thing) { + super(thing); + } + + @Override + public void initialize() { + configuration = getConfigAs(MySensorsSensorConfiguration.class); + nodeId = Integer.parseInt(configuration.nodeId); + childId = Integer.parseInt(configuration.childId); + requestAck = configuration.requestAck; + revertState = configuration.revertState; + smartSleep = configuration.smartSleep; + expectUpdateTimeout = configuration.childUpdateTimeout; + + logger.debug(configuration.toString()); + + myGateway = getBridgeHandler().getMySensorsGateway(); + addIntoGateway(getThing(), configuration); + + registerListeners(); + + updateStatus(ThingStatus.ONLINE); + } + + @Override + public void dispose() { + myGateway.removeEventListener(this); + super.dispose(); + } + + @Override + public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { + logger.debug("MySensors Bridge Status updated to {} for device: {}", bridgeStatusInfo.getStatus().toString(), + getThing().getUID().toString()); + if (bridgeStatusInfo.getStatus().equals(ThingStatus.ONLINE) + || bridgeStatusInfo.getStatus().equals(ThingStatus.OFFLINE)) { + + if (bridgeStatusInfo.getStatus().equals(ThingStatus.ONLINE)) { + registerListeners(); + } else { + myGateway.removeEventListener(this); + } + + // the node has the same status of the bridge + updateStatus(bridgeStatusInfo.getStatus()); + } + } + + @Override + public void handleConfigurationUpdate(Map configurationParameters) { + logger.debug("Configuation update fo thing {}-{}: {}", nodeId, childId, configurationParameters); + super.handleConfigurationUpdate(configurationParameters); + } + + @Override + public void handleUpdate(ChannelUID channelUID, State newState) { + logger.trace("New state {} received for channel uid {}", newState, channelUID); + super.handleUpdate(channelUID, newState); + } + + @Override + public void handleCommand(ChannelUID channelUID, Command command) { + logger.trace("Command {} received for channel uid {}", command, channelUID); + /* + * We don't handle refresh commands yet + * + */ + if (command == RefreshType.REFRESH) { + return; + } + + int intRequestAck = requestAck ? 1 : 0; + + // just forward the message in case it is received via this channel. This is special! + if (channelUID.getId().equals(CHANNEL_MYSENSORS_MESSAGE)) { + if (command instanceof StringType) { + StringType stringTypeMessage = (StringType) command; + try { + MySensorsMessage msg = MySensorsMessage.parse(stringTypeMessage.toString()); + myGateway.sendMessage(msg); + } catch (ParseException e) { + logger.error("Invalid message to send", e); + } + } + } else { + MySensorsTypeConverter adapter = loadAdapterForChannelType(channelUID.getId()); + + if (adapter != null) { + logger.trace("Adapter {} found for type {}", adapter.getClass().getSimpleName(), channelUID.getId()); + + Integer type = adapter.typeFromChannelCommand(channelUID.getId(), command); + + if (type != null) { + logger.trace("Type for channel: {}, command: {} of thing {} is: {}", thing.getUID(), command, + thing.getUID(), type); + + MySensorsVariable var = myGateway.getVariable(nodeId, childId, type); + + if (var != null) { + + int subType = var.getType(); + + // Create the real message to send + MySensorsMessage newMsg = new MySensorsMessage(nodeId, childId, + MySensorsMessage.MYSENSORS_MSG_TYPE_SET, intRequestAck, revertState, smartSleep); + + newMsg.setSubType(subType); + newMsg.setMsg(adapter.fromCommand(command)); + + myGateway.sendMessage(newMsg); + + } else { + logger.warn("Variable not found, cannot handle command for thing {} of type {}", thing.getUID(), + channelUID.getId()); + } + } else { + logger.error("Could not get type of variable for channel: {}, command: {} of thing {}", + thing.getUID(), command, thing.getUID()); + } + + } else { + logger.error("Type adapter not found for {}", channelUID.getId()); + } + + } + } + + @Override + public void messageReceived(MySensorsMessage message) throws Exception { + handleIncomingMessageEvent(message); + + } + + @Override + public void sensorUpdateEvent(MySensorsNode node, MySensorsChild child, MySensorsVariable var, + MySensorsNodeUpdateEventType eventType) { + switch (eventType) { + case UPDATE: + case REVERT: + if ((node.getNodeId() == nodeId) && (child.getChildId() == childId)) { + handleChildUpdateEvent(var); + updateLastUpdate(node, eventType == MySensorsNodeUpdateEventType.REVERT); + } + break; + case BATTERY: + if (node.getNodeId() == nodeId) { + handleBatteryUpdateEvent(node); + updateLastUpdate(node, eventType == MySensorsNodeUpdateEventType.REVERT); + } + break; + } + + } + + @Override + public void connectionStatusUpdate(MySensorsAbstractConnection connection, boolean connected) throws Exception { + if (!connected) { + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE); + } else { + updateStatus(ThingStatus.ONLINE); + } + } + + @Override + public void nodeReachStatusChanged(MySensorsNode node, boolean reach) { + if (node.getNodeId() == nodeId) { + if (!reach) { + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR); + } else { + updateStatus(ThingStatus.ONLINE); + } + } + + } + + /** + * For every thing there is a lastUpdate channel in which the date/time is stored + * a message was received from this thing. + */ + private void updateLastUpdate(MySensorsNode node, boolean isRevert) { + // Don't always fire last update channel, do it only after a minute by + if (lastUpdate == null || (System.currentTimeMillis() > (lastUpdate.getCalendar().getTimeInMillis() + 60000)) + || revertState) { + DateTimeType dt = new DateTimeType( + new SimpleDateFormat(DateTimeType.DATE_PATTERN).format(node.getLastUpdate())); + lastUpdate = dt; + updateState(CHANNEL_LAST_UPDATE, dt); + if (!isRevert) { + logger.debug("Setting last update for node/child {}/{} to {}", nodeId, childId, dt.toString()); + } else { + logger.warn("Setting last update for node/child {}/{} BACK (due to revert) to {}", nodeId, childId, + dt.toString()); + } + } + } + + /** + * Returns the BridgeHandler of the bridge/gateway to the MySensors network + * + * @return BridgeHandler of the bridge/gateway to the MySensors network + */ + private synchronized MySensorsBridgeHandler getBridgeHandler() { + MySensorsBridgeHandler myBridgeHandler = null; + + Bridge bridge = getBridge(); + myBridgeHandler = (MySensorsBridgeHandler) bridge.getHandler(); + + return myBridgeHandler; + } + + private void handleChildUpdateEvent(MySensorsVariable var) { + String channelName = getChannelNameFromVar(var); + State newState = loadAdapterForChannelType(channelName).stateFromChannel(var); + logger.debug("Updating channel: {}({}) value to: {}", channelName, var.getType(), newState); + updateState(channelName, newState); + + } + + private void handleBatteryUpdateEvent(MySensorsNode node) { + logger.debug("Updating channel: {} value to: {}", CHANNEL_BATTERY, node.getBatteryPercent()); + updateState(CHANNEL_BATTERY, new DecimalType(node.getBatteryPercent())); + } + + private String getChannelNameFromVar(MySensorsVariable var) { + // Cover thing has a specific behavior + if (getThing().getThingTypeUID().equals(MySensorsBindingConstants.THING_TYPE_COVER)) { + return MySensorsBindingConstants.CHANNEL_COVER; + } else { + return CHANNEL_MAP.get(var.getType()); + } + } + + private MySensorsTypeConverter loadAdapterForChannelType(String channelName) { + return TYPE_MAP.get(channelName); + } + + /** + * If a new message is received via the MySensors bridge it is handed over to the ThingHandler + * and processed in this method. After parsing the message the corresponding channel is updated. + * + * @param msg The message that was received by the MySensors gateway. + */ + private void handleIncomingMessageEvent(MySensorsMessage msg) { + // Am I the all knowing node that receives all messages? + if (nodeId == MYSENSORS_NODE_ID_ALL_KNOWING && childId == MYSENSORS_CHILD_ID_ALL_KNOWING) { + updateState(CHANNEL_MYSENSORS_MESSAGE, + new StringType(MySensorsMessage.generateAPIString(msg).replaceAll("(\\r|\\n)", ""))); + + } + } + + private void registerListeners() { + if (!myGateway.isEventListenerRegisterd(this)) { + logger.debug("Event listener for node {}-{} not registered yet, registering...", nodeId, childId); + myGateway.addEventListener(this); + } + } + + private void addIntoGateway(Thing thing, MySensorsSensorConfiguration configuration) { + MySensorsNode node = generateNodeFromThing(thing, configuration); + if (node != null) { + myGateway.addNode(node, true); + } else { + logger.error("Failed to build sensor for thing: {}", thing.getUID()); + } + } + + private MySensorsNode generateNodeFromThing(Thing t, MySensorsSensorConfiguration configuration) { + MySensorsNode ret = null; + Integer nodeId = -1, childId = -1, pres = -1; + try { + nodeId = Integer.parseInt(t.getConfiguration().as(MySensorsSensorConfiguration.class).nodeId); + childId = Integer.parseInt(t.getConfiguration().as(MySensorsSensorConfiguration.class).childId); + pres = INVERSE_THING_UID_MAP.get(t.getThingTypeUID()); + + if (pres != null) { + logger.trace("Building sensors from thing: {}, node: {}, child: {}, presentation: {}", t.getUID(), + nodeId, childId, pres); + + MySensorsChild child = MySensorsChild.fromPresentation(pres, childId); + child.setChildConfig(generateChildConfig(configuration)); + if (child != null) { + ret = new MySensorsNode(nodeId); + ret.setNodeConfig(generateNodeConfig(configuration)); + ret.addChild(child); + } + } else { + logger.error("Error on building sensors from thing: {}, node: {}, child: {}, presentation: {}", + t.getUID(), nodeId, childId, pres); + } + + } catch (Exception e) { + logger.error("Failing on create node/child for thing {}", thing.getUID(), e); + } + + return ret; + + } + + private MySensorsChildConfig generateChildConfig(MySensorsSensorConfiguration configuration) { + MySensorsChildConfig ret = new MySensorsChildConfig(); + ret.setRequestAck(configuration.requestAck); + ret.setRevertState(configuration.revertState); + ret.setExpectUpdateTimeout(configuration.childUpdateTimeout); + + logger.trace("ChildConfig for {}/{}: {}", nodeId, childId, ret.toString()); + + return ret; + } + + private MySensorsNodeConfig generateNodeConfig(MySensorsSensorConfiguration configuration) { + MySensorsNodeConfig ret = new MySensorsNodeConfig(); + ret.setRequestHeartbeatResponse(configuration.requestHeartbeatResponse); + ret.setExpectUpdateTimeout(configuration.nodeUpdateTimeout); + + logger.trace("NodeConfig for {}/{}: {}", nodeId, childId, ret.toString()); + + return ret; + } + + @Override + public String toString() { + return "MySensorsThingHandler [nodeId=" + nodeId + ", childId=" + childId + "]"; + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/Mergeable.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/Mergeable.java new file mode 100644 index 000000000000..e17ebbed280f --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/Mergeable.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal; + +import org.openhab.binding.mysensors.internal.exception.MergeException; + +/** + * Indicates that a class could be merged to another one of the same type + * + * @author Andrea Cioni + * + */ +public interface Mergeable { + + /** + * Merge an object to another one. + * + * @param o + * @throws MergeException + */ + public void merge(Object o) throws MergeException; +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/MySensorsUtility.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/MySensorsUtility.java new file mode 100644 index 000000000000..a52aeef8c46f --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/MySensorsUtility.java @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.stream.Collectors; + +import org.openhab.binding.mysensors.internal.exception.MergeException; + +/** + * Class gives some utility methods that not belong to a specific class + * + * @author Andrea Cioni + * + */ +public class MySensorsUtility { + /** + * Invert a generics map swapping key with value + * + * @param map the map to be inverted + * @param hasDuplicate if true only one value (randomly) will be used as key in map that contains same value for + * different keys. + * @return the new inverted map + * @throws NullPointerException if map is null + */ + public static Map invertMap(Map map, boolean hasDuplicate) throws NullPointerException { + if (!hasDuplicate) { + return map.entrySet().stream().collect(Collectors.toMap(Entry::getValue, c -> c.getKey())); + } else { + return map.entrySet().stream().collect(Collectors.toMap(Entry::getValue, c -> c.getKey(), (a, b) -> a)); + } + } + + /** + * Join two map + * + * @param map1 + * @param map2 + * @return the new map that contains the entry of map1 and map2 + * @throws NullPointerException + */ + public static Map joinMap(Map map1, Map map2) throws NullPointerException { + HashMap joinMap = new HashMap(); + joinMap.putAll(map1); + joinMap.putAll(map2); + return joinMap; + } + + /** + * Merge one map in another one + * + * @param map1 the destination map, will be the merged map. + * @param map2 the map that will be merged into map1 + * + * @throws NullPointerException + * @throws MergeException if allowOverwrite is true and a duplicate is found for a key + */ + public static void mergeMap(Map map1, Map map2, boolean allowOverwrite) + throws MergeException, NullPointerException { + if (!allowOverwrite) { + map1.keySet().forEach((a) -> { + if (map2.containsKey(a)) { + throw new IllegalArgumentException("Same key found in map: " + a); + } + }); + } + + map1.putAll(map2); + + } + + public static boolean containsSameKey(Map map1, Map map2) throws NullPointerException { + return map1.keySet().equals(map2.keySet()); + } +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/event/EventRegister.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/event/EventRegister.java new file mode 100644 index 000000000000..ff1c9ef6f1ab --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/event/EventRegister.java @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.event; + +import java.util.EventListener; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Event register generic class + * + * @author Andrea Cioni + * + * @param the EventListener to register + */ +public class EventRegister implements Register { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + private List registeredEventListener; + + public EventRegister() { + registeredEventListener = new LinkedList<>(); + } + + @Override + public boolean isEventListenerRegisterd(T listener) { + boolean ret = false; + + synchronized (registeredEventListener) { + ret = registeredEventListener.contains(listener); + } + return ret; + } + + @Override + public void addEventListener(T listener) { + + if (listener == null) { + return; + } + + synchronized (registeredEventListener) { + if (!isEventListenerRegisterd(listener)) { + logger.trace("Adding listener {} to {}", listener, this); + registeredEventListener.add(listener); + } else { + logger.debug("Event listener {} already registered", listener); + } + } + } + + @Override + public void removeEventListener(T listener) { + + if (listener == null) { + return; + } + + // Thread-safe remove + synchronized (registeredEventListener) { + if (isEventListenerRegisterd(listener)) { + logger.trace("Removing listener {} from {}", listener, this); + Iterator iter = registeredEventListener.iterator(); + while (iter.hasNext()) { + T elem = iter.next(); + if (elem.equals(listener)) { + iter.remove(); + return; + } + } + } else { + logger.debug("Listener {} not present, cannot remove it", listener); + } + } + } + + @Override + public void clearAllListeners() { + logger.trace("Clearing all listeners from {}", this); + synchronized (registeredEventListener) { + registeredEventListener.clear(); + } + + } + + @Override + public List getEventListeners() { + return registeredEventListener; + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/event/MySensorsEventRegister.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/event/MySensorsEventRegister.java new file mode 100644 index 000000000000..a3f1b20c74c1 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/event/MySensorsEventRegister.java @@ -0,0 +1,163 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.event; + +import java.util.List; + +import org.openhab.binding.mysensors.internal.protocol.MySensorsAbstractConnection; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.MySensorsNode; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Andrea Cioni + * + */ +public class MySensorsEventRegister extends EventRegister { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + private EventRegister eventRegister; + + public MySensorsEventRegister() { + eventRegister = new EventRegister<>(); + } + + @Override + public void addEventListener(MySensorsGatewayEventListener listener) { + eventRegister.addEventListener(listener); + + } + + @Override + public void clearAllListeners() { + eventRegister.clearAllListeners(); + + } + + @Override + public List getEventListeners() { + return eventRegister.getEventListeners(); + } + + @Override + public boolean isEventListenerRegisterd(MySensorsGatewayEventListener listener) { + return eventRegister.isEventListenerRegisterd(listener); + } + + @Override + public void removeEventListener(MySensorsGatewayEventListener listener) { + eventRegister.removeEventListener(listener); + } + + public void notifyBridgeStatusUpdate(MySensorsAbstractConnection connection, boolean connected) { + synchronized (eventRegister.getEventListeners()) { + for (MySensorsGatewayEventListener listener : eventRegister.getEventListeners()) { + logger.trace("Broadcasting event {} to: {}", connection.toString(), listener); + + try { + listener.connectionStatusUpdate(connection, connected); + } catch (Exception e) { + logger.error("Event broadcasting throw an exception", e); + } + } + } + } + + public void notifyMessageReceived(MySensorsMessage msg) { + synchronized (eventRegister.getEventListeners()) { + for (MySensorsGatewayEventListener listener : eventRegister.getEventListeners()) { + logger.trace("Broadcasting event {} to: {}", msg, listener); + + try { + listener.messageReceived(msg); + } catch (Exception e) { + logger.error("Event broadcasting throw an exception", e); + } + } + } + + } + + public void notifyNewNodeDiscovered(MySensorsNode node, MySensorsChild child) { + synchronized (eventRegister.getEventListeners()) { + for (MySensorsGatewayEventListener listener : eventRegister.getEventListeners()) { + logger.trace("Broadcasting event {} to: {}", node, listener); + + try { + listener.newNodeDiscovered(node, child); + } catch (Exception e) { + logger.error("Event broadcasting throw an exception", e); + } + } + } + } + + public void notifyNodeIdReserved(Integer reserved) { + synchronized (eventRegister.getEventListeners()) { + for (MySensorsGatewayEventListener listener : eventRegister.getEventListeners()) { + logger.trace("Broadcasting event {} to: {}", reserved, listener); + + try { + listener.nodeIdReservationDone(reserved); + } catch (Exception e) { + logger.error("Event broadcasting throw an exception", e); + } + } + } + } + + public void notifyNodeUpdateEvent(MySensorsNode node, MySensorsChild child, MySensorsVariable variable, + MySensorsNodeUpdateEventType eventType) { + synchronized (eventRegister.getEventListeners()) { + for (MySensorsGatewayEventListener listener : eventRegister.getEventListeners()) { + logger.trace("Broadcasting event {} to: {}", (variable != null ? variable : node), listener); + + try { + listener.sensorUpdateEvent(node, child, variable, eventType); + } catch (Exception e) { + logger.error("Event broadcasting throw an exception", e); + } + } + } + } + + public void notifyNodeReachEvent(MySensorsNode node, boolean reach) { + synchronized (eventRegister.getEventListeners()) { + for (MySensorsGatewayEventListener listener : eventRegister.getEventListeners()) { + logger.trace("Broadcasting event {} to: {}", node, listener); + + try { + listener.nodeReachStatusChanged(node, reach); + } catch (Exception e) { + logger.error("Event broadcasting throw an exception", e); + } + } + } + } + + public void notifyAckNotReceived(MySensorsMessage msg) { + synchronized (eventRegister.getEventListeners()) { + for (MySensorsGatewayEventListener listener : eventRegister.getEventListeners()) { + logger.trace("Broadcasting event {} to: {}", msg, listener); + + try { + listener.ackNotReceived(msg); + } catch (Exception e) { + logger.error("Event broadcasting throw an exception", e); + } + } + } + + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/event/MySensorsGatewayEventListener.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/event/MySensorsGatewayEventListener.java new file mode 100644 index 000000000000..3d425c4ba2bb --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/event/MySensorsGatewayEventListener.java @@ -0,0 +1,85 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.event; + +import java.util.EventListener; + +import org.openhab.binding.mysensors.internal.protocol.MySensorsAbstractConnection; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.MySensorsNode; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * Class that implement (and register) this interface receive update events from the MySensors network. + * Default (Java8) added to allow the class that will implement this interface, to choose + * only the method in which is interested (not best practice, but help code reading). + * + * @author Tim Oberföll + * @author Andrea Cioni + * + */ +public interface MySensorsGatewayEventListener extends EventListener { + + /** + * Triggered when gateway reserve (and send) an ID for a new network device. + * A new ,empty, device is created before this method is triggered + */ + default public void nodeIdReservationDone(Integer reservedId) throws Exception { + } + + /** + * Triggered when new node ID is discovered in the network + * A new ,empty, device is created before this method is triggered. Only if presentation message received, and so a + * description for a child is available, @child is not null. + */ + default public void newNodeDiscovered(MySensorsNode node, MySensorsChild child) throws Exception { + } + + /** + * When a message of type SET has processed correctly (node/child/variable found in gateway) + * the new value is sent to every observer. The @updateType parameter could be set to: + * -REVERT to indicate that channel update was triggered after unsuccessful message sending (when ACK=1) + * -UPDATE when incoming/outgoing message is received/sent to update state of a variable + * -BATTERY indicate that a battery update message was received for a node ( @child and @variable are null in this + * case) + */ + default public void sensorUpdateEvent(MySensorsNode node, MySensorsChild child, MySensorsVariable var, + MySensorsNodeUpdateEventType updateType) throws Exception { + } + + /** + * When a node is not more reachable this method is triggered. + * Reachability changes when connection go down or NetworkSanityChecker tells us the + * device is not responding + */ + default public void nodeReachStatusChanged(MySensorsNode node, boolean reach) throws Exception { + } + + /** + * Procedure to notify new message from MySensorsNetwork. + * Internally, MySensorsGateway, handle this event and update channel state if message is sent to a known node. + */ + default public void messageReceived(MySensorsMessage message) throws Exception { + } + + /** + * Triggered when connection update its status + */ + default public void connectionStatusUpdate(MySensorsAbstractConnection connection, boolean connected) + throws Exception { + } + + /** + * Triggered when one message, that request ack, hasn't received any confirmation. + * Internally, MySensorsGateway, handle this event and restore channel state. + */ + default public void ackNotReceived(MySensorsMessage msg) throws Exception { + } +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/event/MySensorsNodeUpdateEventType.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/event/MySensorsNodeUpdateEventType.java new file mode 100644 index 000000000000..ac9859630e2f --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/event/MySensorsNodeUpdateEventType.java @@ -0,0 +1,15 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.event; + +public enum MySensorsNodeUpdateEventType { + REVERT, + BATTERY, + UPDATE +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/event/Register.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/event/Register.java new file mode 100644 index 000000000000..234ec06da0e4 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/event/Register.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.event; + +import java.util.EventListener; +import java.util.List; + +/** + * Generic interface for an EventListener register + * + * @author Andrea Cioni + * + * @param the EventListener to register + */ +public interface Register { + + /** + * Check if a given listener is already registered + * + * @param listener to be checked + * + * @return true if listener is already registered + */ + public boolean isEventListenerRegisterd(T listener); + + /** + * @param listener An Object, that wants to listen on status updates + */ + public void addEventListener(T listener); + + /** + * Remove a listener + * + * @param listener the one to be removed + */ + public void removeEventListener(T listener); + + /** + * Remove all listeners + */ + public void clearAllListeners(); + + /** + * Get a list of all the registerd listener + * + * @return + */ + public List getEventListeners(); +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/MergeException.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/MergeException.java new file mode 100644 index 000000000000..2a0eb970fd39 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/MergeException.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.exception; + +/** + * Exception is thrown if an error while trying to merge (two nodes or two childs) occures. + * @author Andrea Cioni + * + */ +public class MergeException extends RuntimeException { + private static final long serialVersionUID = 6237378516242187660L; + + private String message; + + public MergeException(String message) { + this.message = message; + } + + @Override + public String getMessage() { + return message; + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/NoAckException.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/NoAckException.java new file mode 100644 index 000000000000..a75bed01df65 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/NoAckException.java @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.exception; + +/** + * Exception occurs if there is an error in + * the ack message that was received by the gateway + * + * @author Tim Oberföll + * + */ +public class NoAckException extends Exception { + private static final long serialVersionUID = -4446354274423342464L; + + private String message; + + public NoAckException(String message) { + this.message = message; + } + + @Override + public String getMessage() { + return message; + } +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/NoContentException.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/NoContentException.java new file mode 100644 index 000000000000..f6972b7626c4 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/NoContentException.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.exception; + +/** + * Exception occurs if there is no content to add, for example in a variable. + * + * @author Tim Oberföll + * + */ +public class NoContentException extends Exception { + private static final long serialVersionUID = -3446354234423332363L; + + private String message; + + public NoContentException(String message) { + this.message = message; + } + + @Override + public String getMessage() { + return message; + } +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/NoMoreIdsException.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/NoMoreIdsException.java new file mode 100644 index 000000000000..2bc793fd86c0 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/NoMoreIdsException.java @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.exception; + +/** + * Exception occurs if no more ids are available. + * + * @author Andrea Cioni + * + */ +public class NoMoreIdsException extends Exception { + + /** + * + */ + private static final long serialVersionUID = -8486356274123302462L; + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/NotInitializedException.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/NotInitializedException.java new file mode 100644 index 000000000000..34bd61223814 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/NotInitializedException.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.exception; + +/** + * Exception occurs if the state of a thing is not yet initialized. + * + * @author Tim Oberföll + * + */ +public class NotInitializedException extends Exception { + private static final long serialVersionUID = -1441354134423131361L; + + private String message; + + public NotInitializedException(String message) { + this.message = message; + } + + @Override + public String getMessage() { + return message; + } +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/RevertVariableStateException.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/RevertVariableStateException.java new file mode 100644 index 000000000000..1a5d34ebc588 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/exception/RevertVariableStateException.java @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.exception; + +/** + * Exception is thrown if an error occures while trying to revert the status of a thing. + * + * @author Tim Oberföll + * + */ +public class RevertVariableStateException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1419826736891461536L; + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/gateway/MySensorsGateway.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/gateway/MySensorsGateway.java new file mode 100644 index 000000000000..9ddb9df81ed3 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/gateway/MySensorsGateway.java @@ -0,0 +1,735 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.gateway; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.openhab.binding.mysensors.internal.event.MySensorsEventRegister; +import org.openhab.binding.mysensors.internal.event.MySensorsGatewayEventListener; +import org.openhab.binding.mysensors.internal.event.MySensorsNodeUpdateEventType; +import org.openhab.binding.mysensors.internal.exception.MergeException; +import org.openhab.binding.mysensors.internal.exception.NoMoreIdsException; +import org.openhab.binding.mysensors.internal.exception.NotInitializedException; +import org.openhab.binding.mysensors.internal.protocol.MySensorsAbstractConnection; +import org.openhab.binding.mysensors.internal.protocol.ip.MySensorsIpConnection; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.protocol.serial.MySensorsSerialConnection; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.MySensorsNode; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Main access point of all the function of MySensors Network, some of there are + * -ID handling for the MySensors network: Requests for IDs get answered and IDs get stored in a local cache. + * -Updating sensors variable and status information + * + * @author Andrea Cioni + * + */ +public class MySensorsGateway implements MySensorsGatewayEventListener { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + private Map nodeMap; + + private MySensorsEventRegister myEventRegister; + + private MySensorsAbstractConnection myCon; + + private MySensorsGatewayConfig myConf; + + private MySensorsNetworkSanityChecker myNetSanCheck; + + public MySensorsGateway() { + nodeMap = new HashMap<>(); + this.myEventRegister = new MySensorsEventRegister(); + } + + public MySensorsGateway(Map nodeMap) { + this.nodeMap = nodeMap; + this.myEventRegister = new MySensorsEventRegister(); + } + + /** + * Build up the gateway following given configuration parameters. Gateway will not start after this method returns. + * Use startup to do that + * + * @param myConf a valid instance of {@link MySensorsGatewayConfig} + * + * @return true if setup done correctly + */ + public boolean setup(MySensorsGatewayConfig myConf) { + boolean ret = false; + + if (myConf != null) { + if (myCon != null) { + throw new IllegalStateException("Connection is alredy instantiated"); + } + + this.myConf = myConf; + + switch (myConf.getGatewayType()) { + case SERIAL: + myCon = new MySensorsSerialConnection(myConf, myEventRegister); + ret = true; + break; + case IP: + myCon = new MySensorsIpConnection(myConf, myEventRegister); + ret = true; + break; + } + } else { + logger.error("Invalid configuration supplied: {}", myConf); + } + + return ret; + } + + /** + * Startup the gateway + */ + public void startup() { + + myCon.initialize(); + + myEventRegister.addEventListener(this); + + if (myConf.getEnableNetworkSanCheck()) { + myNetSanCheck = new MySensorsNetworkSanityChecker(this, myEventRegister, myCon); + } + } + + /** + * Shutdown the gateway + */ + public void shutdown() { + + if (myNetSanCheck != null) { + myNetSanCheck.stop(); + } + + if (myCon != null) { + myCon.destroy(); + myCon = null; + } + + myEventRegister.clearAllListeners(); + } + + /** + * Get node from the gatway + * + * @param nodeId the node to retrieve + * + * @return node if exist or null instead + */ + public MySensorsNode getNode(int nodeId) { + synchronized (nodeMap) { + return nodeMap.get(nodeId); + } + } + + /** + * Get a child from a node + * + * @param nodeId the node of the searched child + * @param childId the child of a node + * + * @return child if exist or null instead + */ + public MySensorsChild getChild(int nodeId, int childId) { + MySensorsChild ret = null; + MySensorsNode node = getNode(nodeId); + if (node != null) { + ret = node.getChild(childId); + } + + return ret; + } + + /** + * Get a variable from a child in a node + * + * @param nodeId the node of the variable + * + * @param childId the child of the variable + * + * @param type the variable type (see sub-type of SET/REQ message in API documentation) + * + * @return variable if exist or null instead + */ + public MySensorsVariable getVariable(int nodeId, int childId, int type) { + MySensorsVariable ret = null; + MySensorsChild child = getChild(nodeId, childId); + if (child != null) { + ret = child.getVariable(type); + } + + return ret; + } + + /** + * Update variable state. This method not send new updated value to network, use sendMessage for it. + * + * @param nodeId node id of sensor + * @param childId child id of sensor + * @param type type of variable to update + * @param state new state + * + * @return a message that should be sent to update variable to desired state + */ + public MySensorsMessage setVariableState(int nodeId, int childId, int type, String state) { + MySensorsNode node = getNode(nodeId); + MySensorsMessage msg = null; + + if (node != null) { + try { + msg = node.updateVariableState(childId, type, state); + } catch (NotInitializedException e) { + logger.error("State not initialized: {}", e.toString()); + } + } + + return msg; + + } + + /** + * Simple method that add node to gateway (only if node is not present previously). + * This function never fail. + * + * @param node the node to add + */ + public void addNode(MySensorsNode node) { + synchronized (nodeMap) { + if (nodeMap.containsKey(node.getNodeId())) { + logger.warn("Overwriting previous node, it was lost."); + } + nodeMap.put(node.getNodeId(), node); + } + } + + /** + * Add node to gateway + * + * @param node the node to add + * @param mergeIfExist if true and node is already present that two nodes will be merged in one + * + * @return true if node added successfully + * + * @throws MergeException if mergeIfExist is true and nodes has common child/children + */ + public boolean addNode(MySensorsNode node, boolean mergeIfExist) throws MergeException { + boolean ret = false; + + synchronized (nodeMap) { + MySensorsNode exist = null; + if (mergeIfExist && ((exist = getNode(node.getNodeId())) != null)) { + logger.debug("Merging child map: {} with: {}", exist.getChildMap(), node.getChildMap()); + + exist.merge(node); + ret = true; + + logger.trace("Merging result is: {}", exist.getChildMap()); + } else { + logger.debug("Adding device {}", node.toString()); + addNode(node); + ret = true; + } + } + + return ret; + } + + /** + * Add child to node + * + * @param nodeId the id of the node to add the child + * @param child the child to add + * + * @return true if node is present and child was added successfully + */ + public boolean addChild(int nodeId, MySensorsChild child) { + boolean ret = false; + + synchronized (nodeMap) { + MySensorsNode node = nodeMap.get(nodeId); + if (node != null) { + node.addChild(child); + } else { + logger.warn("Node {} not found in map", nodeId); + } + } + + return ret; + } + + /** + * @return a Set of Ids that is already used and known to the binding. + */ + public List getGivenIds() { + synchronized (nodeMap) { + return new ArrayList(nodeMap.keySet()); + } + } + + /** + * Reserve an id for network, mainly for request id messages + * + * @return a free id not present in node map + * @throws NoMoreIdsException if no more ids are available to be reserved + */ + public Integer reserveId() throws NoMoreIdsException { + int newId = 1; + + synchronized (nodeMap) { + List takenIds = getGivenIds(); + while (newId < MySensorsNode.MYSENSORS_NODE_ID_RESERVED_255) { + if (!takenIds.contains(newId)) { + addNode(new MySensorsNode(newId)); + break; + } else { + newId++; + } + } + } + + if (newId == MySensorsNode.MYSENSORS_NODE_ID_RESERVED_255) { + throw new NoMoreIdsException(); + } + + myEventRegister.notifyNodeIdReserved(newId); + + return newId; + } + + /** + * Add a {@link MySensorsGatewayEventListener} event listener to this gateway + * + * @param listener + */ + public void addEventListener(MySensorsGatewayEventListener listener) { + myEventRegister.addEventListener(listener); + + } + + /** + * + * Remove a {@link MySensorsGatewayEventListener} event listener from this gateway + * + * @param listener + */ + public void removeEventListener(MySensorsGatewayEventListener listener) { + myEventRegister.removeEventListener(listener); + + } + + /** + * Check if a {@link MySensorsGatewayEventListener} is already registered + * + * @param listener + * + * @return true if listener is already registered + */ + public boolean isEventListenerRegisterd(MySensorsGatewayEventListener listener) { + return myEventRegister.isEventListenerRegisterd(listener); + } + + /** + * Send a message through this gateway. If message is of type SET will update variable state of a node/child, + * this will trigger the update event on the {@link MySensorsEventRegister} + * + * @param message to send + */ + public void sendMessage(MySensorsMessage message) { + + if (message == null) { + throw new IllegalArgumentException("Null message could not be sent over the network"); + } + + try { + handleOutgoingMessage(message); + } catch (Exception e) { + logger.error("Handling outgoing message throw an exception", e); + } + + myCon.sendMessage(message); + } + + @Override + public void messageReceived(MySensorsMessage message) throws Exception { + if (!handleIncomingMessage(message)) { + handleSpecialMessageEvent(message); + } + } + + @Override + public void ackNotReceived(MySensorsMessage msg) throws Exception { + if (MySensorsNode.isValidNodeId(msg.getNodeId()) && MySensorsChild.isValidChildId(msg.getChildId()) + && msg.isSetReqMessage()) { + MySensorsNode node = getNode(msg.getNodeId()); + if (node != null) { + logger.debug("Node {} found in gateway", msg.getNodeId()); + + MySensorsChild child = node.getChild(msg.getChildId()); + if (child != null) { + logger.debug("Child {} found in node {}", msg.getChildId(), msg.getNodeId()); + + MySensorsVariable variable = child.getVariable(msg.getSubType()); + if (variable != null) { + if (variable.isRevertible()) { + logger.debug("Variable {} found, it will be reverted to last know state", + variable.getClass().getSimpleName()); + variable.revertValue(); + myEventRegister.notifyNodeUpdateEvent(node, child, variable, + MySensorsNodeUpdateEventType.REVERT); + } else { + logger.error("Could not revert variable {}, no previous value is present", + variable.getClass().getSimpleName()); + } + + } else { + logger.warn("Variable {} not present", msg.getSubType()); + } + } else { + logger.debug("Child {} not present into node {}", msg.getChildId(), msg.getNodeId()); + } + } + } + } + + @Override + public void connectionStatusUpdate(MySensorsAbstractConnection connection, boolean connected) throws Exception { + if (myNetSanCheck != null) { + if (connected) { + myNetSanCheck.start(); + } else { + myNetSanCheck.stop(); + } + } + + handleBridgeStatusUpdate(connected); + } + + public MySensorsGatewayConfig getConfiguration() { + return myConf; + } + + private void handleBridgeStatusUpdate(boolean connected) { + synchronized (nodeMap) { + for (Integer i : nodeMap.keySet()) { + MySensorsNode node = nodeMap.get(i); + node.setReachable(connected); + myEventRegister.notifyNodeReachEvent(node, connected); + } + } + } + + /** + * Handle the incoming/outgoing message from serial + * + * @param msg the incoming/outgoing message + * @return true if ,and only if: + * -the message is propagated to one of the defined node or + * -message arrives from a device new device in the network or + * -message is REQ type and variable is defined for it + * + * @throws Exception + */ + private boolean handleIncomingMessage(MySensorsMessage msg) throws Exception { + boolean ret = false; + if (MySensorsNode.isValidNodeId(msg.getNodeId()) && MySensorsChild.isValidChildId(msg.getChildId())) { + + if (msg.getDirection() == MySensorsMessage.MYSENSORS_MSG_DIRECTION_INCOMING) { + updateReachable(msg); + updateLastUpdateFromMessage(msg); + switch (msg.getMsgType()) { + case MySensorsMessage.MYSENSORS_MSG_TYPE_INTERNAL: + ret = handleInternalMessage(msg); + break; + case MySensorsMessage.MYSENSORS_MSG_TYPE_REQ: + case MySensorsMessage.MYSENSORS_MSG_TYPE_SET: + ret = handleSetReqMessage(msg, true); + break; + case MySensorsMessage.MYSENSORS_MSG_TYPE_PRESENTATION: + ret = handlePresentationMessage(msg); + break; + } + + if (!ret) { + ret = isNewDevice(msg); + } + } else { + logger.warn("Cannot handle this message, direction MYSENSORS_MSG_DIRECTION_OUTGOING"); + } + + } + + return ret; + } + + private boolean handleOutgoingMessage(MySensorsMessage msg) throws Exception { + boolean ret = false; + if (MySensorsNode.isValidNodeId(msg.getNodeId()) && MySensorsChild.isValidChildId(msg.getChildId())) { + if (msg.getDirection() == MySensorsMessage.MYSENSORS_MSG_DIRECTION_OUTGOING) { + switch (msg.getMsgType()) { + case MySensorsMessage.MYSENSORS_MSG_TYPE_SET: + ret = handleSetReqMessage(msg, false); + break; + } + } else { + logger.warn("Cannot handle this message, direction MYSENSORS_MSG_DIRECTION_INCOMING"); + } + } + return ret; + } + + private void updateReachable(MySensorsMessage msg) { + MySensorsNode node = getNode(msg.getNodeId()); + if (node != null && !node.isReachable()) { + logger.info("Node {} available again!", node.getNodeId()); + node.setReachable(true); + myEventRegister.notifyNodeReachEvent(node, true); + } + + } + + private boolean isNewDevice(MySensorsMessage msg) { + boolean ret = false; + MySensorsNode node = getNode(msg.getNodeId()); + + if (node == null) { + logger.debug("Node {} not present, send new node discovered event", msg.getNodeId()); + + node = new MySensorsNode(msg.getNodeId()); + + addNode(node); + myEventRegister.notifyNewNodeDiscovered(node, null); + ret = true; + } + + return ret; + } + + private boolean handlePresentationMessage(MySensorsMessage msg) { + boolean ret = false, insertNode = false; + + MySensorsNode node = getNode(msg.getNodeId()); + + MySensorsChild child = getChild(msg.getNodeId(), msg.getChildId()); + + logger.debug("Presentation Message received"); + + if (child == null) { + + if (node == null) { + node = new MySensorsNode(msg.getNodeId()); + insertNode = true; + } + + child = MySensorsChild.fromPresentation(msg.getSubType(), msg.getChildId()); + node.addChild(child); + + if (insertNode) { + addNode(node); + } + + myEventRegister.notifyNewNodeDiscovered(node, child); + ret = true; + } else { + logger.warn("Presented child is alredy present in gateway"); + } + + return ret; + } + + private boolean handleSetReqMessage(MySensorsMessage msg, boolean dispatchUpdate) { + boolean ret = false; + + MySensorsNode node = getNode(msg.getNodeId()); + if (node != null) { + logger.debug("Node {} found in gateway", msg.getNodeId()); + + MySensorsChild child = node.getChild(msg.getChildId()); + if (child != null) { + logger.debug("Child {} found in node {}", msg.getChildId(), msg.getNodeId()); + + MySensorsVariable variable = child.getVariable(msg.getSubType()); + if (variable != null) { + + if (msg.isSetMessage()) { + if (node.isReachable()) { + logger.trace("Variable {}({}) found in child, pre-update value: {}", + variable.getClass().getSimpleName(), variable.getType(), variable.getValue()); + variable.setValue(msg); + logger.trace("Variable {}({}) found in child, post-update value: {}", + variable.getClass().getSimpleName(), variable.getType(), variable.getValue()); + + if (dispatchUpdate) { + myEventRegister.notifyNodeUpdateEvent(node, child, variable, + MySensorsNodeUpdateEventType.UPDATE); + } + } else { + logger.warn("Could not set value to node {} if not reachable", node.getNodeId()); + } + } else { + String value = variable.getValue(); + if (value != null) { + logger.debug("Request received!"); + msg.setMsgType(MySensorsMessage.MYSENSORS_MSG_TYPE_SET); + msg.setMsg(value); + + /* + * Do not use sendMessage method (it set the value to the channel again), + * just send it over connection + */ + myCon.sendMessage(msg); + } else { + logger.warn("Request received, but variable state is not yet defined"); + } + } + + ret = true; + } else { + logger.warn("Variable {} not present", msg.getSubType()); + } + } else { + logger.debug("Child {} not present into node {}", msg.getChildId(), msg.getNodeId()); + } + + } + + return ret; + + } + + private boolean handleInternalMessage(MySensorsMessage msg) { + boolean ret = false; + MySensorsNode node = getNode(msg.getNodeId()); + if (node != null) { + switch (msg.getSubType()) { + case MySensorsMessage.MYSENSORS_SUBTYPE_I_BATTERY_LEVEL: + node.setBatteryPercent(Integer.parseInt(msg.getMsg())); + logger.debug("Battery percent for node {} update to: {}%", node.getNodeId(), + node.getBatteryPercent()); + myEventRegister.notifyNodeUpdateEvent(node, null, null, MySensorsNodeUpdateEventType.BATTERY); + ret = true; + break; + } + + } + + return ret; + + } + + private void updateLastUpdateFromMessage(MySensorsMessage msg) { + Date now = new Date(); + + // Last update updated only for incoming message + if (msg != null) { + MySensorsNode node = getNode(msg.getNodeId()); + + if (node != null) { + + node.setLastUpdate(now); + + MySensorsChild child = getChild(msg.getNodeId(), msg.getChildId()); + + if (child != null) { + child.setLastUpdate(now); + + MySensorsVariable var = getVariable(msg.getNodeId(), msg.getChildId(), msg.getSubType()); + + if (var != null) { + var.setLastUpdate(now); + } + } + } + } + } + + private void handleSpecialMessageEvent(MySensorsMessage msg) { + + // Is this an I_CONFIG message? + if (msg.isIConfigMessage()) { + answerIConfigMessage(msg); + } + + // Is this an I_TIME message? + if (msg.isITimeMessage()) { + answerITimeMessage(msg); + } + + // Requesting ID + if (msg.isIdRequestMessage()) { + answerIDRequest(); + } + } + + /** + * Answer to I_TIME message for gateway time request from sensor + * + * @param msg, the incoming I_TIME message from sensor + */ + private void answerITimeMessage(MySensorsMessage msg) { + logger.info("I_TIME request received from {}, answering...", msg.getNodeId()); + + String time = Long.toString(System.currentTimeMillis() / 1000); + MySensorsMessage newMsg = new MySensorsMessage(msg.getNodeId(), msg.getChildId(), + MySensorsMessage.MYSENSORS_MSG_TYPE_INTERNAL, 0, false, MySensorsMessage.MYSENSORS_SUBTYPE_I_TIME, + time); + myCon.sendMessage(newMsg); + + } + + /** + * Answer to I_CONFIG message for imperial/metric request from sensor + * + * @param msg, the incoming I_CONFIG message from sensor + */ + private void answerIConfigMessage(MySensorsMessage msg) { + boolean imperial = myConf.getImperial(); + String iConfig = imperial ? "I" : "M"; + + logger.debug("I_CONFIG request received from {}, answering: (is imperial?){}", iConfig, imperial); + + MySensorsMessage newMsg = new MySensorsMessage(msg.getNodeId(), msg.getChildId(), + MySensorsMessage.MYSENSORS_MSG_TYPE_INTERNAL, 0, false, MySensorsMessage.MYSENSORS_SUBTYPE_I_CONFIG, + iConfig); + myCon.sendMessage(newMsg); + + } + + /** + * If an ID-Request from a sensor is received the controller will send an id to the sensor + */ + private void answerIDRequest() { + logger.info("ID Request received"); + + int newId = 0; + try { + newId = reserveId(); + logger.info("New Node in the MySensors network has requested an ID. ID is: {}", newId); + MySensorsMessage newMsg = new MySensorsMessage(MySensorsNode.MYSENSORS_NODE_ID_RESERVED_255, + MySensorsChild.MYSENSORS_CHILD_ID_RESERVED_255, MySensorsMessage.MYSENSORS_MSG_TYPE_INTERNAL, + MySensorsMessage.MYSENSORS_ACK_FALSE, false, 4, newId + ""); + myCon.sendMessage(newMsg); + } catch (NoMoreIdsException e) { + logger.error("No more IDs available for this node, you could try cleaning cache file"); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/gateway/MySensorsGatewayConfig.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/gateway/MySensorsGatewayConfig.java new file mode 100644 index 000000000000..674155e2e847 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/gateway/MySensorsGatewayConfig.java @@ -0,0 +1,202 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.gateway; + +/** + * Holds the configuration and parameters of the MySensors gateway. + * + * @author Tim Oberföll + * @author Andrea Cioni + * + */ +public class MySensorsGatewayConfig { + + /** + * Is a serial or ip gateway? + */ + private MySensorsGatewayType gatewayType; + + // GLOBALS + /** + * Delay at which messages are send from the internal queue to the MySensors network + */ + private Integer sendDelay; + + /** + * Should nodes send imperial or metric values? + */ + private Boolean imperial; // + + /** + * Should the startup check of the bridge at boot skipped? + */ + private Boolean skipStartupCheck; + + /** + * Network sanity check enabled? + */ + private Boolean enableNetworkSanCheck; + + /** + * Determines interval to start NetworkSanityCheck + */ + private Integer sanityCheckerInterval; + + /** + * Connection will wait this number of attempts before disconnecting + */ + private Integer sanCheckConnectionFailAttempts; + + /** + * Network sanity checker will also send heartbeats to all known nodes + */ + private boolean sanCheckSendHeartbeat; + + /** + * Disconnect nodes that fail to answer to heartbeat request + */ + private Integer sanCheckSendHeartbeatFailAttempts; + + // SERIAL + /** + * Serial port the gateway is attached to + */ + private String serialPort; + + /** + * Baud rate used to connect the serial port + */ + private Integer baudRate; + + // Ip + /** + * ip address the gateway is attached to + */ + private String ipAddress; + + /** + * tcp port the gateway is running at + */ + private Integer tcpPort; + + public MySensorsGatewayType getGatewayType() { + return gatewayType; + } + + public void setGatewayType(MySensorsGatewayType gatewayType) { + this.gatewayType = gatewayType; + } + + public String getSerialPort() { + return serialPort; + } + + public void setSerialPort(String serialPort) { + this.serialPort = serialPort; + } + + public String getIpAddress() { + return ipAddress; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } + + public Integer getTcpPort() { + return tcpPort; + } + + public void setTcpPort(Integer tcpPort) { + this.tcpPort = tcpPort; + } + + public Integer getSendDelay() { + return sendDelay; + } + + public void setSendDelay(Integer sendDelay) { + this.sendDelay = sendDelay; + } + + public Integer getBaudRate() { + return baudRate; + } + + public void setBaudRate(Integer baudRate) { + this.baudRate = baudRate; + } + + public Boolean getImperial() { + return imperial; + } + + public void setImperial(Boolean imperial) { + this.imperial = imperial; + } + + public Boolean getSkipStartupCheck() { + return skipStartupCheck; + } + + public void setSkipStartupCheck(Boolean skipStartupCheck) { + this.skipStartupCheck = skipStartupCheck; + } + + public Boolean getEnableNetworkSanCheck() { + return enableNetworkSanCheck; + } + + public void setEnableNetworkSanCheck(Boolean enableNetworkSanCheck) { + this.enableNetworkSanCheck = enableNetworkSanCheck; + } + + public Integer getSanityCheckerInterval() { + return sanityCheckerInterval; + } + + public void setSanityCheckerInterval(Integer sanityCheckerInterval) { + this.sanityCheckerInterval = sanityCheckerInterval; + } + + public Integer getSanCheckConnectionFailAttempts() { + return sanCheckConnectionFailAttempts; + } + + public void setSanCheckConnectionFailAttempts(Integer sanCheckConnectionFailAttempts) { + this.sanCheckConnectionFailAttempts = sanCheckConnectionFailAttempts; + } + + public boolean getSanCheckSendHeartbeat() { + return sanCheckSendHeartbeat; + } + + public void setSanCheckSendHeartbeat(boolean sanCheckSendHeartbeat) { + this.sanCheckSendHeartbeat = sanCheckSendHeartbeat; + } + + public Integer getSanCheckSendHeartbeatFailAttempts() { + return sanCheckSendHeartbeatFailAttempts; + } + + public void setSanCheckSendHeartbeatFailAttempts(Integer sanCheckSendHeartbeatFailAttempts) { + this.sanCheckSendHeartbeatFailAttempts = sanCheckSendHeartbeatFailAttempts; + } + + @Override + public String toString() { + return "MySensorsGatewayConfig [gatewayType=" + gatewayType + ", sendDelay=" + sendDelay + ", imperial=" + + imperial + ", skipStartupCheck=" + skipStartupCheck + ", enableNetworkSanCheck=" + + enableNetworkSanCheck + ", sanityCheckerInterval=" + sanityCheckerInterval + + ", sanCheckConnectionFailAttempts=" + sanCheckConnectionFailAttempts + ", sanCheckSendHeartbeat=" + + sanCheckSendHeartbeat + ", sanCheckSendHeartbeatFailAttempts=" + sanCheckSendHeartbeatFailAttempts + + ", serialPort=" + serialPort + ", baudRate=" + baudRate + ", ipAddress=" + ipAddress + ", tcpPort=" + + tcpPort + "]"; + } +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/gateway/MySensorsGatewayType.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/gateway/MySensorsGatewayType.java new file mode 100644 index 000000000000..756c2295e251 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/gateway/MySensorsGatewayType.java @@ -0,0 +1,14 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.gateway; + +public enum MySensorsGatewayType { + SERIAL, + IP +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/gateway/MySensorsNetworkSanityChecker.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/gateway/MySensorsNetworkSanityChecker.java new file mode 100644 index 000000000000..18e635e866b2 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/gateway/MySensorsNetworkSanityChecker.java @@ -0,0 +1,268 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.gateway; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; + +import org.openhab.binding.mysensors.internal.event.MySensorsEventRegister; +import org.openhab.binding.mysensors.internal.event.MySensorsGatewayEventListener; +import org.openhab.binding.mysensors.internal.protocol.MySensorsAbstractConnection; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.MySensorsNode; +import org.openhab.binding.mysensors.internal.sensors.MySensorsNodeConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Regulary checks the status of the link to the gateway to the MySensors network. + * + * @author Andrea Cioni + * + */ +public class MySensorsNetworkSanityChecker implements MySensorsGatewayEventListener, Runnable { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + private static final int SEND_DELAY = 3000; + + private MySensorsEventRegister myEventRegister; + private MySensorsAbstractConnection myCon; + private MySensorsGateway myGateway; + + private final int scheduleMinuteDelay; + private final int maxAttemptsBeforeDisconnecting; + + private final boolean sendHeartbeat; + private final int maxAttemptsBeforeDisconnectingNodes; + + private ScheduledExecutorService scheduler = null; + private ScheduledFuture futureSanityChk = null; + + private Integer iVersionMessageMissing = 0; + private boolean iVersionMessageArrived = false; + + private Map missingHearbeatsMap = null; + + public MySensorsNetworkSanityChecker(MySensorsGateway myGateway, MySensorsEventRegister myEventRegister, + MySensorsAbstractConnection myCon) { + this.myGateway = myGateway; + this.myCon = myCon; + this.myEventRegister = myEventRegister; + this.scheduleMinuteDelay = myGateway.getConfiguration().getSanityCheckerInterval(); + this.maxAttemptsBeforeDisconnecting = myGateway.getConfiguration().getSanCheckConnectionFailAttempts(); + this.sendHeartbeat = myGateway.getConfiguration().getSanCheckSendHeartbeat(); + this.maxAttemptsBeforeDisconnectingNodes = myGateway.getConfiguration().getSanCheckSendHeartbeatFailAttempts(); + } + + /** + * Starts the sanity check of the network. + * Tests if the connection to the bridge is still alive. + */ + public void start() { + reset(); + + if (futureSanityChk == null && scheduler == null) { + scheduler = Executors.newSingleThreadScheduledExecutor(); + futureSanityChk = scheduler.scheduleWithFixedDelay(this, scheduleMinuteDelay, scheduleMinuteDelay, + TimeUnit.MINUTES); + } else { + logger.warn("Network Sanity Checker is alredy running"); + } + } + + /** + * Stops the sanity check of the network. + */ + public void stop() { + logger.info("Network Sanity Checker thread stopped"); + + if (futureSanityChk != null) { + futureSanityChk.cancel(true); + futureSanityChk = null; + } + + if (scheduler != null) { + scheduler.shutdown(); + scheduler.shutdownNow(); + scheduler = null; + } + + } + + @Override + public void run() { + Thread.currentThread().setName(MySensorsNetworkSanityChecker.class.getName()); + + try { + + myEventRegister.addEventListener(this); + + if (checkConnectionStatus()) { // Connection is ok, let's go on with other check + + if (sendHeartbeat) { + logger.debug("Sending I_HEARTBEAT_REQUESTs"); + sendHeartbeatRequest(); + Thread.sleep(SEND_DELAY); + checkHeartbeatsResponse(); + } + + checkExpectedUpdate(); + + } + + } catch (Exception e) { + logger.error("Exception in network sanity thread checker", e); + } finally { + myEventRegister.removeEventListener(this); + } + } + + private void checkExpectedUpdate() { + for (Integer nodeId : myGateway.getGivenIds()) { + MySensorsNode node = myGateway.getNode(nodeId); + if (node != null) { + Optional c = node.getNodeConfig(); + if (c.isPresent()) { + MySensorsNodeConfig nodeConfig = c.get(); + int minutesTimeout = nodeConfig.getExpectUpdateTimeout(); + if (minutesTimeout > 0) { + if (!nodeConfig.getRequestHeartbeatResponse()) { + long nodeLastUpdate = node.getLastUpdate().getTime(); + long minutesTimeoutMillis = minutesTimeout * 60 * 1000; + logger.debug("Node {} request update every {} minutes, current: {}", nodeId, minutesTimeout, + (System.currentTimeMillis() - nodeLastUpdate) / (1000 * 60)); + if (((System.currentTimeMillis() - nodeLastUpdate) > minutesTimeoutMillis) + && node.isReachable()) { + logger.warn("Node {} not receive excpected update", nodeId); + node.setReachable(false); + myEventRegister.notifyNodeReachEvent(node, false); + } + } else { + logger.warn( + "Check expected update can't be performed on node {} if request heartbeat is active."); + } + } + } + } + } + } + + private void checkHeartbeatsResponse() { + for (Integer nodeId : myGateway.getGivenIds()) { + MySensorsNode node = myGateway.getNode(nodeId); + if (node != null) { + Optional c = node.getNodeConfig(); + if (c.isPresent()) { + MySensorsNodeConfig nodeConfig = c.get(); + if (nodeConfig.getRequestHeartbeatResponse()) { + synchronized (missingHearbeatsMap) { + Integer missingHearbeat = missingHearbeatsMap.get(nodeId); + logger.debug("Node {} request heartbreat answer, missing {} of {}", nodeId, missingHearbeat, + maxAttemptsBeforeDisconnectingNodes); + if ((missingHearbeat > maxAttemptsBeforeDisconnectingNodes) && node.isReachable()) { + node.setReachable(false); + myEventRegister.notifyNodeReachEvent(node, false); + } else if ((missingHearbeat <= maxAttemptsBeforeDisconnectingNodes) + && !node.isReachable()) { + node.setReachable(true); + myEventRegister.notifyNodeReachEvent(node, true); + } + } + } + } + + } + } + } + + private void sendHeartbeatRequest() { + synchronized (missingHearbeatsMap) { + for (Integer nodeId : myGateway.getGivenIds()) { + if (nodeId != null) { + MySensorsMessage msg = new MySensorsMessage(nodeId, MySensorsChild.MYSENSORS_CHILD_ID_RESERVED_255, + MySensorsMessage.MYSENSORS_MSG_TYPE_INTERNAL, 0, false, + MySensorsMessage.MYSENSORS_SUBTYPE_I_HEARTBEAT_REQUEST, ""); + myGateway.sendMessage(msg); + + } + } + } + } + + /** + * Check connection status based on the {@link MySensorsGatewayConfig} + * + * @return true if connection is ok and no request for disconnection done + * + * @throws InterruptedException see Thread.sleep for more info + */ + private boolean checkConnectionStatus() throws InterruptedException { + boolean ret = true; + myGateway.sendMessage(MySensorsMessage.I_VERSION_MESSAGE); + + Thread.sleep(SEND_DELAY); + + synchronized (iVersionMessageMissing) { + + if (!iVersionMessageArrived) { + logger.warn("I_VERSION message response is not arrived. Remained attempts before disconnection {}", + maxAttemptsBeforeDisconnecting - iVersionMessageMissing); + + if ((maxAttemptsBeforeDisconnecting - iVersionMessageMissing) <= 0) { + logger.error("Retry period expired, gateway is down. Disconneting bridge..."); + + myCon.requestDisconnection(true); + ret = false; + + } else { + iVersionMessageMissing++; + } + } else { + logger.debug("Network sanity check: PASSED"); + iVersionMessageMissing = 0; + } + + iVersionMessageArrived = false; + } + + return ret; + } + + private void reset() { + synchronized (iVersionMessageMissing) { + iVersionMessageArrived = false; + iVersionMessageMissing = 0; + missingHearbeatsMap = new HashMap<>(); + } + } + + @Override + public void messageReceived(MySensorsMessage message) throws Exception { + synchronized (iVersionMessageMissing) { + if (!iVersionMessageArrived) { + if (message.isIVersionMessage()) { + iVersionMessageArrived = true; + } + } + } + + synchronized (missingHearbeatsMap) { + if (message.isHeartbeatResponseMessage()) { + missingHearbeatsMap.put(message.getNodeId(), 0); // Reset or set if exist + } + } + } +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/protocol/MySensorsAbstractConnection.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/protocol/MySensorsAbstractConnection.java new file mode 100644 index 000000000000..b94f92e03a31 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/protocol/MySensorsAbstractConnection.java @@ -0,0 +1,750 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.protocol; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import org.openhab.binding.mysensors.internal.event.MySensorsEventRegister; +import org.openhab.binding.mysensors.internal.exception.NoAckException; +import org.openhab.binding.mysensors.internal.gateway.MySensorsGatewayConfig; +import org.openhab.binding.mysensors.internal.gateway.MySensorsNetworkSanityChecker; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Connection of the bridge (via TCP/IP or serial) to the MySensors network. + * + * @author Tim Oberföll + * @author Andrea Cioni + * + */ +public abstract class MySensorsAbstractConnection implements Runnable { + + // Used by the reader to request a disconnection if there are too much exception + private static final int ERROR_COUNT_REQ_DISCONNECT = 5; + + // How often and at which times should the binding retry to send a message if requestAck is true? + public static final int MYSENSORS_NUMBER_OF_RETRIES = 5; + public static final int[] MYSENSORS_RETRY_TIMES = { 0, 100, 500, 1000, 2000 }; + + // Wait time Arduino reset + public final static int RESET_TIME = 3000; + + // How long should a Smartsleep message be left in the queue? + public static final int MYSENSORS_SMARTSLEEP_TIMEOUT = 216000; // 6 hours + + protected Logger logger = LoggerFactory.getLogger(getClass()); + + // Connector will check for connection status every CONNECTOR_INTERVAL_CHECK seconds + public static final int CONNECTOR_INTERVAL_CHECK = 10; + + // Flag setted to true while connection is up + private boolean connected = false; + + // Flag to be set (through available method below) + private boolean requestDisconnection = false; + + private Object waitingObj = null; + + // I_VERSION response flag + private boolean iVersionResponse = false; + + // Check connection on startup flag + private boolean skipStartupCheck = false; + + // Reader and writer thread + protected MySensorsWriter mysConWriter = null; + protected MySensorsReader mysConReader = null; + + protected MySensorsEventRegister myEventRegister = null; + + protected MySensorsGatewayConfig myGatewayConfig = null; + + // Sanity checker + private MySensorsNetworkSanityChecker netSanityChecker = null; + + // Connection retry done + private int numOfRetry = 0; + + private int errorCount; + + // Connection status watchdog + private ScheduledExecutorService watchdogExecutor = null; + private Future futureWatchdog = null; + + public MySensorsAbstractConnection(MySensorsGatewayConfig myGatewayConfig, MySensorsEventRegister myEventRegister) { + this.myEventRegister = myEventRegister; + this.myGatewayConfig = myGatewayConfig; + this.watchdogExecutor = Executors.newSingleThreadScheduledExecutor(); + this.iVersionResponse = false; + this.errorCount = 0; + } + + /** + * Initialization of the BridgeConnection + */ + public void initialize() { + logger.debug("Set skip check on startup to: {}", myGatewayConfig.getSkipStartupCheck()); + skipStartupCheck = myGatewayConfig.getSkipStartupCheck(); + + // Launch connection watchdog + logger.debug("Enabling connection watchdog"); + futureWatchdog = watchdogExecutor.scheduleWithFixedDelay(this, 0, CONNECTOR_INTERVAL_CHECK, TimeUnit.SECONDS); + } + + @Override + public void run() { + Thread.currentThread().setName(MySensorsAbstractConnection.class.getName()); + + if (requestingDisconnection()) { + logger.info("Connection request disconnection..."); + requestDisconnection(false); + disconnect(); + } + + if (!connected) { + if (connect()) { + logger.info("Successfully connected to MySensors Bridge."); + + numOfRetry = 0; + } else { + logger.error("Failed connecting to bridge...next retry in {} seconds (Retry No.:{})", + CONNECTOR_INTERVAL_CHECK, numOfRetry); + numOfRetry++; + disconnect(); + } + + } else { + logger.trace("Bridge is connected, connection skipped"); + } + + } + + /** + * Startup connection with bridge + * + * @return true, if connection established correctly + */ + private boolean connect() { + connected = establishConnection(); + myEventRegister.notifyBridgeStatusUpdate(this, isConnected()); + return connected; + } + + protected abstract boolean establishConnection(); + + /** + * Shutdown method that allows the correct disconnection with the used bridge + */ + private void disconnect() { + + if (netSanityChecker != null) { + netSanityChecker.stop(); + netSanityChecker = null; + } + + stopConnection(); + connected = false; + requestDisconnection = false; + iVersionResponse = false; + + myEventRegister.notifyBridgeStatusUpdate(this, isConnected()); + } + + protected abstract void stopConnection(); + + /** + * Stop all threads holding the connection (serial/tcp). + */ + public void destroy() { + logger.debug("Destroying connection"); + + if (connected) { + disconnect(); + } + + if (futureWatchdog != null) { + futureWatchdog.cancel(true); + futureWatchdog = null; + } + + if (watchdogExecutor != null) { + watchdogExecutor.shutdown(); + watchdogExecutor.shutdownNow(); + } + + } + + /** + * Start thread managing the incoming/outgoing messages. It also have the task to test the connection to gateway by + * sending a special message (I_VERSION) to it + * + * @return true if the gateway test pass successfully + */ + protected boolean startReaderWriterThread(MySensorsReader reader, MySensorsWriter writer) { + + reader.startReader(); + writer.startWriter(); + + if (!skipStartupCheck) { + try { + int i = 0; + synchronized (this) { + while (!iVersionResponse && i < 5) { + sendMessage(MySensorsMessage.I_VERSION_MESSAGE); + waitingObj = this; + waitingObj.wait(1000); + i++; + } + } + } catch (Exception e) { + logger.error("Exception on waiting for I_VERSION message", e); + } + } else { + logger.warn("Skipping I_VERSION connection test, not recommended..."); + iVersionResponse = true; + } + + if (!iVersionResponse) { + logger.error( + "Cannot start reading/writing thread, probably sync message (I_VERSION) not received. Try set skipStartupCheck to true"); + } + + return iVersionResponse; + } + + /** + * Add a message to the outbound queue. The message will be send automatically. FIFO queue. + * This method also has the task to populate oldMessage (and keep track thought oldMsgContent map) field on + * MySensorsMessage + * + * @param msg The message that should be send. + */ + public void sendMessage(MySensorsMessage msg) { + + if (msg.isSmartSleep()) { + mysConWriter.addMySensorsOutboundSmartSleepMessage(msg); + } else { + mysConWriter.addMySensorsOutboundMessage(msg); + } + } + + /** + * Is a connection to the bridge available? + * + * @return true, if connection is up and running. + */ + public boolean isConnected() { + return connected; + } + + public boolean requestingDisconnection() { + return requestDisconnection; + } + + /** + * Start the disconnection process. + * + * @param flag true if the connection should be stopped. + */ + public void requestDisconnection(boolean flag) { + logger.debug("Request disconnection flag setted to: {}", flag); + requestDisconnection = flag; + } + + private void handleReaderWriterException() { + synchronized (this) { + if (errorCount < ERROR_COUNT_REQ_DISCONNECT) { + errorCount++; + } else { + errorCount = 0; + requestDisconnection(true); + } + } + } + + /** + * Implements the reader (IP & serial) that receives the messages from the MySensors network. + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ + protected class MySensorsReader implements Runnable { + private Logger logger = LoggerFactory.getLogger(MySensorsReader.class); + + private ExecutorService executor = Executors.newSingleThreadExecutor(); + private Future future = null; + + private InputStream inStream = null; + private BufferedReader reads = null; + + private boolean stopReader = false; + + public MySensorsReader(InputStream inStream) { + this.inStream = inStream; + this.reads = new BufferedReader(new InputStreamReader(inStream)); + } + + /** + * Starts the reader process that will receive the messages from the MySensors network. + */ + public void startReader() { + future = executor.submit(this); + } + + @Override + public void run() { + Thread.currentThread().setName(MySensorsReader.class.getName()); + String line = null; + + while (!stopReader) { + // Is there something to read? + + try { + if (!reads.ready()) { + Thread.sleep(10); + continue; + } + line = reads.readLine(); + + // We lost connection + if (line == null) { + logger.warn("Connection to Gateway lost!"); + requestDisconnection(true); + break; + } + + logger.debug(line); + MySensorsMessage msg = MySensorsMessage.parse(line); + + // Debug message are useless, just print it + if (!msg.isDebugMessage()) { + msg.setDirection(MySensorsMessage.MYSENSORS_MSG_DIRECTION_INCOMING); + + // Have we get a I_HEARBEAT_RESPONSE + if (msg.isHeartbeatResponseMessage()) { + handleSmartSleepMessage(msg); + } + + // Have we get a I_VERSION message? + if (msg.isIVersionMessage()) { + iVersionMessageReceived(msg.getMsg()); + } + + // Is this an ACK message? + if (msg.getAck() == 1) { + handleAckReceived(msg); + } + + myEventRegister.notifyMessageReceived(msg); + } + + } catch (InterruptedException e) { + logger.warn("Interrupted MySensorsReader"); + } catch (Exception e) { + logger.warn("Exception on reading from connection", e); + handleReaderWriterException(); + + } + + } + + } + + /** + * Stops the reader process of the bridge that receives messages from the MySensors network. + */ + public void stopReader() { + + logger.debug("Stopping Reader thread"); + + this.stopReader = true; + + if (future != null) { + future.cancel(true); + future = null; + } + + if (executor != null) { + executor.shutdown(); + executor.shutdownNow(); + executor = null; + } + + try { + if (reads != null) { + reads.close(); + reads = null; + } + + if (inStream != null) { + inStream.close(); + inStream = null; + } + } catch (IOException e) { + logger.error("Cannot close reader stream"); + } + + } + + private void iVersionMessageReceived(String msg) { + if (waitingObj != null) { + logger.debug("Good,Gateway is up and running! (Ver:{})", msg); + synchronized (waitingObj) { + iVersionResponse = true; + waitingObj.notifyAll(); + waitingObj = null; + } + } + } + + private void handleAckReceived(MySensorsMessage msg) { + try { + mysConWriter.confirmAcknowledgeMessage(msg); + } catch (NoAckException e) { + logger.warn("Invalid ACK message received: {}", e.toString()); + } + } + + /** + * If a heartbeat is received from a node the queue should be checked + * for pending messages for this node. If a message is pending it has to be send immediately. + * + * @param msg The heartbeat message received from a node. + */ + private void handleSmartSleepMessage(MySensorsMessage msg) { + mysConWriter.checkPendingSmartSleepMessage(msg.getNodeId()); + } + + } + + /** + * Implements the writer (IP & serial) that sends messages to the MySensors network. + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ + protected class MySensorsWriter implements Runnable { + private Logger logger = LoggerFactory.getLogger(MySensorsWriter.class); + + private boolean stopWriting = false; // Stop the thread that sends the messages to the MySensors network + + // Blocking queue wait for message + private BlockingQueue outboundMessageQueue = null; + + // Queue for SmartSleep messages + private Queue smartSleepMessageQueue = null; + + // Map for acknowledge + private List acknowledgeMessages = null; + + private PrintWriter outs = null; + private OutputStream outStream = null; + + private ExecutorService executor = Executors.newSingleThreadExecutor(); + private Future future = null; + + public MySensorsWriter(OutputStream outStream) { + this.outStream = outStream; + this.outboundMessageQueue = new LinkedBlockingQueue<>(); + this.smartSleepMessageQueue = new LinkedList<>(); + this.acknowledgeMessages = new LinkedList<>(); + this.outs = new PrintWriter(outStream); + } + + /** + * Start the writer Process that will poll messages from the FIFO outbound queue + * and send them to the MySensors network. + */ + public void startWriter() { + future = executor.submit(this); + } + + @Override + public void run() { + Thread.currentThread().setName(MySensorsWriter.class.getName()); + while (!stopWriting) { + + try { + MySensorsMessage msg = pollMySensorsOutboundQueue(); + synchronized (outboundMessageQueue) { + if (msg != null) { + + if (msg.getNextSend() < System.currentTimeMillis()) { + /* + * if we request an ACK we will wait for it and keep the message in the queue (at the + * end) otherwise we remove the message from the queue + */ + if (msg.getAck() == 1) { + if (!checkMessageAcknowledge(msg)) { + msg.setRetries(msg.getRetries() + 1); + if (!(msg.getRetries() > MYSENSORS_NUMBER_OF_RETRIES)) { + msg.setNextSend(System.currentTimeMillis() + + MYSENSORS_RETRY_TIMES[msg.getRetries() - 1]); + addMySensorsOutboundMessage(msg); + } else { + logger.warn("NO ACK for message: {}", + MySensorsMessage.generateAPIString(msg)); + myEventRegister.notifyAckNotReceived(msg); + continue; + } + } else { + logger.info("ACK received for message: {}", + MySensorsMessage.generateAPIString(msg)); + continue; + } + + } + String output = MySensorsMessage.generateAPIString(msg); + logger.debug("Sending to MySensors: {}", output.trim()); + + sendMessage(output); + } else { + addMySensorsOutboundMessage(msg); + } + + } else { + logger.warn("Message returned from queue is null"); + } + } + } catch (InterruptedException e) { + logger.warn("Interrupted MySensorsWriter"); + } catch (Exception e) { + logger.error("({}) on writing to connection, message: {}", e, getClass(), e.getMessage()); + handleReaderWriterException(); + } + + try { + Thread.sleep(myGatewayConfig.getSendDelay()); + } catch (Exception e) { + } + } + } + + /** + * Stops the writer process. + */ + public void stopWriting() { + + logger.debug("Stopping Writer thread"); + + this.stopWriting = true; + + if (future != null) { + future.cancel(true); + future = null; + } + + if (executor != null) { + executor.shutdown(); + executor.shutdownNow(); + executor = null; + } + + try { + if (outs != null) { + outs.flush(); + outs.close(); + outs = null; + } + + if (outStream != null) { + outStream.close(); + outStream = null; + } + } catch (IOException e) { + logger.error("Cannot close writer stream"); + } + + } + + /** + * Send a message to the MySensors network. + * + * @param output the message/string/line that should be send to the MySensors gateway. + */ + protected void sendMessage(String output) { + outs.println(output); + outs.flush(); + } + + /** + * Confirm acknowledge for a message from the outbound message queue. + * + * @param msg The message that should be acknowledged from the queue. + * @throws NoAckException + */ + private void confirmAcknowledgeMessage(MySensorsMessage msg) throws NoAckException { + if (msg == null) { + throw new NoAckException("Invalid ack message to insert"); + } + + synchronized (acknowledgeMessages) { + acknowledgeMessages.add(msg); + } + } + + /** + * Confirm acknowledge for a message from the outbound message queue. + * This removes every acknowledge message + * + * @param msg The message that should be acknowledged from the queue. + * + * @return true if message is confirmed + */ + private boolean checkMessageAcknowledge(MySensorsMessage msg) { + boolean ret = false; + synchronized (acknowledgeMessages) { + Iterator iterator = acknowledgeMessages.iterator(); + while (iterator.hasNext()) { + MySensorsMessage ackM = iterator.next(); + if (ackM.getNodeId() == msg.getNodeId() && ackM.getChildId() == msg.getChildId() + && ackM.getMsgType() == msg.getMsgType() && ackM.getSubType() == msg.getSubType() + && ackM.getAck() == msg.getAck() && ackM.getMsg().equals(msg.getMsg())) { + iterator.remove(); + ret = (msg.getRetries() != 0); // First time we only clear old ack, if present + } + } + } + + return ret; + } + + /** + * Store more than one message in the outbound queue. + * + * @param msg the message that should be stored in the queue. + * @param copy the number of copies that should be stored. + */ + private void addMySensorsOutboundMessage(MySensorsMessage msg) { + try { + outboundMessageQueue.put(msg); + } catch (InterruptedException e) { + logger.error("Interrupted message while ruuning"); + } + + } + + /** + * A message to a node that supports smartsleep is not send instantly. + * The message is send in response to a heartbeat received from this node. + * Only one message is allowed in the queue. If a new one arrives the old one + * gets deleted. + * + * @param msg the message that should be added to the queue. + */ + private void addMySensorsOutboundSmartSleepMessage(MySensorsMessage msg) { + + // Only one pending message is allowed in the queue. + removeSmartSleepMessage(msg.getNodeId(), msg.getChildId()); + + synchronized (smartSleepMessageQueue) { + smartSleepMessageQueue.add(msg); + } + + } + + /** + * Get the next message in line from the queue. + * + * @return the next message in line. + * @throws InterruptedException + */ + private MySensorsMessage pollMySensorsOutboundQueue() throws InterruptedException { + return outboundMessageQueue.poll(1, TimeUnit.DAYS); + } + + /** + * Remove all messages in the smartsleep queue for a corresponding nodeId / childId combination + * + * @param nodeId the nodeId which messages should be deleted. + * @param childId the childId which messages should be deleted. + */ + private void removeSmartSleepMessage(int nodeId, int childId) { + synchronized (smartSleepMessageQueue) { + Iterator iterator = smartSleepMessageQueue.iterator(); + if (iterator != null) { + while (iterator.hasNext()) { + MySensorsMessage msgInQueue = iterator.next(); + if (msgInQueue.getNodeId() == nodeId && msgInQueue.getChildId() == childId) { + iterator.remove(); + } else { + logger.debug("Message NOT removed for nodeId: {} and childId: {}.", nodeId, childId); + } + } + } + } + + } + + /** + * Checks if a message is in the smartsleep queue and adds it to the outbound queues + * + * @param nodeId of the messages that should be send immediately + */ + private void checkPendingSmartSleepMessage(int nodeId) { + synchronized (smartSleepMessageQueue) { + Iterator iterator = smartSleepMessageQueue.iterator(); + if (iterator != null) { + + while (iterator.hasNext()) { + MySensorsMessage msgInQueue = iterator.next(); + if (msgInQueue.getNodeId() == nodeId) { + iterator.remove(); + addMySensorsOutboundMessage(msgInQueue); + logger.debug("Message for nodeId: {} in queue needs to be send immediately!", nodeId); + } + } + } + } + } + + /** + * Debug print of the smart sleep queue content to logs + */ + private void printSmartSleepQueue() { + synchronized (smartSleepMessageQueue) { + Iterator iterator = smartSleepMessageQueue.iterator(); + if (iterator != null) { + + logger.debug("####### START SmartSleep queue #####"); + int i = 1; + while (iterator.hasNext()) { + MySensorsMessage msgInQueue = iterator.next(); + + logger.debug("Msg: {}, nodeId: {], childId: {}, nextSend: {}.", i, msgInQueue.getNodeId(), + msgInQueue.getChildId(), msgInQueue.getNextSend()); + i++; + } + logger.debug("####### END SmartSleep queue #####"); + } + } + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/protocol/ip/MySensorsIpConnection.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/protocol/ip/MySensorsIpConnection.java new file mode 100644 index 000000000000..7d9e1b7ffe01 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/protocol/ip/MySensorsIpConnection.java @@ -0,0 +1,97 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.protocol.ip; + +import java.io.IOException; +import java.net.Socket; +import java.net.UnknownHostException; +import org.openhab.binding.mysensors.internal.event.MySensorsEventRegister; +import org.openhab.binding.mysensors.internal.gateway.MySensorsGatewayConfig; +import org.openhab.binding.mysensors.internal.protocol.MySensorsAbstractConnection; + +/** + * Implements the TCP/IP connection to the ethernet gateway of the MySensors network. + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsIpConnection extends MySensorsAbstractConnection { + + private Socket sock = null; + + public MySensorsIpConnection(MySensorsGatewayConfig myConf, MySensorsEventRegister myEventRegister) { + super(myConf, myEventRegister); + } + + /** + * Tries to accomplish a TCP/IP connection via socket to ethernet gateway. + */ + @Override + public boolean establishConnection() { + logger.debug("Connecting to IP bridge [{}:{}]", myGatewayConfig.getIpAddress(), myGatewayConfig.getTcpPort()); + + boolean ret = false; + + if (myGatewayConfig.getIpAddress() == null || myGatewayConfig.getIpAddress().isEmpty()) { + logger.error("IP must be not null/empty"); + } else { + try { + sock = new Socket(myGatewayConfig.getIpAddress(), myGatewayConfig.getTcpPort()); + mysConReader = new MySensorsReader(sock.getInputStream()); + mysConWriter = new MySensorsWriter(sock.getOutputStream()); + + ret = startReaderWriterThread(mysConReader, mysConWriter); + } catch (UnknownHostException e) { + logger.error("Error while trying to connect to: {}:{}", myGatewayConfig.getIpAddress(), + myGatewayConfig.getTcpPort(), e); + } catch (IOException e) { + logger.error("Error while trying to connect InputStreamReader", e); + } + } + + return ret; + } + + /** + * Ensures a clean disconnect from the TCP/IP connection to the gateway. + */ + @Override + public void stopConnection() { + logger.debug("Disconnecting from IP bridge ..."); + + if (mysConWriter != null) { + mysConWriter.stopWriting(); + mysConWriter = null; + } + + if (mysConReader != null) { + mysConReader.stopReader(); + mysConReader = null; + } + + // Shut down socket + try { + if (sock != null && sock.isConnected()) { + sock.close(); + sock = null; + } + } catch (IOException e) { + logger.error("cannot disconnect from socket, message: {}", e.getMessage()); + } + + } + + @Override + public String toString() { + return "MySensorsIpConnection [ipAddress=" + myGatewayConfig.getIpAddress() + ", tcpPort=" + + myGatewayConfig.getTcpPort() + "]"; + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/protocol/message/MySensorsMessage.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/protocol/message/MySensorsMessage.java new file mode 100644 index 000000000000..d6c38359de5c --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/protocol/message/MySensorsMessage.java @@ -0,0 +1,665 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.protocol.message; + +import java.text.ParseException; + +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.MySensorsNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Used to store the content of a MySensors message. + * + * @author Tim Oberföll + * + */ +public class MySensorsMessage { + + // Message direction + public static final int MYSENSORS_MSG_DIRECTION_INCOMING = 0; + public static final int MYSENSORS_MSG_DIRECTION_OUTGOING = 1; + + // Message parts + public static final int MYSENSORS_MSG_PART_NODE = 0; + public static final int MYSENSORS_MSG_PART_CHILD = 1; + public static final int MYSENSORS_MSG_PART_TYPE = 2; + public static final int MYSENSORS_MSG_PART_ACK = 3; + public static final int MYSENSORS_MSG_PART_SUBTYPE = 4; + public static final int MYSENSORS_MSG_PART_PAYLOAD = 5; + + // Message types of the MySensors network + public static final int MYSENSORS_MSG_TYPE_PRESENTATION = 0; + public static final int MYSENSORS_MSG_TYPE_SET = 1; + public static final int MYSENSORS_MSG_TYPE_REQ = 2; + public static final int MYSENSORS_MSG_TYPE_INTERNAL = 3; + public static final int MYSENSORS_MSG_TYPE_STREAM = 4; + + // NO ACK + public static final int MYSENSORS_ACK_TRUE = 1; + public static final int MYSENSORS_ACK_FALSE = 0; + + // Subtypes for presentation + public static final int MYSENSORS_SUBTYPE_S_DOOR = 0; + public static final int MYSENSORS_SUBTYPE_S_MOTION = 1; + public static final int MYSENSORS_SUBTYPE_S_SMOKE = 2; + public static final int MYSENSORS_SUBTYPE_S_LIGHT = 3; + public static final int MYSENSORS_SUBTYPE_S_BINARY = 3; // Old S_LIGHT in MS API < 2.1 + public static final int MYSENSORS_SUBTYPE_S_DIMMER = 4; + public static final int MYSENSORS_SUBTYPE_S_COVER = 5; + public static final int MYSENSORS_SUBTYPE_S_TEMP = 6; + public static final int MYSENSORS_SUBTYPE_S_HUM = 7; + public static final int MYSENSORS_SUBTYPE_S_BARO = 8; + public static final int MYSENSORS_SUBTYPE_S_WIND = 9; + public static final int MYSENSORS_SUBTYPE_S_RAIN = 10; + public static final int MYSENSORS_SUBTYPE_S_UV = 11; + public static final int MYSENSORS_SUBTYPE_S_WEIGHT = 12; + public static final int MYSENSORS_SUBTYPE_S_POWER = 13; + public static final int MYSENSORS_SUBTYPE_S_HEATER = 14; + public static final int MYSENSORS_SUBTYPE_S_DISTANCE = 15; + public static final int MYSENSORS_SUBTYPE_S_LIGHT_LEVEL = 16; + public static final int MYSENSORS_SUBTYPE_S_LOCK = 19; + public static final int MYSENSORS_SUBTYPE_S_IR = 20; + public static final int MYSENSORS_SUBTYPE_S_WATER = 21; + public static final int MYSENSORS_SUBTYPE_S_AIR_QUALITY = 22; + public static final int MYSENSORS_SUBTYPE_S_CUSTOM = 23; + public static final int MYSENSORS_SUBTYPE_S_RGB_LIGHT = 26; + public static final int MYSENSORS_SUBTYPE_S_RGBW_LIGHT = 27; + public static final int MYSENSORS_SUBTYPE_S_HVAC = 29; + public static final int MYSENSORS_SUBTYPE_S_MULTIMETER = 30; + public static final int MYSENSORS_SUBTYPE_S_SPRINKLER = 31; + public static final int MYSENSORS_SUBTYPE_S_WATER_LEAK = 32; + public static final int MYSENSORS_SUBTYPE_S_SOUND = 33; + public static final int MYSENSORS_SUBTYPE_S_VIBRATION = 34; + public static final int MYSENSORS_SUBTYPE_S_MOISTURE = 35; + public static final int MYSENSORS_SUBTYPE_S_INFO = 36; + public static final int MYSENSORS_SUBTYPE_S_GAS = 37; + public static final int MYSENSORS_SUBTYPE_S_GPS = 38; + public static final int MYSENSORS_SUBTYPE_S_WATER_QUALITY = 39; + public static final int MYSENSORS_SUBTYPE_S_SCENE_CONTROLLER = 25; + public static final int MYSENSORS_SUBTYPE_S_DUST = 24; + public static final int MYSENSORS_SUBTYPE_S_COLOR_SENSOR = 28; + public static final int MYSENSORS_SUBTYPE_S_ARDUINO_REPEATER_NODE = 18; + public static final int MYSENSORS_SUBTYPE_S_ARDUINO_NODE = 17; + + // Subtypes for set, req + public static final int MYSENSORS_SUBTYPE_V_TEMP = 0; + public static final int MYSENSORS_SUBTYPE_V_HUM = 1; + public static final int MYSENSORS_SUBTYPE_V_STATUS = 2; + public static final int MYSENSORS_SUBTYPE_V_PERCENTAGE = 3; + public static final int MYSENSORS_SUBTYPE_V_PRESSURE = 4; + public static final int MYSENSORS_SUBTYPE_V_FORECAST = 5; + public static final int MYSENSORS_SUBTYPE_V_RAIN = 6; + public static final int MYSENSORS_SUBTYPE_V_RAINRATE = 7; + public static final int MYSENSORS_SUBTYPE_V_WIND = 8; + public static final int MYSENSORS_SUBTYPE_V_GUST = 9; + public static final int MYSENSORS_SUBTYPE_V_DIRECTION = 10; + public static final int MYSENSORS_SUBTYPE_V_UV = 11; + public static final int MYSENSORS_SUBTYPE_V_WEIGHT = 12; + public static final int MYSENSORS_SUBTYPE_V_DISTANCE = 13; + public static final int MYSENSORS_SUBTYPE_V_IMPEDANCE = 14; + public static final int MYSENSORS_SUBTYPE_V_ARMED = 15; + public static final int MYSENSORS_SUBTYPE_V_TRIPPED = 16; + public static final int MYSENSORS_SUBTYPE_V_WATT = 17; + public static final int MYSENSORS_SUBTYPE_V_KWH = 18; + public static final int MYSENSORS_SUBTYPE_V_SCENE_ON = 19; + public static final int MYSENSORS_SUBTYPE_V_SCENE_OFF = 20; + public static final int MYSENSORS_SUBTYPE_V_HVAC_FLOW_STATE = 21; + public static final int MYSENSORS_SUBTYPE_V_HVAC_SPEED = 22; + public static final int MYSENSORS_SUBTYPE_V_LIGHT_LEVEL = 23; + public static final int MYSENSORS_SUBTYPE_V_VAR1 = 24; + public static final int MYSENSORS_SUBTYPE_V_VAR2 = 25; + public static final int MYSENSORS_SUBTYPE_V_VAR3 = 26; + public static final int MYSENSORS_SUBTYPE_V_VAR4 = 27; + public static final int MYSENSORS_SUBTYPE_V_VAR5 = 28; + public static final int MYSENSORS_SUBTYPE_V_UP = 29; + public static final int MYSENSORS_SUBTYPE_V_DOWN = 30; + public static final int MYSENSORS_SUBTYPE_V_STOP = 31; + public static final int MYSENSORS_SUBTYPE_V_IR_SEND = 32; + public static final int MYSENSORS_SUBTYPE_V_IR_RECEIVE = 33; + public static final int MYSENSORS_SUBTYPE_V_FLOW = 34; + public static final int MYSENSORS_SUBTYPE_V_VOLUME = 35; + public static final int MYSENSORS_SUBTYPE_V_LOCK_STATUS = 36; + public static final int MYSENSORS_SUBTYPE_V_LEVEL = 37; + public static final int MYSENSORS_SUBTYPE_V_VOLTAGE = 38; + public static final int MYSENSORS_SUBTYPE_V_CURRENT = 39; + public static final int MYSENSORS_SUBTYPE_V_RGB = 40; + public static final int MYSENSORS_SUBTYPE_V_RGBW = 41; + public static final int MYSENSORS_SUBTYPE_V_ID = 42; + public static final int MYSENSORS_SUBTYPE_V_UNIT_PREFIX = 43; + public static final int MYSENSORS_SUBTYPE_V_HVAC_SETPOINT_COOL = 44; + public static final int MYSENSORS_SUBTYPE_V_HVAC_SETPOINT_HEAT = 45; + public static final int MYSENSORS_SUBTYPE_V_HVAC_FLOW_MODE = 46; + public static final int MYSENSORS_SUBTYPE_V_TEXT = 47; + public static final int MYSENSORS_SUBTYPE_V_CUSTOM = 48; + public static final int MYSENSORS_SUBTYPE_V_POSITION = 49; + public static final int MYSENSORS_SUBTYPE_V_IR_RECORD = 50; + public static final int MYSENSORS_SUBTYPE_V_PH = 51; + public static final int MYSENSORS_SUBTYPE_V_ORP = 52; + public static final int MYSENSORS_SUBTYPE_V_EC = 53; + public static final int MYSENSORS_SUBTYPE_V_VAR = 54; + public static final int MYSENSORS_SUBTYPE_V_VA = 55; + public static final int MYSENSORS_SUBTYPE_V_POWER_FACTOR = 56; + + public static final int MYSENSORS_SUBTYPE_I_BATTERY_LEVEL = 0; + public static final int MYSENSORS_SUBTYPE_I_TIME = 1; + public static final int MYSENSORS_SUBTYPE_I_VERSION = 2; + public static final int MYSENSORS_SUBTYPE_I_ID_REQUEST = 3; + public static final int MYSENSORS_SUBTYPE_I_ID_RESPONSE = 4; + public static final int MYSENSORS_SUBTYPE_I_INCLUSION_MODE = 5; + public static final int MYSENSORS_SUBTYPE_I_CONFIG = 6; + public static final int MYSENSORS_SUBTYPE_I_FIND_PARENT = 7; + public static final int MYSENSORS_SUBTYPE_I_FIND_PARENT_RESPONSE = 8; + public static final int MYSENSORS_SUBTYPE_I_LOG_MESSAGE = 9; + public static final int MYSENSORS_SUBTYPE_I_CHILDREN = 10; + public static final int MYSENSORS_SUBTYPE_I_SKETCH_NAME = 11; + public static final int MYSENSORS_SUBTYPE_I_SKETCH_VERSION = 12; + public static final int MYSENSORS_SUBTYPE_I_REBOOT = 13; + public static final int MYSENSORS_SUBTYPE_I_GATEWAY_READY = 14; + public static final int MYSENSORS_SUBTYPE_I_REQUEST_SIGNING = 15; + public static final int MYSENSORS_SUBTYPE_I_GET_NONCE = 16; + public static final int MYSENSORS_SUBTYPE_I_GET_NONCE_RESONSE = 17; + public static final int MYSENSORS_SUBTYPE_I_HEARTBEAT_REQUEST = 18; + public static final int MYSENSORS_SUBTYPE_I_PRESENTATION = 19; + public static final int MYSENSORS_SUBTYPE_I_DISCOVER = 20; + public static final int MYSENSORS_SUBTYPE_I_DISCOVER_RESPONSE = 21; + public static final int MYSENSORS_SUBTYPE_I_HEARTBEAT_RESPONSE = 22; + public static final int MYSENSORS_SUBTYPE_I_LOCKED = 23; + public static final int MYSENSORS_SUBTYPE_I_PING = 24; + public static final int MYSENSORS_SUBTYPE_I_PONG = 25; + public static final int MYSENSORS_SUBTYPE_I_REGISTRATION_REQUEST = 26; + public static final int MYSENSORS_SUBTYPE_I_REGISTRATION_RESPONSE = 27; + public static final int MYSENSORS_SUBTYPE_I_DEBUG = 28; + + // I version message for startup check + public static final MySensorsMessage I_VERSION_MESSAGE = new MySensorsMessage( + MySensorsNode.MYSENSORS_NODE_ID_RESERVED_GATEWAY_0, MySensorsChild.MYSENSORS_CHILD_ID_RESERVED_0, + MYSENSORS_MSG_TYPE_INTERNAL, MYSENSORS_ACK_FALSE, false, MYSENSORS_SUBTYPE_I_VERSION, ""); + + private Logger logger = LoggerFactory.getLogger(MySensorsMessage.class); + + private int nodeId = 0; // id of the node in the MySensors network + private int childId = 0; // id of the child of the node (more than one possible) + private int msgType = 0; // type of message: request, internal, presentation ... + private int ack = 0; // is an acknoledgement requested? + private boolean revert = true; // revert status if no ack was received from the node + private int subType = 0; // like: humidity, temperature, light ... + private String msg = ""; // content of the message + private int retries = 0; // number of retries if a message is not acknowledged by the receiver + private long nextSend = 0; // timestamp when the message should be send + private boolean smartSleep = false; // smartsleep message + private int direction = MYSENSORS_MSG_DIRECTION_OUTGOING; // Is this message incoming or outgoing? + + public MySensorsMessage() { + + } + + public MySensorsMessage(int nodeId, int childId, int msgType, int ack, boolean revert) { + setNodeId(nodeId); + setChildId(childId); + setMsgType(msgType); + setAck(ack); + setRevert(revert); + } + + public MySensorsMessage(int nodeId, int childId, int msgType, int ack, boolean revert, boolean smartSleep) { + setNodeId(nodeId); + setChildId(childId); + setMsgType(msgType); + setAck(ack); + setRevert(revert); + setSmartSleep(smartSleep); + } + + public MySensorsMessage(int nodeId, int childId, int msgType, int ack, boolean revert, int subType, String msg) { + setNodeId(nodeId); + setChildId(childId); + setMsgType(msgType); + setAck(ack); + setRevert(revert); + setSubType(subType); + setMsg(msg); + } + + public MySensorsMessage(int nodeId, int childId, int msgType, int ack, boolean revert, int subType, String msg, + boolean smartSleep) { + setNodeId(nodeId); + setChildId(childId); + setMsgType(msgType); + setAck(ack); + setRevert(revert); + setSubType(subType); + setMsg(msg); + setSmartSleep(smartSleep); + } + + /** + * Write message to DEBUG. + */ + public void printDebug() { + logger.debug(getDebugInfo()); + } + + /** + * @return the content of the message as a String. + */ + public String getDebugInfo() { + return String.format("nodeId: %d, childId: %d, msgType: %d, ack: %d, revert: %b, subType: %d ,msg: %s", + this.nodeId, this.childId, this.msgType, this.ack, this.revert, this.subType, this.msg); + } + + public int getNodeId() { + return nodeId; + } + + public void setNodeId(int nodeId) { + this.nodeId = nodeId; + } + + public int getChildId() { + return childId; + } + + public void setChildId(int childId) { + this.childId = childId; + } + + public int getMsgType() { + return msgType; + } + + public void setMsgType(int msgType) { + this.msgType = msgType; + } + + public int getAck() { + return ack; + } + + public boolean getRevert() { + return revert; + } + + public void setRevert(boolean revert) { + this.revert = revert; + } + + public void setAck(int ack) { + if (getMsgType() == MYSENSORS_MSG_TYPE_SET || ack == MYSENSORS_ACK_FALSE) { + this.ack = ack; + } else { + throw new IllegalArgumentException( + "Could not set ack field in message with command/type equals to: " + MYSENSORS_MSG_TYPE_SET); + } + } + + public void setAck(boolean ack) { + setAck(ack ? 1 : 0); + } + + public int getSubType() { + return subType; + } + + public void setSubType(int subType) { + this.subType = subType; + } + + public String getMsg() { + return msg; + } + + public void setSmartSleep(boolean smartSleep) { + this.smartSleep = smartSleep; + } + + public boolean isSmartSleep() { + return smartSleep; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public int getRetries() { + return retries; + } + + public void setRetries(int retries) { + this.retries = retries; + } + + public long getNextSend() { + return nextSend; + } + + public void setNextSend(long nextSend) { + this.nextSend = nextSend; + } + + public int getDirection() { + return direction; + } + + public void setDirection(int direction) { + this.direction = direction; + } + + /** + * Checks if the received message is a I_CONFIG (internal MySensors) message. + * + * @return true, if the received message is a I_CONFIG message. + */ + public boolean isIConfigMessage() { + boolean ret = false; + + if (childId == MySensorsChild.MYSENSORS_CHILD_ID_RESERVED_0 + || childId == MySensorsChild.MYSENSORS_CHILD_ID_RESERVED_255) { + if (msgType == MYSENSORS_MSG_TYPE_INTERNAL) { + if (ack == MYSENSORS_ACK_FALSE) { + if (subType == MYSENSORS_SUBTYPE_I_CONFIG) { + ret = true; + } + } + } + } + + return ret; + } + + /** + * Checks if the received message is a I_VERSION (internal MySensors) message. + * + * @return true, if the received message is a I_VERSION message. + */ + public boolean isIVersionMessage() { + boolean ret = false; + + if (nodeId == MySensorsNode.MYSENSORS_NODE_ID_RESERVED_GATEWAY_0) { + if (childId == MySensorsChild.MYSENSORS_CHILD_ID_RESERVED_0 + || childId == MySensorsChild.MYSENSORS_CHILD_ID_RESERVED_255) { + if (msgType == MYSENSORS_MSG_TYPE_INTERNAL) { + if (ack == MYSENSORS_ACK_FALSE) { + if (subType == MYSENSORS_SUBTYPE_I_VERSION) { + ret = true; + } + } + } + } + } + + return ret; + } + + /** + * Checks if the received message is a I_HEARTBEAT_RESPONSE (internal MySensors) message. + * + * @return true, if the received message is a I_HEARTBEAT_RESPONSE message. + */ + public boolean isIHearbeatResponse() { + return (childId == MySensorsChild.MYSENSORS_CHILD_ID_RESERVED_255) && (msgType == MYSENSORS_MSG_TYPE_INTERNAL) + && (subType == MYSENSORS_SUBTYPE_I_HEARTBEAT_RESPONSE); + } + + /** + * Checks if the received message is a I_TIME (internal MySensors) message. + * + * @return true, if the received message is a I_TIME message. + */ + public boolean isITimeMessage() { + boolean ret = false; + + if (childId == MySensorsChild.MYSENSORS_CHILD_ID_RESERVED_0 + || childId == MySensorsChild.MYSENSORS_CHILD_ID_RESERVED_255) { + if (msgType == MYSENSORS_MSG_TYPE_INTERNAL) { + if (ack == MYSENSORS_ACK_FALSE) { + if (subType == MYSENSORS_SUBTYPE_I_TIME) { + ret = true; + } + } + } + } + + return ret; + } + + /** + * Checks if the received message is a I_ID_REQUEST (internal MySensors) message. + * + * @return true, if the received message is a I_ID_REQUEST message. + */ + public boolean isIdRequestMessage() { + boolean ret = false; + + if (nodeId == MySensorsNode.MYSENSORS_NODE_ID_RESERVED_255) { + if (childId == MySensorsChild.MYSENSORS_CHILD_ID_RESERVED_255) { + if (msgType == MYSENSORS_SUBTYPE_I_ID_REQUEST) { + if (ack == MYSENSORS_ACK_FALSE) { + if (subType == MYSENSORS_MSG_TYPE_INTERNAL) { + ret = true; + } + } + } + } + } + + return ret; + } + + /** + * Checks if the received message is a presentation message. + * + * @return true, if the received message is a presentation message. + */ + public boolean isPresentationMessage() { + return msgType == MYSENSORS_MSG_TYPE_PRESENTATION; + } + + public boolean isSetReqMessage() { + return msgType == MYSENSORS_MSG_TYPE_REQ || msgType == MYSENSORS_MSG_TYPE_SET; + } + + public boolean isReqMessage() { + return msgType == MYSENSORS_MSG_TYPE_REQ; + } + + public boolean isSetMessage() { + return msgType == MYSENSORS_MSG_TYPE_SET; + } + + public boolean isInternalMessage() { + return msgType == MYSENSORS_MSG_TYPE_INTERNAL; + } + + /** + * Checks if the received message is a heartbeat(response) received from a node + * + * @return true, if it is a heartbeat + */ + public boolean isHeartbeatResponseMessage() { + return (subType == MYSENSORS_SUBTYPE_I_HEARTBEAT_RESPONSE + && childId == MySensorsChild.MYSENSORS_CHILD_ID_RESERVED_255); + } + + /** + * Is this a debug message? + * + * @return true if this message is I_DEBUG + */ + public boolean isDebugMessage() { + return (nodeId == MySensorsNode.MYSENSORS_NODE_ID_RESERVED_GATEWAY_0) + && (childId == MySensorsChild.MYSENSORS_CHILD_ID_RESERVED_255) + && (msgType == MYSENSORS_MSG_TYPE_INTERNAL) && (subType == MYSENSORS_SUBTYPE_I_DEBUG); + } + + /** + * Generate a custom hash by message parts passed as vararg + * Usage example: customHashCode(MYSENSORS_MSG_PAYLOAD_PART, MYSENSORS_MSG_SUBTYPE_PART); + * + * @param messagePart one or mode valid message part, use MYSENSORS_MSG_*_PART definition + * + * @return the hash code + */ + public int customHashCode(int... messageParts) { + + final int prime = 101; + + int result = 1; + for (int i = 0; i < messageParts.length; i++) { + switch (messageParts[i]) { + case MYSENSORS_MSG_PART_PAYLOAD: + result = prime * result + ((msg == null) ? 0 : msg.hashCode()); + break; + case MYSENSORS_MSG_PART_SUBTYPE: + result = prime * result + subType; + break; + case MYSENSORS_MSG_PART_ACK: + result = prime * result + ack; + break; + case MYSENSORS_MSG_PART_TYPE: + result = prime * result + msgType; + break; + case MYSENSORS_MSG_PART_CHILD: + result = prime * result + childId; + break; + case MYSENSORS_MSG_PART_NODE: + result = prime * result + nodeId; + break; + default: + throw new IllegalArgumentException("Messsage part must be in [0,5] interval"); + } + + } + + return result; + } + + /** + * @param line Input is a String containing the message received from the MySensors network + * @return Returns the content of the message as a MySensorsMessage + * + * @throws ParseException + */ + public static MySensorsMessage parse(String line) throws ParseException { + try { + String[] splitMessage = line.split(";"); + if (splitMessage.length > 4) { + + MySensorsMessage mysensorsmessage = new MySensorsMessage(); + + int nodeId = Integer.parseInt(splitMessage[MYSENSORS_MSG_PART_NODE]); + + mysensorsmessage.setNodeId(nodeId); + mysensorsmessage.setChildId(Integer.parseInt(splitMessage[MYSENSORS_MSG_PART_CHILD])); + mysensorsmessage.setMsgType(Integer.parseInt(splitMessage[MYSENSORS_MSG_PART_TYPE])); + mysensorsmessage.setAck(Integer.parseInt(splitMessage[MYSENSORS_MSG_PART_ACK])); + mysensorsmessage.setSubType(Integer.parseInt(splitMessage[MYSENSORS_MSG_PART_SUBTYPE])); + if (splitMessage.length == 6) { + String msg = splitMessage[5].replaceAll("\\r|\\n", "").trim(); + mysensorsmessage.setMsg(msg); + } else { + mysensorsmessage.setMsg(""); + } + return mysensorsmessage; + } else { + throw new ParseException("Message lenght is not > 4", 0); + } + + } catch (Exception e) { + throw new ParseException(e.getClass() + " : " + e.getMessage(), 0); + } + } + + /** + * Converts a MySensorsMessage object to a String. + * + * @param msg the MySensorsMessage that should be converted. + * @return the MySensorsMessage as a String. + */ + public static String generateAPIString(MySensorsMessage msg) { + String apiString = ""; + apiString += msg.getNodeId() + ";"; + apiString += msg.getChildId() + ";"; + apiString += msg.getMsgType() + ";"; + apiString += msg.getAck() + ";"; + apiString += msg.getSubType() + ";"; + apiString += msg.getMsg() + "\n"; + + return apiString; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ack; + result = prime * result + childId; + result = prime * result + ((msg == null) ? 0 : msg.hashCode()); + result = prime * result + msgType; + result = prime * result + (int) (nextSend ^ (nextSend >>> 32)); + result = prime * result + nodeId; + result = prime * result + retries; + result = prime * result + (revert ? 1231 : 1237); + result = prime * result + subType; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + MySensorsMessage other = (MySensorsMessage) obj; + if (ack != other.ack) { + return false; + } + if (childId != other.childId) { + return false; + } + if (msg == null) { + if (other.msg != null) { + return false; + } + } else if (!msg.equals(other.msg)) { + return false; + } + if (msgType != other.msgType) { + return false; + } + if (nextSend != other.nextSend) { + return false; + } + if (nodeId != other.nodeId) { + return false; + } + if (retries != other.retries) { + return false; + } + if (revert != other.revert) { + return false; + } + if (subType != other.subType) { + return false; + } + return true; + } + + @Override + public String toString() { + return "MySensorsMessage [" + generateAPIString(this) + "]"; + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/protocol/serial/MySensorsSerialConnection.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/protocol/serial/MySensorsSerialConnection.java new file mode 100644 index 000000000000..4a1bd980dbab --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/protocol/serial/MySensorsSerialConnection.java @@ -0,0 +1,163 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.protocol.serial; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Enumeration; + +import org.apache.commons.lang.StringUtils; +import org.openhab.binding.mysensors.internal.event.MySensorsEventRegister; +import org.openhab.binding.mysensors.internal.gateway.MySensorsGatewayConfig; +import org.openhab.binding.mysensors.internal.protocol.MySensorsAbstractConnection; +import gnu.io.CommPortIdentifier; +import gnu.io.NRSerialPort; + +/** + * Connection to the serial interface where the MySensors Gateway is connected. + * + * @author Tim Oberföll + * @author Andrea Cioni + * + */ +public class MySensorsSerialConnection extends MySensorsAbstractConnection { + + private NRSerialPort serialConnection = null; + + public MySensorsSerialConnection(MySensorsGatewayConfig myConf, MySensorsEventRegister myEventRegister) { + super(myConf, myEventRegister); + } + + /** + * Tries to accomplish a connection via a serial port to the serial gateway. + */ + @Override + public boolean establishConnection() { + logger.debug("Connecting to {} [baudRate:{}]", myGatewayConfig.getSerialPort(), myGatewayConfig.getBaudRate()); + + boolean ret = false; + + updateSerialProperties(myGatewayConfig.getSerialPort()); + // deleteLockFile(serialPort); + + serialConnection = new NRSerialPort(myGatewayConfig.getSerialPort(), myGatewayConfig.getBaudRate()); + if (serialConnection.connect()) { + logger.debug("Successfully connected to serial port."); + + try { + logger.debug("Waiting {} seconds to allow correct reset trigger on serial connection opening", + RESET_TIME / 1000); + Thread.sleep(RESET_TIME); + } catch (InterruptedException e) { + logger.error("Interrupted reset time wait"); + } + + mysConReader = new MySensorsReader(serialConnection.getInputStream()); + mysConWriter = new MySensorsWriter(serialConnection.getOutputStream()); + + ret = startReaderWriterThread(mysConReader, mysConWriter); + } else { + logger.error("Can't connect to serial port. Wrong port?"); + } + + return ret; + } + + /** + * Initiates a clean disconnect from the serial gateway. + */ + @Override + public void stopConnection() { + logger.debug("Shutting down serial connection!"); + + if (mysConWriter != null) { + mysConWriter.stopWriting(); + mysConWriter = null; + } + + if (mysConReader != null) { + mysConReader.stopReader(); + mysConReader = null; + } + + if (serialConnection != null) { + try { + serialConnection.disconnect(); + } catch (Exception e) { + } + serialConnection = null; + } + + } + + /** + * By default, RXTX searches only devices /dev/ttyS* and + * /dev/ttyUSB*, and will therefore not find devices that + * have been symlinked. Adding them however is tricky, see below. + * + * @param devName is the device used as COM/UART port + */ + private void updateSerialProperties(String devName) { + + // + // first go through the port identifiers to find any that are not in + // "gnu.io.rxtx.SerialPorts" + // + ArrayList allPorts = new ArrayList(); + @SuppressWarnings("rawtypes") + Enumeration portList = CommPortIdentifier.getPortIdentifiers(); + while (portList.hasMoreElements()) { + CommPortIdentifier id = (CommPortIdentifier) portList.nextElement(); + if (id.getPortType() == CommPortIdentifier.PORT_SERIAL) { + allPorts.add(id.getName()); + } + } + logger.trace("Ports found from identifiers: {}", StringUtils.join(allPorts, ":")); + // + // now add our port so it's in the list + // + if (!allPorts.contains(devName)) { + allPorts.add(devName); + } + // + // add any that are already in "gnu.io.rxtx.SerialPorts" + // so we don't accidentally overwrite some of those ports + + String ports = System.getProperty("gnu.io.rxtx.SerialPorts"); + if (ports != null) { + ArrayList propPorts = new ArrayList(Arrays.asList(ports.split(":"))); + for (String p : propPorts) { + if (!allPorts.contains(p)) { + allPorts.add(p); + } + } + } + String finalPorts = StringUtils.join(allPorts, ":"); + logger.debug("Final port list: {}", finalPorts); + + // + // Finally overwrite the "gnu.io.rxtx.SerialPorts" System property. + // + // Note: calling setProperty() is not threadsafe. All bindings run in + // the same address space, System.setProperty() is globally visible + // to all bindings. + // This means if multiple bindings use the serial port there is a + // race condition where two bindings could be changing the properties + // at the same time + // + System.setProperty("gnu.io.rxtx.SerialPorts", finalPorts); + } + + @Override + public String toString() { + return "MySensorsSerialConnection [serialPort=" + myGatewayConfig.getSerialPort() + ", baudRate=" + + myGatewayConfig.getBaudRate() + "]"; + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/MySensorsChild.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/MySensorsChild.java new file mode 100644 index 000000000000..930f208e6752 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/MySensorsChild.java @@ -0,0 +1,371 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors; + +import static org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage.*; + +import java.lang.reflect.Constructor; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import org.openhab.binding.mysensors.internal.Mergeable; +import org.openhab.binding.mysensors.internal.exception.MergeException; +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSAirQuality; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSArduinoNode; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSArduinoRepeaterNode; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSBaro; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSBinary; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSColorSensor; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSCover; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSCustom; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSDimmer; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSDistance; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSDoor; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSDust; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSGas; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSGps; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSHeater; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSHum; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSHvac; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSInfo; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSIr; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSLightLevel; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSLock; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSMoisture; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSMotion; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSMultimeter; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSPower; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSRain; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSRgbwLight; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSRgbLight; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSSceneController; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSSmoke; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSSound; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSSprinkler; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSTemp; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSUv; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSVibration; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSWater; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSWaterLeak; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSWaterQuality; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSWeight; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSWind; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVVar1; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVVar2; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVVar3; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVVar4; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVVar5; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Every node may have one ore more children in the MySensors context. + * Instance of this class could be obtained easy if presentation code is know (use static method fromPresentation). + * + * @author Andrea Cioni + * + */ +public abstract class MySensorsChild implements Mergeable { + + // Reserved ids + public static final int MYSENSORS_CHILD_ID_RESERVED_0 = 0; + public static final int MYSENSORS_CHILD_ID_RESERVED_255 = 255; + + protected Logger logger = LoggerFactory.getLogger(getClass()); + + /** + * Used to build child from presentation code + */ + public final static Map> PRESENTATION_TO_CHILD_CLASS = new HashMap>() { + + /** + * + */ + private static final long serialVersionUID = -3479184996747993491L; + + { + put(MYSENSORS_SUBTYPE_S_DOOR, MySensorsChildSDoor.class); + put(MYSENSORS_SUBTYPE_S_MOTION, MySensorsChildSMotion.class); + put(MYSENSORS_SUBTYPE_S_SMOKE, MySensorsChildSSmoke.class); + put(MYSENSORS_SUBTYPE_S_LIGHT, MySensorsChildSBinary.class); // BINARY=LIGHT + put(MYSENSORS_SUBTYPE_S_BINARY, MySensorsChildSBinary.class); + put(MYSENSORS_SUBTYPE_S_DIMMER, MySensorsChildSDimmer.class); + put(MYSENSORS_SUBTYPE_S_COVER, MySensorsChildSCover.class); + put(MYSENSORS_SUBTYPE_S_TEMP, MySensorsChildSTemp.class); + put(MYSENSORS_SUBTYPE_S_HUM, MySensorsChildSHum.class); + put(MYSENSORS_SUBTYPE_S_BARO, MySensorsChildSBaro.class); + put(MYSENSORS_SUBTYPE_S_WIND, MySensorsChildSWind.class); + put(MYSENSORS_SUBTYPE_S_RAIN, MySensorsChildSRain.class); + put(MYSENSORS_SUBTYPE_S_UV, MySensorsChildSUv.class); + put(MYSENSORS_SUBTYPE_S_WEIGHT, MySensorsChildSWeight.class); + put(MYSENSORS_SUBTYPE_S_POWER, MySensorsChildSPower.class); + put(MYSENSORS_SUBTYPE_S_HEATER, MySensorsChildSHeater.class); + put(MYSENSORS_SUBTYPE_S_DISTANCE, MySensorsChildSDistance.class); + put(MYSENSORS_SUBTYPE_S_LIGHT_LEVEL, MySensorsChildSLightLevel.class); + put(MYSENSORS_SUBTYPE_S_LOCK, MySensorsChildSLock.class); + put(MYSENSORS_SUBTYPE_S_IR, MySensorsChildSIr.class); + put(MYSENSORS_SUBTYPE_S_WATER, MySensorsChildSWater.class); + put(MYSENSORS_SUBTYPE_S_AIR_QUALITY, MySensorsChildSAirQuality.class); + put(MYSENSORS_SUBTYPE_S_CUSTOM, MySensorsChildSCustom.class); + put(MYSENSORS_SUBTYPE_S_RGB_LIGHT, MySensorsChildSRgbLight.class); + put(MYSENSORS_SUBTYPE_S_RGBW_LIGHT, MySensorsChildSRgbwLight.class); + put(MYSENSORS_SUBTYPE_S_HVAC, MySensorsChildSHvac.class); + put(MYSENSORS_SUBTYPE_S_MULTIMETER, MySensorsChildSMultimeter.class); + put(MYSENSORS_SUBTYPE_S_SPRINKLER, MySensorsChildSSprinkler.class); + put(MYSENSORS_SUBTYPE_S_WATER_LEAK, MySensorsChildSWaterLeak.class); + put(MYSENSORS_SUBTYPE_S_SOUND, MySensorsChildSSound.class); + put(MYSENSORS_SUBTYPE_S_VIBRATION, MySensorsChildSVibration.class); + put(MYSENSORS_SUBTYPE_S_MOISTURE, MySensorsChildSMoisture.class); + put(MYSENSORS_SUBTYPE_S_INFO, MySensorsChildSInfo.class); + put(MYSENSORS_SUBTYPE_S_GAS, MySensorsChildSGas.class); + put(MYSENSORS_SUBTYPE_S_GPS, MySensorsChildSGps.class); + put(MYSENSORS_SUBTYPE_S_WATER_QUALITY, MySensorsChildSWaterQuality.class); + put(MYSENSORS_SUBTYPE_S_SCENE_CONTROLLER, MySensorsChildSSceneController.class); + put(MYSENSORS_SUBTYPE_S_DUST, MySensorsChildSDust.class); + put(MYSENSORS_SUBTYPE_S_COLOR_SENSOR, MySensorsChildSColorSensor.class); + put(MYSENSORS_SUBTYPE_S_ARDUINO_REPEATER_NODE, MySensorsChildSArduinoRepeaterNode.class); + put(MYSENSORS_SUBTYPE_S_ARDUINO_NODE, MySensorsChildSArduinoNode.class); + } + + }; + + private final int childId; + + private Optional childConfig; + + private Map variableMap = null; + + private Date lastUpdate = null; + + private int presentationCode; + + public MySensorsChild(int childId) { + if (!isValidChildId(childId)) { + throw new IllegalArgumentException("Invalid child id supplied: " + childId); + } + this.childId = childId; + variableMap = new HashMap(); + lastUpdate = new Date(0); + childConfig = Optional.empty(); + addCommonVariables(); + } + + public MySensorsChild(int childId, MySensorsChildConfig config) { + if (!isValidChildId(childId)) { + throw new IllegalArgumentException("Invalid child id supplied: " + childId); + } + + if (config == null) { + throw new IllegalArgumentException("Invalid config supplied for child: " + childId); + } + + this.childId = childId; + variableMap = new HashMap(); + lastUpdate = new Date(0); + childConfig = Optional.of(config); + addCommonVariables(); + } + + /** + * Add a variable to a child + * + * @param var the non-null variable to add to this child + * + * @throws NullPointerException if var is null + */ + public void addVariable(MySensorsVariable var) throws NoContentException { + + if (var == null) { + throw new NoContentException("Cannot add a null variable"); + } + + synchronized (variableMap) { + if (variableMap.containsKey(var.getType())) { + logger.warn("Overwrite variable: " + var.getType()); + } + + variableMap.put(var.getType(), var); + + } + } + + /** + * Get MySensorsVariable of this child + * + * @param type the integer of the subtype + * @return one MySensorsVariable if present, otherwise null + */ + public MySensorsVariable getVariable(int type) { + synchronized (variableMap) { + return variableMap.get(type); + } + } + + /** + * Get child id + * + * @return child id + */ + public int getChildId() { + return childId; + } + + /** + * Get child last update + * + * @return the date represent when the child has received and update from network. Default value is 1970/01/01-00:00 + */ + public Date getLastUpdate() { + synchronized (lastUpdate) { + return lastUpdate; + } + } + + /** + * Set child last update + * + * @param childLastUpdate new date represents when child has received an update from network + */ + public void setLastUpdate(Date childLastUpdate) { + synchronized (this.lastUpdate) { + this.lastUpdate = childLastUpdate; + } + } + + public int getPresentationCode() { + return presentationCode; + } + + public void setPresentationCode(int presentationCode) { + this.presentationCode = presentationCode; + } + + public Optional getChildConfig() { + return childConfig; + } + + public void setChildConfig(MySensorsChildConfig childConfig) { + this.childConfig = Optional.of(childConfig); + } + + @Override + public void merge(Object o) throws MergeException { + if (o == null || !(o instanceof MySensorsChild)) { + throw new MergeException("Invalid object to merge"); + } + + MySensorsChild child = (MySensorsChild) o; + + // Merge configurations + if (child.childConfig.isPresent() && !childConfig.isPresent()) { + childConfig = child.childConfig; + } else if (child.childConfig.isPresent() && childConfig.isPresent()) { + childConfig.get().merge(child.childConfig.get()); + } + + } + + private void addCommonVariables() { + try { + addVariable(new MySensorsVariableVVar1()); + addVariable(new MySensorsVariableVVar2()); + addVariable(new MySensorsVariableVVar3()); + addVariable(new MySensorsVariableVVar4()); + addVariable(new MySensorsVariableVVar5()); + } catch (NoContentException e) { + logger.error("Variable has no content: {}", e.toString()); + } + } + + /** + * Static method to ensure if one id belongs to a valid range + * + * @param id, child id probably from a message + * @return true if passed id is valid + */ + public static boolean isValidChildId(int id) { + return (id >= MYSENSORS_CHILD_ID_RESERVED_0 && id <= MYSENSORS_CHILD_ID_RESERVED_255); + } + + /** + * Generate an instance of MySensorsChild from a presentation code. + * + * @param presentationCode presentation code in a presentation message + * @param childId the id to set to the generated child + * + * @return an instance of a child + */ + public static MySensorsChild fromPresentation(int presentationCode, int childId) { + MySensorsChild ret; + + if (PRESENTATION_TO_CHILD_CLASS.containsKey(presentationCode)) { + try { + Class cls = PRESENTATION_TO_CHILD_CLASS.get(presentationCode); + Constructor constr = cls.getConstructor(int.class); + ret = constr.newInstance(childId); + } catch (Exception e) { + LoggerFactory.getLogger(MySensorsChild.class) + .error("Reflection has failed for presentation {}, childId:", presentationCode, childId, e); + ret = null; + } + } else { + throw new IllegalArgumentException( + "Presentation code (" + presentationCode + ") or child id not valid (" + childId + ")"); + } + + return ret; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + childId; + result = prime * result + presentationCode; + result = prime * result + ((variableMap == null) ? 0 : variableMap.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + MySensorsChild other = (MySensorsChild) obj; + if (childId != other.childId) { + return false; + } + if (presentationCode != other.presentationCode) { + return false; + } + if (variableMap == null) { + if (other.variableMap != null) { + return false; + } + } else if (!variableMap.equals(other.variableMap)) { + return false; + } + return true; + } + + @Override + public String toString() { + return "MySensorsChild [childId=" + childId + ", nodeValue=" + variableMap + "]"; + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/MySensorsChildConfig.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/MySensorsChildConfig.java new file mode 100644 index 000000000000..0a459b47d97c --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/MySensorsChildConfig.java @@ -0,0 +1,90 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors; + +import org.openhab.binding.mysensors.internal.Mergeable; +import org.openhab.binding.mysensors.internal.exception.MergeException; + +/** + * Configuration and parameters of a child from a MySensors node. + * + * @author Tim Oberföll + * @author Andrea Cioni + * + */ +public class MySensorsChildConfig implements Mergeable { + + private boolean requestAck; + private boolean revertState; + private boolean smartSleep; + private int expectUpdateTimeout; + + public MySensorsChildConfig() { + requestAck = false; + revertState = false; + smartSleep = false; + expectUpdateTimeout = -1; + } + + public boolean getSmartSleep() { + return smartSleep; + } + + public void setSmartSleep(boolean smartSleep) { + this.smartSleep = smartSleep; + } + + public int getExpectUpdateTimeout() { + return expectUpdateTimeout; + } + + public void setExpectUpdateTimeout(int expectUpdateTimeout) { + this.expectUpdateTimeout = expectUpdateTimeout; + } + + public boolean getRequestAck() { + return requestAck; + } + + public void setRequestAck(boolean requestAck) { + this.requestAck = requestAck; + } + + public boolean getRevertState() { + return revertState; + } + + public void setRevertState(boolean revertState) { + this.revertState = revertState; + } + + @Override + public void merge(Object o) throws MergeException { + if (o == null || !(o instanceof MySensorsChildConfig)) { + throw new MergeException("Invalid object to merge"); + } + + MySensorsChildConfig childConfig = (MySensorsChildConfig) o; + + requestAck |= childConfig.requestAck; + revertState |= childConfig.revertState; + smartSleep |= childConfig.smartSleep; + + if (expectUpdateTimeout <= 0) { + expectUpdateTimeout = childConfig.expectUpdateTimeout; + } + } + + @Override + public String toString() { + return "MySensorsChildConfig [requestAck=" + requestAck + ", revertState=" + revertState + ", smartSleep=" + + smartSleep + ", expectUpdateTimeout=" + expectUpdateTimeout + "]"; + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/MySensorsNode.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/MySensorsNode.java new file mode 100644 index 000000000000..42f5b7443327 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/MySensorsNode.java @@ -0,0 +1,342 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import org.openhab.binding.mysensors.internal.exception.MergeException; +import org.openhab.binding.mysensors.internal.exception.NotInitializedException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; + +/** + * Characteristics of a thing/node are stored here: + * - List of children + * - Last update (DateTime) from the node + * - is the child reachable? + * - battery percent (if available) + * + * @author Andrea Cioni + * + */ +public class MySensorsNode { + + // Reserved ids + public static final int MYSENSORS_NODE_ID_RESERVED_GATEWAY_0 = 0; + public static final int MYSENSORS_NODE_ID_RESERVED_255 = 255; + + private final int nodeId; + + private Optional nodeConfig; + + private boolean reachable = true; + + private Map chidldMap = null; + + private Date lastUpdate = null; + + private int batteryPercent = 0; + + public MySensorsNode(int nodeId) { + if (!isValidNodeId(nodeId)) { + throw new IllegalArgumentException("Invalid node id supplied: " + nodeId); + } + this.nodeId = nodeId; + this.chidldMap = new HashMap(); + this.nodeConfig = Optional.empty(); + this.lastUpdate = new Date(0); + } + + public MySensorsNode(int nodeId, MySensorsNodeConfig config) { + if (!isValidNodeId(nodeId)) { + throw new IllegalArgumentException("Invalid node id supplied: " + nodeId); + } + + if (config == null) { + throw new IllegalArgumentException("Invalid config supplied for node: " + nodeId); + } + + this.nodeId = nodeId; + this.chidldMap = new HashMap(); + this.nodeConfig = Optional.of(config); + this.lastUpdate = new Date(0); + } + + public Map getChildMap() { + return chidldMap; + } + + /** + * Get node ID + * + * @return the ID of this node + */ + public int getNodeId() { + return nodeId; + } + + /** + * Add a child not null child to child to this node + * + * @param child to add + */ + public void addChild(MySensorsChild child) { + if (child == null) { + throw new IllegalArgumentException("Null child could't be add"); + } + + synchronized (chidldMap) { + chidldMap.put(child.getChildId(), child); + } + } + + /** + * Get a child from a node + * + * @param childId the id of the child to get from this node + * @return + */ + public MySensorsChild getChild(int childId) { + return chidldMap.get(childId); + } + + /** + * Set node reachable status. + * + * @param reachable (true=yes,false=no) + */ + public void setReachable(boolean reachable) { + this.reachable = reachable; + } + + /** + * Check if this node is reachable + * + * @return true if this node is reachable + */ + public boolean isReachable() { + return reachable; + } + + /** + * Get battery percent of this node + * + * @return the battery percent + */ + public int getBatteryPercent() { + return batteryPercent; + } + + /** + * Set battery percent + * + * @param batteryPercent that will be set + */ + public void setBatteryPercent(int batteryPercent) { + this.batteryPercent = batteryPercent; + } + + /** + * Get last update + * + * @return the last update, 1970-01-01 00:00 means no update received + */ + public Date getLastUpdate() { + synchronized (this.lastUpdate) { + return lastUpdate; + } + } + + /** + * Set last update + * + * @param lastUpdate + */ + public void setLastUpdate(Date lastUpdate) { + synchronized (this.lastUpdate) { + this.lastUpdate = lastUpdate; + } + } + + /** + * Get optional node configuration + * + * @return the Optional that could contains {@link MySensorsNodeConfig} + */ + public Optional getNodeConfig() { + return nodeConfig; + } + + /** + * Set configuration for node + * + * @param nodeConfig is a valid instance of {@link MySensorsNodeConfig}ß + */ + public void setNodeConfig(MySensorsNodeConfig nodeConfig) { + this.nodeConfig = Optional.of(nodeConfig); + } + + /** + * Merge to node into one. + * + * @param node + * + * @throws MergeException if try to merge to node with same child/children + */ + public void merge(Object o) throws MergeException { + + if (o == null || !(o instanceof MySensorsNode)) { + throw new MergeException("Invalid object to merge"); + } + + MySensorsNode node = (MySensorsNode) o; + + // Merge configurations + if (node.nodeConfig.isPresent() && !nodeConfig.isPresent()) { + nodeConfig = node.nodeConfig; + } else if (node.nodeConfig.isPresent() && nodeConfig.isPresent()) { + nodeConfig.get().merge(node.nodeConfig.get()); + } + + synchronized (chidldMap) { + for (Integer i : node.chidldMap.keySet()) { + MySensorsChild child = node.chidldMap.get(i); + chidldMap.merge(i, child, (child1, child2) -> { + child1.merge(child2); + return child1; + }); + } + + } + } + + /** + * Generate message from a state. This method doesn't update variable itself. + * No check will be performed on value of state parameter + * + * @param childId + * @param type + * @param state + * + * @return a non-null message ready to be sent if childId/type are available on this node + * + * @throws NotInitializedException if state is null + */ + public MySensorsMessage updateVariableState(int childId, int type, String state) throws NotInitializedException{ + MySensorsMessage msg = null; + + if (state == null) { + throw new NotInitializedException("State is null"); + } + + synchronized (chidldMap) { + MySensorsChild child = getChild(childId); + MySensorsChildConfig childConfig = (child.getChildConfig().isPresent()) ? child.getChildConfig().get() + : new MySensorsChildConfig(); + if (child != null) { + MySensorsVariable var = child.getVariable(type); + if (var != null) { + msg = new MySensorsMessage(); + + // MySensors + msg.setNodeId(nodeId); + msg.setChildId(childId); + msg.setMsgType(MySensorsMessage.MYSENSORS_MSG_TYPE_SET); + msg.setSubType(type); + msg.setAck(childConfig.getRequestAck()); + msg.setMsg(state); + + // Optional + msg.setRevert(childConfig.getRevertState()); + msg.setSmartSleep(childConfig.getSmartSleep()); + } + } + } + + return msg; + } + + /** + * Check if an integer is a valid node ID + * + * @param ID to test + * + * @return true if ID is valid + */ + public static boolean isValidNodeId(int id) { + return (id >= MYSENSORS_NODE_ID_RESERVED_GATEWAY_0 && id < MYSENSORS_NODE_ID_RESERVED_255); + } + + /** + * Check if a node has a valid node ID + * + * @param node to test + * + * @return true if node is valid + */ + public static boolean isValidNode(MySensorsNode n) { + return (n != null) && (isValidNodeId(n.nodeId)); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((chidldMap == null) ? 0 : chidldMap.hashCode()); + result = prime * result + nodeId; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + MySensorsNode other = (MySensorsNode) obj; + if (batteryPercent != other.batteryPercent) { + return false; + } + if (chidldMap == null) { + if (other.chidldMap != null) { + return false; + } + } else if (!chidldMap.equals(other.chidldMap)) { + return false; + } + if (lastUpdate == null) { + if (other.lastUpdate != null) { + return false; + } + } else if (!lastUpdate.equals(other.lastUpdate)) { + return false; + } + if (nodeId != other.nodeId) { + return false; + } + if (reachable != other.reachable) { + return false; + } + return true; + } + + @Override + public String toString() { + return "MySensorsNode [nodeId=" + nodeId + ", childNumber=" + chidldMap.size() + ", chidldList=" + chidldMap + + "]"; + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/MySensorsNodeConfig.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/MySensorsNodeConfig.java new file mode 100644 index 000000000000..f93efed48e7e --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/MySensorsNodeConfig.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors; + +import org.openhab.binding.mysensors.internal.Mergeable; +import org.openhab.binding.mysensors.internal.exception.MergeException; + +/** + * Configuration and parameters of a MySensors node. + * + * @author Tim Oberföll + * @author Andrea Cioni + * + */ +public class MySensorsNodeConfig implements Mergeable { + + private boolean requestHeartbeatResponse; + private int expectUpdateTimeout; + + public MySensorsNodeConfig() { + requestHeartbeatResponse = false; + expectUpdateTimeout = -1; + } + + public boolean getRequestHeartbeatResponse() { + return requestHeartbeatResponse; + } + + public void setRequestHeartbeatResponse(boolean requestHeartbeatResponse) { + this.requestHeartbeatResponse = requestHeartbeatResponse; + } + + public int getExpectUpdateTimeout() { + return expectUpdateTimeout; + } + + public void setExpectUpdateTimeout(int expectUpdateTimeout) { + this.expectUpdateTimeout = expectUpdateTimeout; + } + + @Override + public void merge(Object o) throws MergeException { + if (o == null || !(o instanceof MySensorsNodeConfig)) { + throw new MergeException("Invalid object to merge"); + } + + MySensorsNodeConfig nodeConfig = (MySensorsNodeConfig) o; + + requestHeartbeatResponse |= nodeConfig.requestHeartbeatResponse; + + if (expectUpdateTimeout <= 0) { + expectUpdateTimeout = nodeConfig.expectUpdateTimeout; + } + + } + + @Override + public String toString() { + return "MySensorsNodeConfig [requestHeartbeatResponse=" + requestHeartbeatResponse + ", expectUpdateTimeout=" + + expectUpdateTimeout + "]"; + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/MySensorsVariable.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/MySensorsVariable.java new file mode 100644 index 000000000000..c01c53eb6559 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/MySensorsVariable.java @@ -0,0 +1,121 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors; + +import java.util.Date; + +import org.openhab.binding.mysensors.internal.exception.RevertVariableStateException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; + +/** + * Variables (states) of a MySensors child. + * + * @author Tim Oberföll + * @author Andrea Cioni + * + */ +public abstract class MySensorsVariable { + + private final int type; + + private String value; + + private Date lastUpdate; + + private String oldState; + + private Date oldLastUpdate; + + public MySensorsVariable(int type) { + this.type = type; + } + + public synchronized String getValue() { + return value; + } + + public synchronized void setValue(String value) { + oldState = getValue(); + oldLastUpdate = getLastUpdate(); + setLastUpdate(new Date()); + this.value = value; + } + + public synchronized void setValue(MySensorsMessage message) { + setValue(message.getMsg()); + } + + public synchronized int getType() { + return type; + } + + public synchronized Date getLastUpdate() { + return lastUpdate; + } + + public synchronized void setLastUpdate(Date lastupdate) { + this.lastUpdate = lastupdate; + } + + public synchronized boolean isRevertible() { + return (oldState != null && oldLastUpdate != null); + } + + public synchronized void revertValue() throws RevertVariableStateException { + if (isRevertible()) { + setValue(oldState); + setLastUpdate(oldLastUpdate); + oldState = null; + oldLastUpdate = null; + } else { + throw new RevertVariableStateException(); + } + + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + type; + result = prime * result + ((value == null) ? 0 : value.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + MySensorsVariable other = (MySensorsVariable) obj; + if (type != other.type) { + return false; + } + if (value == null) { + if (other.value != null) { + return false; + } + } else if (!value.equals(other.value)) { + return false; + } + return true; + } + + @Override + public String toString() { + return getClass().getSimpleName() + " [value=" + value + "]"; + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSAirQuality.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSAirQuality.java new file mode 100644 index 000000000000..e98397673e69 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSAirQuality.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVLevel; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVUnitPrefix; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSAirQuality extends MySensorsChild { + + public MySensorsChildSAirQuality(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_AIR_QUALITY); + try { + addVariable(new MySensorsVariableVLevel()); + addVariable(new MySensorsVariableVUnitPrefix()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSArduinoNode.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSArduinoNode.java new file mode 100644 index 000000000000..a61bdef9972b --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSArduinoNode.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSArduinoNode extends MySensorsChild { + + public MySensorsChildSArduinoNode(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_ARDUINO_NODE); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSArduinoRepeaterNode.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSArduinoRepeaterNode.java new file mode 100644 index 000000000000..5526b604b4b3 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSArduinoRepeaterNode.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSArduinoRepeaterNode extends MySensorsChild { + + public MySensorsChildSArduinoRepeaterNode(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_ARDUINO_REPEATER_NODE); + + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSBaro.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSBaro.java new file mode 100644 index 000000000000..2de5115268e2 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSBaro.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVForecast; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVPressure; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSBaro extends MySensorsChild { + + public MySensorsChildSBaro(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_BARO); + try { + addVariable(new MySensorsVariableVPressure()); + addVariable(new MySensorsVariableVForecast()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSBinary.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSBinary.java new file mode 100644 index 000000000000..bc6dcc1c5a71 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSBinary.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVStatus; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVWatt; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSBinary extends MySensorsChild { + + public MySensorsChildSBinary(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_BINARY); + try { + addVariable(new MySensorsVariableVStatus()); + addVariable(new MySensorsVariableVWatt()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSColorSensor.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSColorSensor.java new file mode 100644 index 000000000000..9514b605b1a0 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSColorSensor.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVRgb; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSColorSensor extends MySensorsChild { + + public MySensorsChildSColorSensor(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_COLOR_SENSOR); + try { + addVariable(new MySensorsVariableVRgb()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSCover.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSCover.java new file mode 100644 index 000000000000..019f99feab85 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSCover.java @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVDown; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVPercentage; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVStop; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVUp; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSCover extends MySensorsChild { + + public MySensorsChildSCover(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_COVER); + try { + addVariable(new MySensorsVariableVUp()); + addVariable(new MySensorsVariableVDown()); + addVariable(new MySensorsVariableVStop()); + addVariable(new MySensorsVariableVPercentage()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSCustom.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSCustom.java new file mode 100644 index 000000000000..7e3a796b1bae --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSCustom.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSCustom extends MySensorsChild { + + public MySensorsChildSCustom(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_CUSTOM); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSDimmer.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSDimmer.java new file mode 100644 index 000000000000..f5f8dc8ff0b0 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSDimmer.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVPercentage; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVStatus; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVWatt; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSDimmer extends MySensorsChild { + + public MySensorsChildSDimmer(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_DIMMER); + try { + addVariable(new MySensorsVariableVStatus()); + addVariable(new MySensorsVariableVPercentage()); + addVariable(new MySensorsVariableVWatt()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSDistance.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSDistance.java new file mode 100644 index 000000000000..39e6759cee81 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSDistance.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVDistance; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVUnitPrefix; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSDistance extends MySensorsChild { + + public MySensorsChildSDistance(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_DISTANCE); + try { + addVariable(new MySensorsVariableVDistance()); + addVariable(new MySensorsVariableVUnitPrefix()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSDoor.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSDoor.java new file mode 100644 index 000000000000..8f11d1ec7495 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSDoor.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVArmed; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVTripped; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSDoor extends MySensorsChild { + + public MySensorsChildSDoor(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_DOOR); + try { + addVariable(new MySensorsVariableVTripped()); + addVariable(new MySensorsVariableVArmed()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSDust.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSDust.java new file mode 100644 index 000000000000..78e18687c617 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSDust.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVLevel; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVUnitPrefix; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSDust extends MySensorsChild { + + public MySensorsChildSDust(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_DUST); + try { + addVariable(new MySensorsVariableVLevel()); + addVariable(new MySensorsVariableVUnitPrefix()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSGas.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSGas.java new file mode 100644 index 000000000000..09212bbfe032 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSGas.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVFlow; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVUnitPrefix; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSGas extends MySensorsChild { + + public MySensorsChildSGas(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_GAS); + try { + addVariable(new MySensorsVariableVFlow()); + addVariable(new MySensorsVariableVUnitPrefix()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSGps.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSGps.java new file mode 100644 index 000000000000..b85894f3f600 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSGps.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVPosition; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSGps extends MySensorsChild { + + public MySensorsChildSGps(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_GPS); + try { + addVariable(new MySensorsVariableVPosition()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSHeater.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSHeater.java new file mode 100644 index 000000000000..bb61fc1c1c1d --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSHeater.java @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVHvacFlowState; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVHvacSetpointHeat; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVStatus; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVTemp; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSHeater extends MySensorsChild { + + public MySensorsChildSHeater(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_HEATER); + try { + addVariable(new MySensorsVariableVHvacSetpointHeat()); + addVariable(new MySensorsVariableVHvacFlowState()); + addVariable(new MySensorsVariableVTemp()); + addVariable(new MySensorsVariableVStatus()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSHum.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSHum.java new file mode 100644 index 000000000000..100ec63dc6af --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSHum.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVHum; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSHum extends MySensorsChild { + + public MySensorsChildSHum(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_HUM); + try { + addVariable(new MySensorsVariableVHum()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSHvac.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSHvac.java new file mode 100644 index 000000000000..7886ded44736 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSHvac.java @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVHvacFlowMode; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVHvacFlowState; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVHvacSetpointCool; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVHvacSetpointHeat; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVHvacSpeed; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVStatus; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVTemp; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSHvac extends MySensorsChild { + + public MySensorsChildSHvac(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_HVAC); + try { + addVariable(new MySensorsVariableVStatus()); + addVariable(new MySensorsVariableVTemp()); + addVariable(new MySensorsVariableVHvacSetpointHeat()); + addVariable(new MySensorsVariableVHvacSetpointCool()); + addVariable(new MySensorsVariableVHvacFlowState()); + addVariable(new MySensorsVariableVHvacFlowMode()); + addVariable(new MySensorsVariableVHvacSpeed()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSInfo.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSInfo.java new file mode 100644 index 000000000000..55305c045f19 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSInfo.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVText; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSInfo extends MySensorsChild { + + public MySensorsChildSInfo(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_INFO); + try { + addVariable(new MySensorsVariableVText()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSIr.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSIr.java new file mode 100644 index 000000000000..215248660eb8 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSIr.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVIrReceive; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVIrRecord; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVIrSend; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSIr extends MySensorsChild { + + public MySensorsChildSIr(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_IR); + try { + addVariable(new MySensorsVariableVIrSend()); + addVariable(new MySensorsVariableVIrReceive()); + addVariable(new MySensorsVariableVIrRecord()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSLightLevel.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSLightLevel.java new file mode 100644 index 000000000000..10b68f768f72 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSLightLevel.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVLevel; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVLightLevel; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSLightLevel extends MySensorsChild { + + public MySensorsChildSLightLevel(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_LIGHT_LEVEL); + try { + addVariable(new MySensorsVariableVLightLevel()); + addVariable(new MySensorsVariableVLevel()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSLock.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSLock.java new file mode 100644 index 000000000000..102904887bc6 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSLock.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVLockStatus; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSLock extends MySensorsChild { + + public MySensorsChildSLock(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_LOCK); + try { + addVariable(new MySensorsVariableVLockStatus()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSMoisture.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSMoisture.java new file mode 100644 index 000000000000..e14d7c35a1e3 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSMoisture.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVArmed; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVLevel; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVTripped; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSMoisture extends MySensorsChild { + + public MySensorsChildSMoisture(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_MOISTURE); + try { + addVariable(new MySensorsVariableVLevel()); + addVariable(new MySensorsVariableVTripped()); + addVariable(new MySensorsVariableVArmed()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSMotion.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSMotion.java new file mode 100644 index 000000000000..5aaf48cac487 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSMotion.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVArmed; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVTripped; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSMotion extends MySensorsChild { + + public MySensorsChildSMotion(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_MOTION); + try { + addVariable(new MySensorsVariableVTripped()); + addVariable(new MySensorsVariableVArmed()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSMultimeter.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSMultimeter.java new file mode 100644 index 000000000000..717ab8ad91fa --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSMultimeter.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVCurrent; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVImpedance; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVVoltage; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSMultimeter extends MySensorsChild { + + public MySensorsChildSMultimeter(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_MULTIMETER); + try { + addVariable(new MySensorsVariableVVoltage()); + addVariable(new MySensorsVariableVCurrent()); + addVariable(new MySensorsVariableVImpedance()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSPower.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSPower.java new file mode 100644 index 000000000000..a3bc719cc7e2 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSPower.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVKwh; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVPowerFactor; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVVa; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVVar; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVWatt; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSPower extends MySensorsChild { + + public MySensorsChildSPower(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_POWER); + try { + addVariable(new MySensorsVariableVWatt()); + addVariable(new MySensorsVariableVKwh()); + addVariable(new MySensorsVariableVVar()); + addVariable(new MySensorsVariableVVa()); + addVariable(new MySensorsVariableVPowerFactor()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSRain.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSRain.java new file mode 100644 index 000000000000..71c72dc14b35 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSRain.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVRain; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVRainrate; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSRain extends MySensorsChild { + + public MySensorsChildSRain(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_RAIN); + try { + addVariable(new MySensorsVariableVRain()); + addVariable(new MySensorsVariableVRainrate()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSRgbLight.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSRgbLight.java new file mode 100644 index 000000000000..2b1721cae0ab --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSRgbLight.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVRgb; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVWatt; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSRgbLight extends MySensorsChild { + + public MySensorsChildSRgbLight(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_RGB_LIGHT); + try { + addVariable(new MySensorsVariableVRgb()); + addVariable(new MySensorsVariableVWatt()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSRgbwLight.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSRgbwLight.java new file mode 100644 index 000000000000..55c5cb2ebc75 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSRgbwLight.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVRgbw; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVWatt; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSRgbwLight extends MySensorsChild { + + public MySensorsChildSRgbwLight(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_RGBW_LIGHT); + try { + addVariable(new MySensorsVariableVRgbw()); + addVariable(new MySensorsVariableVWatt()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSSceneController.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSSceneController.java new file mode 100644 index 000000000000..602140fc86ff --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSSceneController.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVSceneOff; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVSceneOn; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSSceneController extends MySensorsChild { + + public MySensorsChildSSceneController(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_SCENE_CONTROLLER); + try { + addVariable(new MySensorsVariableVSceneOn()); + addVariable(new MySensorsVariableVSceneOff()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSSmoke.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSSmoke.java new file mode 100644 index 000000000000..6c2f80a9ae78 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSSmoke.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVArmed; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVTripped; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSSmoke extends MySensorsChild { + + public MySensorsChildSSmoke(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_SMOKE); + try { + addVariable(new MySensorsVariableVTripped()); + addVariable(new MySensorsVariableVArmed()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSSound.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSSound.java new file mode 100644 index 000000000000..791245ff796d --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSSound.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVArmed; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVLevel; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVTripped; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSSound extends MySensorsChild { + + public MySensorsChildSSound(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_SOUND); + try { + addVariable(new MySensorsVariableVLevel()); + addVariable(new MySensorsVariableVTripped()); + addVariable(new MySensorsVariableVArmed()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSSprinkler.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSSprinkler.java new file mode 100644 index 000000000000..de284329b07d --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSSprinkler.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVStatus; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVTripped; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSSprinkler extends MySensorsChild { + + public MySensorsChildSSprinkler(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_SPRINKLER); + try { + addVariable(new MySensorsVariableVStatus()); + addVariable(new MySensorsVariableVTripped()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSTemp.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSTemp.java new file mode 100644 index 000000000000..aefcbcd5d5fd --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSTemp.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVId; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVTemp; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSTemp extends MySensorsChild { + + public MySensorsChildSTemp(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_TEMP); + try { + addVariable(new MySensorsVariableVTemp()); + addVariable(new MySensorsVariableVId()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSUv.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSUv.java new file mode 100644 index 000000000000..fab0635c80b5 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSUv.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVUv; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSUv extends MySensorsChild { + + public MySensorsChildSUv(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_UV); + try { + addVariable(new MySensorsVariableVUv()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSVibration.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSVibration.java new file mode 100644 index 000000000000..dd55c4915827 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSVibration.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVArmed; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVLevel; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVTripped; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSVibration extends MySensorsChild { + + public MySensorsChildSVibration(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_VIBRATION); + try { + addVariable(new MySensorsVariableVLevel()); + addVariable(new MySensorsVariableVTripped()); + addVariable(new MySensorsVariableVArmed()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSWater.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSWater.java new file mode 100644 index 000000000000..c57f6f29661d --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSWater.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVFlow; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVVolume; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSWater extends MySensorsChild { + + public MySensorsChildSWater(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_WATER); + try { + addVariable(new MySensorsVariableVFlow()); + addVariable(new MySensorsVariableVVolume()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSWaterLeak.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSWaterLeak.java new file mode 100644 index 000000000000..528aed417a60 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSWaterLeak.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVArmed; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVTripped; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSWaterLeak extends MySensorsChild { + + public MySensorsChildSWaterLeak(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_WATER_LEAK); + try { + addVariable(new MySensorsVariableVTripped()); + addVariable(new MySensorsVariableVArmed()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSWaterQuality.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSWaterQuality.java new file mode 100644 index 000000000000..c54bbe984d36 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSWaterQuality.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVEc; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVOrp; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVPh; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVStatus; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVTemp; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSWaterQuality extends MySensorsChild { + + public MySensorsChildSWaterQuality(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_WATER_QUALITY); + try { + addVariable(new MySensorsVariableVTemp()); + addVariable(new MySensorsVariableVPh()); + addVariable(new MySensorsVariableVOrp()); + addVariable(new MySensorsVariableVEc()); + addVariable(new MySensorsVariableVStatus()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSWeight.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSWeight.java new file mode 100644 index 000000000000..523105ef97f5 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSWeight.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVImpedance; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVWeight; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSWeight extends MySensorsChild { + + public MySensorsChildSWeight(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_WEIGHT); + try { + addVariable(new MySensorsVariableVWeight()); + addVariable(new MySensorsVariableVImpedance()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSWind.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSWind.java new file mode 100644 index 000000000000..a5de40e4d790 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChildSWind.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.child; + +import org.openhab.binding.mysensors.internal.exception.NoContentException; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsChild; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVDirection; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVGust; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVWind; + +/** + * MySensors Child definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsChildSWind extends MySensorsChild { + + public MySensorsChildSWind(int childId) { + super(childId); + setPresentationCode(MySensorsMessage.MYSENSORS_SUBTYPE_S_WIND); + try { + addVariable(new MySensorsVariableVWind()); + addVariable(new MySensorsVariableVGust()); + addVariable(new MySensorsVariableVDirection()); + } catch (NoContentException e) { + logger.debug("No content to add: {}", e.toString()); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVArmed.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVArmed.java new file mode 100644 index 000000000000..2ed58f5458ec --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVArmed.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVArmed extends MySensorsVariable { + + public MySensorsVariableVArmed() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_ARMED); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVCurrent.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVCurrent.java new file mode 100644 index 000000000000..d64857cd7c44 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVCurrent.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVCurrent extends MySensorsVariable { + + public MySensorsVariableVCurrent() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_CURRENT); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVCustom.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVCustom.java new file mode 100644 index 000000000000..98cd77ddcb5b --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVCustom.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVCustom extends MySensorsVariable { + + public MySensorsVariableVCustom() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_CUSTOM); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVDirection.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVDirection.java new file mode 100644 index 000000000000..4b74aa956f29 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVDirection.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVDirection extends MySensorsVariable { + + public MySensorsVariableVDirection() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_DIRECTION); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVDistance.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVDistance.java new file mode 100644 index 000000000000..1fcba9fc3e79 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVDistance.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVDistance extends MySensorsVariable { + + public MySensorsVariableVDistance() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_DISTANCE); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVDown.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVDown.java new file mode 100644 index 000000000000..a6497b5d5dc4 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVDown.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVDown extends MySensorsVariable { + + public MySensorsVariableVDown() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_DOWN); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVEc.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVEc.java new file mode 100644 index 000000000000..53be782d546e --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVEc.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVEc extends MySensorsVariable { + + public MySensorsVariableVEc() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_EC); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVFlow.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVFlow.java new file mode 100644 index 000000000000..8c6e54b1556d --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVFlow.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVFlow extends MySensorsVariable { + + public MySensorsVariableVFlow() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_FLOW); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVForecast.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVForecast.java new file mode 100644 index 000000000000..f12a7efaf8d4 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVForecast.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVForecast extends MySensorsVariable { + + public MySensorsVariableVForecast() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_FORECAST); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVGust.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVGust.java new file mode 100644 index 000000000000..0968da8af1f5 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVGust.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVGust extends MySensorsVariable { + + public MySensorsVariableVGust() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_GUST); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHum.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHum.java new file mode 100644 index 000000000000..4465d2939e23 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHum.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVHum extends MySensorsVariable { + + public MySensorsVariableVHum() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_HUM); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHvacFlowMode.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHvacFlowMode.java new file mode 100644 index 000000000000..6e69ce453f2e --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHvacFlowMode.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVHvacFlowMode extends MySensorsVariable { + + public MySensorsVariableVHvacFlowMode() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_HVAC_FLOW_MODE); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHvacFlowState.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHvacFlowState.java new file mode 100644 index 000000000000..a7e94ea02aec --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHvacFlowState.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVHvacFlowState extends MySensorsVariable { + + public MySensorsVariableVHvacFlowState() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_HVAC_FLOW_STATE); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHvacSetpointCool.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHvacSetpointCool.java new file mode 100644 index 000000000000..6825e9ae100b --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHvacSetpointCool.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVHvacSetpointCool extends MySensorsVariable { + + public MySensorsVariableVHvacSetpointCool() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_HVAC_SETPOINT_COOL); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHvacSetpointHeat.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHvacSetpointHeat.java new file mode 100644 index 000000000000..20dd64f01ac3 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHvacSetpointHeat.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVHvacSetpointHeat extends MySensorsVariable { + + public MySensorsVariableVHvacSetpointHeat() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_HVAC_SETPOINT_HEAT); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHvacSpeed.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHvacSpeed.java new file mode 100644 index 000000000000..3e7fcefada69 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVHvacSpeed.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVHvacSpeed extends MySensorsVariable { + + public MySensorsVariableVHvacSpeed() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_HVAC_SPEED); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVId.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVId.java new file mode 100644 index 000000000000..21287d5c9b53 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVId.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVId extends MySensorsVariable { + + public MySensorsVariableVId() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_ID); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVImpedance.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVImpedance.java new file mode 100644 index 000000000000..0ed94a382562 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVImpedance.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVImpedance extends MySensorsVariable { + + public MySensorsVariableVImpedance() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_IMPEDANCE); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVIrReceive.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVIrReceive.java new file mode 100644 index 000000000000..74cba9ab1334 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVIrReceive.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVIrReceive extends MySensorsVariable { + + public MySensorsVariableVIrReceive() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_IR_RECEIVE); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVIrRecord.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVIrRecord.java new file mode 100644 index 000000000000..f5df72c4f935 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVIrRecord.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVIrRecord extends MySensorsVariable { + + public MySensorsVariableVIrRecord() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_IR_RECORD); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVIrSend.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVIrSend.java new file mode 100644 index 000000000000..36c32d63251c --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVIrSend.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVIrSend extends MySensorsVariable { + + public MySensorsVariableVIrSend() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_IR_SEND); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVKwh.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVKwh.java new file mode 100644 index 000000000000..0609eb775cde --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVKwh.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVKwh extends MySensorsVariable { + + public MySensorsVariableVKwh() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_KWH); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVLevel.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVLevel.java new file mode 100644 index 000000000000..80ba4fe3d575 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVLevel.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVLevel extends MySensorsVariable { + + public MySensorsVariableVLevel() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_LEVEL); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVLightLevel.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVLightLevel.java new file mode 100644 index 000000000000..c1fbfea1c21c --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVLightLevel.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVLightLevel extends MySensorsVariable { + + public MySensorsVariableVLightLevel() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_LIGHT_LEVEL); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVLockStatus.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVLockStatus.java new file mode 100644 index 000000000000..96520b2a9f68 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVLockStatus.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVLockStatus extends MySensorsVariable { + + public MySensorsVariableVLockStatus() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_LOCK_STATUS); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVOrp.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVOrp.java new file mode 100644 index 000000000000..91a607a3e866 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVOrp.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVOrp extends MySensorsVariable { + + public MySensorsVariableVOrp() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_ORP); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVPercentage.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVPercentage.java new file mode 100644 index 000000000000..90eff2031566 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVPercentage.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVPercentage extends MySensorsVariable { + + public MySensorsVariableVPercentage() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_PERCENTAGE); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVPh.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVPh.java new file mode 100644 index 000000000000..7b8eb478eab4 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVPh.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVPh extends MySensorsVariable { + + public MySensorsVariableVPh() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_PH); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVPosition.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVPosition.java new file mode 100644 index 000000000000..efcb038a2e8b --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVPosition.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVPosition extends MySensorsVariable { + + public MySensorsVariableVPosition() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_POSITION); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVPowerFactor.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVPowerFactor.java new file mode 100644 index 000000000000..8f75380d6ef4 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVPowerFactor.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVPowerFactor extends MySensorsVariable { + + public MySensorsVariableVPowerFactor() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_POWER_FACTOR); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVPressure.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVPressure.java new file mode 100644 index 000000000000..486b5133505e --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVPressure.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVPressure extends MySensorsVariable { + + public MySensorsVariableVPressure() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_PRESSURE); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVRain.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVRain.java new file mode 100644 index 000000000000..8c67617eecbf --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVRain.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVRain extends MySensorsVariable { + + public MySensorsVariableVRain() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_RAIN); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVRainrate.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVRainrate.java new file mode 100644 index 000000000000..305e9f0031e0 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVRainrate.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVRainrate extends MySensorsVariable { + + public MySensorsVariableVRainrate() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_RAINRATE); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVRgb.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVRgb.java new file mode 100644 index 000000000000..7115d4f8ca9e --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVRgb.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVRgb extends MySensorsVariable { + + public MySensorsVariableVRgb() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_RGB); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVRgbw.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVRgbw.java new file mode 100644 index 000000000000..6bcf1f83792e --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVRgbw.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVRgbw extends MySensorsVariable { + + public MySensorsVariableVRgbw() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_RGBW); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVSceneOff.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVSceneOff.java new file mode 100644 index 000000000000..04aa0f9f7870 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVSceneOff.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVSceneOff extends MySensorsVariable { + + public MySensorsVariableVSceneOff() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_SCENE_OFF); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVSceneOn.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVSceneOn.java new file mode 100644 index 000000000000..afbe64690d93 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVSceneOn.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVSceneOn extends MySensorsVariable { + + public MySensorsVariableVSceneOn() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_SCENE_ON); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVStatus.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVStatus.java new file mode 100644 index 000000000000..0a6b43607ac4 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVStatus.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVStatus extends MySensorsVariable { + + public MySensorsVariableVStatus() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_STATUS); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVStop.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVStop.java new file mode 100644 index 000000000000..d6b4c77f02df --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVStop.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVStop extends MySensorsVariable { + + public MySensorsVariableVStop() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_STOP); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVTemp.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVTemp.java new file mode 100644 index 000000000000..b810d7a798cb --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVTemp.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVTemp extends MySensorsVariable { + + public MySensorsVariableVTemp() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_TEMP); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVText.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVText.java new file mode 100644 index 000000000000..8eaeb327c708 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVText.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVText extends MySensorsVariable { + + public MySensorsVariableVText() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_TEXT); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVTripped.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVTripped.java new file mode 100644 index 000000000000..0aa5a5db43ca --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVTripped.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVTripped extends MySensorsVariable { + + public MySensorsVariableVTripped() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_TRIPPED); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVUnitPrefix.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVUnitPrefix.java new file mode 100644 index 000000000000..5f947037055b --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVUnitPrefix.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVUnitPrefix extends MySensorsVariable { + + public MySensorsVariableVUnitPrefix() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_UNIT_PREFIX); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVUp.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVUp.java new file mode 100644 index 000000000000..4b5b6bd7be35 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVUp.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVUp extends MySensorsVariable { + + public MySensorsVariableVUp() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_UP); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVUv.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVUv.java new file mode 100644 index 000000000000..fd4040c8a642 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVUv.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVUv extends MySensorsVariable { + + public MySensorsVariableVUv() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_UV); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVa.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVa.java new file mode 100644 index 000000000000..eb2eafd63ff4 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVa.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVVa extends MySensorsVariable { + + public MySensorsVariableVVa() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_VA); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar.java new file mode 100644 index 000000000000..da7c0f83a046 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVVar extends MySensorsVariable { + + public MySensorsVariableVVar() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_VAR); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar1.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar1.java new file mode 100644 index 000000000000..a3057fbad043 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar1.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVVar1 extends MySensorsVariable { + + public MySensorsVariableVVar1() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_VAR1); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar2.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar2.java new file mode 100644 index 000000000000..5ee774254e45 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar2.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVVar2 extends MySensorsVariable { + + public MySensorsVariableVVar2() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_VAR2); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar3.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar3.java new file mode 100644 index 000000000000..e3fc6f4bffe9 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar3.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVVar3 extends MySensorsVariable { + + public MySensorsVariableVVar3() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_VAR3); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar4.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar4.java new file mode 100644 index 000000000000..2beefa897d6a --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar4.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVVar4 extends MySensorsVariable { + + public MySensorsVariableVVar4() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_VAR4); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar5.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar5.java new file mode 100644 index 000000000000..abf043dd9a62 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVar5.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVVar5 extends MySensorsVariable { + + public MySensorsVariableVVar5() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_VAR5); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVoltage.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVoltage.java new file mode 100644 index 000000000000..eb68533b83a5 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVoltage.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVVoltage extends MySensorsVariable { + + public MySensorsVariableVVoltage() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_VOLTAGE); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVolume.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVolume.java new file mode 100644 index 000000000000..32858263b356 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVVolume.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVVolume extends MySensorsVariable { + + public MySensorsVariableVVolume() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_VOLUME); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVWatt.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVWatt.java new file mode 100644 index 000000000000..b30f0816734e --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVWatt.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVWatt extends MySensorsVariable { + + public MySensorsVariableVWatt() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_WATT); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVWeight.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVWeight.java new file mode 100644 index 000000000000..69d190ea9bbd --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVWeight.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVWeight extends MySensorsVariable { + + public MySensorsVariableVWeight() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_WEIGHT); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVWind.java b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVWind.java new file mode 100644 index 000000000000..929e1c2c1b3c --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariableVWind.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.internal.sensors.variable; + +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; + +/** + * MySensors variable definition according to MySensors serial API + * https://www.mysensors.org/download/serial_api_20 + * + * @author Andrea Cioni + * @author Tim Oberföll + * + */ +public class MySensorsVariableVWind extends MySensorsVariable { + + public MySensorsVariableVWind() { + super(MySensorsMessage.MYSENSORS_SUBTYPE_V_WIND); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/CacheTest.java b/addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/CacheTest.java new file mode 100644 index 000000000000..571bc78afed9 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/CacheTest.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.test; + +import java.util.ArrayList; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openhab.binding.mysensors.factory.MySensorsCacheFactory; + +import com.google.gson.reflect.TypeToken; + +/** + * Test cases for the MySensorsCacheFactory (ID cache). + * + * @author Andrea Cioni + * + */ +public class CacheTest { + + private MySensorsCacheFactory c = null; + + @BeforeClass + public void init() { + c = new MySensorsCacheFactory(); + } + + @Test + public void writeGivenIdsCache() { + ArrayList ids = new ArrayList(); + ids.add(2); + ids.add(3); + ids.add(5); + c.writeCache(MySensorsCacheFactory.GIVEN_IDS_CACHE_FILE, ids, new TypeToken>() { + }.getType()); + } + + @Test + public void readGivenIdsCache() { + System.out.println(c.readCache(MySensorsCacheFactory.GIVEN_IDS_CACHE_FILE, new ArrayList(), + new TypeToken>() { + }.getType())); + } + + @AfterClass + public void deleteCache() { + c.deleteCache(MySensorsCacheFactory.GIVEN_IDS_CACHE_FILE); + } +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/DiscoveryServiceTest.java b/addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/DiscoveryServiceTest.java new file mode 100644 index 000000000000..dcfa0b2cb629 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/DiscoveryServiceTest.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.test; + +import static org.junit.Assert.assertEquals; +import static org.openhab.binding.mysensors.MySensorsBindingConstants.THING_UID_MAP; + +import java.util.Set; + +import org.eclipse.smarthome.core.thing.ThingTypeUID; +import org.junit.Test; + +public class DiscoveryServiceTest { + + @Test + public void testThingUidMap() { + Set keySet = THING_UID_MAP.keySet(); + + for (Integer key : keySet) { + ThingTypeUID thingTypeUid = THING_UID_MAP.get(key); + // System.out.println(thingTypeUid.getId()); + assertEquals(true, thingTypeUid.getId().matches("^[a-zA-Z-]*$")); + } + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/MessageTest.java b/addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/MessageTest.java new file mode 100644 index 000000000000..1c97c15d1f9c --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/MessageTest.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.test; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage; + +public class MessageTest { + + private static final int OLD_MESSAGE_CUSTOM_HASH[] = { MySensorsMessage.MYSENSORS_MSG_PART_NODE, + MySensorsMessage.MYSENSORS_MSG_PART_CHILD, MySensorsMessage.MYSENSORS_MSG_PART_TYPE, + MySensorsMessage.MYSENSORS_MSG_PART_SUBTYPE }; + + @Test + public void testCustomHashCode() { + MySensorsMessage m1 = new MySensorsMessage(1, 2, MySensorsMessage.MYSENSORS_MSG_TYPE_SET, + MySensorsMessage.MYSENSORS_ACK_FALSE, false); + MySensorsMessage m2 = new MySensorsMessage(1, 2, MySensorsMessage.MYSENSORS_MSG_TYPE_SET, + MySensorsMessage.MYSENSORS_ACK_FALSE, false); + + assertEquals(m2.customHashCode(OLD_MESSAGE_CUSTOM_HASH), m1.customHashCode(OLD_MESSAGE_CUSTOM_HASH)); + + m2.setMsg("test"); + + assertEquals(m2.customHashCode(OLD_MESSAGE_CUSTOM_HASH), m1.customHashCode(OLD_MESSAGE_CUSTOM_HASH)); + + m1.setMsg("test"); + + assertEquals(m2.customHashCode(OLD_MESSAGE_CUSTOM_HASH), m1.customHashCode(OLD_MESSAGE_CUSTOM_HASH)); + + m1.setAck(MySensorsMessage.MYSENSORS_ACK_TRUE); + + assertEquals(m2.customHashCode(OLD_MESSAGE_CUSTOM_HASH), m1.customHashCode(OLD_MESSAGE_CUSTOM_HASH)); + + m2.setRevert(true); + + assertEquals(m2.customHashCode(OLD_MESSAGE_CUSTOM_HASH), m1.customHashCode(OLD_MESSAGE_CUSTOM_HASH)); + + m1.setSubType(MySensorsMessage.MYSENSORS_SUBTYPE_S_DOOR); + + assertEquals(m2.customHashCode(OLD_MESSAGE_CUSTOM_HASH), m1.customHashCode(OLD_MESSAGE_CUSTOM_HASH)); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/MySensorsUtilityTest.java b/addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/MySensorsUtilityTest.java new file mode 100644 index 000000000000..01b71c5011c1 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/MySensorsUtilityTest.java @@ -0,0 +1,103 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.test; + +import static org.junit.Assert.assertEquals; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.openhab.binding.mysensors.internal.MySensorsUtility; +import org.openhab.binding.mysensors.internal.sensors.MySensorsNode; + +public class MySensorsUtilityTest { + + @Test + public void testSameKey() { + Map m1 = new HashMap<>(); + Map m2 = new HashMap<>(); + + m1.put(1, new Object()); + m1.put(2, new Object()); + m1.put(3, new Object()); + + m2.put(4, new Object()); + m2.put(6, new Object()); + m2.put(7, new Object()); + + assertEquals(false, MySensorsUtility.containsSameKey(m1, m2)); + + m1.clear(); + m2.clear(); + + m1.put(1, new Object()); + m1.put(232, new Object()); + m1.put(569, new Object()); + + m2.put(1, new Object()); + m2.put(232, new Object()); + m2.put(569, new Object()); + + assertEquals(true, MySensorsUtility.containsSameKey(m1, m2)); + + m1.clear(); + m2.clear(); + + m1.put(569, new Object()); + m1.put(1, new Object()); + m1.put(232, new Object()); + + m2.put(232, new Object()); + m2.put(1, new Object()); + m2.put(569, new Object()); + + assertEquals(true, MySensorsUtility.containsSameKey(m1, m2)); + } + + @Test + public void testMergeMap() { + Map m1 = new HashMap<>(); + Map m2 = new HashMap<>(); + + m1.put(1, new MySensorsNode(1)); + m1.put(2, new MySensorsNode(2)); + + m2.put(4, new MySensorsNode(4)); + m2.put(6, new MySensorsNode(6)); + m2.put(7, new MySensorsNode(7)); + + MySensorsUtility.mergeMap(m1, m2, true); + + assertEquals(5, m1.size()); + + assertEquals(1, m1.get(1).getNodeId()); + assertEquals(2, m1.get(2).getNodeId()); + assertEquals(4, m1.get(4).getNodeId()); + assertEquals(6, m1.get(6).getNodeId()); + assertEquals(7, m1.get(7).getNodeId()); + + } + + @Test(expected = IllegalArgumentException.class) + public void testExceptionMergeMap() { + Map m1 = new HashMap<>(); + Map m2 = new HashMap<>(); + + m1.put(1, new MySensorsNode(1)); + m1.put(2, new MySensorsNode(2)); + + m2.put(2, new MySensorsNode(4)); + m2.put(3, new MySensorsNode(6)); + + MySensorsUtility.mergeMap(m1, m2, false); + + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/NodeChildTest.java b/addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/NodeChildTest.java new file mode 100644 index 000000000000..edb81d8cda37 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/NodeChildTest.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.test; + +import org.junit.Test; +import org.openhab.binding.mysensors.internal.sensors.MySensorsNode; +import org.openhab.binding.mysensors.internal.sensors.child.MySensorsChildSCustom; + +public class NodeChildTest { + + @Test(expected = IllegalArgumentException.class) + public void testWrongChildIdNeg() { + new MySensorsChildSCustom(-1); + } + + @Test(expected = IllegalArgumentException.class) + public void testWrongChildId() { + new MySensorsChildSCustom(255); + } + + @Test(expected = IllegalArgumentException.class) + public void testWrongNodeId0() { + new MySensorsNode(0); + } + + @Test(expected = IllegalArgumentException.class) + public void testWrongNodeId255() { + new MySensorsNode(255); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/VariableTest.java b/addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/VariableTest.java new file mode 100644 index 000000000000..34899ece8a0e --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/src/main/test/org/openhab/binding/mysensors/test/VariableTest.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2010-2017 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.mysensors.test; + +import static org.junit.Assert.assertEquals; + +import java.util.Date; + +import org.junit.Test; +import org.openhab.binding.mysensors.internal.exception.RevertVariableStateException; +import org.openhab.binding.mysensors.internal.sensors.MySensorsVariable; +import org.openhab.binding.mysensors.internal.sensors.variable.MySensorsVariableVCustom; + +public class VariableTest { + + @Test(expected = RevertVariableStateException.class) + public void testRevertException1() throws RevertVariableStateException { + MySensorsVariable v = new MySensorsVariableVCustom(); + v.revertValue(); + } + + @Test(expected = RevertVariableStateException.class) + public void testRevertException2() throws RevertVariableStateException { + MySensorsVariable v = new MySensorsVariableVCustom(); + + v.setValue("1"); + + v.revertValue(); + } + + @Test + public void testRevert() throws RevertVariableStateException { + MySensorsVariable v = new MySensorsVariableVCustom(); + + v.setValue("1"); + String s = v.getValue(); + Date d = v.getLastUpdate(); + + v.setValue("0"); + + v.revertValue(); + + assertEquals(d, v.getLastUpdate()); + assertEquals(s, v.getValue()); + } + +} diff --git a/addons/binding/org.openhab.binding.mysensors/test/iVersionMessage.sh b/addons/binding/org.openhab.binding.mysensors/test/iVersionMessage.sh new file mode 100755 index 000000000000..f4b57c7b80d7 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/test/iVersionMessage.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +serialPort=$1 + +echo "0;0;3;0;2;0" > $serialPort diff --git a/addons/binding/org.openhab.binding.mysensors/test/smartSleepTest.sh b/addons/binding/org.openhab.binding.mysensors/test/smartSleepTest.sh new file mode 100755 index 000000000000..be343b3422a2 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/test/smartSleepTest.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +serialPort=$1 + +# Receive random value for sensor +echo "104;0;1;0;1;87" > $serialPort + +# sleep a bit +sleep 3 + +# I_HEARTBEAT_RESPONSE +echo "104;255;3;0;22;4999" > $serialPort \ No newline at end of file diff --git a/addons/binding/org.openhab.binding.mysensors/test/testscript.sh b/addons/binding/org.openhab.binding.mysensors/test/testscript.sh new file mode 100755 index 000000000000..e7edecf5b15b --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/test/testscript.sh @@ -0,0 +1,211 @@ +#!/bin/sh + +serialPort=$1 + +# socat -d -d pty,raw,echo=0 pty,raw,echo=0 + +# Gateway startup notification +#echo "0;0;3;0;14;Gateway startup complete." > $serialPort + +# Switch light on: +# 102;1;1;0;2;1 + +# Request node id +#echo "255;255;3;0;3" > $serialPort #Sensor --> gateway +# 255;255;3;0;4; gateway --> sensor + + +# Representation of a new (started) sensor +#0;0;3;0;9;read: 172-172-0 s=255,c=0,t=18,pt=0,l=5:1.4.1 +#echo "172;255;0;0;18;1.4.1" > $serialPort +#0;0;3;0;9;read: 172-172-0 s=255,c=3,t=6,pt=1,l=1:0 + +#0;0;3;0;9;read: 172-172-0 s=255,c=3,t=11,pt=0,l=23:Humidity + Temp + +#echo "172;255;3;0;11;Humidity + Temp + Relay" > $serialPort +#0;0;3;0;9;read: 172-172-0 s=255,c=3,t=12,pt=0,l=3:1.0 +#echo "172;255;3;0;12;1.0" > $serialPort +#0;0;3;0;9;read: 172-172-0 s=0,c=0,t=7,pt=0,l=5:1.4.1 +#echo "172;0;0;0;7;1.4.1" > $serialPort +#0;0;3;0;9;read: 172-172-0 s=1,c=0,t=6,pt=0,l=5:1.4.1 +#echo "172;1;0;0;6;1.4.1" > $serialPort +#0;0;3;0;9;read: 172-172-0 s=2,c=0,t=38,pt=0,l=5:1.4.1 +#echo "172;2;0;0;38;1.4.1" > $serialPort +#0;0;3;0;9;read: 172-172-0 s=3,c=0,t=3,pt=0,l=5:1.4.1 +#echo "172;3;0;0;3;1.4.1" > $serialPort + +# Request I_TIME +#echo "172;255;3;0;1;0" > $serialPort # What time is it? + +#echo "172;255;3;0;6;0" > $serialPort ############################### is metric? + +# Set Humidty status +#echo "172;0;1;0;1;87" > $serialPort + +# Set Humidty status +echo "173;0;0;0;7;1.4.1" > $serialPort +echo "173;0;1;0;1;44" > $serialPort + +# Set Temperature status +#echo "172;1;1;0;0;27" > $serialPort + +# Set V_TEXT +#echo "123;123;1;0;47;ipsumlorum" > $serialPort + +# Set V_IR_RECEIVE +#echo "111;111;1;0;33;FADEXXFE" > $serialPort + +# Set V_IR_SEND +#echo "111;112;1;0;32;ABCDEFGHIJKL" > $serialPort + +#### Represent door +echo "172;4;0;0;0;1.4.1" > $serialPort + +# Set Tripped status +echo "172;4;1;0;16;1" > $serialPort + +# Set Armed status +echo "172;4;1;0;15;1" > $serialPort + +#### Represent motion +#echo "174;0;0;0;1;2.0.1" > $serialPort + +# Set Tripped status +#echo "174;0;1;0;16;1" > $serialPort + +# Set Armed status +#echo "174;0;1;0;15;0" > $serialPort + +#### Represent smoke +#echo "172;6;0;0;2;1.4.1" > $serialPort + +# Set Tripped status +#echo "172;6;1;0;16;1" > $serialPort + +#### Represent Dimmer +#echo "172;7;0;0;4;1.4.1" > $serialPort + +# Set dimmer status +#echo "172;7;1;0;3;49" > $serialPort + +# Set dimmer status +#echo "172;7;1;0;2;1" > $serialPort + +#### Represent Cover +#echo "172;8;0;0;5;1.4.1" > $serialPort + +# Set cover status UP(29) == 1, DOWN(30) == 1 +#echo "172;8;1;0;29;1" > $serialPort + +# Set cover status +#echo "172;8;1;0;30;1" > $serialPort + + +#### Represent wind +#echo "172;9;0;0;9;1.4.1" > $serialPort + +# Set wind speed +#echo "172;9;1;0;8;4.9" > $serialPort + +# Set wind gust +#echo "172;9;1;0;9;11.8" > $serialPort + + +#### Represent rain +#echo "172;10;0;0;10;1.4.1" > $serialPort + +# Set rain +#echo "172;10;1;0;6;19.7" > $serialPort + +# Set rain rate +#echo "172;10;1;0;7;114" > $serialPort + + +#### Represent UV +#echo "172;11;0;0;11;1.4.1" > $serialPort + +# Set rain +#echo "172;11;1;0;11;8.15" > $serialPort + +#### Represent WEIGHT +#echo "172;12;0;0;12;1.4.1" > $serialPort + +# Set weight +#echo "172;12;1;0;12;1982.12" > $serialPort + +# Set impedance +#echo "172;12;1;0;14;1000000" > $serialPort + +#### Represent DISTANCE +#echo "172;13;0;0;15;1.4.1" > $serialPort + +# Set DISTANCE +#echo "172;13;1;0;13;1543.98" > $serialPort + +#### Represent LIGHT_LEVEL +#echo "172;14;0;0;16;1.4.1" > $serialPort +#echo "101;2;0;0;16;2.1.0" > $serialPort + +# Set LIGHT_LEVEL +#echo "101;2;1;0;23;1543.98" > $serialPort +#echo "101;2;1;0;37;246" > $serialPort + +# Set watt status +#echo "172;7;1;0;17;0815" > $serialPort + +#echo "172;0;1;0;1;38.6" > $serialPort +#echo "172;1;1;0;0;27.2" > $serialPort +#echo "172;2;1;0;38;8.4" > $serialPort + + +# Representation of a S_POWER Sensor +#echo "3;1;0;0;13;1.4.1" > $serialPort + +# S_POWER Sensor +#echo "3;1;1;0;17;2810" > $serialPort # the current power consumption (Watt) +#echo "3;1;1;0;18;106.2550" > $serialPort # the overall power usage since sensor boot (KWH) + +# Representation of a S_BARO +#echo "6;3;0;0;8;1.4.1" > $serialPort + +# Barometer forecast V_BARO +#echo "6;3;1;0;5;stable" > $serialPort + +# Barometer pressure V_PRESSURE +#echo "6;3;1;0;4;1.2" > $serialPort + +# Representation of S_MULTIMETER Sensor +#echo "12;3;0;0;30;1.5.0" > $serialPort + +# set volt +#echo "12;3;1;0;38;5678" > $serialPort + +# set current +#echo "12;3;1;0;39;1234" > $serialPort + +# set impedance +#echo "12;3;1;0;14;1000000" > $serialPort + +# waterQuality +#echo "10;0;1;0;52;996.3" > $serialPort + +#get time +#echo "172;255;3;0;1;0" > $serialPort # I_TIME + +# INTERNAL +# batteryLevel +#echo "101;255;3;0;0;94" > $serialPort + +# I_HEARTBEAT_RESPONSE +#echo "172;3;3;0;22;1" > $serialPort + +# Representation of a S_COLOR_SENSOR +#echo "1;0;0;0;28;2.1.0" > $serialPort + +# set rgb +#echo "1;0;1;0;40;ff00ff" > $serialPort + +# Representation of a S_DUST +#echo "1;1;0;0;24;2.1.0" > $serialPort + +# set dust level +#echo "1;1;1;0;37;66" > $serialPort diff --git a/addons/binding/pom.xml b/addons/binding/pom.xml index 183f5da0341c..a70ca5028900 100644 --- a/addons/binding/pom.xml +++ b/addons/binding/pom.xml @@ -77,6 +77,7 @@ org.openhab.binding.yamahareceiver org.openhab.binding.zoneminder org.openhab.binding.zway + org.openhab.binding.mysensors - + \ No newline at end of file From e0e532b6d8f904a01b3772f546ffaea484c8f16e Mon Sep 17 00:00:00 2001 From: Sean McGuire Date: Thu, 23 Mar 2017 14:54:30 +0000 Subject: [PATCH 2/9] merge --- .../org.openhab.binding.mysensors/.classpath | 1 + .../.settings/org.eclipse.pde.core.prefs | 2 + .../ESH-INF/thing/thing-types.xml | 96 +++++++++ .../META-INF/MANIFEST.MF | 13 +- .../OSGI-INF/MySensorsDiscovery.xml | 2 +- .../OSGI-INF/MySensorsHandlerFactory.xml | 2 +- .../OSGI-INF/MySensorsMQTTService.xml | 5 + .../build.properties | 4 +- .../org.openhab.binding.mysensors/pom.xml | 1 + .../mysensors/MySensorsBindingConstants.java | 7 +- .../config/MySensorsBridgeConfiguration.java | 20 +- .../config/MySensorsSensorConfiguration.java | 3 +- .../MySensorsDecimalTypeConverter.java | 8 +- .../MySensorsOnOffTypeConverter.java | 8 +- .../MySensorsOpenCloseTypeConverter.java | 8 +- .../MySensorsPercentTypeConverter.java | 8 +- .../MySensorsStringTypeConverter.java | 8 +- .../converter/MySensorsTypeConverter.java | 2 +- .../MySensorsUpDownTypeConverter.java | 8 +- .../discovery/MySensorsDiscoveryService.java | 59 +++--- .../factory/MySensorsCacheFactory.java | 19 +- .../factory/MySensorsHandlerFactory.java | 5 +- .../handler/MySensorsBridgeHandler.java | 20 +- .../handler/MySensorsThingHandler.java | 12 +- .../binding/mysensors/internal/Mergeable.java | 8 - .../mysensors/internal/MySensorsUtility.java | 2 +- .../internal/event/EventRegister.java | 2 +- .../event/MySensorsEventRegister.java | 19 +- .../event/MySensorsGatewayEventListener.java | 18 +- .../event/MySensorsNodeUpdateEventType.java | 2 +- .../mysensors/internal/event/Register.java | 2 +- .../internal/exception/MergeException.java | 11 +- .../exception/NoMoreIdsException.java | 2 +- .../RevertVariableStateException.java | 8 +- .../internal/gateway/MySensorsGateway.java | 29 ++- .../gateway/MySensorsGatewayConfig.java | 51 ++++- .../gateway/MySensorsGatewayType.java | 5 +- .../MySensorsNetworkSanityChecker.java | 4 +- .../protocol/MySensorsAbstractConnection.java | 24 +-- .../protocol/ip/MySensorsIpConnection.java | 7 +- .../protocol/message/MySensorsMessage.java | 20 +- .../mqtt/MySensorsMqttConnection.java | 186 +++++++++++++++++ .../protocol/mqtt/MySensorsMqttService.java | 44 ++++ .../serial/MySensorsSerialConnection.java | 7 +- .../internal/sensors/MySensorsChild.java | 193 +++++++++--------- .../sensors/MySensorsChildConfig.java | 15 -- .../internal/sensors/MySensorsNode.java | 9 +- .../internal/sensors/MySensorsNodeConfig.java | 15 -- .../internal/sensors/MySensorsVariable.java | 9 +- .../child/MySensorsChild_S_AIR_QUALITY.java | 25 +++ .../child/MySensorsChild_S_ARDUINO_NODE.java | 21 ++ ...ySensorsChild_S_ARDUINO_REPEATER_NODE.java | 22 ++ .../sensors/child/MySensorsChild_S_BARO.java | 25 +++ .../child/MySensorsChild_S_BINARY.java | 25 +++ .../child/MySensorsChild_S_COLOR_SENSOR.java | 23 +++ .../sensors/child/MySensorsChild_S_COVER.java | 29 +++ .../child/MySensorsChild_S_CUSTOM.java | 21 ++ .../child/MySensorsChild_S_DIMMER.java | 27 +++ .../child/MySensorsChild_S_DISTANCE.java | 25 +++ .../sensors/child/MySensorsChild_S_DOOR.java | 25 +++ .../sensors/child/MySensorsChild_S_DUST.java | 25 +++ .../sensors/child/MySensorsChild_S_GAS.java | 25 +++ .../sensors/child/MySensorsChild_S_GPS.java | 23 +++ .../child/MySensorsChild_S_HEATER.java | 29 +++ .../sensors/child/MySensorsChild_S_HUM.java | 23 +++ .../sensors/child/MySensorsChild_S_HVAC.java | 35 ++++ .../sensors/child/MySensorsChild_S_INFO.java | 23 +++ .../sensors/child/MySensorsChild_S_IR.java | 27 +++ .../child/MySensorsChild_S_LIGHT_LEVEL.java | 25 +++ .../sensors/child/MySensorsChild_S_LOCK.java | 23 +++ .../child/MySensorsChild_S_MOISTURE.java | 27 +++ .../child/MySensorsChild_S_MOTION.java | 25 +++ .../child/MySensorsChild_S_MULTIMETER.java | 27 +++ .../sensors/child/MySensorsChild_S_POWER.java | 31 +++ .../sensors/child/MySensorsChild_S_RAIN.java | 25 +++ .../child/MySensorsChild_S_RGBW_LIGHT.java | 25 +++ .../child/MySensorsChild_S_RGB_LIGHT.java | 25 +++ .../MySensorsChild_S_SCENE_CONTROLLER.java | 25 +++ .../sensors/child/MySensorsChild_S_SMOKE.java | 25 +++ .../sensors/child/MySensorsChild_S_SOUND.java | 27 +++ .../child/MySensorsChild_S_SPRINKLER.java | 25 +++ .../sensors/child/MySensorsChild_S_TEMP.java | 25 +++ .../sensors/child/MySensorsChild_S_UV.java | 23 +++ .../child/MySensorsChild_S_VIBRATION.java | 27 +++ .../sensors/child/MySensorsChild_S_WATER.java | 25 +++ .../child/MySensorsChild_S_WATER_LEAK.java | 25 +++ .../child/MySensorsChild_S_WATER_QUALITY.java | 31 +++ .../child/MySensorsChild_S_WEIGHT.java | 25 +++ .../sensors/child/MySensorsChild_S_WIND.java | 27 +++ .../variable/MySensorsVariable_V_ARMED.java | 20 ++ .../variable/MySensorsVariable_V_CURRENT.java | 20 ++ .../variable/MySensorsVariable_V_CUSTOM.java | 20 ++ .../MySensorsVariable_V_DIRECTION.java | 20 ++ .../MySensorsVariable_V_DISTANCE.java | 20 ++ .../variable/MySensorsVariable_V_DOWN.java | 20 ++ .../variable/MySensorsVariable_V_EC.java | 20 ++ .../variable/MySensorsVariable_V_FLOW.java | 20 ++ .../MySensorsVariable_V_FORECAST.java | 20 ++ .../variable/MySensorsVariable_V_GUST.java | 20 ++ .../variable/MySensorsVariable_V_HUM.java | 20 ++ .../MySensorsVariable_V_HVAC_FLOW_MODE.java | 20 ++ .../MySensorsVariable_V_HVAC_FLOW_STATE.java | 20 ++ ...ySensorsVariable_V_HVAC_SETPOINT_COOL.java | 20 ++ ...ySensorsVariable_V_HVAC_SETPOINT_HEAT.java | 20 ++ .../MySensorsVariable_V_HVAC_SPEED.java | 20 ++ .../variable/MySensorsVariable_V_ID.java | 20 ++ .../MySensorsVariable_V_IMPEDANCE.java | 20 ++ .../MySensorsVariable_V_IR_RECEIVE.java | 20 ++ .../MySensorsVariable_V_IR_RECORD.java | 20 ++ .../variable/MySensorsVariable_V_IR_SEND.java | 20 ++ .../variable/MySensorsVariable_V_KWH.java | 20 ++ .../variable/MySensorsVariable_V_LEVEL.java | 20 ++ .../MySensorsVariable_V_LIGHT_LEVEL.java | 20 ++ .../MySensorsVariable_V_LOCK_STATUS.java | 20 ++ .../variable/MySensorsVariable_V_ORP.java | 20 ++ .../MySensorsVariable_V_PERCENTAGE.java | 20 ++ .../variable/MySensorsVariable_V_PH.java | 20 ++ .../MySensorsVariable_V_POSITION.java | 20 ++ .../MySensorsVariable_V_POWER_FACTOR.java | 20 ++ .../MySensorsVariable_V_PRESSURE.java | 20 ++ .../variable/MySensorsVariable_V_RAIN.java | 20 ++ .../MySensorsVariable_V_RAINRATE.java | 20 ++ .../variable/MySensorsVariable_V_RGB.java | 20 ++ .../variable/MySensorsVariable_V_RGBW.java | 20 ++ .../MySensorsVariable_V_SCENE_OFF.java | 20 ++ .../MySensorsVariable_V_SCENE_ON.java | 20 ++ .../variable/MySensorsVariable_V_STATUS.java | 20 ++ .../variable/MySensorsVariable_V_STOP.java | 20 ++ .../variable/MySensorsVariable_V_TEMP.java | 20 ++ .../variable/MySensorsVariable_V_TEXT.java | 20 ++ .../variable/MySensorsVariable_V_TRIPPED.java | 20 ++ .../MySensorsVariable_V_UNIT_PREFIX.java | 20 ++ .../variable/MySensorsVariable_V_UP.java | 20 ++ .../variable/MySensorsVariable_V_UV.java | 20 ++ .../variable/MySensorsVariable_V_VA.java | 20 ++ .../variable/MySensorsVariable_V_VAR.java | 20 ++ .../variable/MySensorsVariable_V_VAR1.java | 20 ++ .../variable/MySensorsVariable_V_VAR2.java | 20 ++ .../variable/MySensorsVariable_V_VAR3.java | 20 ++ .../variable/MySensorsVariable_V_VAR4.java | 20 ++ .../variable/MySensorsVariable_V_VAR5.java | 20 ++ .../variable/MySensorsVariable_V_VOLTAGE.java | 20 ++ .../variable/MySensorsVariable_V_VOLUME.java | 20 ++ .../variable/MySensorsVariable_V_WATT.java | 20 ++ .../variable/MySensorsVariable_V_WEIGHT.java | 20 ++ .../variable/MySensorsVariable_V_WIND.java | 20 ++ .../binding/mysensors/test/CacheTest.java | 7 +- .../mysensors/test/DiscoveryServiceTest.java | 2 +- .../binding/mysensors/test/MessageTest.java | 2 +- .../mysensors/test/MySensorsUtilityTest.java | 2 +- .../binding/mysensors/test/NodeChildTest.java | 8 +- .../binding/mysensors/test/VariableTest.java | 10 +- .../test/testscript.sh | 21 +- 153 files changed, 2846 insertions(+), 380 deletions(-) create mode 100644 addons/binding/org.openhab.binding.mysensors/.settings/org.eclipse.pde.core.prefs create mode 100644 addons/binding/org.openhab.binding.mysensors/OSGI-INF/MySensorsMQTTService.xml create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/protocol/mqtt/MySensorsMqttConnection.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/protocol/mqtt/MySensorsMqttService.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_AIR_QUALITY.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_ARDUINO_NODE.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_ARDUINO_REPEATER_NODE.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_BARO.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_BINARY.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_COLOR_SENSOR.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_COVER.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_CUSTOM.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_DIMMER.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_DISTANCE.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_DOOR.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_DUST.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_GAS.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_GPS.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_HEATER.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_HUM.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_HVAC.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_INFO.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_IR.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_LIGHT_LEVEL.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_LOCK.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_MOISTURE.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_MOTION.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_MULTIMETER.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_POWER.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_RAIN.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_RGBW_LIGHT.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_RGB_LIGHT.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_SCENE_CONTROLLER.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_SMOKE.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_SOUND.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_SPRINKLER.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_TEMP.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_UV.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_VIBRATION.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_WATER.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_WATER_LEAK.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_WATER_QUALITY.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_WEIGHT.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/child/MySensorsChild_S_WIND.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_ARMED.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_CURRENT.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_CUSTOM.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_DIRECTION.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_DISTANCE.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_DOWN.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_EC.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_FLOW.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_FORECAST.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_GUST.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_HUM.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_HVAC_FLOW_MODE.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_HVAC_FLOW_STATE.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_HVAC_SETPOINT_COOL.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_HVAC_SETPOINT_HEAT.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_HVAC_SPEED.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_ID.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_IMPEDANCE.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_IR_RECEIVE.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_IR_RECORD.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_IR_SEND.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_KWH.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_LEVEL.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_LIGHT_LEVEL.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_LOCK_STATUS.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_ORP.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_PERCENTAGE.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_PH.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_POSITION.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_POWER_FACTOR.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_PRESSURE.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_RAIN.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_RAINRATE.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_RGB.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_RGBW.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_SCENE_OFF.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_SCENE_ON.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_STATUS.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_STOP.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_TEMP.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_TEXT.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_TRIPPED.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_UNIT_PREFIX.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_UP.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_UV.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_VA.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_VAR.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_VAR1.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_VAR2.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_VAR3.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_VAR4.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_VAR5.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_VOLTAGE.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_VOLUME.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_WATT.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_WEIGHT.java create mode 100644 addons/binding/org.openhab.binding.mysensors/src/main/java/org/openhab/binding/mysensors/internal/sensors/variable/MySensorsVariable_V_WIND.java diff --git a/addons/binding/org.openhab.binding.mysensors/.classpath b/addons/binding/org.openhab.binding.mysensors/.classpath index 1ff253c6199b..9202456484fb 100644 --- a/addons/binding/org.openhab.binding.mysensors/.classpath +++ b/addons/binding/org.openhab.binding.mysensors/.classpath @@ -5,5 +5,6 @@ + diff --git a/addons/binding/org.openhab.binding.mysensors/.settings/org.eclipse.pde.core.prefs b/addons/binding/org.openhab.binding.mysensors/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 000000000000..923c37fb8d55 --- /dev/null +++ b/addons/binding/org.openhab.binding.mysensors/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +resolve.requirebundle=false diff --git a/addons/binding/org.openhab.binding.mysensors/ESH-INF/thing/thing-types.xml b/addons/binding/org.openhab.binding.mysensors/ESH-INF/thing/thing-types.xml index cf2f3bc327b1..3101d452c958 100644 --- a/addons/binding/org.openhab.binding.mysensors/ESH-INF/thing/thing-types.xml +++ b/addons/binding/org.openhab.binding.mysensors/ESH-INF/thing/thing-types.xml @@ -145,12 +145,77 @@ + + + MySensors Gateway connected via MQTT + + + + + MQTT topic to subscribe to + + + + + MQTT topic to publish to + + + + + name of the MQTT broker as defined in the mqtt.cfg file + + + + + Allow the user to bypass the I_VERSION check on startup + false + + + + Metric answer with imperial instead of metric + false + + + + Network sanity check periodically unsure that gateway is up and running + false + + + + Network sanity check periodically unsure that gateway is up and running + 3 + + + + When gateway not respond, you could configure how many retry, sanity check, will do before + disconnecting it + + 3 + + + + When network sanity checker run, send heartbeat to all nodes + false + + + + When nodes not respond to heartbeat, you could configure how many retry, sanity check, will do before + disconnecting them + + 10 + + + + + + + @@ -216,6 +281,7 @@ + @@ -279,6 +345,7 @@ + @@ -342,6 +409,7 @@ + @@ -403,6 +471,7 @@ + @@ -465,6 +534,7 @@ + @@ -527,6 +597,7 @@ + @@ -589,6 +660,7 @@ + @@ -651,6 +723,7 @@ + @@ -712,6 +785,7 @@ + @@ -775,6 +849,7 @@ + @@ -836,6 +911,7 @@ + @@ -898,6 +974,7 @@ + @@ -960,6 +1037,7 @@ + @@ -1021,6 +1099,7 @@ + @@ -1083,6 +1162,7 @@ + @@ -1144,6 +1224,7 @@ + @@ -1205,6 +1286,7 @@ + @@ -1276,6 +1358,7 @@ + @@ -1339,6 +1422,7 @@ + @@ -1403,6 +1487,7 @@ + @@ -1466,6 +1551,7 @@ + @@ -1531,6 +1617,7 @@ + @@ -1597,6 +1684,7 @@ + @@ -1664,6 +1752,7 @@ + @@ -1725,10 +1814,12 @@ + + @@ -1793,6 +1884,7 @@ + @@ -1857,6 +1949,7 @@ + @@ -1922,6 +2015,7 @@ + @@ -1983,6 +2077,7 @@ + @@ -2044,6 +2139,7 @@ + diff --git a/addons/binding/org.openhab.binding.mysensors/META-INF/MANIFEST.MF b/addons/binding/org.openhab.binding.mysensors/META-INF/MANIFEST.MF index 7f6cb434e0a0..ac1ca058cc2a 100644 --- a/addons/binding/org.openhab.binding.mysensors/META-INF/MANIFEST.MF +++ b/addons/binding/org.openhab.binding.mysensors/META-INF/MANIFEST.MF @@ -4,19 +4,16 @@ Bundle-Name: MySensors Binding Bundle-SymbolicName: org.openhab.binding.mysensors;singleton:=true Bundle-Vendor: openHAB Bundle-Version: 2.1.0.qualifier -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ClassPath: . Import-Package: com.google.common.base, com.google.common.collect, com.google.gson, - com.google.gson.reflect, - com.google.gson.stream, - gnu.io, org.apache.commons.lang, + org.eclipse.paho.client.mqttv3, org.eclipse.smarthome.config.core, org.eclipse.smarthome.config.discovery, - org.eclipse.smarthome.core.common.registry, org.eclipse.smarthome.core.library.types, org.eclipse.smarthome.core.thing, org.eclipse.smarthome.core.thing.binding, @@ -25,6 +22,8 @@ Import-Package: org.eclipse.smarthome.core.types, org.openhab.binding.mysensors, org.openhab.binding.mysensors.handler, + org.openhab.core.events, + org.openhab.io.transport.mqtt, org.osgi.framework, org.osgi.service.cm, org.osgi.service.component, @@ -32,3 +31,7 @@ Import-Package: Service-Component: OSGI-INF/*.xml Export-Package: org.openhab.binding.mysensors, org.openhab.binding.mysensors.handler +Require-Bundle: org.eclipse.smarthome.core, + com.neuronrobotics.nrjavaserial, + com.google.gson +Bundle-ActivationPolicy: lazy diff --git a/addons/binding/org.openhab.binding.mysensors/OSGI-INF/MySensorsDiscovery.xml b/addons/binding/org.openhab.binding.mysensors/OSGI-INF/MySensorsDiscovery.xml index df498775bc43..c8214cd83897 100644 --- a/addons/binding/org.openhab.binding.mysensors/OSGI-INF/MySensorsDiscovery.xml +++ b/addons/binding/org.openhab.binding.mysensors/OSGI-INF/MySensorsDiscovery.xml @@ -1,7 +1,7 @@