I'm currently working on a HomeSeer -> Hubitat plugin that is working well with @rob LIFX app. However I have some questions as well.
What are the input parameters for setColor, setState as they are presented through Maker API as "commands". However through the HE web interface nor through Maker API can I get anything to work with them.
At the device handler level, for setColor it should be a map, for setState it should be a string that looks like a map e.g. "[brightness: 30]".
The full list of parameters for setState are:
hue (0-100)
saturation (0-100)
brightness (0-100)
level (0-100)
power (on/off)
kelvin (the literal kelvin value, depends on the bulb)
duration (number: transition time in seconds)
color
'random' - pick a random colour from the colour list
a hex colour e.g. #224759
a named colour from the colour list
colour (exactly the same as color, just because I'm British )
Both of those work fine in the web interface, but as I said earlier I've never tried using the Maker API so I'm not sure how you'd pass them in.
I could possibly make them more flexible and allow JSON if that would help?
Note that both of these only apply to LIFX Color and LIFX Plus Colour devices - a white only version of setState could be possible I suppose in future.
From the HE interface working with the "Set Color" I've found.
[random] does not work
Using a named color/colour is not working me. Perhaps I need to update? Example [white] or [White] or [red], [green] etc does not work
In Set Color using the "Color Picker" that works fine.
The Maker API takes the input as part of the URL in a GET call which makes it simple to work with. Ideally it would be nice to use this for integration purposes.
setColor could accept either 'name' ie 'blue' or the hex value minus the '#' symbol
@jeubanks, the parameters listed are for setState. This is a Lifx api specific command that gives a bit more flexibility than the standard setColor.
Eg. Under setState you can use
[color:random]
[color:red]
[color:green]
I don't believe the Maker Api can use custom commands (which setState is) so it may not be possible to configure the bulbs with that method. I could be wrong as I have not been following the Maker api changes with each update.
Simply passing the map as the subCommand to setState is working.
[EDIT]: Colors in the color map with a 'space' in the name even with it being HTML encoded is not working through Maker API but all other single word colors are working with exception of light/white colors (not really a color though right?
Here's some log info from using Maker API with setColor.
app:2542019-04-20 10:59:14.236 debugExecuting with secondary command:
setColor [hue:31,saturation:100,level:100] on device: Desk Lamp
dev:5102019-04-20 10:59:14.233 errorgroovy.lang.MissingMethodException: No
signature of method: user_driver_robheyes_LIFX_Color_651.setColor() is
applicable for argument types: (java.lang.String) values:
[[hue:31,saturation:100,level:100]]
Possible solutions: setColor(java.util.Map), iterator() (setColor)
In the Lifx Color driver I notice that the setState method does an active conversion of string to map where as the setColor method assumes an incoming map. I'm not a good enough coder to know the solution but something tells me that is where the problem lies.
For the ones with space in the name, edit the LIFX Master app and change line 565 to be myColor = (null == color) ? null : lookupColor(color.replace('_', ' '))
Then you can use an underscore where you need a space.
I haven't tried this at all. Just trying to help @jeubanks out. My assumption is that the Maker Api is sending the secondary command value as a different value type than just entering it in from the HE device page. I have no plans to test any of this myself.
@rob thanks for the info on updating the code. I can make the changes on my install, however I'm working on a HomeSeer plugin to integrate Hubitat. Will this be updated in mainline or should I fork this to keep the change?
The @SuppressWarnings annotation already exists. I made the other modification from the previous post and I will test.
[EDIT]: So far the replacement is working. I can use the '_' instead of space through Maker API and on the first few test colors it works. BTW the names are interesting but the Aloeswood Brown is more like a older Soft Incandescent
Sounds like you pasted the code in the wrong place, or maybe the annotation applies to all versions of the same method?
Yeah, you're not wrong about Aloeswood Brown, it's way too bright - I should probably go through all the colours and make sure they work properly - that'll be fun! As the comment in the code says, the colours come from Named Color Codes / Reference Chart, not 100% sure why that one doesn't work properly - greys really don't I think.
Actually I didn't copy/paste anything. I looked at the code and compared. The annotation was already there, unless I was looking at the wrong block (possible). Either way I have not tested/verified the suppression as it's not effecting anything that i can tell but just something I noticed. Now I'm gonna have to go back through the code as the "did I miss that" is bugging me
Yeah not blaming you for the colors from the chart. I've found that a lot of the "charts" are somewhat "off" and possible I'm a bit color blind or so my wife thinks so
Ah, did you replace the existing method? You need to have both methods for it to work with the normal means.
The @SuppressWarnings is really only for my benefit in the IDE I use, it doesn't do anything as far as Hubitat is concerned. I just like to ensure that the code is as clean as possible.