Open SJRepos opened 3 years ago
OpenHAB supports on/off for the color control but smartthings defines Color, Hue and Saturation. See the definition here. I've tried to follow the Smartthings Capabilities reference in my implementation. That said, it would be possible for me to extend the Color Control but what would I name the on/off attribute and how would I then document that?
I have a Sengled bulb and it supports the switch and switchLevel capabilities and I use those to control on/off and brightness. Can you use that? Here are my things and items definitions:
// Sengled Bulb colorControl SengledColorControl [ smartthingsName="Sengled Bulb"] colorTemperature SengledColorTemperature [ smartthingsName="Sengled Bulb"] switch SengledSwitch [ smartthingsName="Sengled Bulb"] switchLevel SengledSwitchLevel [ smartthingsName="Sengled Bulb"]
// Sengled bulb Color SengledColorControl "Sengled bulb color" <colorpicker> {channel="smartthings:colorControl:Home:SengledColorControl:color"} Number SengledTemperature "Sengled bulb color temperature" {channel="smartthings:colorTemperature:Home:SengledColorTemperature:colorTemperature"} Switch SengledSwitch "Sengled bulb switch" <switch> {channel="smartthings:switch:Home:SengledSwitch:switch"} Dimmer SengledDimmer "Sengled bulb dimmer" <slider> {channel="smartthings:switchLevel:Home:SengledSwitchLevel:level"}
If you want me to look into this further, please send me the steps I could use to reproduce this error.
Thanks,
Bob
I understand that you have followed the Smartthings definitions, and I have actually worked around this myself by modifying the code for the 'OpenHabAppV2' smart app. In particular I changed the 'actionColorControl' routine so that it would check for color values of 'off' and 'on':
// This is the original color control
def actionColorControl(device, attribute, value) {
log.debug "actionColorControl: attribute \"${attribute}\", value \"${value}\""
switch (attribute) {
case "hue":
device.setHue(value as int)
break
case "saturation":
device.setSaturation(value as int)
break
case "color":
if (value == "off") {
device.off()
} else if (value == "on") {
device.on()
} else {
def colormap = ["hue": value[0] as int, "saturation": value[1] as int]
// log.debug "actionColor: Setting device \"${device}\" with attribute \"${attribute}\" to colormap \"${colormap}\""
device.setColor(colormap)
device.setLevel(value[2] as int)
}
break
}
}
I also added 'Off' an 'On' to the 'actionColor' routine:
// This is the new "proposed" color. Here hue is 0-360
def actionColor(device, attribute, value) {
log.debug "[SJ2] actionColor: attribute \"${attribute}\", value \"${value}\""
switch (attribute) {
case "hue":
device.setHue(value as int)
break
case "saturation":
device.setSaturation(value as int)
break
case "colorValue":
def colormap = ["hue": value[0] as int, "saturation": value[1] as int]
// log.debug "actionColor: Setting device \"${device}\" with attribute \"${attribute}\" to colormap \"${colormap}\""
device.setColor(colormap)
device.setLevel(value[2] as int)
break
case "off":
device.off()
break
case "on":
device.on()
break
}
}
FYI, I do have Switch channels defined for the bulbs I am using, its just that the OH3 color picker sends the 'off' value to the color channel if the brightness is reduced to 0%. I believe my modification is sane since it maps the OH color channel to the Smartthings device.
I am just starting to experiment with OH3 so hadn't discovered that yet. Actually doing OH3 setup is where I discovered that the discovery service is broken. And, I've gotten slowed down because the Eclipse IDE has problems AGAIN. I was just about to bag doing anything and I tried setting up the VSCode IDE and that works well.
Couple of questions:
I agree that you changes make complete since since that is the use case that OH is providing.
Thanks for your help.
Bob
To answer your questions:
@sjhangiani What version are you using? I've been able to partially reproduce the issue you are describing using version 3.0. But in version 3.1 the color picker seems to work differently. Your enhancement doesn't seem necessary under 3.1. I'm wondering if you have found this true or not?
Within OpenHab the color channel supports On/Off which is not supported by the 'actionColorControl' capability and hence we get the following error in the log:
Error message from Smartthings: Error occured while calling action: {actionColorControl} for Capability: Color Control with device name: ItemName changed to: off. Exception java.lang.NumberFormatException: For input string: "o"