mattdavis90 / node-red-contrib-tado-client

Tado web API client node for Node Red
MIT License
23 stars 16 forks source link

Add tado° central switch feature #39

Open Ilkase7en opened 3 years ago

Ilkase7en commented 3 years ago

tado° has a feature to turn on and off the whole tado home with just one click inside the app. Is there a way to add this feature, or is the v2 API not capable of doing this?

mattdavis90 commented 3 years ago

Hi,

I've just had a quick look at how the app does the call. It does use a call that isn't supported in the library today.

POST https://my.tado.com/api/v2/homes/???/overlay

{
   "overlays":[
      {
         "overlay":{
            "setting":{
               "power":"OFF",
               "type":"HEATING"
            },
            "termination":{
               "typeSkillBasedApp":"MANUAL"
            }
         },
         "room":1
      }
   ]
}

and DELETE https://my.tado.com/api/v2/homes/???/overlay?rooms=1

The library does however allow you to overlay each zone/room individually by sending very similar JSON to the overlay endpoint. It would be reasonably easy to add utility functions to make these calls but the direction of the library and NodeRed node so far has been to give the user the lower level calls. It may be possible to add an option to send the same overlay to every zone/room.

Ilkase7en commented 3 years ago

I have currently solved it for all zones individually with a separate overlay function (7x setZoneOverlay and 7x cearZoneOverlay). But I was wondering if it works reliably in the long run to send all overlay commands for each zone in parallel with individual API commands.

mattdavis90 commented 3 years ago

Hi @Ilkase7en, I'm still trying to work out exactly how this would look in the NodeRedUI but I've updated the underlying library to support multiple overlays and even deprecated support for single ones. The PR is available to view here, I'm looking for some testers if you're able to. Thanks

Ilkase7en commented 2 years ago

Hi, if you explain to me how I can set up your changes to run on my system, I would be glad to test it.

mattdavis90 commented 5 months ago

I've slowly been implementing the features you asked for (apologies that it has taken a number of years).

The latest master branch has code that will let you implement a the "central switch" feature in a single call. Currently it isn't released waiting on some test.

To install it you can do something like (the below works inside a Docker container)

cd /data
npm i git+https://github.com/mattdavis90/node-red-contrib-tado-client

At that point a Flow like the one below should implement a "central switch" - make sure to create a wire to the function you wish to run - and update your home_id in the function nodes ( first argument in the return array ).

[{"id":"f13c18b017f80295","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"e7c47735e23946c7","type":"inject","z":"f13c18b017f80295","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":60,"wires":[["a214ec8ff4c3f6c5"]]},{"id":"c06dd6a372ed67b1","type":"tado","z":"f13c18b017f80295","acMode":"AUTO","apiCall":"getZones","configName":"d1cf260f.0bb368","deviceId":"","endDate":"","fanSpeed":"AUTO","geoTracking":true,"homeId":"","name":"","openWindowMode":true,"power":"on","presence":"HOME","reading":"","readingDate":"","readingId":"","reportDate":"","startDate":"","tariffId":"","tariffInCents":"0","temperature":"18","temperatureOffset":0,"terminationTimeout":900,"terminationType":"manual","timetableId":"","windowDetection":true,"windowDetectionTimeout":900,"zoneId":"3","x":320,"y":160,"wires":[[]]},{"id":"bbbe7d1e2d469540","type":"function","z":"f13c18b017f80295","name":"Clear All Overlays","func":"const overlays = [];\n\nfor (const zone of msg.payload) {\n    overlays.push(zone.id);\n}\n\nreturn {\n    apiCall: \"clearZoneOverlays\",\n    payload: [\n        12345,\n        overlays,\n        \"MANUAL\"\n    ]\n}","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":200,"wires":[["0fd706789171578d"]]},{"id":"d7ce16038bb88350","type":"function","z":"f13c18b017f80295","name":"Boost All Zones","func":"const overlays = [];\n\nfor (const zone of msg.payload) {\n    overlays.push({\n        zone_id: zone.id,\n        power: \"ON\",\n        temperature: {\n            celsius: 23\n        }\n    });\n}\n\nreturn {\n    apiCall: \"setZoneOverlays\",\n    payload: [\n        12345,\n        overlays,\n        \"MANUAL\"\n    ]\n}","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":140,"wires":[["0fd706789171578d"]]},{"id":"0fd706789171578d","type":"tado","z":"f13c18b017f80295","acMode":"AUTO","apiCall":"getMe","configName":"d1cf260f.0bb368","deviceId":"","endDate":"","fanSpeed":"AUTO","geoTracking":true,"homeId":"","name":"Custom API Call","openWindowMode":true,"power":"on","presence":"HOME","reading":"","readingDate":"","readingId":"","reportDate":"","startDate":"","tariffId":"","tariffInCents":"0","temperature":"18","temperatureOffset":0,"terminationTimeout":900,"terminationType":"manual","timetableId":"","windowDetection":true,"windowDetectionTimeout":900,"zoneId":"3","x":740,"y":160,"wires":[["acee2fb7c096e0fa"]]},{"id":"acee2fb7c096e0fa","type":"debug","z":"f13c18b017f80295","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":910,"y":160,"wires":[]},{"id":"a214ec8ff4c3f6c5","type":"tado","z":"f13c18b017f80295","acMode":"AUTO","apiCall":"getMe","configName":"d1cf260f.0bb368","deviceId":"","endDate":"","fanSpeed":"AUTO","geoTracking":true,"homeId":"","name":"","openWindowMode":true,"power":"on","presence":"HOME","reading":"","readingDate":"","readingId":"","reportDate":"","startDate":"","tariffId":"","tariffInCents":"0","temperature":"18","temperatureOffset":0,"terminationTimeout":900,"terminationType":"manual","timetableId":"","windowDetection":true,"windowDetectionTimeout":900,"zoneId":"3","x":270,"y":60,"wires":[["915c43bfccb7c54b"]]},{"id":"915c43bfccb7c54b","type":"change","z":"f13c18b017f80295","name":"Set Home ID","rules":[{"t":"set","p":"homeId","pt":"msg","to":"msg.payload.homes[0].id","tot":"jsonata"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":130,"y":160,"wires":[["c06dd6a372ed67b1"]]},{"id":"d1cf260f.0bb368","type":"tado-config","name":""}]