Skip to content

Commit

Permalink
[insteon] use correct units of measure for watts and kWh (openhab#7565)
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Nielsen <rob.nielsen@yahoo.com>
  • Loading branch information
robnielsen authored and andrewfg committed Aug 31, 2020
1 parent f033ff2 commit acd7c29
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
12 changes: 6 additions & 6 deletions bundles/org.openhab.binding.insteon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ In order to determine which channels a device supports, you can look at the devi
| keypadButtonF | Switch | Keypad Button F |
| keypadButtonG | Switch | Keypad Button G |
| keypadButtonH | Switch | Keypad Button H |
| kWh | Number | Kilowatt Hour |
| kWh | Number:Energy | Kilowatt Hour |
| lastHeardFrom | DateTime | Last Heard From |
| ledBrightness | Number | LED brightness |
| ledOnOff | Switch | LED On/Off |
Expand Down Expand Up @@ -183,7 +183,7 @@ In order to determine which channels a device supports, you can look at the devi
| temperature | Number:Temperature | Temperature |
| topOutlet | Switch | Top Outlet |
| update | Switch | Update |
| watts | Number | Watts |
| watts | Number:Power | Watts |


## Full Example
Expand Down Expand Up @@ -648,10 +648,10 @@ See the example below:
**Items**

```
Number iMeterWatts "iMeter [%d watts]" { channel="insteon:device:home:AABBCC:watts" }
Number iMeterKwh "iMeter [%.04f kwh]" { channel="insteon:device:home:AABBCC:kwh" }
Switch iMeterUpdate "iMeter Update" { channel="insteon:device:home:AABBCC:update" }
Switch iMeterReset "iMeter Reset" { channel="insteon:device:home:AABBCC:reset" }
Number:Power iMeterWatts "iMeter [%d watts]" { channel="insteon:device:home:AABBCC:watts" }
Number:Energy iMeterKwh "iMeter [%.04f kWh]" { channel="insteon:device:home:AABBCC:kWh" }
Switch iMeterUpdate "iMeter Update" { channel="insteon:device:home:AABBCC:update" }
Switch iMeterReset "iMeter Reset" { channel="insteon:device:home:AABBCC:reset" }
```

### Fan Controllers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.eclipse.smarthome.core.library.types.QuantityType;
import org.eclipse.smarthome.core.library.unit.ImperialUnits;
import org.eclipse.smarthome.core.library.unit.SIUnits;
import org.eclipse.smarthome.core.library.unit.SmartHomeUnits;
import org.eclipse.smarthome.core.types.State;
import org.openhab.binding.insteon.internal.device.DeviceFeatureListener.StateChangeType;
import org.openhab.binding.insteon.internal.device.GroupMessageStateMachine.GroupMessage;
Expand Down Expand Up @@ -820,8 +821,10 @@ public void handleMessage(int group, byte cmd1, Msg msg, DeviceFeature f, String
}

logger.debug("{}:{} watts: {} kwh: {} ", nm(), f.getDevice().getAddress(), watts, kwh);
feature.publish(new DecimalType(kwh), StateChangeType.CHANGED, "field", "kwh");
feature.publish(new DecimalType(watts), StateChangeType.CHANGED, "field", "watts");
feature.publish(new QuantityType<>(kwh, SmartHomeUnits.KILOWATT_HOUR), StateChangeType.CHANGED,
"field", "kwh");
feature.publish(new QuantityType<>(watts, SmartHomeUnits.WATT), StateChangeType.CHANGED, "field",
"watts");
} catch (FieldException e) {
logger.warn("error parsing {}: ", msg, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
</channel-type>

<channel-type id="kWh">
<item-type>Number</item-type>
<item-type>Number:Energy</item-type>
<label>Kilowatt Hour</label>
</channel-type>

Expand Down Expand Up @@ -481,7 +481,7 @@
</channel-type>

<channel-type id="watts">
<item-type>Number</item-type>
<item-type>Number:Power</item-type>
<label>Watts</label>
</channel-type>

Expand Down

0 comments on commit acd7c29

Please sign in to comment.