Skip to content

Instantly share code, notes, and snippets.

@DIYtechie
Last active May 20, 2024 14:39
Show Gist options
  • Save DIYtechie/c95d562d4858cbe1bf80fee95ba9815f to your computer and use it in GitHub Desktop.
Save DIYtechie/c95d562d4858cbe1bf80fee95ba9815f to your computer and use it in GitHub Desktop.
deCONZ Philips Hue dial music and light remote

A great flow to control music playback and volume as well as brightness of lights with a Philips Hue Tap Dial switch. As demonstrated in this video: https://youtu.be/Ujoe9kHXYUk?si=ge89olyDpl3-DbyP

As can be seen, the beauty of this flow is that it uses the detailed sensor data from the hue dial switch to dynamically change volume and brightness. The faster you twist the dial, the more the volume/brightness changes.

Here's what the flow looks like: Hue dial flow

When the volume is 0 % the music will auto-pause, and when the volume is turned up, the music will auto-play. To avoid any unpleasant surprises, the volume will always start at 8 % if you twist the dial while no music is currently playing. For the same reason the maximum volume increase on a single twist is set to 9 %. Turning down the volume is a bit faster as well.

As for the buttons: 1 dot = previous track, 2 dots = next track, 3 dots (triangle) = play/pause, 4 dots = change to brightness mode (hold to switch between radio and playlist).

When the remote is in "brightness mode" it will auto-revert to volume mode after 3 seconds with no adjustment.

The inject node resets the volume and source every night at 4 am (without starting playback)

The flow is tested with Sonos media players but might also work with others, at least for volume, play/pause and next/prev control.

This flow uses Home Assistant nodes and deCONZ nodes, so make sure these are installed (see the pallette) in Node-RED first. The flow can easily be modified to use ZHA events or Zigbee2mqtt events instead.

For the Hue dial button events node select the device "ZHASwitch" and choose "button event" as output payload:

ZHA switch

For the Hue dial rotation events node select the device "ZHARelativeRotary" keep "complete payload" as output: ZHA relative rotary

Copy the flow below to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option.

Then double click all the blue nodes and select your own Home Assistant server and media player. Leave all other settings unchanged.

[
{
"id": "5dd0e25c44412e0c",
"type": "tab",
"label": "Hue dial remote",
"disabled": false,
"info": "",
"env": []
},
{
"id": "8bc5fb7924af3190",
"type": "comment",
"z": "5dd0e25c44412e0c",
"name": "Philips Hue dial music control",
"info": "",
"x": 160,
"y": 60,
"wires": []
},
{
"id": "78c65964b2ab94bf",
"type": "deconz-input",
"z": "5dd0e25c44412e0c",
"name": "Hue dial button events",
"topic": "",
"config_version": 2,
"server": "",
"statustext": "",
"statustext_type": "auto",
"search_type": "device",
"device_list": [
"sensors/uniqueid/00:17:88:01:0d:13:48:df-01-fc00"
],
"device_name": "",
"query": "{}",
"outputs": 1,
"output_rules": [
{
"type": "state",
"format": "single",
"output": "always",
"onstart": false,
"payload": [
"buttonevent"
]
}
],
"x": 140,
"y": 240,
"wires": [
[
"199f446c65e3c02d"
]
]
},
{
"id": "199f446c65e3c02d",
"type": "switch",
"z": "5dd0e25c44412e0c",
"name": "sort input",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "1000",
"vt": "str"
},
{
"t": "eq",
"v": "2000",
"vt": "str"
},
{
"t": "eq",
"v": "3000",
"vt": "str"
},
{
"t": "eq",
"v": "4000",
"vt": "str"
},
{
"t": "eq",
"v": "4001",
"vt": "str"
},
{
"t": "eq",
"v": "4002",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 6,
"x": 180,
"y": 340,
"wires": [
[
"7e8685070b7773df"
],
[
"adae7d3101ed1a40"
],
[
"e2ecc6e34af6d4ca"
],
[],
[
"0562225c775cd0de"
],
[
"16ac675e87aad462"
]
]
},
{
"id": "f551cae5c6b0810a",
"type": "switch",
"z": "5dd0e25c44412e0c",
"name": "last played?",
"property": "lastplayed",
"propertyType": "flow",
"rules": [
{
"t": "eq",
"v": "Discover Weekly",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 420,
"y": 460,
"wires": [
[
"5e524b65ed9b08a1",
"90932a826a9d177c"
],
[
"2d9ddb50d67dbf0b",
"12af02341ad4c3af"
]
]
},
{
"id": "7fd0e348b3a2d305",
"type": "deconz-input",
"z": "5dd0e25c44412e0c",
"name": "Hue dial rotation events",
"topic": "",
"config_version": 2,
"server": "",
"statustext": "",
"statustext_type": "auto",
"search_type": "device",
"device_list": [
"sensors/uniqueid/00:17:88:01:0d:13:48:df-14-fc00"
],
"device_name": "",
"query": "{}",
"outputs": 1,
"output_rules": [
{
"type": "state",
"format": "single",
"output": "always",
"onstart": false,
"payload": [
"__complete__"
]
}
],
"x": 140,
"y": 670,
"wires": [
[
"abcbdf6139ea4ac7"
]
]
},
{
"id": "43a567bfbde17006",
"type": "switch",
"z": "5dd0e25c44412e0c",
"name": "playing?",
"property": "playerstate",
"propertyType": "flow",
"rules": [
{
"t": "neq",
"v": "playing",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 550,
"y": 800,
"wires": [
[
"6805c3d1a5b5a517"
],
[
"d76167f4bb52dc37"
]
]
},
{
"id": "d76167f4bb52dc37",
"type": "function",
"z": "5dd0e25c44412e0c",
"name": "rotation -> volume",
"func": "var currentVolume = flow.get(\"volume\")||0.08 //msg.media.attributes.volume_level\n\nvar NEWexpectedrotation = msg.payload.expectedrotation\n\nvar OLDexpectedrotation = flow.get(\"OLDexpectedrotation\")||0\nvar NETexpectedrotation = NEWexpectedrotation-OLDexpectedrotation\n\nvar rotaryevent = msg.payload.rotaryevent\nif (rotaryevent == 1)\n{\n if (NEWexpectedrotation < 0)\n {\n msg.payload = Math.round((NEWexpectedrotation)/15)\n } \n else if (Math.round((NEWexpectedrotation)/25)+1 > 9)\n {\n msg.payload = 9\n }\n else\n {\n msg.payload = Math.round((NEWexpectedrotation)/25)\n }\n} \nelse \n{\n if (NEWexpectedrotation < 0)\n {\n msg.payload = Math.round((NETexpectedrotation)/15)\n }\n else if (Math.round((NETexpectedrotation)/25)+1 > 9)\n {\n msg.payload = 9\n }\n else\n {\n msg.payload = Math.round((NETexpectedrotation)/25)\n }\n}\nflow.set(\"OLDexpectedrotation\", NEWexpectedrotation)\n\nmsg.payload = msg.payload/100 + currentVolume\n\nif (msg.payload < 0.01) \n{\n msg.payload = 0\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 300,
"y": 900,
"wires": [
[
"27bde9ef1f71ffd3"
]
]
},
{
"id": "daf271e0db84057f",
"type": "switch",
"z": "5dd0e25c44412e0c",
"name": "vol up/down?",
"property": "payload.expectedrotation",
"propertyType": "msg",
"rules": [
{
"t": "gt",
"v": "0",
"vt": "num"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 350,
"y": 800,
"wires": [
[
"43a567bfbde17006"
],
[
"d76167f4bb52dc37"
]
]
},
{
"id": "5e524b65ed9b08a1",
"type": "change",
"z": "5dd0e25c44412e0c",
"name": "",
"rules": [
{
"t": "set",
"p": "lastplayed",
"pt": "flow",
"to": "Smooth Jazz",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 640,
"y": 400,
"wires": [
[]
]
},
{
"id": "2d9ddb50d67dbf0b",
"type": "change",
"z": "5dd0e25c44412e0c",
"name": "",
"rules": [
{
"t": "set",
"p": "lastplayed",
"pt": "flow",
"to": "Discover Weekly",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 640,
"y": 540,
"wires": [
[]
]
},
{
"id": "005ac1fc7dc38a83",
"type": "inject",
"z": "5dd0e25c44412e0c",
"name": "Auto-reset source and volume",
"props": [],
"repeat": "",
"crontab": "00 04 * * *",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 200,
"y": 1000,
"wires": [
[
"3ff1d02cb9dd3027"
]
]
},
{
"id": "9b4ad4f683e81722",
"type": "api-call-service",
"z": "5dd0e25c44412e0c",
"name": "Adjust brightness living room lights",
"server": "",
"version": 5,
"debugenabled": false,
"domain": "light",
"service": "turn_on",
"areaId": [],
"deviceId": [],
"entityId": [
"light.kokken_spisestue"
],
"data": "{\"brightness_step\": {{payload}}}",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "data"
}
],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 680,
"y": 720,
"wires": [
[
"4e60a8cd5372cdab"
]
]
},
{
"id": "fbe955868666e0e2",
"type": "function",
"z": "5dd0e25c44412e0c",
"name": "rotation -> brightness",
"func": "var NEWexpectedrotation = msg.payload.expectedrotation\n\nvar OLDexpectedrotation = flow.get(\"OLDexpectedrotation\")||0\nvar NETexpectedrotation = NEWexpectedrotation-OLDexpectedrotation\n\nvar rotaryevent = msg.payload.rotaryevent\nif (rotaryevent == 1)\n{\n msg.payload = Math.round((NEWexpectedrotation)/3)\n} \nelse \n{\n msg.payload = Math.round((NETexpectedrotation)/3)\n}\nflow.set(\"OLDexpectedrotation\", NEWexpectedrotation)\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 390,
"y": 720,
"wires": [
[
"9b4ad4f683e81722",
"87d876e98a136465"
]
]
},
{
"id": "abcbdf6139ea4ac7",
"type": "switch",
"z": "5dd0e25c44412e0c",
"name": "mode",
"property": "mode",
"propertyType": "flow",
"rules": [
{
"t": "eq",
"v": "light",
"vt": "str"
},
{
"t": "eq",
"v": "blinds",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 190,
"y": 770,
"wires": [
[
"fbe955868666e0e2"
],
[],
[
"daf271e0db84057f"
]
]
},
{
"id": "87d876e98a136465",
"type": "trigger",
"z": "5dd0e25c44412e0c",
"name": "",
"op1": "light",
"op2": "volume",
"op1type": "str",
"op2type": "str",
"duration": "3",
"extend": true,
"overrideDelay": false,
"units": "s",
"reset": "",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 620,
"y": 670,
"wires": [
[
"0c09e88dd7ecc96f"
]
]
},
{
"id": "0c09e88dd7ecc96f",
"type": "change",
"z": "5dd0e25c44412e0c",
"name": "",
"rules": [
{
"t": "set",
"p": "mode",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 790,
"y": 670,
"wires": [
[]
]
},
{
"id": "b4c04c52686aead3",
"type": "api-call-service",
"z": "5dd0e25c44412e0c",
"name": "toggle living room lights",
"server": "",
"version": 5,
"debugenabled": false,
"domain": "light",
"service": "turn_on",
"areaId": [],
"deviceId": [],
"entityId": [
"light.kokken_spisestue"
],
"data": "{\"brightness_step\": -150, \"transition\": 0.5}",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 650,
"y": 620,
"wires": [
[
"0b593c6a34853abb"
]
]
},
{
"id": "a99d53dcfc42c53d",
"type": "api-call-service",
"z": "5dd0e25c44412e0c",
"name": "toggle living room lights",
"server": "",
"version": 5,
"debugenabled": false,
"domain": "light",
"service": "turn_on",
"areaId": [],
"deviceId": [],
"entityId": [
"light.kokken_spisestue"
],
"data": "{\"brightness_step\": 155, \"transition\": 0.5}",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 1050,
"y": 620,
"wires": [
[]
]
},
{
"id": "16ac675e87aad462",
"type": "delay",
"z": "5dd0e25c44412e0c",
"name": "",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "2",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"allowrate": false,
"outputs": 1,
"x": 430,
"y": 620,
"wires": [
[
"b4c04c52686aead3",
"87d876e98a136465"
]
]
},
{
"id": "90932a826a9d177c",
"type": "api-call-service",
"z": "5dd0e25c44412e0c",
"name": "\"Playing Smooth Jazz radio\"",
"server": "",
"version": 5,
"debugenabled": false,
"domain": "tts",
"service": "cloud_say",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.spisestue"
],
"data": "{\"message\":\"Playing smooth Jazz radio\",\"language\":\"en-GB\"}",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [
{
"property": "meta",
"propertyType": "msg",
"value": "",
"valueType": "data"
}
],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 670,
"y": 440,
"wires": [
[
"8f287415b24a1cc0",
"fea8517a72a603d7"
]
]
},
{
"id": "12af02341ad4c3af",
"type": "api-call-service",
"z": "5dd0e25c44412e0c",
"name": "\"Playing Discover Weekly on Spotify\"",
"server": "",
"version": 5,
"debugenabled": false,
"domain": "tts",
"service": "cloud_say",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.spisestue"
],
"data": "{\"message\":\"Playing Discover Weekly on Spotify\",\"language\":\"en-GB\"}",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [
{
"property": "meta",
"propertyType": "msg",
"value": "",
"valueType": "data"
}
],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 700,
"y": 490,
"wires": [
[
"9a19f991d5e451fb",
"fea8517a72a603d7"
]
]
},
{
"id": "f3b822ffd79a706f",
"type": "api-call-service",
"z": "5dd0e25c44412e0c",
"name": "",
"server": "",
"version": 5,
"debugenabled": false,
"domain": "media_player",
"service": "volume_set",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.spisestue"
],
"data": "{\"volume_level\": {{payload}}}",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [
{
"property": "meta",
"propertyType": "msg",
"value": "",
"valueType": "data"
}
],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 670,
"y": 900,
"wires": [
[
"d7e8c8de48bc71a9"
]
]
},
{
"id": "d7e8c8de48bc71a9",
"type": "trigger",
"z": "5dd0e25c44412e0c",
"name": "",
"op1": "",
"op2": "",
"op1type": "nul",
"op2type": "payl",
"duration": "1",
"extend": true,
"overrideDelay": false,
"units": "s",
"reset": "",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 870,
"y": 900,
"wires": [
[
"0eb560332410b8d0"
]
]
},
{
"id": "0eb560332410b8d0",
"type": "switch",
"z": "5dd0e25c44412e0c",
"name": "if volume 0",
"property": "volume",
"propertyType": "flow",
"rules": [
{
"t": "lte",
"v": "0",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 1030,
"y": 900,
"wires": [
[
"daaba533b506a972"
]
]
},
{
"id": "daaba533b506a972",
"type": "api-call-service",
"z": "5dd0e25c44412e0c",
"name": "",
"server": "",
"version": 5,
"debugenabled": false,
"domain": "media_player",
"service": "media_pause",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.spisestue"
],
"data": "",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [
{
"property": "meta",
"propertyType": "msg",
"value": "",
"valueType": "data"
}
],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 1240,
"y": 900,
"wires": [
[
"d9247bdadf98192c"
]
]
},
{
"id": "e2ecc6e34af6d4ca",
"type": "api-call-service",
"z": "5dd0e25c44412e0c",
"name": "",
"server": "",
"version": 5,
"debugenabled": false,
"domain": "media_player",
"service": "media_play_pause",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.spisestue"
],
"data": "",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "data"
}
],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 470,
"y": 330,
"wires": [
[
"02d61bf0e79fc6ab"
]
]
},
{
"id": "c3d56136cf787832",
"type": "api-call-service",
"z": "5dd0e25c44412e0c",
"name": "",
"server": "",
"version": 5,
"debugenabled": false,
"domain": "media_player",
"service": "volume_set",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.spisestue"
],
"data": "{\"volume_level\": 0.08}",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [
{
"property": "meta",
"propertyType": "msg",
"value": "",
"valueType": "data"
}
],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 1230,
"y": 800,
"wires": [
[
"248b147806138ad6",
"d9247bdadf98192c"
]
]
},
{
"id": "248b147806138ad6",
"type": "api-call-service",
"z": "5dd0e25c44412e0c",
"name": "",
"server": "",
"version": 5,
"debugenabled": false,
"domain": "media_player",
"service": "media_play",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.spisestue"
],
"data": "",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [
{
"property": "meta",
"propertyType": "msg",
"value": "",
"valueType": "data"
}
],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 1480,
"y": 800,
"wires": [
[
"d9247bdadf98192c"
]
]
},
{
"id": "7e8685070b7773df",
"type": "api-call-service",
"z": "5dd0e25c44412e0c",
"name": "",
"server": "",
"version": 5,
"debugenabled": false,
"domain": "media_player",
"service": "media_previous_track",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.spisestue"
],
"data": "",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "data"
}
],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 480,
"y": 230,
"wires": [
[
"02d61bf0e79fc6ab"
]
]
},
{
"id": "adae7d3101ed1a40",
"type": "api-call-service",
"z": "5dd0e25c44412e0c",
"name": "",
"server": "",
"version": 5,
"debugenabled": false,
"domain": "media_player",
"service": "media_next_track",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.spisestue"
],
"data": "",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "data"
}
],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 470,
"y": 280,
"wires": [
[
"02d61bf0e79fc6ab"
]
]
},
{
"id": "9a19f991d5e451fb",
"type": "api-call-service",
"z": "5dd0e25c44412e0c",
"name": "",
"server": "",
"version": 5,
"debugenabled": false,
"domain": "media_player",
"service": "select_source",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.spisestue"
],
"data": "{\"source\":\"Royalty Free\"}",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 990,
"y": 490,
"wires": [
[
"4a8575614017cd47"
]
]
},
{
"id": "4a8575614017cd47",
"type": "api-call-service",
"z": "5dd0e25c44412e0c",
"name": "",
"server": "",
"version": 5,
"debugenabled": false,
"domain": "media_player",
"service": "media_play",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.spisestue"
],
"data": "",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 1240,
"y": 490,
"wires": [
[
"c590c380ba2dba82"
]
]
},
{
"id": "c590c380ba2dba82",
"type": "api-call-service",
"z": "5dd0e25c44412e0c",
"name": "",
"server": "",
"version": 5,
"debugenabled": false,
"domain": "media_player",
"service": "shuffle_set",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.spisestue"
],
"data": "{\"shuffle\": true}",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 1280,
"y": 540,
"wires": [
[]
]
},
{
"id": "8f287415b24a1cc0",
"type": "api-call-service",
"z": "5dd0e25c44412e0c",
"name": "",
"server": "",
"version": 5,
"debugenabled": false,
"domain": "media_player",
"service": "select_source",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.spisestue"
],
"data": "{\"source\":\"Smooth Jazz 24/7\"}",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 930,
"y": 440,
"wires": [
[
"b2effcf13df6558c"
]
]
},
{
"id": "b2effcf13df6558c",
"type": "api-call-service",
"z": "5dd0e25c44412e0c",
"name": "",
"server": "",
"version": 5,
"debugenabled": false,
"domain": "media_player",
"service": "media_play",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.spisestue"
],
"data": "",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 1190,
"y": 440,
"wires": [
[]
]
},
{
"id": "15337bb4e8fabe88",
"type": "api-call-service",
"z": "5dd0e25c44412e0c",
"name": "",
"server": "",
"version": 5,
"debugenabled": false,
"domain": "media_player",
"service": "volume_set",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.spisestue"
],
"data": "{\"volume_level\": 0.08}",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 720,
"y": 1000,
"wires": [
[
"f4a1030dc6d31775"
]
]
},
{
"id": "f4a1030dc6d31775",
"type": "api-call-service",
"z": "5dd0e25c44412e0c",
"name": "",
"server": "",
"version": 5,
"debugenabled": false,
"domain": "media_player",
"service": "media_pause",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.spisestue"
],
"data": "",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 970,
"y": 1000,
"wires": [
[
"65cbd5b14680674e"
]
]
},
{
"id": "3ff1d02cb9dd3027",
"type": "api-call-service",
"z": "5dd0e25c44412e0c",
"name": "",
"server": "",
"version": 5,
"debugenabled": false,
"domain": "media_player",
"service": "select_source",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.spisestue"
],
"data": "{\"source\":\"Discover Weekly\"}",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"output_location": "",
"output_location_type": "none",
"x": 470,
"y": 1000,
"wires": [
[
"15337bb4e8fabe88"
]
]
},
{
"id": "65cbd5b14680674e",
"type": "change",
"z": "5dd0e25c44412e0c",
"name": "",
"rules": [
{
"t": "set",
"p": "lastplayed",
"pt": "flow",
"to": "Discover Weekly",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1200,
"y": 1000,
"wires": [
[]
]
},
{
"id": "0b593c6a34853abb",
"type": "delay",
"z": "5dd0e25c44412e0c",
"name": "",
"pauseType": "delay",
"timeout": "0.3",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 850,
"y": 620,
"wires": [
[
"a99d53dcfc42c53d"
]
]
},
{
"id": "df6679347cdf05dd",
"type": "change",
"z": "5dd0e25c44412e0c",
"name": "save volume and playing state",
"rules": [
{
"t": "set",
"p": "volume",
"pt": "flow",
"to": "media.new_state.attributes.volume_level",
"tot": "msg"
},
{
"t": "set",
"p": "playerstate",
"pt": "flow",
"to": "media.new_state.state",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 490,
"y": 170,
"wires": [
[]
]
},
{
"id": "fc0651f9e014f471",
"type": "server-state-changed",
"z": "5dd0e25c44412e0c",
"name": "",
"server": "",
"version": 4,
"exposeToHomeAssistant": false,
"haConfig": [
{
"property": "name",
"value": ""
},
{
"property": "icon",
"value": ""
}
],
"entityidfiltertype": "exact",
"outputinitially": true,
"state_type": "str",
"haltifstate": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"outputs": 1,
"output_only_on_state_change": false,
"for": "0",
"forType": "num",
"forUnits": "minutes",
"ignorePrevStateNull": false,
"ignorePrevStateUnknown": false,
"ignorePrevStateUnavailable": false,
"ignoreCurrentStateUnknown": true,
"ignoreCurrentStateUnavailable": true,
"outputProperties": [
{
"property": "media",
"propertyType": "msg",
"value": "",
"valueType": "eventData"
}
],
"x": 150,
"y": 170,
"wires": [
[
"df6679347cdf05dd",
"4f169da0ac4b0f4b"
]
]
},
{
"id": "e899412aee76010e",
"type": "delay",
"z": "5dd0e25c44412e0c",
"name": "",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"allowrate": false,
"outputs": 1,
"x": 1020,
"y": 800,
"wires": [
[
"c3d56136cf787832"
]
]
},
{
"id": "6805c3d1a5b5a517",
"type": "change",
"z": "5dd0e25c44412e0c",
"name": "",
"rules": [
{
"t": "set",
"p": "OLDexpectedrotation",
"pt": "flow",
"to": "0",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 790,
"y": 800,
"wires": [
[
"e899412aee76010e"
]
]
},
{
"id": "27bde9ef1f71ffd3",
"type": "delay",
"z": "5dd0e25c44412e0c",
"name": "limit",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "0.1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"allowrate": false,
"outputs": 1,
"x": 480,
"y": 900,
"wires": [
[
"f3b822ffd79a706f",
"af049ad5d64afebc"
]
]
},
{
"id": "0562225c775cd0de",
"type": "delay",
"z": "5dd0e25c44412e0c",
"name": "",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "2",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"allowrate": false,
"outputs": 1,
"x": 400,
"y": 400,
"wires": [
[
"f551cae5c6b0810a"
]
]
},
{
"id": "4f169da0ac4b0f4b",
"type": "debug",
"z": "5dd0e25c44412e0c",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "media.new_state.attributes.volume_level",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 540,
"y": 130,
"wires": []
},
{
"id": "02d61bf0e79fc6ab",
"type": "debug",
"z": "5dd0e25c44412e0c",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload.service",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 860,
"y": 270,
"wires": []
},
{
"id": "fea8517a72a603d7",
"type": "debug",
"z": "5dd0e25c44412e0c",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "meta.data.message",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1060,
"y": 370,
"wires": []
},
{
"id": "4e60a8cd5372cdab",
"type": "debug",
"z": "5dd0e25c44412e0c",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload.data.brightness_step",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 990,
"y": 720,
"wires": []
},
{
"id": "d9247bdadf98192c",
"type": "debug",
"z": "5dd0e25c44412e0c",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "meta.service",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1440,
"y": 740,
"wires": []
},
{
"id": "af049ad5d64afebc",
"type": "debug",
"z": "5dd0e25c44412e0c",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 630,
"y": 950,
"wires": []
},
{
"id": "60eb5361f1fdbe74",
"type": "comment",
"z": "5dd0e25c44412e0c",
"name": "link to latest version of this flow",
"info": "Latest version of this flow can be found at \nhttps://flows.nodered.org/flow/c95d562d4858cbe1bf80fee95ba9815f#",
"x": 460,
"y": 60,
"wires": []
}
]
@zstonez
Copy link

zstonez commented Mar 3, 2024

Hi,
thanks for sharing this. Its exactly that, what i wanted to do. But i havent such good skills with node-red and after copy this to node red, i tried to do this without a deConz-node. I always have a node red flow, that gives me the events from here

https://rudd-o.com/linux-and-free-software/make-the-philips-hue-tap-dial-control-anything-in-your-home

so how caan i use these to get the right input for sort_input- and mode-node or is there even a better way you can tell me?
best regards

@zstonez
Copy link

zstonez commented Mar 3, 2024

Hi after trying and trying without deConz nodes, i actually instaalled this within node red in palette. But now i dont know how to setup these nodes. What should i write into the deconz server?
any hlp aappreciaated

@zstonez
Copy link

zstonez commented Mar 4, 2024

Hi again,
after some trying, i got the 3 Buttons (1-3 dots) to the right nodes. As you can see, i got my own "hue tap dial" subflow. It has 6 exits,

  1. up
  2. down
  3. click
  4. doubleclick
  5. trippleclick
  6. else
    on port 3 i have a switch that gives me the button 1-4 when only clicked one time. I also tried the up and down exits to put on the same nodes when coming from your "sort_input". But i still cant get, where you set the modes with button 4 pressed.

flow

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