Support for Hue switches (tab/ dimmer)

With the intention of making light switches perform different tasks at different times… (e.g. baby room full light before 6pm, but only dimmed after 6pm), or even having the hue switches control more than just the hue lights (e.g. long press => switch off all lights and set thermostat to away). I was hoping to see integration of the hue switches in the hass system.

1 Like

Philips Hue is classified as local polling, so it makes sense to buy switches that can do push notification. Besides, you would want to set the polling rate to 100ms, which could congest your home network and Philips Hue may not be able to receive commands at a fast polling rate.

You will want to buy switches with a hub that supports local push.

Thanks for the info…
Is there a consensus on what the best switches are that support local push?

1 Like

Hmm… not sure if this would work or not, but what about an Arduino with a couple of push buttons? Could set up the push button interaction to a scene/switch (like the Hue bulbs).

If you want a wireless option, look into the MySensors project. You could go with a battery powered Arduino set up with a Scene Controller sketch. The sketch would talk to HA, and HA could talk to the Hue bridge in return.

You could also run a 16 or 32 button keypad ( https://forum.mysensors.org/topic/3128/slim-node-scene-controller-keypad/5 ) and have even more options.

@mannerisms while this isn’t any help with HASS you and other forum members might find this interesting or useful.

http://www.developers.meethue.com/documentation/getting-started

I have had a play around with it not really knowing what I am doing and there appears to be some useful underutilised features in there like the sensor for tracking daylight. Someone who is more experienced with RESTful interfaces might be able to figure out how to use the rules to change the action of the Hue Tap switch buttons, depending on the time of the day?

This is another useful link. http://www.developers.meethue.com/documentation/core-concepts

I dug into this. Currently, it would be very ugly to integrate this support as we would have to poll the bridge very frequently, as in every 0.1-0.5 seconds.

More info from the Hue developer forums here.

any idea for the dimmer support …i was thinking about emulated hue hub with emularedlights. means i want to turn on emulated light whichnturns on real light

Any new to this issue?

I would like to use the Philips Hue for triggering other events (beside using Hue products) within HA. Is this possible?

For example I have a mix of Yeelight and Hue bulb: I would like the Hue switch to turn on the Hue lights AND the yeelight

Very cool!

Any finished product available?

@anon35356645 I have a MQTT bridge to realize this request. Means. You uh button. MQTT reads out the “sensor” of the dimmer and u can build automations.

to make this do following:

I ahve this automation for example:

  - alias: Turn off Ceiling light 
    trigger:
      - platform: mqtt
        topic: hue/sleeping_room_color_light/buttonevent
        payload: '4002'
    action:
      - service: light.turn_off
        entity_id: light.sleeping_room_ceiling
Philips Hue Sensor MQTT Bridge

This should be compatible with multiple Hue bridges, but it has only been tested with one. Also, this has only been tested with Hue Dimmer.

I have noticed the best performance when running the polling interval at 500ms.

If you have any issues, please post them on GitHub.

Configuration

{
  "broker": {
    "host": "localhost",
    "username": "XXXXXXXX",
    "password": "XXXXXXXX"
  },
  "bridges": [
    {
      "host": "XXX.XXX.XXX.XXX",
      "username": "XXXXXXXX",
      "interval": 1000,
      "prefix": "hue"
    }
  ]
}
Installation

A huge thank you goes out to @LaurensBot for writing this guide.

The instructions are based on the Raspberry Pi and assume that you already have the following installed:

Node.js
Home Assistant
git
mosquitto MQTT broker
Create a parent folder for hue-mqtt-bridge:

mkdir /home/pi/node
cd /home/pi/node
Clone the git repository:

git clone git://github.com/dale3h/hue-mqtt-bridge.git
cd hue-mqtt-bridge
Install dependencies (do not run as root):

npm install
Create the config file and edit it to your liking:

cp config.sample.json config.json
nano config.json
You can find the username in the Home Assistant directory in a file named phue.conf. It is the long string of random characters.

Make hue-mqtt-bridge start at boot:

sudo npm install -g pm2
pm2 startup systemd
This will give you a command that includes sudo -- run that command.

Time to run hue-mqtt-bridge:

./bin/hue-mqtt-bridge
If no errors are shown, all should be working.

If no errors are shown stop (Ctrl+C) the process and run:

pm2 start index.js --name hue-mqtt-bridge
pm2 save
The topics in MQTT start with hue by default, so to see the output run:

mosquitto_sub -h localhost -p 1883 -u YOUR_MQTT_USERNAME -P YOUR_MQTT_PASSWORD -v -t '#'
Click a button on your Hue Dimmer or Hue Tap, or trigger your Hue Motion.

Add it to Home Assistant

Running the above command showed the following output when pressing a button:

hue/hue_tap_tap1/buttonevent 34
The topic will be different so adjust the trigger below with your topic:

automation:
  - alias: hue_tap_button_1
    trigger:
      - platform: mqtt
        topic: hue/hue_tap_tap1/buttonevent
        payload: '34'
    action:
      - service: homeassistant.turn_on
        entity_id: script.todosomething
1 Like

As I didn’t find any ready to use solution, I mixed a few of the snipets available online and came up with this : https://github.com/drcursor/home-assistant-huedimmer/

Basically it’s a python helper script that polls the hue bridge and calls homeassistant API whenever a button press is detected.

@drcursor nice idea but a bit complicated for me … i stay at mqtt for the moment. Thanks for sharing anyway!

hi @anon35356645

There are several projects on the MySensors website. While I do no think there are any pre-built systems available to buy, you may find something on their sister website openhardware.io for boards to at least get you going there. The best bet after that would be if you have access to a 3D printer and just design a case around that.

The SlimKeypad that I linked to originally is also battery based and uses sleep intervals. Theoretically, it should last you a year or two on a set of batteries (if not longer).

I just installed the mqtt hue bridge and everything went great, but when I’m running the following command as it say in the guide
mosquitto_sub -h localhost -p 1883 -u YOUR_MQTT_USERNAME -P YOUR_MQTT_PASSWORD -v -t '#'

It doesn’t return anything when I’m pressing the buttons of the hue tap.

Any ideas? @dale3h @thundergreen

Can you run pm2 logs hue-mqtt-bridge and see if there are any errors?

I just checked and I get the following error in the log

0|hue-mqtt | at IncomingMessage. (/home/pi/node/hue-mqtt-bridge/node_modules/request/request.js:1001:12)
0|hue-mqtt | Polling Hue bridge 192.168.1.101 every 500ms
0|hue-mqtt | ReferenceError: Map is not defined
0|hue-mqtt | at type (/home/pi/node/hue-mqtt-bridge/node_modules/equals/node_modules/jkroso-type/index.js:20:22)
0|hue-mqtt | at equal (/home/pi/node/hue-mqtt-bridge/node_modules/equals/index.js:7:19)
0|hue-mqtt | at /home/pi/node/hue-mqtt-bridge/index.js:89:37
0|hue-mqtt | at Array.forEach (native)
0|hue-mqtt | at Request._callback (/home/pi/node/hue-mqtt-bridge/index.js:80:26)
0|hue-mqtt | at Request.self.callback (/home/pi/node/hue-mqtt-bridge/node_modules/request/request.js:186:22)
0|hue-mqtt | at Request.emit (events.js:98:17)
0|hue-mqtt | at Request. (/home/pi/node/hue-mqtt-bridge/node_modules/request/request.js:1081:10)
0|hue-mqtt | at Request.emit (events.js:95:17)
0|hue-mqtt | at IncomingMessage. (/home/pi/node/hue-mqtt-bridge/node_modules/request/request.js:1001:12)

I checked on the js files of the log but I didn’t really find something. I guess that something is wrong with the “Map” reference.
Any ideas?

@dale3h I guess you don’t have any tips on how to fix that?

Finally I had some time to take a look at the error by myself and I found I that I was on an old nodejs version even if I thought that I was on the lateste. Updating nodejs did the trick and now it seems to work.

When I’m running
mosquitto_sub -h localhost -p 1883 -u YOUR_MQTT_USERNAME -P YOUR_MQTT_PASSWORD -v -t '#'

I can see the output when I’m pressing an button.

Next step to get it working in automations :slight_smile:

Does the continous polling oh the philips hub every 1 sec have an impact on the performance of the hub?