Skip to content

Commit

Permalink
fix(example): Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
csuermann committed Jan 20, 2024
1 parent e6afad1 commit c38d7cd
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions examples/alexa_to_homeassistant.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"id": "affffc88a48e1001",
"type": "subflow",
"name": "Alexa -> Homeassistant",
"name": "Alexa -> Home Assistant",
"info": "",
"category": "",
"in": [{ "x": 60, "y": 80, "wires": [{ "id": "2565add7dc2c886d" }] }],
Expand All @@ -22,8 +22,9 @@
"type": "function",
"z": "affffc88a48e1001",
"name": "convert",
"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}",
"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}",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
Expand All @@ -38,14 +39,16 @@
"z": "affffc88a48e1001",
"name": "",
"server": "",
"version": 3,
"version": 5,
"debugenabled": false,
"service_domain": "",
"domain": "",
"service": "",
"entityId": "",
"areaId": [],
"deviceId": [],
"entityId": [],
"data": "",
"dataType": "jsonata",
"mergecontext": "",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
Expand Down Expand Up @@ -79,7 +82,7 @@
"z": "3156dd60.366d12",
"name": "Kitchen Light",
"topic": "",
"metadata": "{\"domain\":\"light\",\"entityId\":\"kitchen_light\"}",
"metadata": "{\"domain\":\"light\",\"entityId\":\"kitchen\"}",
"connection": "",
"template": "SWITCH",
"retrievable": false,
Expand All @@ -95,7 +98,7 @@
"id": "f057c4815e3be504",
"type": "subflow:affffc88a48e1001",
"z": "3156dd60.366d12",
"name": "Alexa -> Homeassistant",
"name": "",
"x": 430,
"y": 280,
"wires": []
Expand Down

0 comments on commit c38d7cd

Please sign in to comment.