node-red-contrib-home-assistant-websocket
Version:
Node-RED integration with Home Assistant through websocket and REST API
1 lines • 8.93 kB
JSON
[{"id":"0050317002075c30","type":"group","z":"776c027950fc8c3f","name":"Call Service node - build a data object / process call return","style":{"label":true,"color":"#000000"},"nodes":["a67d69634829a418","86cbf80d.5a9cf8","8aad6643.9ee7a8","897a31873370f8cb","3bbb02bc34fb543a","6601ecbcd16c5aa3","fe24231bb58e259d","b0b87dc3a978e67e","8602b67dfe66a5e3","fe9baddadc8fea32","fd65cb1e1c933b3a","0acd153a39f25184","be9ef2598f33324a","8446a03e6d2b76a3","3c75c1ae78ed9894","9fc179c38d22f267","c84c9a405862bb69","f0d2bc4cc11a7608"],"x":34,"y":39,"w":1212,"h":442},{"id":"a67d69634829a418","type":"api-call-service","z":"776c027950fc8c3f","g":"0050317002075c30","name":"","server":"","version":5,"debugenabled":false,"domain":"climate","service":"set_temperature","areaId":[],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1030,"y":220,"wires":[[]]},{"id":"86cbf80d.5a9cf8","type":"api-call-service","z":"776c027950fc8c3f","g":"0050317002075c30","name":"","server":"","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.kitchen"],"data":"{\"brightness\": $min([$entities(\"light.kitchen\").attributes.brightness + $number($entities(\"input_number.brightness\").state), 255])}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","output_location":"payload","output_location_type":"msg","x":730,"y":120,"wires":[[]]},{"id":"8aad6643.9ee7a8","type":"server-state-changed","z":"776c027950fc8c3f","g":"0050317002075c30","name":"Remote Button","server":"","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"sensor.button","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":520,"y":120,"wires":[["86cbf80d.5a9cf8"]]},{"id":"897a31873370f8cb","type":"server-state-changed","z":"776c027950fc8c3f","g":"0050317002075c30","name":"Input Number (Temp)","server":"","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"input_number.help_temp_number","entityIdType":"exact","outputInitially":false,"stateType":"num","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":540,"y":220,"wires":[["fe24231bb58e259d"]]},{"id":"3bbb02bc34fb543a","type":"inject","z":"776c027950fc8c3f","g":"0050317002075c30","name":"Manual Test","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":530,"y":80,"wires":[["86cbf80d.5a9cf8"]]},{"id":"6601ecbcd16c5aa3","type":"comment","z":"776c027950fc8c3f","g":"0050317002075c30","name":"1a - JSONata builds object in Call Service node \\n Increase light brightness with remote","info":"","x":240,"y":100,"wires":[]},{"id":"fe24231bb58e259d","type":"change","z":"776c027950fc8c3f","g":"0050317002075c30","name":"Service Call Settings","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t \"target\": {\"entity_id\": $globalContext(\"AClist\")},\t \"data\": {\t \"temperature\": payload,\t \"hvac_mode\": payload>20 ? \"heat\" : \"cool\"\t }\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":220,"wires":[["a67d69634829a418"]]},{"id":"b0b87dc3a978e67e","type":"api-call-service","z":"776c027950fc8c3f","g":"0050317002075c30","name":"Send notification","server":"","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_geoff_phone","areaId":[],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":790,"y":300,"wires":[[]]},{"id":"8602b67dfe66a5e3","type":"server-state-changed","z":"776c027950fc8c3f","g":"0050317002075c30","name":"Last person to leave","server":"","version":5,"outputs":2,"exposeAsEntityConfig":"","entityId":"person.","entityIdType":"substring","outputInitially":false,"stateType":"str","ifState":"\"home\" in $entities().*[$substringBefore(entity_id,\".\")=\"person\"].state","ifStateType":"jsonata","ifStateOperator":"jsonata","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"{\t \"data\": {\t \"message\": \"The \" & $join($entities().*[state = \"on\" and entity_id ~> /^light|^switch/].attributes.friendly_name, \", \") & \" are on.\",\t \"title\": \"Things Left On \" & $entity().attributes.friendly_name\t }\t}","valueType":"jsonata"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":530,"y":300,"wires":[[],["b0b87dc3a978e67e"]]},{"id":"fe9baddadc8fea32","type":"api-call-service","z":"776c027950fc8c3f","g":"0050317002075c30","name":"","server":"","version":5,"debugenabled":false,"domain":"weather","service":"get_forecasts","areaId":[],"deviceId":[],"entityId":["weather.forecast_home"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"results","propertyType":"msg","value":"","valueType":"results"}],"queue":"none","x":360,"y":440,"wires":[["8446a03e6d2b76a3"]]},{"id":"fd65cb1e1c933b3a","type":"inject","z":"776c027950fc8c3f","g":"0050317002075c30","name":"Set Forecast type","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"data\": {\"type\": \"hourly\"}}","payloadType":"jsonata","x":160,"y":440,"wires":[["fe9baddadc8fea32"]]},{"id":"0acd153a39f25184","type":"debug","z":"776c027950fc8c3f","g":"0050317002075c30","name":"Start Hour","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"$substringAfter(payload.time,\"T\")~>$substringBefore(\"+\")","targetType":"jsonata","statusVal":"$substringAfter(payload.time,\"T\")~>$substringBefore(\"+\")","statusType":"auto","x":1130,"y":440,"wires":[]},{"id":"be9ef2598f33324a","type":"comment","z":"776c027950fc8c3f","g":"0050317002075c30","name":"1d - JSONata extracts details from service call return \\n using Inject, Change, and Debug nodes","info":"","x":250,"y":380,"wires":[]},{"id":"8446a03e6d2b76a3","type":"change","z":"776c027950fc8c3f","g":"0050317002075c30","name":"Extract forecast time and arrays of hourly temp, cloud, and rain","rules":[{"t":"set","p":"payload","pt":"msg","to":"results.*.forecast{\t \"time\": $[0].datetime,\t \"temp\": $.temperature,\t \"cloud\": $.cloud_coverage,\t \"rain\": $.precipitation\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":440,"wires":[["0acd153a39f25184","3c75c1ae78ed9894"]]},{"id":"3c75c1ae78ed9894","type":"debug","z":"776c027950fc8c3f","g":"0050317002075c30","name":"Payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1120,"y":400,"wires":[]},{"id":"9fc179c38d22f267","type":"comment","z":"776c027950fc8c3f","g":"0050317002075c30","name":"1b - JSONata builds object in Change Node \\n Set a/c target temperature and mode","info":"","x":230,"y":200,"wires":[]},{"id":"c84c9a405862bb69","type":"comment","z":"776c027950fc8c3f","g":"0050317002075c30","name":"1c - JSONata builds object in Event: State node \\n Send notification when leaving home","info":"","x":240,"y":300,"wires":[]},{"id":"f0d2bc4cc11a7608","type":"inject","z":"776c027950fc8c3f","g":"0050317002075c30","name":"Turn Off","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\t \"domain\": \"homeassistant\",\t \"service\": \"turn_off\",\t \"target\": {\t \"area_id\": [\"bedroom\"]\t },\t \"data\": {} \t}","payloadType":"jsonata","x":820,"y":180,"wires":[["a67d69634829a418"]]}]