Midea/Inventor (and other brand) Air Condition API

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

daemonshome
Posts: 19
Joined: Saturday 30 May 2020 15:30
Target OS: -
Domoticz version:
Contact:

Re: Midea/Inventor (and other brand) Air Condition API

Post by daemonshome »

Just for the record.

Just got another SK102, and it seems good. It looks like Version2, which is supported, not like V3 which I have tried earlier.
Need to test in detail, but the AC seems to be available and functioning properly under domoticz.

Code: Select all

# sudo midea-discover 
        INFO:msmart.cli:msmart version: 0.1.23
        INFO:msmart.cli:Sending Device Scan Broadcast...
        INFO:msmart.cli:Midea Local Data 192.168.1.130 xyz
        INFO:msmart.cli:Decrypt Reply: 192.168.1.130 xyz
        INFO:msmart.cli:*** Found a supported device - type: '0xac' - version: V2 - ip: 192.168.1.130 - port: 
        6444 - id: xyz - sn: xyz - ssid: net_ac_A97E
        

Notes:
1. It shows 102.5 degC if off, then on - seems ok.
2. response seems a bit laggy // domoticz-to AC.
3. in domoticz I press On, seems nothing, then suddelnly in phone app i see it is on, then i press heat, then suddenly goes to FAN.
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Midea/Inventor (and other brand) Air Condition API

Post by waltervl »

waltervl wrote: Sunday 27 September 2020 22:03
LouiS22 wrote: Monday 06 July 2020 12:21
Alain wrote: Saturday 04 July 2020 23:50 I created a repository, but but it's all a bit messy. Not quite sure how to properly go about it as I have used parts from Mac_Zhou (msmart repo) and from NeoArcheron (to obtain device id).

Here's a link to my plugin: https://github.com/awalsum/Qlima
During your tests have you noticed an issue where the AC somehow changes its state (ie from 24 celsius and ECO to ECO OFF and 27celsius) without any interaction?
I had these issue too (BTW thanks Alain for this plugin!).
I fixed it by outcommenting lines 284, 299, 311 as they where trying to update the the Domoticz device with an invalid value like:

Devices[5].Update(nValue=device.power_state, sValue=str(device.operational_mode))
device.operational_mode is auto, heat, cool etc but the Device[5] sValue is expecting 10, 20 30 etc
@deamonshome do you have the latest version of the Qlima plugin? As the midea witching issues were solved by removing some incorrect device updates.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Midea/Inventor (and other brand) Air Condition API

Post by waltervl »

Alain wrote: Tuesday 13 October 2020 11:27
waltervl wrote: Sunday 27 September 2020 22:03
I had these issue too (BTW thanks Alain for this plugin!).
I fixed it by outcommenting lines 284, 299, 311 as they where trying to update the the Domoticz device with an invalid value like:

Devices[5].Update(nValue=device.power_state, sValue=str(device.operational_mode))
device.operational_mode is auto, heat, cool etc but the Device[5] sValue is expecting 10, 20 30 etc
Thanks waltervl. I had another look at the code and outcommented some lines. I updated the repository on Github.
I do not think the changes you made are solving the issue, you outcommented the wrong lines......
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
daemonshome
Posts: 19
Joined: Saturday 30 May 2020 15:30
Target OS: -
Domoticz version:
Contact:

Re: Midea/Inventor (and other brand) Air Condition API

Post by daemonshome »

yes, I am with the latest update.
Last edited by daemonshome on Tuesday 27 October 2020 22:23, edited 1 time in total.
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Midea/Inventor (and other brand) Air Condition API

Post by waltervl »

daemonshome wrote: Tuesday 27 October 2020 13:23 yes, I am with teh latest update.
Then you will have to comment out lines 284, 299, 311 with incorrect domotica device update commands as I proposed earlier to Alain. But he commented out the incorrect lines.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
daemonshome
Posts: 19
Joined: Saturday 30 May 2020 15:30
Target OS: -
Domoticz version:
Contact:

Re: Midea/Inventor (and other brand) Air Condition API

Post by daemonshome »

waltervl wrote: Tuesday 27 October 2020 13:30
daemonshome wrote: Tuesday 27 October 2020 13:23 yes, I am with teh latest update.
Then you will have to comment out lines 284, 299, 311 with incorrect domotica device update commands as I proposed earlier to Alain. But he commented out the incorrect lines.
Ok,
thanks for the hint, I give it a try. done.

Just for the curiousity, the comented lineas are updating the outdoor temp if available? or permamently disabling the update for out sensor complately?
I would prefer the svalue update send to domoticz if correct, then the device is on, if the device is off, then dont send the update.

