Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify request headers in order to remotely turn on dishwasher #67

Open
RaffoNin opened this issue Apr 28, 2022 · 4 comments
Open

Modify request headers in order to remotely turn on dishwasher #67

RaffoNin opened this issue Apr 28, 2022 · 4 comments

Comments

@RaffoNin
Copy link

I managed to enable remote turn on on my dishwasher by changing the request header to as follows:

  headers: {
    accept: "*/*",
    Authorization: this.token?.getAccessToken(),
    "Content-Type": "application/json",
  },

I basically just added accept value and it seems to work. Would be willing to submit a PR if this modification does not break anything.

@RaffoNin
Copy link
Author

I also noticed how the integration pings the server to get all the available action that a devices has like so:

{
"processAction": [],
"light": [],
"ambientLight": [],
"startTime": [],
"ventilationStep": [],
"programId": [],
"targetTemperature": [],
"deviceName": true,
"powerOn": false,
"powerOff": true,
"colors": [],
"modes": []
}

The problem is the device only checks processAction to look at all the available actions. The powerOn and powerOff property is controllable if it is true. powerOn is true when the device is turned off and vice versa.

Modifying the characteristics to not only check processAction but also check powerOn and powerOff and send the corresponding put method with the modified headers i mentioned above is enough to make the plugin turn on and turn off the dishwasher.

@RaffoNin
Copy link
Author

Heres a snippet of what I did to turn on the dishwasher remotely:

  if (response.data.powerOn === true && value === this.onState) {
    this.platform.log.info(`${this.deviceName}: Will turn on`);

    const response = await axios.put(
      this.platform.getActionsUrl(this.serialNumber),
      {
        powerOn: true,
      },
      this.platform.getHttpRequestConfig()
    );

    this.platform.log.debug(
      `${this.deviceName}: Process action response code: ${response.status}: "${response.statusText}"`
    );
  }

Keep in mind that I already modified the headers to contain the accept value.

@QuickSander
Copy link
Owner

QuickSander commented Jun 25, 2022

The problem is the device only checks processAction to look at all the available actions. The powerOn and powerOff property is controllable if it is true. powerOn is true when the device is turned off and vice versa.

What do you mean with device? The plug-in's Binarywrotablestate class? I was verifying my own code and I do check all possible processActions to verify them. I can't see what I did wrong yet. Can you maybe dump logging of the plugin which will tell you the allowed processActions when you try to turn it off.

@RaffoNin
Copy link
Author

Kinda late to replying my bad.

I don't really remember anymore but checking processActions to verify the actions isn't enough.

{
"processAction": [],
"light": [],
"ambientLight": [],
"startTime": [],
"ventilationStep": [],
"programId": [],
"targetTemperature": [],
"deviceName": true,
"powerOn": false,
"powerOff": true,
"colors": [],
"modes": []
}

The payload from the server also contains a "powerOn" and "powerOff" property. If, poweron is true, for example, then that means that the dishwasher can be turned on vice versa.

I haven't replied to this in so long because the branch I created has been working fine for my dishwasher until now. Im hesitant to add a pull request as I do not know what effects this has with other devices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants