morrijr / node-red-contrib-nanoleaf-aurora

Node-Red contribution. Control Nanoleaf Aurora
Apache License 2.0
8 stars 2 forks source link

Add color node #1

Closed xaliander closed 5 years ago

xaliander commented 5 years ago

First off - thanks a ton for all of your effort! Second, is there a reason you have not added color manipulation as of yet? This would vastly improve the node-red module in my humble opinion. Cheers

morrijr commented 5 years ago

Hi,

Your welcome.

The only reason I stopped is that I had all the functionality I needed/wanted at the time. When you say color manipulation you mean changing the hue? Solid color?

I'll see if I can expose the API around that. Give me a couple of weekends.

Regards,

J.

xaliander commented 5 years ago

Hi, yes exactly, I would like to control the color of the nanoleaf panel (same color for all) through node-RED. Awesome, that would be great. Thanks again!

xaliander commented 5 years ago

Hi J., just a quick reminder on the hue change ;) Let me know if there is anything that I can do. Cheers

morrijr commented 5 years ago

Added a 'color' node. Payload needs to be something like; {"r":10,"g":100,"b":5} {"red":10,"green":100,"blue":5} or {"h":15,"s":50,"v":40} {"hue":15,"saturation":50,"value":40}

I'll try and find some time to support more 'CSS' styles of defining the colors, but this should do for you to be getting on with :)

Feel free to send me some example flows!

J.

xaliander commented 5 years ago

Awesome thanks! Exactly what I was looking for. =)

I noticed something interesting: When passing a 0 for either red green or blue, there is an error. I'll take a look into it,... maybe I'll be able to contribute a little something as well ;)

morrijr commented 5 years ago

Have you tried HSV? It might be somewhere in the conversion code, which is in the library I actually depend on to control the nanoleaf. If it is I might have to either send them a bug request or pull the code into my own library.

xaliander commented 5 years ago

Hi @morrijr, as you can see, the problem still persists even when changing to HSV. I marked the debug message after firing in red. The value 0 seems to be causing the issue as everything works fine when using 1 instead.

screenshot
morrijr commented 5 years ago

I'm trying to switch from using the nanoleaf-aurora-client to calling the device directly since nanoleaf-aurora-client is no longer supported. Since that library also had the HSV -> RGB function in it I was also looking to use something like color-convert. It would allow a far wider range of color conversions too.

No promises as to timeline though. I have somethings I need to investigate for a work problem too.

xaliander commented 5 years ago

OK sounds good - for now I'll make sure not to put any zeros anywhere ;)... Thanks again for your effort!

morrijr commented 5 years ago

Give this one a try.

Lots more ways to specify the color and hopefully no problems with 0! (At least, I didn't in my tests)

xaliander commented 5 years ago

Have you pushed the update to npm or does it automatically occur? So far I'm having trouble finding the 0.0.5 update...

morrijr commented 5 years ago

It's there in npmjs. Don't know how often node-red scans npmjs though...

xaliander commented 5 years ago

Nice, after the update everything works great. I also appreciated the 0.1.0 update! The transition duration will come in handy =) Thank again!

xaliander commented 5 years ago

Hi John, long time no see! Thanks again for your wisdom some time back.

After a firmware upgrade I am receiving the following message:

Screenshot 2019-07-19 at 22 06 00

Is there something I might be doing wrong? The payload looks like this:

Screenshot 2019-07-19 at 22 16 22

Cheers Alex

morrijr commented 5 years ago

Hi Alex,

This was working with 3.0.8 updating to what my phone says is the latest; 3.1.3.

To see information about your installation there's a Info node you can wire up to an inject and a debug. It should give you (amongst other stuff) something like;

{ name: "Nanoleaf Light Panels XX:XX:XX", serialNo: "XXXXXXX", manufacturer: "Nanoleaf", firmwareVersion: "3.0.8", model: "NL22" }, rhythm: { hardwareVersion: "1.4" firmwareVersion: "2.4.2" }

Can you get me that information? (Please don't post serialNo or name since that has security issues)

In the meantime I'll upgrade and checkout the API see if anything's changed.

J.

PS, better to open a new issue on GitHub when it's not related than appending to a closed issue. Helps other folks search for things :) But don't worry/bother about it for now.

xaliander commented 5 years ago

Here you go =) Makes sense, I just wasn't sure if it's an error or just me...

{ "name":"Nanoleaf Light Panels XX:XX:XX”, "serialNo":”XXXXXXXXXXX”, "manufacturer":"Nanoleaf", "firmwareVersion":"3.1.2", "hardwareVersion":"1.6-2", "model":"NL22", [...] "rhythm":{ "firmwareVersion":"2.4.3", "hardwareVersion":"2.0", } }

morrijr commented 5 years ago

OK, I think I've got it. Basically they've made the API stricter. If you push this payload

{ "brightness": { "value": 100, "duration": 0 }, "hue": { "value": 120 }, "sat": { "value": 20 } }

into an 'advanced' node set to put and /state it'll work. So I'll update the color node to be correct. I'll also expose a duration property and update the documents. Should be in the next couple of days or so.

Regards,

J.

morrijr commented 5 years ago

There should be a fix available now.

J.

xaliander commented 5 years ago

Before I update to 3.1.3 - that includes firmware 3.1.3.? Thanks again, Alex

morrijr commented 5 years ago

Hi, mine is saying it's 3.1.3 so it should be good.

J.