## 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
### 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
// 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";
*/
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;
private static class MyStromReport {
public float power;
+ public float Ws;
public boolean relay;
public float temperature;
}
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));
}
}
# 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
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
+
<channels>
<channel id="switch" typeId="system.power"/>
<channel id="power" typeId="power-channel"/>
+ <channel id="energy-consumed-since-last-call" typeId="energy-consumed-since-last-call-channel"/>
<channel id="temperature" typeId="temperature-channel"/>
</channels>
<property name="dns"/>
<property name="static"/>
<property name="connected"/>
+ <property name="thingTypeVersion">1</property>
</properties>
<representation-property>mac</representation-property>
<state pattern="%.3f %unit%" readOnly="true"/>
</channel-type>
+ <channel-type id="energy-consumed-since-last-call-channel">
+ <item-type>Number:Energy</item-type>
+ <label>Energy Consumption</label>
+ <description>Energy consumed since last API call</description>
+ <state pattern="%.2f %unit%" readOnly="true"/>
+ </channel-type>
+
+
<channel-type id="temperature-channel">
<item-type>Number:Temperature</item-type>
<label>Temperature</label>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<update:update-descriptions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:update="https://openhab.org/schemas/update-description/v1.0.0"
+ xsi:schemaLocation="https://openhab.org/schemas/update-description/v1.0.0 https://openhab.org/schemas/update-description-1.0.0.xsd">
+
+ <thing-type uid="mystrom:mystromplug">
+ <instruction-set targetVersion="1">
+ <add-channel id="energy-consumed-since-last-call">
+ <type>mystrom:energy-consumed-since-last-call-channel</type>
+ <label>Energy Consumption</label>
+ </add-channel>
+ </instruction-set>
+ </thing-type>
+
+</update:update-descriptions>