Für alle die den SoC vom Polestar gerne hätte und keine Ports nach außen öffnen wollen, habe ich jetzt die IOBroker Implementierung in eine NodeRed Version umgebaut.
Vorbedingung:
- NodeRed sollte installiert sein
- Tibber Account sollte erstellt sein
- Polestar ist zu Tibber hinzugefügt
Wenn das alles passt, dann das JSON unten in NodeRed importieren, in der ersten Inject Node im JSON Username und Passwort vom Tibber setzen, dann sollte es eigentlcih auch schon funktionieren.
[{"id":"eead83edc52abe9d","type":"http request","z":"981980d8b7db0ea7","name":"Tibber getToken","method":"POST","ret":"obj","paytoqs":"ignore","url":"https://app.tibber.com/login.credentials","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":420,"y":2060,"wires":[["74d37211a81aaa87"]]},{"id":"fb6eab53b1a336f6","type":"inject","z":"981980d8b7db0ea7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"300","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"{\"@type\":\"login\",\"email\":\"myusername\",\"password\":\"mypassword\"}","payloadType":"json","x":250,"y":2060,"wires":[["eead83edc52abe9d"]]},{"id":"74d37211a81aaa87","type":"function","z":"981980d8b7db0ea7","name":"getCorrectDataFromTibber","func":"var mytoken = msg.payload.token;\n\nmsg.headers = {\n 'Authorization': 'Bearer ' + mytoken\n }\nmsg.url = 'https://app.tibber.com/v4/gql?query=%7Bme%7Bhomes%7BelectricVehicles%7BlastSeen%0A%20%20battery%20%7Bpercent%7D%7D%7D%7D%7D';\nmsg.mytoken = mytoken;\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":820,"y":2060,"wires":[["1aa8379fbbb3a380"]]},{"id":"a83bd3e26f8f56ce","type":"function","z":"981980d8b7db0ea7","name":"get SoC","func":"msg.payload = msg.payload.data.me.homes[0].electricVehicles[0].battery.percent\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1260,"y":2060,"wires":[["cb2d4945a9613763"]]},{"id":"1aa8379fbbb3a380","type":"http request","z":"981980d8b7db0ea7","name":"Tibber getSoC","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":1080,"y":2060,"wires":[["a83bd3e26f8f56ce"]]},{"id":"cb2d4945a9613763","type":"debug","z":"981980d8b7db0ea7","name":"SoC Data from Tibber","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1480,"y":2060,"wires":[]}]