mattdavis90 / node-red-contrib-tado-client

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

Fan level doesn't work #54

Closed neonsp closed 1 year ago

neonsp commented 1 year ago

Trying to set the fan level doesn't work.

Firmware: v118.5

Via app.tado.com it works. Following json with the developers request: PUT Request to URL: https://my.tado.com/api/v2/homes/</zones/</overlay?ngsw-bypass=true {"termination":{"typeSkillBasedApp":"MANUAL"},"setting":{"type":"AIR_CONDITIONING","power":"ON","mode":"HEAT","temperature":{"celsius":25,"fahrenheit":77},"fanLevel":"LEVEL1","verticalSwing":"OFF","horizontalSwing":"OFF","light":"ON"}}

zone capabilities: {"_msgid":"9132a6608f40b3e6","payload":{"type":"AIR_CONDITIONING","FAN":{"fanLevel":["LEVEL2","LEVEL3","AUTO","LEVEL1"],"verticalSwing":["ON","OFF"],"horizontalSwing":["OFF","ON"],"light":["OFF","ON"]},"HEAT":{"temperatures":{"celsius":{"min":16,"max":30,"step":1},"fahrenheit":{"min":61,"max":86,"step":1}},"fanLevel":["LEVEL2","LEVEL3","AUTO","LEVEL1"],"verticalSwing":["ON","OFF"],"horizontalSwing":["OFF","ON"],"light":["OFF","ON"]},"COOL":{"temperatures":{"celsius":{"min":18,"max":30,"step":1},"fahrenheit":{"min":64,"max":86,"step":1}},"fanLevel":["LEVEL2","LEVEL3","AUTO","LEVEL1"],"verticalSwing":["ON","OFF"],"horizontalSwing":["OFF","ON"],"light":["OFF","ON"]},"DRY":{"fanLevel":["LEVEL2","LEVEL3","AUTO","LEVEL1"],"verticalSwing":["ON","OFF"],"horizontalSwing":["OFF","ON"],"light":["OFF","ON"]},"AUTO":{"verticalSwing":["ON","OFF"],"horizontalSwing":["OFF","ON"],"light":["OFF","ON"]},"initialStates":{"mode":"COOL","modes":{"COOL":{"temperature":{"celsius":24,"fahrenheit":75},"fanLevel":"LEVEL2","verticalSwing":"OFF","horizontalSwing":"OFF","light":"ON"},"HEAT":{"temperature":{"celsius":23,"fahrenheit":74},"fanLevel":"LEVEL2","verticalSwing":"OFF","horizontalSwing":"OFF","light":"ON"},"DRY":{"fanLevel":"LEVEL2","verticalSwing":"OFF","horizontalSwing":"OFF","light":"ON"},"FAN":{"fanLevel":"LEVEL2","verticalSwing":"OFF","horizontalSwing":"OFF","light":"ON"},"AUTO":{"verticalSwing":"OFF","horizontalSwing":"OFF","light":"ON"}}}},"topic":"getZoneCapabilities"}

mattdavis90 commented 1 year ago

That looks like the sort of API call the library is making. Do you know what version of the plugin you're using? Do you have an example flow that you can share? I don't own an AC to test so the code for ACs is purely based on contributions.

neonsp commented 1 year ago

Updated with version, 118.5 and capabilities.

Thanks for the quick answer btw

mattdavis90 commented 1 year ago

No problem. Do you know which version of this library you're using?

neonsp commented 1 year ago

0.10.4

mattdavis90 commented 1 year ago

How adept are you with JavaScript? The underlying library should give you a better sense of what's going wrong and give you a point to debug the outgoing messages. I'm wondering if some of the logic that determines whether to use fanSpeed or fanLevel is failing. Not having an AC unit has made this quite tricky to debug in the past.

neonsp commented 1 year ago

Where is that library so I can check? And how to debug it?

mattdavis90 commented 1 year ago

Sorry, I should have included that.

https://github.com/mattdavis90/node-tado-client

Probably in this function https://github.com/mattdavis90/node-tado-client/blob/c944bf9be23ca2f3620c0c4cb19ad79f27ed18f7/src/index.ts#L494

Maybe start with adding a console.log(config); just before this API call https://github.com/mattdavis90/node-tado-client/blob/c944bf9be23ca2f3620c0c4cb19ad79f27ed18f7/src/index.ts#L591

Sorry I'm having to ask you fix the problem.

neonsp commented 1 year ago

Could you share a simple html file with the client imported and working?

mattdavis90 commented 1 year ago

The library runs using Node.js rather than in browser. Something like this should do what you want.

import { Tado } from './build/index.js';

async function run() {
    try {
        const tado = new Tado('email_address', 'password');

        const me = await tado.getMe();
        const home_id = me.homes[0].id;

        await tado.setZoneOverlays(home_id, [
            {
                power: 'ON',
                temperature: { celsius: 25 },
                mode: 'HEAT',
                fanLevel: 'LEVEL1',
                zone_id: 2
            }
        ]);
    } catch (err) {
        console.warn(err);
    }
}

run()
neonsp commented 1 year ago

image

Do you use telegram?

mattdavis90 commented 1 year ago

No, sorry. Did you run an npm i in the repo to install dependencies?

neonsp commented 1 year ago

config.overlays[0].overlay.setting= { type: 'AIR_CONDITIONING', power: 'ON', mode: 'HEAT', temperature: { celsius: 25 }, fanSpeed: 'LEVEL1' }

mattdavis90 commented 1 year ago

fanSpeed 😢

Ok, I'll have a dig around and see if I can work out why that's happening

neonsp commented 1 year ago

Is it possible that you have to check on the capabilities that there is fanLevel and not fanSpeed?

neonsp commented 1 year ago

zone_capabilities.AUTO = { verticalSwing: [ 'ON', 'OFF' ], horizontalSwing: [ 'ON', 'OFF' ], light: [ 'OFF', 'ON' ] }

neonsp commented 1 year ago

image

The auto doesn't contain the fanLevel, but as you can see in the screenshot, in all the other methods, there is the fanLevel

mattdavis90 commented 1 year ago

Yeh, the library attempts to check. Good to know that AUTO doesn't contain either type. I should be able to throw together a fix when I'm back on my laptop

mattdavis90 commented 1 year ago

This should now be fixed in the underlying library. I have another PR to merge then I'll update this library with the changes

mattdavis90 commented 1 year ago

I've just published v0.10.5

neonsp commented 1 year ago

I just tested it, now it turns on, but the fan level is always medium.

If I try to setZoneOverlay without turning it off, I see in node red the following error:

"Invalid value for property setting.fanLevel"

On top of that, not there is a red triangle above each tado node, and when I put the mouse over it, "Invalid properties: Invalid number"

image

neonsp commented 1 year ago

Using the website app.tado.com the fanLevel parameter for the request selecting the slow is 'LEVEL1':

image

{"termination":{"typeSkillBasedApp":"MANUAL"},"setting":{"temperature":{"celsius":23,"fahrenheit":73.4},"fanLevel":"LEVEL1","verticalSwing":"OFF","horizontalSwing":"OFF","light":"ON","mode":"HEAT","type":"AIR_CONDITIONING","power":"ON"}}

mattdavis90 commented 1 year ago

I'm not sure what the little triangles are; they're not something my code does. The "Invalid value" error message isn't one of mine either I don't think. I'm wondering if the NodeRed app tries to sanity check something and errors.

I'll do some digging to see what that might be.

LEVEL1 should be an option in the dropdown.

neonsp commented 1 year ago

Looks like the values in the dropdown are AUTO, LOW, MIDDLE and HIGH, perhaps that's the issue

mattdavis90 commented 1 year ago

Probably. Sounds like I missed that when Tado switched from fanSpeed to fanLevel. I'll be able to get the change out tomorrow.

neonsp commented 1 year ago

Perfect, thank you!

mattdavis90 commented 1 year ago

I've added the option and released v0.10.6 which hopefully fixes your issue.

neonsp commented 1 year ago

Sadly its not working. In node red I get this error:

image

neonsp commented 1 year ago

I'm checking now with the method "setZoneOverlay", and the issue in that method is that "zone_state.setting['fanLevel']" doesn't exists as zone_state.setting = { type: 'AIR_CONDITIONING', power: 'OFF' } with no other information. Forcing it to put fanLevel instead of fanSpeed it works.

About the "setZoneOverlays" I don't know, this is part of the request:

url: 'https://my.tado.com/api/v2/homes/589180/overlay', method: 'post', data: '{"overlays":[{"overlay":{"setting":{"type":"AIR_CONDITIONING","power":"ON","mode":"HEAT","temperature":{"celsius":25},"fanLevel":"LEVEL1"},"termination":{"typeSkillBasedApp":"MANUAL"}},"room":6}]}',

Edit to add: Looks like in node red the method "setZoneOverlay" is the one used, and not "setZoneOverlays", so there are 2 issues

mattdavis90 commented 1 year ago

I've just published v0.13.6 of the underlying library whereby setZoneOverlay should now use the Zone Capabilities call. Are you able to test with that version before I update NodeRed?

Sorry that you're having these issues. I don't use the zone overlay calls or own an AC unit.

neonsp commented 1 year ago

You didn't updated the build/index.js, so I replicated your changes and now "setZoneOverlay" works!

mattdavis90 commented 1 year ago

Ah. I'm working off my phone so couldn't rebuild. Thanks for testing. I'll rebuild the JS later and also publish a NodeRed build

mattdavis90 commented 1 year ago

This should be included in v0.10.7 now

neonsp commented 1 year ago

https://flows.nodered.org/node/node-red-contrib-tado-client

I can't update, it shows latest version 0.10.6

mattdavis90 commented 1 year ago

I've forced the NodeRed server to check for updates. Hopefully it will pull through soon

neonsp commented 1 year ago

Updated. Now it works perfectly! Thank you so much for keeping this updated!

About the "setZoneOverlays", do you know what can be the issue, or can I help you in any way to debug that one? I don't really need it, but I think It would be great to get that one also working.

One last question, any plans on supporting the horizontal and vertical swing control? Should I create a new issue describing options, parameters and request?

mattdavis90 commented 1 year ago

No problem.

SetZoneOverlays should work if you call it directly and pass in a list of objects. That call should already support horizontal and vertical swing (and light I think).

Exposing the call in NodeRed was mostly an issue of time. The GUI elements are a pain because you need to build up the list of zones, which depends on each zone's capabilities. I found an example I could use but could never quite get it working. Issues #39 and #44 are sort of tracking this. You're welcome to contribute if you have the time. My availability is limited; I'm on annual leave this week so have a little more time than usual.

mattdavis90 commented 1 year ago

Hi @neonsp, Are you happy for me to close this issue?

neonsp commented 1 year ago

Hi @mattdavis90 , yes you can close it.

Thank you again

mattdavis90 commented 1 year ago

No problem. Glad it's working for you now