Trigger flow using device not entity

With the latest hue integration, it adds support for the hue switches. I was using the hue remotes hass integration through HACS, but now the standard integration can see the hue switches. The issue is, the battery level is exposed as a sensor, and the switches are exposed as devices. (https://www.home-assistant.io/integrations/hue/) I want to use the device trigger to trigger a flow in node red, how do I do it? I can add a change state node, but it wants an entity id, and I don’t have one, since this isn’t an entity but a device. Am I missing something totally obvious? I know I can build the automation in HA, but I don’t want to since all my automations are in node-red…

I could make an automation that fires an event or calls service… something like mqtt then listen for that in node-red. Is there no cleaner way to do it? Also, would it be slower to do it this way?

Alright - i used an ‘events all’ node, set to debug everything, hit the button on the hue switch and got an event for ‘hue_event’ with an event id of 1002! Yay! So, now I just need to figure out what each event is, but at least I am on the right track. I will document so maybe the default hue integration can be updated with a note on how to use node red to listen for these instead of using the built in automations.

1000=Button(ON) INITIAL_PRESSED
1001=Button(ON) HOLD
1002=Button(ON) SHORT RELEASED
1003=Button(ON) LONG RELEASED
2000=Button(DIM UP) INITIAL_PRESSED
2001=Button(DIM UP) HOLD
2002=Button(DIM UP) SHORT RELEASED
2003=Button(DIM UP) LONG RELEASED
3000=Button(DIM DOWN) INITIAL_PRESSED
3001=Button(DIM DOWN) HOLD
3002=Button(DIM DOWN) SHORT RELEASED
3003=Button(DIM DOWN) LONG RELEASED
4000=Button(OFF) INITIAL_PRESSED
4001=Button(OFF) HOLD
4002=Button(OFF) SHORT RELEASED
4003=Button(OFF) LONG RELEASED

These are the commands - found them on another forum somewhere.

2 Likes

hi @revan415 - did you get this working OK then, and do you have multiple remotes at all?

I’m just starting with node-red, and have 4 Hue dimmers in the house - I have them triggering YAML-based automations using the deviceIDs, but would like to transition all automations to node-red eventually. The event IDs you posted above would be common to all remotes, so just wondering how to establish which remote was pressed?

Thanks!

Answering my own question here for anyone else who searches for this :slight_smile:

hue_event : msg.payload : Object
object
event_type: "hue_event"
event: object
id: "master_dimmer"
unique_id: "00:17:88:01:04:f2:c6:98-02-fc00"
event: 4002
last_updated: "2020-10-22T15:54:49"
origin: "LOCAL"
time_fired: "2020-10-22T15:54:51.031447+00:00"

so the object -> event -> id path contains the name of the dimmer, as found in HASS and / or the Hue app - which is better than the random ID of the device used by YAML automations in HASS!

Did you get this to work Scott? Would you mind sharing your Node Red?

Thanks

Yeah I got it working - basically event.id gives the name of the dimmer switch pressed, and event.event gives the button that was pressed; I have 4 dimmers, hence the first switch node separates out the dimmer device (by name) and the the second switch node separates out the buttons:

[{"id":"e0867982.9fe578","type":"tab","label":"Hue","disabled":false,"info":""},{"id":"1a60866e.eb60fa","type":"server-events","z":"e0867982.9fe578","name":"HueEvent","server":"2993e8b4.fc1e78","event_type":"hue_event","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"x":60,"y":280,"wires":[["5e9fd622.0bf928"]]},{"id":"5e9fd622.0bf928","type":"switch","z":"e0867982.9fe578","name":"Device","property":"payload.event.id","propertyType":"msg","rules":[{"t":"eq","v":"master_dimmer","vt":"str"},{"t":"eq","v":"robin_dimmer","vt":"str"},{"t":"eq","v":"zara_dimmer","vt":"str"},{"t":"eq","v":"utility_dimmer","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":190,"y":280,"wires":[["f8c2ed78.827bc"],[],[],[]]},{"id":"f8c2ed78.827bc","type":"switch","z":"e0867982.9fe578","name":"Button","property":"payload.event.event","propertyType":"msg","rules":[{"t":"eq","v":"1003","vt":"num"},{"t":"eq","v":"2003","vt":"num"},{"t":"eq","v":"3003","vt":"num"}],"checkall":"true","repair":false,"outputs":3,"x":370,"y":160,"wires":[["8968b45e.e24f68"],[],[]]},{"id":"8968b45e.e24f68","type":"api-current-state","z":"e0867982.9fe578","name":"BedMotion?","server":"2993e8b4.fc1e78","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"switch.bedroom_detector","state_type":"str","state_location":"bedmotion","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":550,"y":80,"wires":[["57c3804d.7bffb"],["ea990268.7a197"]],"outputLabels":["On","Off"]},{"id":"57c3804d.7bffb","type":"api-call-service","z":"e0867982.9fe578","name":"BedMotionOff","server":"2993e8b4.fc1e78","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.bedroom_detector","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":740,"y":40,"wires":[["fe1a2886.83ce38"]]},{"id":"ea990268.7a197","type":"api-call-service","z":"e0867982.9fe578","name":"BedBright","server":"2993e8b4.fc1e78","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.master_bedroom","data":"{\"brightness\":255,\"xy_color\":[0.37,0.372]}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":720,"y":120,"wires":[[]]},{"id":"fe1a2886.83ce38","type":"api-call-service","z":"e0867982.9fe578","name":"BedBright","server":"2993e8b4.fc1e78","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.master_bedroom","data":"{\"brightness\":255,\"xy_color\":[0.37,0.372]}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":900,"y":40,"wires":[["4d5e6cb4.6d39d4"]]},{"id":"4d5e6cb4.6d39d4","type":"ha-wait-until","z":"e0867982.9fe578","name":"LightOff","server":"2993e8b4.fc1e78","outputs":1,"entityId":"light.master_bedroom","entityIdFilterType":"exact","property":"state","comparator":"is","value":"off","valueType":"str","timeout":0,"timeoutType":"num","timeoutUnits":"seconds","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":1040,"y":40,"wires":[["3d50491c.eb58e6"]]},{"id":"3d50491c.eb58e6","type":"api-call-service","z":"e0867982.9fe578","name":"BedMotionOn","server":"2993e8b4.fc1e78","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.bedroom_detector","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1200,"y":40,"wires":[[]]},{"id":"2993e8b4.fc1e78","type":"server","name":"Home Assistant","addon":true}]

Note sure how to upload a file here, sorry!!

1 Like

That’s awesome! Thank you so much!

Just to follow up - This also works very well for the Lutron Caseta Pico Remotes.

Thanks for the figuring this out, and sharing your flow. I always forget about events: all. Such a useful feature although it can be very intimidating.

Thank you!
Was able to catch the events from my dimmer switches too by using (and altering of course) your code.

I am now able to use the switches for all kind of things. Like a homekit doorbell :slight_smile: