From 98e1215ecafe47108bf106cf66bba5417c49c00a Mon Sep 17 00:00:00 2001 From: Timo Schober Date: Fri, 19 Apr 2024 13:14:11 +0200 Subject: [PATCH 1/6] feat: add support for emt7110 energy meter with jeelink Signed-off-by: tischober --- .../internal/JeeLinkBindingConstants.java | 1 + .../jeelink/internal/SensorDefinition.java | 7 +- .../internal/config/EMT7110SensorConfig.java | 22 ++++ .../internal/emt7110/Emt7110Reading.java | 67 ++++++++++++ .../emt7110/Emt7110ReadingConverter.java | 75 +++++++++++++ .../emt7110/Emt7110SensorDefinition.java | 46 ++++++++ .../emt7110/Emt7110SensorHandler.java | 101 ++++++++++++++++++ .../resources/OH-INF/i18n/jeelink.properties | 3 + .../OH-INF/i18n/jeelink_de.properties | 2 + .../resources/OH-INF/thing/thing-types.xml | 39 +++++++ 10 files changed, 360 insertions(+), 3 deletions(-) create mode 100644 bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/config/EMT7110SensorConfig.java create mode 100644 bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110Reading.java create mode 100644 bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110ReadingConverter.java create mode 100644 bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110SensorDefinition.java create mode 100644 bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110SensorHandler.java diff --git a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/JeeLinkBindingConstants.java b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/JeeLinkBindingConstants.java index 2a5c398496697..16f191480bfa8 100644 --- a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/JeeLinkBindingConstants.java +++ b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/JeeLinkBindingConstants.java @@ -42,6 +42,7 @@ private JeeLinkBindingConstants() { public static final ThingTypeUID LACROSSE_SENSOR_THING_TYPE = new ThingTypeUID(BINDING_ID, "lacrosse"); public static final ThingTypeUID EC3000_SENSOR_THING_TYPE = new ThingTypeUID(BINDING_ID, "ec3k"); public static final ThingTypeUID PCA301_SENSOR_THING_TYPE = new ThingTypeUID(BINDING_ID, "pca301"); + public static final ThingTypeUID EMT7110_SENSOR_THING_TYPE = new ThingTypeUID(BINDING_ID, "emt7110"); public static final ThingTypeUID TX22_SENSOR_THING_TYPE = new ThingTypeUID(BINDING_ID, "tx22"); public static final ThingTypeUID REVOLT_SENSOR_THING_TYPE = new ThingTypeUID(BINDING_ID, "revolt"); public static final ThingTypeUID LGW_SENSOR_THING_TYPE = new ThingTypeUID(BINDING_ID, "lgw"); diff --git a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/SensorDefinition.java b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/SensorDefinition.java index c939818b0397e..b56fe6a808b91 100644 --- a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/SensorDefinition.java +++ b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/SensorDefinition.java @@ -17,6 +17,7 @@ import java.util.stream.Stream; import org.openhab.binding.jeelink.internal.ec3k.Ec3kSensorDefinition; +import org.openhab.binding.jeelink.internal.emt7110.Emt7110SensorDefinition; import org.openhab.binding.jeelink.internal.lacrosse.LaCrosseSensorDefinition; import org.openhab.binding.jeelink.internal.lacrosse.LgwSensorDefinition; import org.openhab.binding.jeelink.internal.lacrosse.Tx22SensorDefinition; @@ -36,9 +37,9 @@ public abstract class SensorDefinition { public static final String ALL_TYPE = "All"; - private static final Set> SENSOR_DEFS = Stream - .of(new LaCrosseSensorDefinition(), new Ec3kSensorDefinition(), new Pca301SensorDefinition(), - new Tx22SensorDefinition(), new RevoltSensorDefinition(), new LgwSensorDefinition()) + private static final Set> SENSOR_DEFS = Stream.of(new LaCrosseSensorDefinition(), + new Ec3kSensorDefinition(), new Pca301SensorDefinition(), new Emt7110SensorDefinition(), + new Tx22SensorDefinition(), new RevoltSensorDefinition(), new LgwSensorDefinition()) .collect(Collectors.toSet()); private static final Set> CONVERTERS = SENSOR_DEFS.stream() .map(SensorDefinition::createConverter).collect(Collectors.toSet()); diff --git a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/config/EMT7110SensorConfig.java b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/config/EMT7110SensorConfig.java new file mode 100644 index 0000000000000..d3eeabc3714ce --- /dev/null +++ b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/config/EMT7110SensorConfig.java @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2010-2024 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.jeelink.internal.config; + +/** + * Configuration for a EMT7110SensorHandler. + * + * @author Timo Schober - Initial contribution + */ +public class EMT7110SensorConfig extends JeeLinkSensorConfig { + +} diff --git a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110Reading.java b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110Reading.java new file mode 100644 index 0000000000000..67d3dd326d0f9 --- /dev/null +++ b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110Reading.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2010-2024 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.jeelink.internal.emt7110; + +import org.openhab.binding.jeelink.internal.Reading; + +/** + * Handler for a EMT7110 energy Sensor thing. + * + * @author Timo Schober - Initial contribution + */ +public class Emt7110Reading implements Reading { + private final String sensorId; + private final float voltage; + private final float current; + private final float power; + private final float aPower; + private final boolean on; + + public Emt7110Reading(String sensorId, float voltage, float current, float power, float aPower, boolean deviceOn) { + this.sensorId = sensorId; + this.voltage = voltage; + this.current = current; + this.power = power; + this.aPower = aPower; + this.on = deviceOn; + } + + @Override + public String getSensorId() { + return sensorId; + } + + public int getChannel() { + return 0; + } + + public float getVoltage() { + return voltage; + } + + public float getCurrent() { + return current; + } + + public boolean isOn() { + return on; + } + + public float getPower() { + return power; + } + + public float getaPower() { + return aPower; + } +} diff --git a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110ReadingConverter.java b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110ReadingConverter.java new file mode 100644 index 0000000000000..9c22671d42455 --- /dev/null +++ b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110ReadingConverter.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2010-2024 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.jeelink.internal.emt7110; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.openhab.binding.jeelink.internal.JeeLinkReadingConverter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Handler for a EMT7110 energy Sensor thing. + * + * @author Timo Schober - Initial contribution + */ +public class Emt7110ReadingConverter implements JeeLinkReadingConverter { + private static final Pattern READING_P = Pattern.compile( + "OK EMT7110\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)"); + + private final Logger logger = LoggerFactory.getLogger(Emt7110ReadingConverter.class); + + @Override + public Emt7110Reading createReading(String inputLine) { + // parse lines only if we have registered listeners + if (inputLine != null) { + Matcher matcher = READING_P.matcher(inputLine); + if (matcher.matches()) { + // Format + // OK EMT7110 84 81 8 237 0 13 0 2 1 6 1 -> ID 5451 228,5V 13mA 2W 2,62kWh + // OK EMT7110 84 162 8 207 0 76 0 7 0 0 1 + // OK EMT7110 ID ID VV VV AA AA WW WW KW KW Flags + // | | | | | | | | | | | + // | | | | | | | | | | `--- AccumulatedPower * 100 LSB + // | | | | | | | | | `------ AccumulatedPower * 100 MSB + // | | | | | | | | `--- Power (W) LSB + // | | | | | | | `------ Power (W) MSB + // | | | | | | `--- Current (mA) LSB + // | | | | | `------ Current (mA) MSB + // | | | | `--- Voltage (V) * 10 LSB + // | | | `----- Voltage (V) * 10 MSB + // | | `--- ID + // | `------- ID + // `--- fix "EMT7110" + // logger.trace("Creating reading from: {}", inputLine); + + String id = matcher.group(1) + matcher.group(2); + float voltage = (Integer.parseInt(matcher.group(3)) * 256 + Integer.parseInt(matcher.group(4))) / 10f; + float current = (Integer.parseInt(matcher.group(5)) * 256 + Integer.parseInt(matcher.group(6))); + float power = (Integer.parseInt(matcher.group(7)) * 256 + Integer.parseInt(matcher.group(8))); + float aPower = (Integer.parseInt(matcher.group(9)) * 256 + Integer.parseInt(matcher.group(10))) / 100f; + + return new Emt7110Reading(id, voltage, current, power, aPower, true); + } + } + + return null; + } + /* + * public static void main(String[] args){ + * Emt7110ReadingConverter emt = new Emt7110ReadingConverter(); + * emt.createReading("OK EMT7110 84 81 9 91 0 72 0 2 1 6 1"); + * } + */ +} diff --git a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110SensorDefinition.java b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110SensorDefinition.java new file mode 100644 index 0000000000000..5a253c0b00f9e --- /dev/null +++ b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110SensorDefinition.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2010-2024 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.jeelink.internal.emt7110; + +import org.openhab.binding.jeelink.internal.JeeLinkBindingConstants; +import org.openhab.binding.jeelink.internal.JeeLinkReadingConverter; +import org.openhab.binding.jeelink.internal.JeeLinkSensorHandler; +import org.openhab.binding.jeelink.internal.SensorDefinition; +import org.openhab.core.thing.Thing; + +/** + * Handler for a EMT7110 energy Sensor thing. + * + * @author Timo Schober - Initial contribution + */ +public class Emt7110SensorDefinition extends SensorDefinition { + + public Emt7110SensorDefinition() { + super(JeeLinkBindingConstants.EMT7110_SENSOR_THING_TYPE, "EMT7110 power monitoring wireless socket", "EMT"); + } + + @Override + public JeeLinkReadingConverter createConverter() { + return new Emt7110ReadingConverter(); + } + + @Override + public Class getReadingClass() { + return Emt7110Reading.class; + } + + @Override + public JeeLinkSensorHandler createHandler(Thing thing) { + return new Emt7110SensorHandler(thing, type); + } +} diff --git a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110SensorHandler.java b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110SensorHandler.java new file mode 100644 index 0000000000000..92bc95282793a --- /dev/null +++ b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110SensorHandler.java @@ -0,0 +1,101 @@ +/** + * Copyright (c) 2010-2024 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.jeelink.internal.emt7110; + +import static org.openhab.binding.jeelink.internal.JeeLinkBindingConstants.*; + +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.atomic.AtomicInteger; + +import org.openhab.binding.jeelink.internal.JeeLinkHandler; +import org.openhab.binding.jeelink.internal.JeeLinkSensorHandler; +import org.openhab.binding.jeelink.internal.ReadingPublisher; +import org.openhab.core.library.types.OnOffType; +import org.openhab.core.library.types.QuantityType; +import org.openhab.core.library.unit.Units; +import org.openhab.core.thing.ChannelUID; +import org.openhab.core.thing.Thing; +import org.openhab.core.types.Command; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Handler for an EMT7110 sensor thing. + * + * @author Timo Schober - Initial contribution + */ +public class Emt7110SensorHandler extends JeeLinkSensorHandler { + private final Logger logger = LoggerFactory.getLogger(Emt7110SensorHandler.class); + private OnOffType state; + private JeeLinkHandler bridge; + private final AtomicInteger channel = new AtomicInteger(-1); + + private ScheduledFuture retry; + + public Emt7110SensorHandler(Thing thing, String sensorType) { + super(thing, sensorType); + } + + @Override + public Class getReadingClass() { + return Emt7110Reading.class; + } + + @Override + public void initialize() { + super.initialize(); + + bridge = (JeeLinkHandler) getBridge().getHandler(); + + logger.debug("initilized handler for thing {} ({})}", getThing().getLabel(), getThing().getUID().getId()); + } + + @Override + public void dispose() { + super.dispose(); + cancelRetry(); + } + + @Override + public synchronized void handleCommand(ChannelUID channelUid, Command command) { + logger.debug("received command for thing {} ({}): {}", getThing().getLabel(), getThing().getUID().getId(), + command); + } + + @Override + public ReadingPublisher createPublisher() { + return new ReadingPublisher<>() { + @Override + public void publish(Emt7110Reading reading) { + if (reading != null) { + updateState(CURRENT_POWER_CHANNEL, new QuantityType<>(reading.getPower(), Units.WATT)); + updateState(CONSUMPTION_CHANNEL, new QuantityType<>(reading.getaPower(), Units.KILOWATT_HOUR)); + updateState(ELECTRIC_POTENTIAL_CHANNEL, new QuantityType<>(reading.getVoltage(), Units.VOLT)); + updateState(ELECTRIC_CURRENT_CHANNEL, + new QuantityType<>(reading.getCurrent() / 1000, Units.AMPERE)); + } + } + + @Override + public void dispose() { + } + }; + } + + private synchronized void cancelRetry() { + if (retry != null) { + retry.cancel(true); + retry = null; + } + } +} diff --git a/bundles/org.openhab.binding.jeelink/src/main/resources/OH-INF/i18n/jeelink.properties b/bundles/org.openhab.binding.jeelink/src/main/resources/OH-INF/i18n/jeelink.properties index 17199247b43ec..73a2d36ad132f 100644 --- a/bundles/org.openhab.binding.jeelink/src/main/resources/OH-INF/i18n/jeelink.properties +++ b/bundles/org.openhab.binding.jeelink/src/main/resources/OH-INF/i18n/jeelink.properties @@ -19,6 +19,9 @@ thing-type.ec3k.label = ec3k thing-type.ec3k.description = Thing for an EnergyCount 3000 Power Monitor connected to a JeeLink USB Receiver. thing-type.pca301.label = PCA301 thing-type.pca301.description = Thing for a PCA301 power monitoring wireless socket connected to a JeeLink USB Receiver. +thing-type.emt7110.label = EMT7110 +thing-type.emt7110.description = Thing for a EMT7110 power monitoring wireless socket connected to a JeeLink USB Receiver. + thing-type.tx22.label = TX22 Sensor thing-type.tx22.description = Thing for a TX22 Sensor connected to a JeeLink USB Receiver. thing-type.revolt.label = Revolt Power Monitor diff --git a/bundles/org.openhab.binding.jeelink/src/main/resources/OH-INF/i18n/jeelink_de.properties b/bundles/org.openhab.binding.jeelink/src/main/resources/OH-INF/i18n/jeelink_de.properties index 092ae377f2406..318c002814b9c 100644 --- a/bundles/org.openhab.binding.jeelink/src/main/resources/OH-INF/i18n/jeelink_de.properties +++ b/bundles/org.openhab.binding.jeelink/src/main/resources/OH-INF/i18n/jeelink_de.properties @@ -19,6 +19,8 @@ thing-type.ec3k.label = ec3k thing-type.ec3k.description = Ein mit dem JeeLink USB Empfänger verbundenes EC3000 Energiekosten-Messgerät. thing-type.pca301.label = PCA301 thing-type.pca301.description = Eine mit dem JeeLink USB Empfänger verbundene PCA301 Steckdose. +thing-type.emt7110.label = EMT7110 +thing-type.emt7110.description = Eine mit dem JeeLink USB Empfänger verbundene EMT7110 Steckdose. thing-type.tx22.label = TX22 Sensor thing-type.tx22.description = Ein mit dem JeeLink USB Empfänger verbundener TX22 Sensor. thing-type.revolt.label = Revolt Energie-Messgerät diff --git a/bundles/org.openhab.binding.jeelink/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.jeelink/src/main/resources/OH-INF/thing/thing-types.xml index 1539455ccdbc1..fd965a467543d 100644 --- a/bundles/org.openhab.binding.jeelink/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.jeelink/src/main/resources/OH-INF/thing/thing-types.xml @@ -291,6 +291,38 @@ + + + + + + + + + + + @text/thing-type.emt7110.description + + + + + + + + + + + + @text/parameter.sensorid.description + + + + @text/parameter.sensortimeout.description + 600 + + + + @@ -534,4 +566,11 @@ @text/channel-type.power-frequency.description + + + Number:ElectricPotential + + Voltage + + From 83e07a00a152cbd2bb26f5e39a58c319c7eab448 Mon Sep 17 00:00:00 2001 From: tischober Date: Tue, 7 May 2024 22:39:31 +0200 Subject: [PATCH 2/6] fix: changes 4 code-review Signed-off-by: tischober --- .../emt7110/Emt7110ReadingConverter.java | 18 ------------------ .../internal/emt7110/Emt7110SensorHandler.java | 1 + .../OH-INF/i18n/jeelink_de.properties | 2 -- .../resources/OH-INF/thing/thing-types.xml | 7 ------- 4 files changed, 1 insertion(+), 27 deletions(-) diff --git a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110ReadingConverter.java b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110ReadingConverter.java index 9c22671d42455..d934bf24c0396 100644 --- a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110ReadingConverter.java +++ b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110ReadingConverter.java @@ -36,24 +36,6 @@ public Emt7110Reading createReading(String inputLine) { if (inputLine != null) { Matcher matcher = READING_P.matcher(inputLine); if (matcher.matches()) { - // Format - // OK EMT7110 84 81 8 237 0 13 0 2 1 6 1 -> ID 5451 228,5V 13mA 2W 2,62kWh - // OK EMT7110 84 162 8 207 0 76 0 7 0 0 1 - // OK EMT7110 ID ID VV VV AA AA WW WW KW KW Flags - // | | | | | | | | | | | - // | | | | | | | | | | `--- AccumulatedPower * 100 LSB - // | | | | | | | | | `------ AccumulatedPower * 100 MSB - // | | | | | | | | `--- Power (W) LSB - // | | | | | | | `------ Power (W) MSB - // | | | | | | `--- Current (mA) LSB - // | | | | | `------ Current (mA) MSB - // | | | | `--- Voltage (V) * 10 LSB - // | | | `----- Voltage (V) * 10 MSB - // | | `--- ID - // | `------- ID - // `--- fix "EMT7110" - // logger.trace("Creating reading from: {}", inputLine); - String id = matcher.group(1) + matcher.group(2); float voltage = (Integer.parseInt(matcher.group(3)) * 256 + Integer.parseInt(matcher.group(4))) / 10f; float current = (Integer.parseInt(matcher.group(5)) * 256 + Integer.parseInt(matcher.group(6))); diff --git a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110SensorHandler.java b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110SensorHandler.java index 92bc95282793a..35e8c2615624b 100644 --- a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110SensorHandler.java +++ b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110SensorHandler.java @@ -93,6 +93,7 @@ public void dispose() { } private synchronized void cancelRetry() { + ScheduledFuture retry = this.retry; if (retry != null) { retry.cancel(true); retry = null; diff --git a/bundles/org.openhab.binding.jeelink/src/main/resources/OH-INF/i18n/jeelink_de.properties b/bundles/org.openhab.binding.jeelink/src/main/resources/OH-INF/i18n/jeelink_de.properties index 318c002814b9c..092ae377f2406 100644 --- a/bundles/org.openhab.binding.jeelink/src/main/resources/OH-INF/i18n/jeelink_de.properties +++ b/bundles/org.openhab.binding.jeelink/src/main/resources/OH-INF/i18n/jeelink_de.properties @@ -19,8 +19,6 @@ thing-type.ec3k.label = ec3k thing-type.ec3k.description = Ein mit dem JeeLink USB Empfänger verbundenes EC3000 Energiekosten-Messgerät. thing-type.pca301.label = PCA301 thing-type.pca301.description = Eine mit dem JeeLink USB Empfänger verbundene PCA301 Steckdose. -thing-type.emt7110.label = EMT7110 -thing-type.emt7110.description = Eine mit dem JeeLink USB Empfänger verbundene EMT7110 Steckdose. thing-type.tx22.label = TX22 Sensor thing-type.tx22.description = Ein mit dem JeeLink USB Empfänger verbundener TX22 Sensor. thing-type.revolt.label = Revolt Energie-Messgerät diff --git a/bundles/org.openhab.binding.jeelink/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.jeelink/src/main/resources/OH-INF/thing/thing-types.xml index fd965a467543d..494c15a909f84 100644 --- a/bundles/org.openhab.binding.jeelink/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.jeelink/src/main/resources/OH-INF/thing/thing-types.xml @@ -566,11 +566,4 @@ @text/channel-type.power-frequency.description - - - Number:ElectricPotential - - Voltage - - From 2fd523cc58516b9e06a44ff336b79e6a0fac10fe Mon Sep 17 00:00:00 2001 From: tischober Date: Tue, 7 May 2024 23:39:40 +0200 Subject: [PATCH 3/6] fix: changes 4 code-review Signed-off-by: tischober --- .../jeelink/internal/emt7110/Emt7110ReadingConverter.java | 6 ------ .../jeelink/internal/emt7110/Emt7110SensorHandler.java | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110ReadingConverter.java b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110ReadingConverter.java index d934bf24c0396..c64ebf45a2326 100644 --- a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110ReadingConverter.java +++ b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110ReadingConverter.java @@ -48,10 +48,4 @@ public Emt7110Reading createReading(String inputLine) { return null; } - /* - * public static void main(String[] args){ - * Emt7110ReadingConverter emt = new Emt7110ReadingConverter(); - * emt.createReading("OK EMT7110 84 81 9 91 0 72 0 2 1 6 1"); - * } - */ } diff --git a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110SensorHandler.java b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110SensorHandler.java index 35e8c2615624b..e86a84b984932 100644 --- a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110SensorHandler.java +++ b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110SensorHandler.java @@ -92,7 +92,7 @@ public void dispose() { }; } - private synchronized void cancelRetry() { + private void cancelRetry() { ScheduledFuture retry = this.retry; if (retry != null) { retry.cancel(true); From 0cd85457a42073e768c639676f373b9cdefa1468 Mon Sep 17 00:00:00 2001 From: tischober Date: Wed, 8 May 2024 00:28:14 +0200 Subject: [PATCH 4/6] fix: changes 4 code-review Signed-off-by: tischober --- .../emt7110/Emt7110ReadingConverter.java | 7 ------ .../emt7110/Emt7110SensorHandler.java | 24 ------------------- 2 files changed, 31 deletions(-) diff --git a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110ReadingConverter.java b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110ReadingConverter.java index c64ebf45a2326..21ead8610e66a 100644 --- a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110ReadingConverter.java +++ b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110ReadingConverter.java @@ -1,13 +1,10 @@ /** * Copyright (c) 2010-2024 Contributors to the openHAB project - * * See the NOTICE file(s) distributed with this work for additional * information. - * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 - * * SPDX-License-Identifier: EPL-2.0 */ package org.openhab.binding.jeelink.internal.emt7110; @@ -16,8 +13,6 @@ import java.util.regex.Pattern; import org.openhab.binding.jeelink.internal.JeeLinkReadingConverter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Handler for a EMT7110 energy Sensor thing. @@ -28,8 +23,6 @@ public class Emt7110ReadingConverter implements JeeLinkReadingConverter { private final Logger logger = LoggerFactory.getLogger(Emt7110SensorHandler.class); - private OnOffType state; - private JeeLinkHandler bridge; - private final AtomicInteger channel = new AtomicInteger(-1); - - private ScheduledFuture retry; public Emt7110SensorHandler(Thing thing, String sensorType) { super(thing, sensorType); @@ -55,15 +42,12 @@ public Class getReadingClass() { public void initialize() { super.initialize(); - bridge = (JeeLinkHandler) getBridge().getHandler(); - logger.debug("initilized handler for thing {} ({})}", getThing().getLabel(), getThing().getUID().getId()); } @Override public void dispose() { super.dispose(); - cancelRetry(); } @Override @@ -91,12 +75,4 @@ public void dispose() { } }; } - - private void cancelRetry() { - ScheduledFuture retry = this.retry; - if (retry != null) { - retry.cancel(true); - retry = null; - } - } } From 32fbe1511557656c4e80e835872738116e07b721 Mon Sep 17 00:00:00 2001 From: tischober Date: Wed, 8 May 2024 17:01:48 +0200 Subject: [PATCH 5/6] fix: revert Copyright Signed-off-by: tischober --- .../jeelink/internal/emt7110/Emt7110ReadingConverter.java | 3 +++ .../binding/jeelink/internal/emt7110/Emt7110SensorHandler.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110ReadingConverter.java b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110ReadingConverter.java index 21ead8610e66a..057bea6f3b2a3 100644 --- a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110ReadingConverter.java +++ b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110ReadingConverter.java @@ -1,10 +1,13 @@ /** * Copyright (c) 2010-2024 Contributors to the openHAB project + * * See the NOTICE file(s) distributed with this work for additional * information. + * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 + * * SPDX-License-Identifier: EPL-2.0 */ package org.openhab.binding.jeelink.internal.emt7110; diff --git a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110SensorHandler.java b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110SensorHandler.java index 443b1994d2568..f1ea565076ac6 100644 --- a/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110SensorHandler.java +++ b/bundles/org.openhab.binding.jeelink/src/main/java/org/openhab/binding/jeelink/internal/emt7110/Emt7110SensorHandler.java @@ -1,10 +1,13 @@ /** * Copyright (c) 2010-2024 Contributors to the openHAB project + * * See the NOTICE file(s) distributed with this work for additional * information. + * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 + * * SPDX-License-Identifier: EPL-2.0 */ package org.openhab.binding.jeelink.internal.emt7110; From c941b084f156274b7991a5550b4723b9e8144a20 Mon Sep 17 00:00:00 2001 From: tischober Date: Wed, 8 May 2024 17:25:59 +0200 Subject: [PATCH 6/6] fix: add to readme Signed-off-by: tischober --- bundles/org.openhab.binding.jeelink/README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bundles/org.openhab.binding.jeelink/README.md b/bundles/org.openhab.binding.jeelink/README.md index ab58d4684cffd..ba5cb17ed7166 100644 --- a/bundles/org.openhab.binding.jeelink/README.md +++ b/bundles/org.openhab.binding.jeelink/README.md @@ -92,6 +92,14 @@ The available init commands depend on the sketch that is running on the USB stic | Sensor ID | Number | The ID of the connected sensor | | Sensor Timeout | Number | The amount of time in seconds that should result in OFFLINE status when no readings have been received from the sensor | +### EMT7110 energy meter + +| Parameter | Item Type | Description | +|-------------------|--------------|------------------------------------------------------------------------------------------------------------------------| +| Sensor ID | Number | The ID of the connected sensor | +| Sensor Timeout | Number | The amount of time in seconds that should result in OFFLINE status when no readings have been received from the sensor | + + ## Channels ### LaCrosse temperature sensors @@ -145,6 +153,16 @@ The available init commands depend on the sketch that is running on the USB stic | electricPotential | Number:ElectricPotential | The measured Electric Potential | | powerFrequency | Number:Frequency | The measured AC power frequency | +### EMT7110 energy meter + +| Channel Type ID | Item Type | Description | +|-------------------|--------------------------|---------------------------------------| +| currentPower | Number:Power | Current power draw | +| consumptionTotal | Number:Energy | Total energy consumption in kWh | +| electricCurrent | Number:ElectricCurrent | The measured Electric Current | +| electricPotential | Number:ElectricPotential | The measured Electric Potential in mA | + + ## Commands ### PCA301 power monitoring wireless sockets