Skip to content

Commit

Permalink
[miio] Fix issue battery channel (openhab#4752)
Browse files Browse the repository at this point in the history
* Fix issue battery channel

- Fix error for devices with battery channel
- Add chungmi plug m3
- minor edits

Signed-off-by: Marcel Verpaalen <[email protected]>
  • Loading branch information
marcelrv authored and cweitkamp committed Jan 30, 2019
1 parent 8f80805 commit b1c45ae
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"deviceMapping": {
"id": [
"chuangmi.plug.m1",
"chuangmi.plug.m3",
"chuangmi.plug.hmi205"
],
"channels": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"property": "battery",
"friendlyName": "Battery",
"channel": "battery",
"channelType":"system.battery-level",
"channelType":"system:battery-level",
"type": "Number",
"refresh": true,
"ChannelGroup": "Status",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
"property": "battery",
"friendlyName": "Battery",
"channel": "battery",
"channelType": "system.battery-level",
"channelType": "system:battery-level",
"type": "Number",
"refresh": true,
"ChannelGroup": "Status",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public enum MiIoDevices {
POWERPLUG1("chuangmi.plug.v1", "Mi Power-plug v1", THING_TYPE_BASIC),
POWERPLUG2("chuangmi.plug.v2", "Mi Power-plug v2", THING_TYPE_BASIC),
POWERPLUG3("chuangmi.plug.v3", "Mi Power-plug v3", THING_TYPE_BASIC),
POWERPLUGM3("chuangmi.plug.m3", "Mi Power-plug", THING_TYPE_BASIC),
POWERPLUG_HMI205("chuangmi.plug.hmi205", "Mi Smart Plug", THING_TYPE_BASIC),
POWERSTRIP("qmi.powerstrip.v1", "Qing Mi Smart Power Strip v1", THING_TYPE_BASIC),
POWERSTRIP2("zimi.powerstrip.v2", "Mi Power-strip v2", THING_TYPE_BASIC),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package org.openhab.binding.miio.internal.basic;

import static org.openhab.binding.miio.internal.MiIoBindingConstants.BINDING_ID;

import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -78,7 +80,8 @@ public void setChannel(String channel) {
}

public String getChannelType() {
return channelType == null || channelType.isEmpty() ? channel : channelType;
return channelType == null || channelType.isEmpty() ? BINDING_ID + ":" + channel
: (channelType.startsWith("system") ? channelType : BINDING_ID + ":" + channelType);
}

public void setChannelType(String channelType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ private boolean addChannel(ThingBuilder thingBuilder, String channel, String cha
return false;
}
ChannelUID channelUID = new ChannelUID(getThing().getUID(), channel);
ChannelTypeUID channelTypeUID = new ChannelTypeUID(MiIoBindingConstants.BINDING_ID, channelType);
ChannelTypeUID channelTypeUID = new ChannelTypeUID(channelType);

// TODO: Need to understand if this harms anything. If yes, channel only to be added when not there already.
// current way allows to have no issues when channels are changing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public enum StatusType {
SHUTTING_DOWN(13, "Shutting Down"),
UPDATING(14, "Updating"),
DOCKING(15, "Docking"),
GOTO(16, "Go To"),
ZONE(17, "Zone Clean"),
FULL(100, "Full");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class MiIoAsyncCommunication {
private int timeout;
private boolean needPing = true;
private static final int MAX_ERRORS = 3;
private static final int MAX_ID = 1000;
private static final int MAX_ID = 15000;

private ConcurrentLinkedQueue<MiIoSendCommand> concurrentLinkedQueue = new ConcurrentLinkedQueue<MiIoSendCommand>();

Expand Down

0 comments on commit b1c45ae

Please sign in to comment.