As a basic idea at the moment, i'm using a lua script to check the outdoor sensor value, if the value is bigger than 100 then i use another outdoor sensor value - this gives me a much better temp value at least.
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Midea/Inventor (and other brand) Air Condition API

Post by waltervl »

The lines to be outcommented are invalid as I explained earlier. They give text instead of the numbers that domoticz devices expects to receive. That will cause strange results that will cause strange reactions of your Airco unit (changing status, target temp etc without reason)

The outdoor temperature sensor is not that accurate (as the indoor temperature). You can only use it as a rough reference. I see misreadings of 2 degrees + or minus.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
daemonshome
Posts: 19
Joined: Saturday 30 May 2020 15:30
Target OS: -
Domoticz version:
Contact:

Re: Midea/Inventor (and other brand) Air Condition API

Post by daemonshome »

waltervl wrote: Wednesday 28 October 2020 10:06 The lines to be outcommented are invalid as I explained earlier. They give text instead of the numbers that domoticz devices expects to receive. That will cause strange results that will cause strange reactions of your Airco unit (changing status, target temp etc without reason)

The outdoor temperature sensor is not that accurate (as the indoor temperature). You can only use it as a rough reference. I see misreadings of 2 degrees + or minus.
The first and main problem with outdoor sensor is the value, i dont mind to have rough-estimated at this stage.
The issue is that it is 102degC :) at OFF stage, which is complately wrong .
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Midea/Inventor (and other brand) Air Condition API

Post by waltervl »

Perhaps in fahrenheit? Does it always have this value when offline? Because I had another issue with this plugin that when de Airco could not be reached it reported the init values like 0.0 degrees. I solved it, solution is somewhat earlier in this thread.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Midea/Inventor (and other brand) Air Condition API

Post by waltervl »

What temperatures are reported when you run the following python program?

Code: Select all

#!/usr/bin/env python3
from msmart.device import device as midea_device
from msmart.device import air_conditioning_device as ac
import logging
logging.basicConfig(level=logging.DEBUG)

# first take device's ip and id
# pip3 install msmart; midea-discover
c = midea_device('YourDeviceIP', YourDeviceID, 6444 )
device = c.setup()
# Refresh the object with the actual state by querying it
device.refresh()
print({
        'id': device.id,
        'name': device.ip,
        'power_state': device.power_state,
        'prompt_tone': device.prompt_tone,
        'target_temperature': device.target_temperature,
        'operational_mode': device.operational_mode,
        'fan_speed': device.fan_speed,
        'swing_mode': device.swing_mode,
        'eco_mode': device.eco_mode,
        'turbo_mode': device.turbo_mode,
        'indoor_temperature': device.indoor_temperature,
        'outdoor_temperature': device.outdoor_temperature
    })
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
daemonshome
Posts: 19
Joined: Saturday 30 May 2020 15:30
Target OS: -
Domoticz version:
Contact:

Re: Midea/Inventor (and other brand) Air Condition API

Post by daemonshome »

waltervl wrote: Wednesday 28 October 2020 19:45 What temperatures are reported when you run the following python program?

Code: Select all

#!/usr/bin/env python3
from msmart.device import device as midea_device
from msmart.device import air_conditioning_device as ac
import logging
logging.basicConfig(level=logging.DEBUG)

# first take device's ip and id
# pip3 install msmart; midea-discover
c = midea_device('YourDeviceIP', YourDeviceID, 6444 )
device = c.setup()
# Refresh the object with the actual state by querying it
device.refresh()
print({
        'id': device.id,
        'name': device.ip,
        'power_state': device.power_state,
        'prompt_tone': device.prompt_tone,
        'target_temperature': device.target_temperature,
        'operational_mode': device.operational_mode,
        'fan_speed': device.fan_speed,
        'swing_mode': device.swing_mode,
        'eco_mode': device.eco_mode,
        'turbo_mode': device.turbo_mode,
        'indoor_temperature': device.indoor_temperature,
        'outdoor_temperature': device.outdoor_temperature
    })
ON stage:

Code: Select all

Appliance response data: c00188667f7f003f00000053430c0056000000000000002f799f 
{'id': '093102000011', 'name': '192.168.1.130', 'power_state': True, 'prompt_tone': False, 'target_temperature': 24.0, 'operational_mode': <operational_mode_enum.heat: 4>, 'fan_speed': <fan_speed_enum.Auto: 102>, 'swing_mode': <swing_mode_enum.Both: 15>, 'eco_mode': False, 'turbo_mode':False, 'indoor_temperature': 16.6, 'outdoor_temperature': 8.5}  
OFF stage:

