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

Support Hue Smart Button #123

Closed
vbambuch opened this issue Jan 5, 2020 · 25 comments
Closed

Support Hue Smart Button #123

vbambuch opened this issue Jan 5, 2020 · 25 comments

Comments

@vbambuch
Copy link

vbambuch commented Jan 5, 2020

Hi, is there a way how to connect Hue Smart Button with this project?

If not, would that be possible to add it to the component stack? 🙂

@dongennl
Copy link
Contributor

I have the same question! Happy to help develop it, just a bit new to JS.

@Foddy
Copy link
Owner

Foddy commented Jan 26, 2020

I started working on it but I couldn’t find any docs for this device. I mean I don’t know what kind of button events there are available for this device and how the bridge addresses them.

Maybe somebody can provide me this information?

@dongennl
Copy link
Contributor

Hi @Foddy, thanks.

There's not much documentation, even Philips doesn't have it in their documentation yet.

I did find this thread, which contains the events:
dresden-elektronik/deconz-rest-plugin#2077

I don't have one yet, but maybe someone else with one can confirm.

@Radiotechniman
Copy link

+1 for me too

@bacongravy
Copy link

I am also curious about this. I looked at the thread linked to by @dongennl and according to this comment it looks like the Smart Button presents itself as "type": "ZLLSwitch", which also seems to be what the Hue switch node searches for:

else if(payload.type == "ZLLSwitch")

$.get('hue/sensors', {bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "ZLLSwitch"})

It looks to me like the buttonevents (1000, 1001, 1002, 1003) match up to the events here:
var buttonActionRaw = parseInt(sensor.state.buttonEvent.toString().substring(3));
if(buttonActionRaw == 0)
{
buttonAction = "pressed";
buttonActionLocalized = RED._("hue-switch.node.action-pressed");
}
else if(buttonActionRaw == 1)
{
buttonAction = "holded";
buttonActionLocalized = RED._("hue-switch.node.action-holded");
}
else if(buttonActionRaw == 2)
{
buttonAction = "short released";
buttonActionLocalized = RED._("hue-switch.node.action-shortreleased");
}
else
{
buttonAction = "long released";
buttonActionLocalized = RED._("hue-switch.node.action-longreleased");
}

So as far as I can tell, the Smart Button should already show up in HueMagic as a Hue Switch that acts like it only has an "On" button. Can anyone confirm? Thanks!

@dongennl
Copy link
Contributor

Thanks @bacongravy ; I've just ordered one, as need one anyway; hopefully be able to confirm your findings soon.

@jimmyeao
Copy link

Looking forwards to this, literally just has a look to see if I could trigger some logic. Sadly, doesn't appear in the Hue Switch List.

@dongennl
Copy link
Contributor

Yep, just got mine, It does NOT show up as a Switch or Tap. Do we need to make a new component?

@jimmyeao
Copy link

It would be great if we could!

@jimmyeao
Copy link

jimmyeao commented Aug 4, 2020

Any update on this? Would be really cool to see it added

@dongennl
Copy link
Contributor

dongennl commented Aug 15, 2020

I'm very new to all this, but reading the js/html I think we need this info from my bridge to be able to select the Smart Button:

"43": { "state": { "buttonevent": 1003, "lastupdated": "2020-08-10T00:04:20" }, "swupdate": { "state": "noupdates", "lastinstall": "2020-04-17T14:06:01" }, "config": { "on": true, "battery": 100, "reachable": true, "pending": [] }, "name": "Hue Smart button 1", "type": "ZLLSwitch", "modelid": "ROM001", "manufacturername": "Signify Netherlands B.V.", "productname": "Hue Smart button", "diversityid": "8b18a40c-eb6a-40d7-a0af-eb0906613d41", "swversion": "2.30.0_r30777", "uniqueid": "00:17:88:01:06:07:60:0c-01-fc00", "capabilities": { "certified": true, "primary": true, "inputs": [ { "repeatintervals": [ 800 ], "events": [ { "buttonevent": 1000, "eventtype": "initial_press" }, { "buttonevent": 1001, "eventtype": "repeat" }, { "buttonevent": 1002, "eventtype": "short_release" }, { "buttonevent": 1003, "eventtype": "long_release" } ] } ] } }

I'm looking at 'hue-switch.html' to see how the selection is done:
I found this line:
if(sensor.model == "Hue Wireless Dimmer Switch")

I don't see this value anywhere in the JSON for the Switch, I only see:
"productname": "Hue dimmer switch"

So not sure how we change the selection here to make it show buttons instead of switches...
How do we make it select on "productname": "Hue Smart button" ?
Anyone knows how this works?

@dongennl
Copy link
Contributor

Ok, did some work on this, the "Hue Wireless Dimmer Switch" comes from Huejay, a dependency; it doesn't seem to be maintained.
Created a new mechanism using the bridge JSON to separate the Switches from the Buttons; got it working locally; need to clean up and will do a pull request (I'm new to this!).

Any help testing/reviewing appreciated, my fork is here:
https://github.com/dongennl/node-red-contrib-huemagic

@jimmyeao
Copy link

jimmyeao commented Aug 16, 2020 via email

@dongennl
Copy link
Contributor

Just created pull request #191

@jimmyeao
Copy link

Darn, I run Node-Red in a docker, looks like I'll have to wait for the Pull to be merged first. Everytime I restart Node-Red it just overwrites the package with the original version :/

@dongennl
Copy link
Contributor

Oh @jimmyeao it's super-easy on Docker; I use it too; just copy your main node-red container on another port (make sure to map to different volumes if using); now you have a blank node-red install; attach to the container, apt install npm, go into the node-red directory and 'npm install [github URL (not ssh, use https)]'.
You can attach to the same Hue Hub at the same time and test.

@jimmyeao
Copy link

jimmyeao commented Aug 17, 2020

pi@raspberrypi:~ $ npm install git@github.com:dongennl/node-red-contrib-huemagic.git
npm ERR! code ENOLOCAL
npm ERR! Could not install from "github.com:dongennl/node-red-contrib-huemagic.git" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pi/.npm/_logs/2020-08-17T11_42_09_047Z-debug.log

Edit, never mind, got it installed with https 👍

@dongennl
Copy link
Contributor

try
npm install https://github.com/dongennl/node-red-contrib-huemagic.git

probably a permission issue; there is a package.json in the root.

@jimmyeao
Copy link

Got it installed now, can detect long and short presses just fine :)

@Foddy
Copy link
Owner

Foddy commented Aug 17, 2020

Thanks you all for contributing and testing! I've just merged the new Hue Button node along with updated docs in v2.8.5+ :)!

@Foddy Foddy closed this as completed Aug 17, 2020
@vbambuch
Copy link
Author

Awesome! Thanks a lot guys. Looking forward to test it out. 😉

@jimmyeao
Copy link

Hmm, since updating my palette the Hue Button node isn't outputting anything, despite its status text changing

@dongennl
Copy link
Contributor

Same for me, I had cloned the Switch Message, but looks like Foddy is already making a fix for 2.8.6 (change to HueButtonMessage).

@dongennl
Copy link
Contributor

Just updated to 2.8.6 and works now. Thanks @Foddy

@jimmyeao
Copy link

Yep, working like a dream, thanks for this @dongennl and @Foddy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants