diff --git a/bundles/org.openhab.binding.mystrom/README.md b/bundles/org.openhab.binding.mystrom/README.md index 7a42372fe..8c8035910 100644 --- a/bundles/org.openhab.binding.mystrom/README.md +++ b/bundles/org.openhab.binding.mystrom/README.md @@ -50,18 +50,19 @@ Disabling/enabling the thing can be used to update the properties. ## Channels -| Channel ID | Item Type | Read only | Description | Thing types supporting this channel | -| ---------------- | -------------------- | --------- | --------------------------------------------------------------------- |-------------------------------------| -| switch | Switch | false | Turn the device on or off | mystromplug, mystrombulb | -| power | Number:Power | true | The currently delivered power | mystromplug, mystrombulb | -| temperature | Number:Temperature | true | The temperature at the plug | mystromplug, mystrompir | -| color | Color | false | The color we set the bulb to (mode 'hsv') | mystrombulb | -| colorTemperature | Dimmer | false | The color temperature of the bulb in mode 'mono' (percentage) | mystrombulb | -| brightness | Dimmer | false | The brightness of the bulb in mode 'mono' | mystrombulb | -| ramp | Number:Time | false | Transition time from the light’s current state to the new state. [ms] | mystrombulb | -| mode | String | false | The color mode we want the Bulb to set to (rgb, hsv or mono) | mystrombulb | -| light | Dimmer | true | The brightness of the Room. | mystrompir | -| motion | Switch | true | Motionstatus of the sensor | mystrompir | +| Channel ID | Item Type | Read only | Description | Thing types supporting this channel | +|---------------------------------|--------------------|-----------|---------------------------------------------------------------------------------------------------|------------------------------------| +| switch | Switch | false | Turn the device on or off | mystromplug, mystrombulb | +| power | Number:Power | true | The currently delivered power | mystromplug, mystrombulb | +| energy-consumed-since-last-call | Number:Energy | true | The watt seconds / Energy consumed since last call. Useful for accurate data logging and analysis | mystromplug | +| temperature | Number:Temperature | true | The temperature at the plug | mystromplug, mystrompir | +| color | Color | false | The color we set the bulb to (mode 'hsv') | mystrombulb | +| colorTemperature | Dimmer | false | The color temperature of the bulb in mode 'mono' (percentage) | mystrombulb | +| brightness | Dimmer | false | The brightness of the bulb in mode 'mono' | mystrombulb | +| ramp | Number:Time | false | Transition time from the light’s current state to the new state. [ms] | mystrombulb | +| mode | String | false | The color mode we want the Bulb to set to (rgb, hsv or mono) | mystrombulb | +| light | Dimmer | true | The brightness of the Room. | mystrompir | +| motion | Switch | true | Motionstatus of the sensor | mystrompir | ## Full Example @@ -74,12 +75,13 @@ Thing mystrom:mystromplug:d6217a31 "Plug" [hostname="hostname|ip"] ### Item Configuration ```java -Switch PlugSwitch "Plug" {channel="mystrom:mystromplug:d6217a31:switch"} -Number:Temperature PlugTemperature "Temperature: [%.1f °C]" {channel="mystrom:mystromplug:d6217a31:temperature"} -Number:Power PlugPower "Power: [%.1f W]" {channel="mystrom:mystromplug:d6217a31:power"} - +Switch PlugSwitch "Plug" {channel="mystrom:mystromplug:d6217a31:switch"} +Number:Temperature PlugTemperature "Temperature: [%.1f °C]" {channel="mystrom:mystromplug:d6217a31:temperature"} +Number:Power PlugPower "Power: [%.1f W]" {channel="mystrom:mystromplug:d6217a31:power"} +Number:Energy PlugEnergyConsumedSinceLastCall "Ws: [%.1f Ws]" {channel="mystrom:mystromplug:d6217a31:energy-consumed-since-last-call"} ``` + ### Sitemap Configuration ```perl diff --git a/bundles/org.openhab.binding.mystrom/src/main/java/org/openhab/binding/mystrom/internal/MyStromBindingConstants.java b/bundles/org.openhab.binding.mystrom/src/main/java/org/openhab/binding/mystrom/internal/MyStromBindingConstants.java index 182ae7e69..5248a1ae9 100644 --- a/bundles/org.openhab.binding.mystrom/src/main/java/org/openhab/binding/mystrom/internal/MyStromBindingConstants.java +++ b/bundles/org.openhab.binding.mystrom/src/main/java/org/openhab/binding/mystrom/internal/MyStromBindingConstants.java @@ -38,6 +38,7 @@ public class MyStromBindingConstants { // List of all Channel ids public static final String CHANNEL_SWITCH = "switch"; public static final String CHANNEL_POWER = "power"; + public static final String CHANNEL_ENERGY_CONSUMED_SINCE_LAST_CALL = "energy-consumed-since-last-call"; public static final String CHANNEL_TEMPERATURE = "temperature"; public static final String CHANNEL_COLOR = "color"; public static final String CHANNEL_RAMP = "ramp"; diff --git a/bundles/org.openhab.binding.mystrom/src/main/java/org/openhab/binding/mystrom/internal/MyStromPlugHandler.java b/bundles/org.openhab.binding.mystrom/src/main/java/org/openhab/binding/mystrom/internal/MyStromPlugHandler.java index f7bb0243a..0d2a64e15 100644 --- a/bundles/org.openhab.binding.mystrom/src/main/java/org/openhab/binding/mystrom/internal/MyStromPlugHandler.java +++ b/bundles/org.openhab.binding.mystrom/src/main/java/org/openhab/binding/mystrom/internal/MyStromPlugHandler.java @@ -12,11 +12,13 @@ */ package org.openhab.binding.mystrom.internal; +import static org.openhab.binding.mystrom.internal.MyStromBindingConstants.CHANNEL_ENERGY_CONSUMED_SINCE_LAST_CALL; import static org.openhab.binding.mystrom.internal.MyStromBindingConstants.CHANNEL_POWER; import static org.openhab.binding.mystrom.internal.MyStromBindingConstants.CHANNEL_SWITCH; import static org.openhab.binding.mystrom.internal.MyStromBindingConstants.CHANNEL_TEMPERATURE; import static org.openhab.core.library.unit.SIUnits.CELSIUS; import static org.openhab.core.library.unit.Units.WATT; +import static org.openhab.core.library.unit.Units.WATT_SECOND; import java.time.Duration; import java.util.concurrent.TimeUnit; @@ -50,6 +52,7 @@ public class MyStromPlugHandler extends AbstractMyStromHandler { private static class MyStromReport { public float power; + public float Ws; public boolean relay; public float temperature; } @@ -96,6 +99,7 @@ public class MyStromPlugHandler extends AbstractMyStromHandler { if (report != null) { updateState(CHANNEL_SWITCH, report.relay ? OnOffType.ON : OnOffType.OFF); updateState(CHANNEL_POWER, QuantityType.valueOf(report.power, WATT)); + updateState(CHANNEL_ENERGY_CONSUMED_SINCE_LAST_CALL, QuantityType.valueOf(report.Ws, WATT_SECOND)); updateState(CHANNEL_TEMPERATURE, QuantityType.valueOf(report.temperature, CELSIUS)); } } diff --git a/bundles/org.openhab.binding.mystrom/src/main/resources/OH-INF/i18n/mystrom.properties b/bundles/org.openhab.binding.mystrom/src/main/resources/OH-INF/i18n/mystrom.properties index 18a914510..b426e3c1c 100644 --- a/bundles/org.openhab.binding.mystrom/src/main/resources/OH-INF/i18n/mystrom.properties +++ b/bundles/org.openhab.binding.mystrom/src/main/resources/OH-INF/i18n/mystrom.properties @@ -38,6 +38,8 @@ thing-type.config.mystrom.mystromplug.refresh.description = Specifies the refres # channel types +channel-type.mystrom.energy-consumed-since-last-call-channel.label = Energy Consumption +channel-type.mystrom.energy-consumed-since-last-call-channel.description = Energy consumed since last API call channel-type.mystrom.mode-channel.label = Mode channel-type.mystrom.mode-channel.description = The color mode we want the Bulb to set to channel-type.mystrom.mode-channel.command.option.rgb = RGB @@ -49,3 +51,4 @@ channel-type.mystrom.ramp-channel.label = Ramp channel-type.mystrom.ramp-channel.description = Transition time from the light’s current state to the new state. channel-type.mystrom.temperature-channel.label = Temperature channel-type.mystrom.temperature-channel.description = The current temperature at the plug + diff --git a/bundles/org.openhab.binding.mystrom/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.mystrom/src/main/resources/OH-INF/thing/thing-types.xml index 92998051f..301234a04 100644 --- a/bundles/org.openhab.binding.mystrom/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.mystrom/src/main/resources/OH-INF/thing/thing-types.xml @@ -11,6 +11,7 @@ + @@ -25,6 +26,7 @@ + 1 mac @@ -157,6 +159,14 @@ + + Number:Energy + + Energy consumed since last API call + + + + Number:Temperature diff --git a/bundles/org.openhab.binding.mystrom/src/main/resources/OH-INF/update/instructions.xml b/bundles/org.openhab.binding.mystrom/src/main/resources/OH-INF/update/instructions.xml new file mode 100644 index 000000000..5ccf6e5a5 --- /dev/null +++ b/bundles/org.openhab.binding.mystrom/src/main/resources/OH-INF/update/instructions.xml @@ -0,0 +1,15 @@ + + + + + + + mystrom:energy-consumed-since-last-call-channel + + + + + +