Code: Select all

Appliance response data: c00087667f7f003f00000052ff0b0002000000000000002710ac
{'id': '093102000011', 'name': '192.168.1.130', 'power_state': False, 'prompt_tone': False, 'target_temperature': 23.0, 'operational_mode': <operational_mode_enum.heat: 4>, 'fan_speed': <fan_speed_enum.Auto: 102>, 'swing_mode': <swing_mode_enum.Both: 15>, 'eco_mode': False, 'turbo_mode': False, 'indoor_temperature': 16.2, 'outdoor_temperature': 102.5}
Had to put the original qlima plugin back , without modification addviced earlier, since i had troubles with it.
If switched on via domoticz, and put to heat mode, it switched back to fan, in a minute or so.
Not really stable and efficient at this time as i need to work on workshop and it is chilly inside/outside :)

As a basic idea in all my scripts:
I save the current state of sensor, and compare with previous state, if they not matching i send to domoticz, otherwise nothing to send.
I would rather like so see the plugin work in such a maner. No need to update every minute from my side.
Last edited by daemonshome on Friday 30 October 2020 20:03, edited 2 times in total.
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Midea/Inventor (and other brand) Air Condition API

Post by waltervl »

I get normal response when my unit is turned off, including a normal response for temperatures. So you not getting a normal response is something in the Midea core library and not a plugin issue.
Perhaps your Midea airco is not fully supported?
I also get debug lines responses in my tests. There is also sometimes a clue. I did not see them in your response.

Code: Select all

DEBUG:msmart.command:Finalize request data: aa20ac00000000000003418100ff03ff0002000000000000000000000000002f3d
INFO:msmart.lan:Couldn't connect with Device 192.168.1.55:6444
DEBUG:msmart.device:refresh - Recieved from 192.168.1.55, 97370000001: 
{'id': '97370000001', 'name': '192.168.1.55', 'power_state': False, 'prompt_tone': True, 'target_temperature': 20.0, 'operational_mode': <operational_mode_enum.auto: 1>, 'fan_speed': <fan_speed_enum.Auto: 102>, 'swing_mode': <swing_mode_enum.Off: 0>, 'eco_mode': False, 'turbo_mode': False, 'indoor_temperature': 0.0, 'outdoor_temperature': 0.0}
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Alain
Posts: 166
Joined: Sunday 26 April 2020 5:27
Target OS: Linux
Domoticz version: 2022.1
Location: Netherlands
Contact:

Re: Midea/Inventor (and other brand) Air Condition API

Post by Alain »

waltervl wrote: Tuesday 27 October 2020 0:25
Alain wrote: Tuesday 13 October 2020 11:27
waltervl wrote: Sunday 27 September 2020 22:03
I had these issue too (BTW thanks Alain for this plugin!).
I fixed it by outcommenting lines 284, 299, 311 as they where trying to update the the Domoticz device with an invalid value like:

Devices[5].Update(nValue=device.power_state, sValue=str(device.operational_mode))
device.operational_mode is auto, heat, cool etc but the Device[5] sValue is expecting 10, 20 30 etc
Thanks waltervl. I had another look at the code and outcommented some lines. I updated the repository on Github.
I do not think the changes you made are solving the issue, you outcommented the wrong lines......
It solved the errors I was getting. I think, somehow, your line numbers differ from mine. On line 299 it says "Level = '20' " in my script, which is heating mode.
Line 311 says "if str(device.fan_speed) == 'fan_speed_enum.High':"

I don't think outcommenting them is going to solve any sort of error. I was getting errors in the logs too when I would send a command and outcommenting the lines I did, fixed it.
Hue | Zigbee2Mqtt | MQTT | P1 | Xiaomi | RFXCom | Modbus | Qlima | Solaredge
TP-Link | Plugwise | Thermosmart | Node-Red | Grafana | Master and 5 remote servers
Alain
Posts: 166
Joined: Sunday 26 April 2020 5:27
Target OS: Linux
Domoticz version: 2022.1
Location: Netherlands
Contact:

Re: Midea/Inventor (and other brand) Air Condition API

Post by Alain »

Could there be a slight difference in how the plugin works if you're using a Midea airconditioner or a Qlima? I have Qlima units and they work fine with the plugin I wrote.
Hue | Zigbee2Mqtt | MQTT | P1 | Xiaomi | RFXCom | Modbus | Qlima | Solaredge
TP-Link | Plugwise | Thermosmart | Node-Red | Grafana | Master and 5 remote servers
Alain
Posts: 166
Joined: Sunday 26 April 2020 5:27
Target OS: Linux
Domoticz version: 2022.1
Location: Netherlands
Contact:

Re: Midea/Inventor (and other brand) Air Condition API

Post by Alain »

waltervl wrote: Monday 19 October 2020 22:39 I did not accept ;-)

I followed your suggestion and checked for the init values and raise an ConnectionError exception when they do. This will skip the updating of Domoticz values so no more 0 degree spikes in temp logging. In the end when the connection fails to many times (eg due to failing Wifi dongle in the device) Domoticz will see the non responsiveness and make the devices color red if it reaches the sensor timeout (default 90 minutes).
I will let it run now for a couple of days, see how it works out.

Code: Select all

    def DataUpdate(self):
        device_ip = Parameters["Address"]
        device_id = Parameters["Mode3"]
        client = midea_device(device_ip, int(device_id),6444)
        device = client.setup()
        
        try:
            device.refresh()
            if device.indoor_temperature == 0.0 and device.indoor_temperature == 0.0 and device.target_temperature == 20.0:
               raise ConnectionError('Could not connect with device',)

            ******* Device updates *************

        except ConnectionError as error:
            Domoticz.Error(repr(error))
            return
        except:
            Domoticz.Error("Qlima (" + Parameters["Address"] + ") unavailable")
            return   
I added this suggestion to the plugin.
Hue | Zigbee2Mqtt | MQTT | P1 | Xiaomi | RFXCom | Modbus | Qlima | Solaredge
TP-Link | Plugwise | Thermosmart | Node-Red | Grafana | Master and 5 remote servers
Alain
Posts: 166
Joined: Sunday 26 April 2020 5:27
Target OS: Linux
Domoticz version: 2022.1
Location: Netherlands
Contact:

Re: Midea/Inventor (and other brand) Air Condition API

Post by Alain »

Sorry I was offline for a while. Had a lot of things going on.
Hue | Zigbee2Mqtt | MQTT | P1 | Xiaomi | RFXCom | Modbus | Qlima | Solaredge
TP-Link | Plugwise | Thermosmart | Node-Red | Grafana | Master and 5 remote servers
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Midea/Inventor (and other brand) Air Condition API

Post by waltervl »

No problem Alain, I documented the changes for others to follow.
Btw I have 2 Qlima airco's running on this plugin now. All working fine now.

This evening on both units the wifi dongle failed suddenly. I had to reboot my wifi router and airco units (use them for heating now).
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Alain
Posts: 166
Joined: Sunday 26 April 2020 5:27
Target OS: Linux
Domoticz version: 2022.1
Location: Netherlands
Contact:

Re: Midea/Inventor (and other brand) Air Condition API

Post by Alain »

Good to hear they're working now. Yeah, the connection of the dongle is pretty unstable, although I haven't had a unit go down for quite a while now. The units going down were the sole reason for me to connect a TP-link HS-110 between the power cord and the wall socket in the first place. This allowed me to re-establish the connection with an app on my phone, without having to physically go to the wall socket (which in one instance is actually in the shed because the power cord goes through the wall). Now I don't need the Kasa app anymore either because I have since also implemented them in Domoticz.
Hue | Zigbee2Mqtt | MQTT | P1 | Xiaomi | RFXCom | Modbus | Qlima | Solaredge
TP-Link | Plugwise | Thermosmart | Node-Red | Grafana | Master and 5 remote servers
shubharora734
Posts: 1
Joined: Thursday 10 December 2020 11:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Midea/Inventor (and other brand) Air Condition API

Post by shubharora734 »

I have a loxone home automation and want to control the AC (got three of them). Loxone is a small locally installed server that is able to send TCP, UDP or HTTP commands. So it should nearly be the same way of getting it working with loxone as getting it working with domoticz. Axis Bank Corporate Login

Regards, teatv apk
Last edited by shubharora734 on Tuesday 19 January 2021 17:03, edited 1 time in total.
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Midea/Inventor (and other brand) Air Condition API

Post by waltervl »

shubharora734 wrote: Thursday 10 December 2020 15:26 I have a loxone home automation and want to control the AC (got three of them). Loxone is a small locally installed server that is able to send TCP, UDP or HTTP commands. So it should nearly be the same way of getting it working with loxone as getting it working with domoticz.
See if you can do something with this library: https://github.com/mac-zhou/midea-msmart

This is the core of the current Domoticz plugin.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest