Example usage of Senec App API with Node Red
Example Flow to use Senec APP Api 4.3.3 to collect Data from the app-gateway the app uses as well. Enter username and apssword in the config Node and inject to initialize flow variables. Use login flow first to obtain permanent token Use systems to obtain system id used by other services
Available services are documented at https://documenter.getpostman.com/view/932140/2s9YXib2td
[{"id":"fbd0cf6e86f963d3","type":"tab","label":"Senec APP API","disabled":false,"info":"","env":[]},{"id":"98ccb7f9f8dcc28c","type":"inject","z":"fbd0cf6e86f963d3","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"username\":$flowContext(\"username\"),\"password\":$flowContext(\"password\")}","payloadType":"jsonata","x":90,"y":240,"wires":[["eed9c58ad9141b8f"]]},{"id":"eed9c58ad9141b8f","type":"http request","z":"fbd0cf6e86f963d3","name":"login","method":"POST","ret":"obj","paytoqs":"ignore","url":"https://app-gateway.prod.senec.dev/v1/senec/login","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"Content-Type","valueType":"other","valueValue":"application/json"}],"x":310,"y":240,"wires":[["2b75af4deb61d0ca"]]},{"id":"aeede202545dee4d","type":"debug","z":"fbd0cf6e86f963d3","name":"debug 43","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1000,"y":240,"wires":[]},{"id":"8ea298d22026a934","type":"config","z":"fbd0cf6e86f963d3","name":"","properties":[{"p":"SENEC_TOKEN","pt":"flow","to":"to be set with senec login service","tot":"str"},{"p":"SENEC_ANLAGE","pt":"flow","to":"0","tot":"num"},{"p":"SENEC_CONTROLLER","pt":"flow","to":"set with technical data-service","tot":"str"},{"p":"username","pt":"flow","to":"enter username","tot":"str"},{"p":"password","pt":"flow","to":"enter password","tot":"str"}],"active":true,"x":90,"y":120,"wires":[]},{"id":"2b75af4deb61d0ca","type":"change","z":"fbd0cf6e86f963d3","name":"","rules":[{"t":"set","p":"SENEC_TOKEN","pt":"flow","to":"payload.token","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":240,"wires":[["aeede202545dee4d"]]},{"id":"3ae5ef98d9520e65","type":"http request","z":"fbd0cf6e86f963d3","name":"systems","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://app-gateway.prod.senec.dev/v1/senec/systems","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Authorization","keyValue":"","valueType":"msg","valueValue":"SENEC_TOKEN"}],"x":320,"y":320,"wires":[["ceca6d24e3d55898","ab947e495561b414"]]},{"id":"ab947e495561b414","type":"debug","z":"fbd0cf6e86f963d3","name":"debug 44","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1060,"y":600,"wires":[]},{"id":"a211f594f00f56bc","type":"function","z":"fbd0cf6e86f963d3","name":"timestamp von ms in sec","func":"msg.NOW = Math.floor(msg.NOW/1000);\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":720,"wires":[["520ea25be03fcc2c"]]},{"id":"ceca6d24e3d55898","type":"change","z":"fbd0cf6e86f963d3","name":"","rules":[{"t":"set","p":"SENEC_ANLAGE","pt":"flow","to":"payload[0].id","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":320,"wires":[[]]},{"id":"5092de5fdcc4bbc1","type":"inject","z":"fbd0cf6e86f963d3","name":"","props":[{"p":"SENEC_ANLAGE","v":"SENEC_ANLAGE","vt":"flow"},{"p":"SENEC_TOKEN","v":"SENEC_TOKEN","vt":"flow"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":90,"y":440,"wires":[["534be77e0f2ea08d"]]},{"id":"534be77e0f2ea08d","type":"http request","z":"fbd0cf6e86f963d3","name":"systems/{{SENEC_ANLAGE}}/technical-data","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://app-gateway.prod.senec.dev/v1/senec/systems/{{SENEC_ANLAGE}}/technical-data","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Authorization","keyValue":"","valueType":"msg","valueValue":"SENEC_TOKEN"}],"x":430,"y":440,"wires":[["ab947e495561b414","8981df1a97dda17a"]]},{"id":"7b1a9c972ad0191c","type":"inject","z":"fbd0cf6e86f963d3","name":"","props":[{"p":"SENEC_TOKEN","v":"SENEC_TOKEN","vt":"flow"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":90,"y":320,"wires":[["3ae5ef98d9520e65"]]},{"id":"72c3240cedca531b","type":"inject","z":"fbd0cf6e86f963d3","name":"","props":[{"p":"SENEC_ANLAGE","v":"SENEC_ANLAGE","vt":"flow"},{"p":"SENEC_TOKEN","v":"SENEC_TOKEN","vt":"flow"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":90,"y":520,"wires":[["7b79b21875e1bc27"]]},{"id":"7b79b21875e1bc27","type":"http request","z":"fbd0cf6e86f963d3","name":"v1/systems/{{SENEC_ANLAGE}}/dashboard","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://app-gateway.prod.senec.dev/v1/senec/systems/{{SENEC_ANLAGE}}/dashboard","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Authorization","keyValue":"","valueType":"msg","valueValue":"SENEC_TOKEN"}],"x":430,"y":520,"wires":[["ab947e495561b414"]]},{"id":"fc0a471cf2edf53b","type":"inject","z":"fbd0cf6e86f963d3","name":"","props":[{"p":"SENEC_ANLAGE","v":"SENEC_ANLAGE","vt":"flow"},{"p":"SENEC_TOKEN","v":"SENEC_TOKEN","vt":"flow"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":90,"y":600,"wires":[["3aa553f9da1bb32d"]]},{"id":"3aa553f9da1bb32d","type":"http request","z":"fbd0cf6e86f963d3","name":"v2/systems/{{SENEC_ANLAGE}}/dashboard","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://app-gateway.prod.senec.dev/v2/senec/systems/{{SENEC_ANLAGE}}/dashboard","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Authorization","keyValue":"","valueType":"msg","valueValue":"SENEC_TOKEN"}],"x":430,"y":600,"wires":[["ab947e495561b414"]]},{"id":"428c3d4db14c4c20","type":"inject","z":"fbd0cf6e86f963d3","name":"","props":[{"p":"SENEC_ANLAGE","v":"SENEC_ANLAGE","vt":"flow"},{"p":"SENEC_TOKEN","v":"SENEC_TOKEN","vt":"flow"},{"p":"DATE","v":"2023-11-12","vt":"str"},{"p":"PERIOD","v":"DAY","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":90,"y":660,"wires":[["d7c6a15e81b1a6a6"]]},{"id":"d7c6a15e81b1a6a6","type":"http request","z":"fbd0cf6e86f963d3","name":"v1/systems/{{SENEC_ANLAGE}}/Monitor","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://app-gateway.prod.senec.dev/v1/senec/monitor/{{SENEC_ANLAGE}}/data?period={{PERIOD}}&date={{DATE}}&locale=de_DE&timezone=Europe%2FBerlin","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Authorization","keyValue":"","valueType":"msg","valueValue":"SENEC_TOKEN"}],"x":420,"y":660,"wires":[["ab947e495561b414"]]},{"id":"3032dcc91dbfb39b","type":"inject","z":"fbd0cf6e86f963d3","name":"","props":[{"p":"SENEC_ANLAGE","v":"SENEC_ANLAGE","vt":"flow"},{"p":"SENEC_TOKEN","v":"SENEC_TOKEN","vt":"flow"},{"p":"NOW","v":"","vt":"date"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":90,"y":720,"wires":[["a211f594f00f56bc"]]},{"id":"520ea25be03fcc2c","type":"http request","z":"fbd0cf6e86f963d3","name":"v1/senec/systems/{{SENEC_ANLAGE}}/measurements","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://app-gateway.prod.senec.dev/v1/senec/systems/{{SENEC_ANLAGE}}/measurements?resolution=YEAR&from=1672531200&to={{NOW}}","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Authorization","keyValue":"","valueType":"msg","valueValue":"SENEC_TOKEN"}],"x":740,"y":720,"wires":[["ab947e495561b414"]]},{"id":"8981df1a97dda17a","type":"change","z":"fbd0cf6e86f963d3","name":"","rules":[{"t":"set","p":"SENEC_CONTROLLER","pt":"flow","to":"payload.mcu.mainControllerSerial","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":440,"wires":[[]]},{"id":"f35020853d68f4b7","type":"comment","z":"fbd0cf6e86f963d3","name":"Initialisierung Flow Variable. Senec username und password eintragen","info":"","x":270,"y":80,"wires":[]},{"id":"57092ded5197a7e8","type":"comment","z":"fbd0cf6e86f963d3","name":"Login Service holt Token und setzt in flow Variable SENEC_TOKEN zur Nutzung in allen weiteren Services","info":"","x":380,"y":180,"wires":[]},{"id":"a3e685afbc0384db","type":"comment","z":"fbd0cf6e86f963d3","name":"Login Service holt Analgen Nummer und setzt in flow Variable SENEC_ANLAGE zur Nutzung in allen weiteren Services","info":"","x":420,"y":280,"wires":[]},{"id":"89ac81f8703a9590","type":"comment","z":"fbd0cf6e86f963d3","name":"Login Service holt Controller Nummer und setzt in flow Variable SENEC_CONTOLLER zur Nutzung in Service Online state","info":"","x":430,"y":380,"wires":[]},{"id":"0d87858139708a3b","type":"inject","z":"fbd0cf6e86f963d3","name":"","props":[{"p":"SENEC_CONTROLLER","v":"SENEC_CONTROLLER","vt":"flow"},{"p":"SENEC_TOKEN","v":"SENEC_TOKEN","vt":"flow"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":90,"y":780,"wires":[["0c53bbb0dc3dd47a"]]},{"id":"0c53bbb0dc3dd47a","type":"http request","z":"fbd0cf6e86f963d3","name":"v2/systems/{{SENEC_CONTROLLER}}/online-state","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://app-gateway.prod.senec.dev/v1/senec/systems/{{SENEC_CONTROLLER}}/online-state","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Authorization","keyValue":"","valueType":"msg","valueValue":"SENEC_TOKEN"}],"x":450,"y":780,"wires":[["ab947e495561b414"]]}]