diy-melview icon indicating copy to clipboard operation
diy-melview copied to clipboard

Local Commands ++

Open aurc opened this issue 3 years ago • 7 comments

Hello NovaGL,

I've been working on a Homebridge plugin (melview-mitsubishi-au-nz) and the information in this repo was crucial to get it across the line. So, first of all, thank you a lot!

One issue I'd like to get resolved is the delay for the unit to respond, which is also happens with other integrations (e.g. Alexa). With homebridge, there's a bridge running on the local network, therefore I'd like to improve the experience through issue local commands.

Based on the information I gathered, my workflow is:

  1. Call unitcapabilities.aspx to extract local IP
  2. Call unitcommand.aspx with the following payload (for turning it ON):
  {
    "unitid":"{{unitid}}",
    "v":2,
    "commands":"PW1",
    "lc":1
  }
  1. Upon successful return of the above, extract the LC value and POST to the local unit as follows: POST: http://192.168.44.22/smart (example local IP) Body:
 <?xml version="1.0" encoding="UTF-8"?>
<CSV>
    <CONNECT>ON</CONNECT>
    <CODE>
        <VALUE>U0xjQ2h6RTM ... 0z19wTEVs+U=</VALUE>
    </CODE>
</CSV>

I keep getting a 403 Forbidden. I've tried several things, including using BASIC Auth passing the unit SSID and KEY.

I've tried with several of my units: Unit 1: * Model: MSZ-GL35VGD * Wifi Interface MAC-568IF-E Unit 2: * Model: MSZ-GL71VGD * Wifi Interface MAC-568IF-E Unit 3: * Model: MSZ-AP25VGD * Wifi Interface MAC-568IF-E

Could you please kindly clarify if I'm missing something?

aurc avatar Jul 03 '21 14:07 aurc

I'll be keen to see the outcome of this, I have also been writing an integration for my MEL air conditioner, as well as other MEL / Kumo A/C's in the US and Europe, for my Hubitat system, and have also benefitted greatly from this example. Local control is soon going to come up as the next feature to develop, so am keen to see more details on exactly how it is done. It's been a while since I looked at some notes on how to do it, but what you have outlined sounds like what I remember. If I come across anything I'll post here with more details.

sburke781 avatar Jul 12 '21 01:07 sburke781

Seeing as NovaGL hasn't responded I'll chime in.

I haven't updated my config for ages, and to be honest I can't remember half of it, but a quick look at my node red flow for the local unit commands and it seems what you are doing makes sense. You shouldn't need any auth to the unit, or at least I am not using any.

My XML payload looks like this.

<?xml version="1.0" encoding="UTF-8"?>
<CSV>
	<CONNECT>ON</CONNECT>
	<CODE>
		<VALUE>{{{payload.lc}}}</VALUE>
	</CODE>
</CSV>

The device URL is "http://" + global.get("ac_localip") + "/smart"

and my HTTP request is formatted as follows; Method: POST Return UTF-8 String

You should receive a response, but we never could decipher it enough to use it for anything useful

Let me know if you need any other details and I'll see if I can work them out again :)

Wob76 avatar Jul 12 '21 05:07 Wob76

What I ended up doing was: The device URL is "http://" + global.get("ac_localip") + "/smart"

<?xml version="1.0" encoding="UTF-8"?>
<ESV>{{{payload.lc}}}</ESV>

I managed to sniff the app and the AC units, and basically the app passes the whole payload enclosed in the <ESV> tags. I'd really much prefer know what commands I'm sending and also have the option to send them should the internet be down, but it's doing for now.

I can't make the <CSV> payload work.

aurc avatar Jul 12 '21 10:07 aurc

Yeah that is not an option, the lc is an encoded packet, and at least when I did all this a few years back there was no knowledge of how it is encoded. We did try logging packets to see if we could decipher it but didn't have any luck.

In the end sending the local packets really just helps to speed up the response time, so you are not waiting for the servers message.

There should be an old issue where NovaGL and I discussed this.

Wob76 avatar Jul 12 '21 10:07 Wob76

I've been looking at a driver for Kumo Cloud in the states (their equivalent of MELView) that encodes commands, I am hoping the same can be done for MELView.

https://github.com/fjs21/homebridge-kumo/blob/4c5b91a2d95d36e7fb9cec30ef279c3fc53a17a6/src/kumo-api.ts#L418

sburke781 avatar Jul 12 '21 13:07 sburke781

I'm a bit rusty on this as my current place doesn't use this air conditioner.

As Wob76 mentioned we were unable to find a truly local version.

When you posted the local command that got forbidden did you include headers?

msg.headers = {
    'Origin': 'http://app.melview.net',
    'Referer': 'http://app.melview.net/ata.html',
    'Content-Type': 'text/plain;charset=UTF-8',
    'Host': url
    
};

NovaGL avatar Jul 13 '21 09:07 NovaGL

@aurc I apologize for bumping this, but I'm currently looking into this whole ecosystem. On newer wifi adapters such as yours they did indeed change the whole format from CSV to ESV. I don't have any melview supported device for testing unfortunately as I'm in Europe where we are forced onto MELCloud.

The lc code snippet you shared looks a lot like base64 encoded to me and it's probably encoded again or encrypted after that. Did you ever test how strongly these codes change between tiny adjustments of the device and/or would you mind posting an unredacted one for analysis if you have one?

dragonbane0 avatar Sep 28 '23 23:09 dragonbane0