Skip to content

Commit c38d7cd

Browse files
committed
fix(example): Minor tweaks
1 parent e6afad1 commit c38d7cd

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

examples/alexa_to_homeassistant.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
"id": "affffc88a48e1001",
44
"type": "subflow",
5-
"name": "Alexa -> Homeassistant",
5+
"name": "Alexa -> Home Assistant",
66
"info": "",
77
"category": "",
88
"in": [{ "x": 60, "y": 80, "wires": [{ "id": "2565add7dc2c886d" }] }],
@@ -22,8 +22,9 @@
2222
"type": "function",
2323
"z": "affffc88a48e1001",
2424
"name": "convert",
25-
"func": "const directiveToService = {\n TurnOff: \"turn_off\",\n TurnOn: \"turn_on\",\n SetBrightness: \"turn_on\",\n SetColorTemperature: \"turn_on\",\n SetColor: \"turn_on\"\n}\n\nconst {domain, entityId} = msg.metadata\n\nconst service = directiveToService[msg.payload.directive]\n\nnode.status({\n fill: service == 'turn_on' ? 'yellow' : 'grey',\n shape: 'dot',\n text: msg.payload.directive\n})\n\nreturn {\n payload: {\n domain,\n service,\n data: {\n entity_id: domain + \".\" + entityId,\n ...(service === \"turn_on\" & msg.payload.brightness !== undefined && { brightness_pct: msg.payload.brightness}),\n ...(service === \"turn_on\" & msg.payload.color_xy !== undefined && msg.payload.lightMode === \"hsb\" && { color_xy: msg.payload.color_xy }),\n ...(service === \"turn_on\" & msg.payload.colorTemperatureInKelvin !== undefined & msg.payload.lightMode === \"temp\" && { color_temp: msg.payload.colorTemperatureInKelvin}) }\n }\n}",
25+
"func": "const directiveToService = {\n TurnOff: \"turn_off\",\n TurnOn: \"turn_on\",\n SetBrightness: \"turn_on\",\n SetColorTemperature: \"turn_on\",\n SetColor: \"turn_on\"\n}\n\nconst {domain, entityId} = msg.metadata ?? {}\n\nconst service = directiveToService[msg.payload.directive]\n\nnode.status({\n fill: service == 'turn_on' ? 'yellow' : 'grey',\n shape: 'dot',\n text: msg.payload.directive\n})\n\nreturn {\n payload: {\n domain,\n service,\n data: {\n entity_id: domain + \".\" + entityId,\n ...(service === \"turn_on\" & msg.payload.brightness !== undefined && { brightness_pct: msg.payload.brightness}),\n ...(service === \"turn_on\" & msg.payload.color_xy !== undefined && msg.payload.lightMode === \"hsb\" && { color_xy: msg.payload.color_xy }),\n ...(service === \"turn_on\" & msg.payload.colorTemperatureInKelvin !== undefined & msg.payload.lightMode === \"temp\" && { color_temp: msg.payload.colorTemperatureInKelvin}) }\n }\n}",
2626
"outputs": 1,
27+
"timeout": "",
2728
"noerr": 0,
2829
"initialize": "",
2930
"finalize": "",
@@ -38,14 +39,16 @@
3839
"z": "affffc88a48e1001",
3940
"name": "",
4041
"server": "",
41-
"version": 3,
42+
"version": 5,
4243
"debugenabled": false,
43-
"service_domain": "",
44+
"domain": "",
4445
"service": "",
45-
"entityId": "",
46+
"areaId": [],
47+
"deviceId": [],
48+
"entityId": [],
4649
"data": "",
4750
"dataType": "jsonata",
48-
"mergecontext": "",
51+
"mergeContext": "",
4952
"mustacheAltTags": false,
5053
"outputProperties": [],
5154
"queue": "none",
@@ -79,7 +82,7 @@
7982
"z": "3156dd60.366d12",
8083
"name": "Kitchen Light",
8184
"topic": "",
82-
"metadata": "{\"domain\":\"light\",\"entityId\":\"kitchen_light\"}",
85+
"metadata": "{\"domain\":\"light\",\"entityId\":\"kitchen\"}",
8386
"connection": "",
8487
"template": "SWITCH",
8588
"retrievable": false,
@@ -95,7 +98,7 @@
9598
"id": "f057c4815e3be504",
9699
"type": "subflow:affffc88a48e1001",
97100
"z": "3156dd60.366d12",
98-
"name": "Alexa -> Homeassistant",
101+
"name": "",
99102
"x": 430,
100103
"y": 280,
101104
"wires": []

0 commit comments

Comments
 (0)