Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[miio] Fix issue battery channel #4752

Merged
merged 2 commits into from
Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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