Skip to content

Commit

Permalink
Added support for Yeelight LED Ceiling Lamp v4 (JIAOYUE 650 RGB) (#7)
Browse files Browse the repository at this point in the history
* Added item "Yeelight LED Ceiling Lamp v4 (JIAOYUE 650 RGB)"

- added new device yeelink.light.ceiling4 ("Yeelight LED Ceiling Lamp v4
(JIAOYUE 650 RGB)")
- fixed checkstyle errors (mainly 2017 > 2018 in copyright message) and
some warnings about string placeholders in debug messages

Signed-off-by: AnthraxLeprosyPi <anthrax.leprosy.pi@gmail.com>

* Added support for Yeelight LED Ceiling Lamp v4 (JIAOYUE 650 RGB)

- Added compatibility for Yeelight LED Ceiling Lamp v4 (JIAOYUE 650 RGB)
- Added new channels ambientColor and ambientColorTemperature

Signed-off-by: AnthraxLeprosyPi <anthrax.leprosy.pi@gmail.com>
  • Loading branch information
AnthraxLeprosyPi authored and marcelrv committed May 27, 2018
1 parent 2f4d8c3 commit 019d15f
Show file tree
Hide file tree
Showing 31 changed files with 177 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
<item-type>String</item-type>
<label>Execute Command</label>
</channel-type>

<channel-type id="power">
<item-type>Switch</item-type>
<label>Power On/Off</label>
Expand Down Expand Up @@ -75,6 +74,10 @@
<item-type>Number</item-type>
<label>Color Temperature</label>
</channel-type>
<channel-type id="ambientColorTemperature">
<item-type>Number</item-type>
<label>Ambient Color Temperature</label>
</channel-type>
<channel-type id="cct">
<item-type>Number</item-type>
<label>Correlated Color Temperature</label>
Expand All @@ -87,7 +90,6 @@
<item-type>Number</item-type>
<label>DV</label>
</channel-type>

<channel-type id="delayoff">
<item-type>Number</item-type>
<label>Delay off</label>
Expand All @@ -108,6 +110,10 @@
<item-type>Color</item-type>
<label>Color</label>
</channel-type>
<channel-type id="ambientColor">
<item-type>Color</item-type>
<label>Ambient Color</label>
</channel-type>

<!-- Common Properties channels -->
<channel-type id="temperature">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"deviceMapping": {
"id": [
"yeelink.light.ceiling4"
],
"channels": [
{
"property": "power",
"friendlyName": "Power",
"channel": "power",
"type": "Switch",
"refresh": true,
"ChannelGroup": "",
"actions": [
{
"command": "set_power",
"parameterType": "ONOFF"
}
]
},
{
"property": "bright",
"friendlyName": "Brightness",
"channel": "brightness",
"type": "Number",
"refresh": true,
"ChannelGroup": "actions",
"actions": [
{
"command": "set_bright",
"parameterType": "NUMBER"
}
]
},
{
"property": "delayoff",
"friendlyName": "delayoff",
"channel": "delayoff",
"type": "Number",
"refresh": true,
"ChannelGroup": "actions",
"actions": [
{
"command": "set_ct",
"parameterType": "NUMBER"
}
]
},
{
"property": "ct",
"friendlyName": "Color Temperature ",
"channel": "colorTemperature",
"type": "Number",
"refresh": true,
"ChannelGroup": "actions",
"actions": [
{
"command": "set_ct_abx",
"parameterType": "NUMBER"
}
]
},
{
"property": "color_mode",
"friendlyName": "colorMode",
"channel": "colorMode",
"type": "Number",
"refresh": true,
"ChannelGroup": "actions",
"actions": [
{
"command": "set_scene",
"parameterType": "NUMBER"
}
]
},
{
"property": "name",
"friendlyName": "Name",
"channel": "name",
"type": "String",
"refresh": true,
"ChannelGroup": "actions",
"actions": [
{
"command": "set_name",
"parameterType": "STRING"
}
]
},
{
"property": "bg_rgb",
"friendlyName": "Ambient Color",
"channel": "ambientColor",
"type": "Color",
"refresh": true,
"ChannelGroup": "actions",
"actions": [
{
"command": "bg_set_rgb",
"parameterType": "COLOR"
}
]
},
{
"property": "bg_ct",
"friendlyName": "Ambient Color Temperature ",
"channel": "ambientColorTemperature",
"type": "Number",
"refresh": true,
"ChannelGroup": "actions",
"actions": [
{
"command": "bg_set_ct_abx",
"parameterType": "NUMBER"
}
]
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -124,7 +124,7 @@ private boolean tolkenCheckPass(String tokenSting) {
.hexStringToByteArray(MiIoCrypto.decryptTolken(Utils.hexStringToByteArray(tokenSting)));
logger.debug("IOS token decrypted to {}", Utils.getHex(token));
} catch (MiIoCryptoException e) {
logger.warn("Could not decrypt token {}", tokenSting, e.getMessage());
logger.warn("Could not decrypt token {}{}", tokenSting, e.getMessage());
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -10,6 +10,7 @@

import static org.openhab.binding.miio.MiIoBindingConstants.CHANNEL_COMMAND;

import java.awt.Color;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
Expand Down Expand Up @@ -126,10 +127,13 @@ public void handleCommand(ChannelUID channelUID, Command command) {
}
} else if (command instanceof StringType) {
cmd = cmd + "[\"" + command.toString() + "\"]";
} else if (command instanceof HSBType) {
HSBType hsb = (HSBType) command;
Color color = Color.getHSBColor(hsb.getHue().floatValue() / 360,
hsb.getSaturation().floatValue() / 100, hsb.getBrightness().floatValue() / 100);
cmd = cmd + "[" + ((color.getRed() * 65536) + (color.getGreen() * 256) + color.getBlue()) + "]";
} else if (command instanceof DecimalType) {
cmd = cmd + "[" + command.toString().toLowerCase() + "]";
} else if (command instanceof HSBType) {
cmd = cmd + "[" + ((HSBType) command).getRGB() + "]";
}
logger.debug("Sending command {}", cmd);
sendCommand(cmd);
Expand Down Expand Up @@ -236,7 +240,7 @@ private URL findDatabaseEntry(String deviceName) {
Bundle bundle = FrameworkUtil.getBundle(getClass());
fn = bundle.getEntry(MiIoBindingConstants.DATABASE_PATH + deviceName + ".json");
if (fn != null) {
logger.trace("bundle: {}, {}, {}", bundle, fn.getFile());
logger.trace("bundle: {}, {}", bundle, fn.getFile());
return fn;
}
for (URL db : Collections.list(bundle.findEntries(MiIoBindingConstants.DATABASE_PATH, "*.json", false))) {
Expand Down Expand Up @@ -314,7 +318,8 @@ private boolean buildChannelStructure(String deviceName) {
private boolean addChannel(ThingBuilder thingBuilder, String channel, String channelType, String datatype,
String friendlyName) {
if (channel == null || channel.isEmpty() || datatype == null || datatype.isEmpty()) {
logger.info("Channel '{}' cannot be added incorrectly configured database. ", channel, getThing().getUID());
logger.info("Channel '{}', UID '{}' cannot be added incorrectly configured database. ", channel,
getThing().getUID());
return false;
}
ChannelUID channelUID = new ChannelUID(getThing().getUID(), channel);
Expand Down Expand Up @@ -376,10 +381,9 @@ void updateProperties(MiIoSendCommand response) {
val.getAsString().toLowerCase().equals("on") ? OnOffType.ON : OnOffType.OFF);
}
if (basicChannel.getType().equals("Color")) {
// TODO: very experimental
HSBType color = HSBType.fromRGB((val.getAsInt() >> 16) & 0xFF, (val.getAsInt() >> 8) & 0xFF,
val.getAsInt() & 0xFF);
updateState(basicChannel.getChannel(), color);
Color rgb = new Color(val.getAsInt());
HSBType hsb = HSBType.fromRGB(rgb.getRed(), rgb.getGreen(), rgb.getBlue());
updateState(basicChannel.getChannel(), hsb);
}
} catch (Exception e) {
logger.debug("Error updating propery {} with '{}' : {}", basicChannel.getChannel(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -267,7 +267,7 @@ protected boolean skipUpdate() {
return true;
}
if (ThingStatusDetail.CONFIGURATION_ERROR.equals(getThing().getStatusInfo().getStatusDetail())) {
logger.debug("Skipping periodic update for '{}'. Thing Status", getThing().getUID().toString(),
logger.debug("Skipping periodic update for '{}' UID '{}'. Thing Status", getThing().getUID().toString(),
getThing().getStatusInfo().getStatusDetail());
refreshNetwork();
return true;
Expand All @@ -293,7 +293,7 @@ protected synchronized void updateData() {
refreshNetwork();
consumables.getValue();
} catch (Exception e) {
logger.debug("Error while updating '{}': ", getThing().getUID().toString(), e.getLocalizedMessage(), e);
logger.debug("Error while updating '{}': '{}", getThing().getUID().toString(), e.getLocalizedMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -66,6 +66,8 @@ public enum MiIoDevices {
YEELIGHT_CEIL1("yeelink.light.ceiling1", "Yeelight LED Ceiling Lamp", MiIoBindingConstants.THING_TYPE_BASIC),
YEELIGHT_CEIL2("yeelink.light.ceiling2", "Yeelight LED Ceiling Lamp v2", MiIoBindingConstants.THING_TYPE_BASIC),
YEELIGHT_CEIL3("yeelink.light.ceiling3", "Yeelight LED Ceiling Lamp v3", MiIoBindingConstants.THING_TYPE_BASIC),
YEELIGHT_CEIL4("yeelink.light.ceiling4", "Yeelight LED Ceiling Lamp v4 (JIAOYUE 650 RGB)",
MiIoBindingConstants.THING_TYPE_BASIC),
YEELIGHT_L1("yeelink.light.lamp1", "Yeelight", MiIoBindingConstants.THING_TYPE_BASIC),
YEELIGHT_M1("yeelink.light.mono1", "Yeelight White Bulb", MiIoBindingConstants.THING_TYPE_BASIC),
YEELIGHT_M2("yeelink.light.mono2", "Yeelight White Bulb v2", MiIoBindingConstants.THING_TYPE_BASIC),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2017 by the respective copyright holders.
* Copyright (c) 2010-2018 by the respective copyright holders.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down
Loading

0 comments on commit 019d15f

Please sign in to comment.