Skip to content

Commit cff335e

Browse files
authored
[mideaac] Add Midea Dehumidifier to Midea AC binding (#20665)
* Add Midea Dehumidifier to Midea AC binding Signed-off-by: Bob Eckhoff <katmandodo@yahoo.com>
1 parent 1bd4da1 commit cff335e

50 files changed

Lines changed: 3460 additions & 1065 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bundles/org.openhab.binding.mideaac/README.md

Lines changed: 68 additions & 46 deletions
Large diffs are not rendered by default.

bundles/org.openhab.binding.mideaac/src/main/java/org/openhab/binding/mideaac/internal/MideaACBindingConstants.java

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,44 @@
2727
* used across the whole binding.
2828
*
2929
* @author Jacek Dobrowolski - Initial contribution
30-
* @author Bob Eckhoff - OH naming conventions and capability properties
30+
* @author Bob Eckhoff - OH naming conventions, capability properties and dehumidifier additions
3131
*/
3232
@NonNullByDefault
3333
public class MideaACBindingConstants {
3434

3535
private static final String BINDING_ID = "mideaac";
3636

3737
/**
38-
* Thing Type
38+
* Thing Types
3939
*/
40-
public static final ThingTypeUID THING_TYPE_MIDEAAC = new ThingTypeUID(BINDING_ID, "ac");
40+
public static final ThingTypeUID THING_TYPE_AC = new ThingTypeUID(BINDING_ID, "ac");
41+
public static final ThingTypeUID THING_TYPE_DEHUMIDIFIER = new ThingTypeUID(BINDING_ID, "a1");
4142

42-
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_MIDEAAC);
43+
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
44+
.unmodifiableSet(Set.of(THING_TYPE_AC, THING_TYPE_DEHUMIDIFIER));
4345

4446
/**
45-
* List of all channel IDS
47+
* List of all channel IDS for all Devices
4648
*/
4749
public static final String CHANNEL_POWER = "power";
4850
public static final String CHANNEL_APPLIANCE_ERROR = "appliance-error";
4951
public static final String CHANNEL_TARGET_TEMPERATURE = "target-temperature";
5052
public static final String CHANNEL_OPERATIONAL_MODE = "operational-mode";
53+
public static final String CHANNEL_DEHUMIDIFIER_MODE = "dehumidifier-mode";
5154
public static final String CHANNEL_FAN_SPEED = "fan-speed";
55+
public static final String CHANNEL_DH_FAN_SPEED = "dh-fan-speed";
5256
public static final String CHANNEL_ON_TIMER = "on-timer";
5357
public static final String CHANNEL_OFF_TIMER = "off-timer";
5458
public static final String CHANNEL_SWING_MODE = "swing-mode";
59+
public static final String CHANNEL_SWING_ANGLE_HORIZONTAL = "swing-angle-horizontal";
60+
public static final String CHANNEL_SWING_ANGLE_VERTICAL = "swing-angle-vertical";
61+
public static final String CHANNEL_DEHUMIDIFIER_SWING = "dehumidifier-swing";
5562
public static final String CHANNEL_AUXILIARY_HEAT = "auxiliary-heat";
63+
public static final String CHANNEL_PURIFIER_MODE = "purifier-mode";
64+
public static final String CHANNEL_CHILD_LOCK = "child-lock";
65+
public static final String CHANNEL_ANION = "anion";
66+
public static final String CHANNEL_DEHUMIDIFIER_TANK = "dehumidifier-tank";
67+
public static final String CHANNEL_DEHUMIDIFIER_TANK_SETPOINT = "dh-tank-setpoint";
5668
public static final String CHANNEL_ECO_MODE = "eco-mode";
5769
public static final String CHANNEL_TEMPERATURE_UNIT = "temperature-unit";
5870
public static final String CHANNEL_SLEEP_FUNCTION = "sleep-function";
@@ -75,11 +87,12 @@ public class MideaACBindingConstants {
7587
public static final String CHARSET = "US-ASCII";
7688

7789
/**
78-
* List of all AC thing properties
90+
* List of all thing properties
7991
*/
8092
public static final String CONFIG_IP_ADDRESS = "ipAddress";
8193
public static final String CONFIG_IP_PORT = "ipPort";
8294
public static final String CONFIG_DEVICEID = "deviceId";
95+
public static final String CONFIG_DEVICE_TYPE = "deviceType";
8396
public static final String CONFIG_CLOUD = "cloud";
8497
public static final String CONFIG_EMAIL = "email";
8598
public static final String CONFIG_PASSWORD = "password";
@@ -96,15 +109,18 @@ public class MideaACBindingConstants {
96109
// Properties from LAN Discovery
97110
public static final String PROPERTY_SN = "sn";
98111
public static final String PROPERTY_SSID = "ssid";
99-
public static final String PROPERTY_TYPE = "type";
100112

101113
// Capabilities properties discoverable
102114
public static final String PROPERTY_ANION = "anion";
103115
public static final String PROPERTY_AUX_ELECTRIC_HEAT = "auxElectricHeat";
116+
public static final String PROPERTY_AUX_MODE_AUTO = "auxModeAuto";
117+
public static final String PROPERTY_AUX_MODE_ON = "auxModeOn";
118+
public static final String PROPERTY_AUX_MODE_OFF = "auxModeOff";
104119
public static final String PROPERTY_BREEZE_AWAY = "breezeAway";
105120
public static final String PROPERTY_BREEZE_CONTROL = "breezeControl";
106121
public static final String PROPERTY_BREEZELESS = "breezeless";
107122
public static final String PROPERTY_BUZZER = "buzzer";
123+
public static final String PROPERTY_CHILD_LOCK = "childLock";
108124
public static final String PROPERTY_DISPLAY_CONTROL = "displayControl";
109125
public static final String PROPERTY_ENERGY_STATS = "energyStats";
110126
public static final String PROPERTY_ENERGY_SETTING = "energySetting";
@@ -132,8 +148,10 @@ public class MideaACBindingConstants {
132148
public static final String PROPERTY_PRESET_IECO = "ieco";
133149
public static final String PROPERTY_PRESET_TURBO_COOL = "turboCool";
134150
public static final String PROPERTY_PRESET_TURBO_HEAT = "turboHeat";
151+
public static final String PROPERTY_PURIFIER = "purifier";
135152
public static final String PROPERTY_RATE_SELECT = "rateSelect5Level";
136153
public static final String PROPERTY_SELF_CLEAN = "selfClean";
154+
public static final String PROPERTY_SLEEP_MODE = "sleepMode";
137155
public static final String PROPERTY_SMART_EYE = "smartEye";
138156
public static final String PROPERTY_SWING_LR_ANGLE = "swingHorizontalAngle";
139157
public static final String PROPERTY_SWING_UD_ANGLE = "swingVerticalAngle";

bundles/org.openhab.binding.mideaac/src/main/java/org/openhab/binding/mideaac/internal/MideaACConfiguration.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ public class MideaACConfiguration {
4040
*/
4141
public String deviceId = "0";
4242

43+
/**
44+
* Device Type. Default Midea AC
45+
*/
46+
public String deviceType = "ac";
47+
4348
/**
4449
* Cloud Account email
4550
*/

bundles/org.openhab.binding.mideaac/src/main/java/org/openhab/binding/mideaac/internal/MideaACHandlerFactory.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.eclipse.jdt.annotation.NonNullByDefault;
1818
import org.eclipse.jdt.annotation.Nullable;
1919
import org.openhab.binding.mideaac.internal.handler.MideaACHandler;
20+
import org.openhab.binding.mideaac.internal.handler.MideaDehumidifierHandler;
2021
import org.openhab.core.i18n.UnitProvider;
2122
import org.openhab.core.io.net.http.HttpClientFactory;
2223
import org.openhab.core.thing.Thing;
@@ -33,13 +34,16 @@
3334
* handlers.
3435
*
3536
* @author Jacek Dobrowolski - Initial contribution
37+
* @author Bob Eckhoff - OH addons changes, added Dehumidifier handler
3638
*/
3739
@NonNullByDefault
3840
@Component(configurationPid = "binding.mideaac", service = ThingHandlerFactory.class)
3941
public class MideaACHandlerFactory extends BaseThingHandlerFactory {
4042

4143
private final HttpClientFactory httpClientFactory;
4244
private final UnitProvider unitProvider;
45+
private static final ThingTypeUID THING_TYPE_AC = MideaACBindingConstants.THING_TYPE_AC;
46+
private static final ThingTypeUID THING_TYPE_DEHUMIDIFIER = MideaACBindingConstants.THING_TYPE_DEHUMIDIFIER;
4347

4448
@Override
4549
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
@@ -60,10 +64,14 @@ public MideaACHandlerFactory(@Reference UnitProvider unitProvider, @Reference Ht
6064

6165
@Override
6266
protected @Nullable ThingHandler createHandler(Thing thing) {
63-
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
64-
if (SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID)) {
67+
ThingTypeUID typeUID = thing.getThingTypeUID();
68+
69+
if (typeUID.equals(THING_TYPE_AC)) {
6570
return new MideaACHandler(thing, unitProvider, httpClientFactory.getCommonHttpClient());
71+
} else if (typeUID.equals(THING_TYPE_DEHUMIDIFIER)) {
72+
return new MideaDehumidifierHandler(thing, unitProvider, httpClientFactory.getCommonHttpClient());
6673
}
74+
6775
return null;
6876
}
6977
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Copyright (c) 2010-2026 Contributors to the openHAB project
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
*/
13+
package org.openhab.binding.mideaac.internal.callbacks;
14+
15+
import org.eclipse.jdt.annotation.NonNullByDefault;
16+
import org.openhab.binding.mideaac.internal.devices.a1.A1Response;
17+
import org.openhab.binding.mideaac.internal.devices.ac.EnergyResponse;
18+
import org.openhab.binding.mideaac.internal.devices.ac.HumidityResponse;
19+
import org.openhab.binding.mideaac.internal.devices.ac.Response;
20+
import org.openhab.binding.mideaac.internal.devices.ac.TemperatureResponse;
21+
import org.openhab.binding.mideaac.internal.devices.capabilities.CapabilitiesResponse;
22+
23+
/**
24+
* The {@link Response} performs the polling byte data stream decoding
25+
* The {@link CapabilitiesResponse} performs the capability byte data stream decoding
26+
* The {@link EnergyResponse} performs the energy byte stream data decoding
27+
* The {@link HumidityResponse} performs decoding of unsolicited message 0xA0
28+
* The {@link TemperatureResponse} performs decoding of unsolicited message 0xA1
29+
*
30+
* @author Bob Eckhoff - Initial contribution
31+
*/
32+
@NonNullByDefault
33+
public interface ACCallback extends Callback {
34+
/**
35+
* Updates channels with a standard response (0xC0).
36+
*
37+
* @param response The standard response from the device used to update channels.
38+
*/
39+
@Override
40+
void updateChannels(Response response);
41+
42+
/**
43+
* Updates channels with a capabilities response (0xB5).
44+
*
45+
* @param capabilitiesResponse The capabilities response from the device used to update properties.
46+
*/
47+
@Override
48+
void updateChannels(CapabilitiesResponse capabilitiesResponse);
49+
50+
/**
51+
* Updates channels with a Energy response (0xC1 - 0x44).
52+
*
53+
* @param energyResponse The Energy response from the device used to update energy.
54+
*/
55+
@Override
56+
void updateChannels(EnergyResponse energyResponse);
57+
58+
/**
59+
* Updates humidity with a Energy response (0xC1 - 0x45).
60+
*
61+
* @param energyResponse The Energy response from a humidity Poll used to update humidity.
62+
*/
63+
@Override
64+
void updateHumidityFromEnergy(EnergyResponse energyResponse);
65+
66+
/**
67+
* Updates channels with an unsolicted Humidity Response (0xA0).
68+
*
69+
* @param humidityResponse The unsolicited (0xA0) response from the device used to update properties.
70+
*/
71+
@Override
72+
void updateChannels(HumidityResponse humidityResponse);
73+
74+
/**
75+
* Updates channels with an unsolicited Temperature response (0xA1).
76+
*
77+
* @param temperatureResponse The unsolicited (0xA1) response from the device used to update properties.
78+
*/
79+
@Override
80+
void updateChannels(TemperatureResponse temperatureResponse);
81+
82+
default void updateChannels(A1Response a1Response) {
83+
// No implementation needed for AC
84+
}
85+
}

bundles/org.openhab.binding.mideaac/src/main/java/org/openhab/binding/mideaac/internal/handler/Callback.java renamed to bundles/org.openhab.binding.mideaac/src/main/java/org/openhab/binding/mideaac/internal/callbacks/Callback.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,23 @@
1010
*
1111
* SPDX-License-Identifier: EPL-2.0
1212
*/
13-
package org.openhab.binding.mideaac.internal.handler;
13+
package org.openhab.binding.mideaac.internal.callbacks;
1414

1515
import org.eclipse.jdt.annotation.NonNullByDefault;
16-
import org.openhab.binding.mideaac.internal.handler.capabilities.CapabilitiesResponse;
16+
import org.openhab.binding.mideaac.internal.devices.a1.A1Response;
17+
import org.openhab.binding.mideaac.internal.devices.ac.EnergyResponse;
18+
import org.openhab.binding.mideaac.internal.devices.ac.HumidityResponse;
19+
import org.openhab.binding.mideaac.internal.devices.ac.Response;
20+
import org.openhab.binding.mideaac.internal.devices.ac.TemperatureResponse;
21+
import org.openhab.binding.mideaac.internal.devices.capabilities.CapabilitiesResponse;
1722

1823
/**
1924
* The {@link Response} performs the polling byte data stream decoding
2025
* The {@link CapabilitiesResponse} performs the capability byte data stream decoding
2126
* The {@link EnergyResponse} performs the energy byte stream data decoding
2227
* The {@link HumidityResponse} performs decoding of unsolicited message 0xA0
2328
* The {@link TemperatureResponse} performs decoding of unsolicited message 0xA1
29+
* The {@link A1Response} performs decoding of standard humidifier message 0xC8
2430
*
2531
* @author Leo Siepel - Initial contribution
2632
* @author Bob Eckhoff - added additional Callbacks after Response
@@ -68,4 +74,11 @@ public interface Callback {
6874
* @param temperatureResponse The unsolicited (0xA1) response from the device used to update properties.
6975
*/
7076
void updateChannels(TemperatureResponse temperatureResponse);
77+
78+
/**
79+
* Updates channels with standard humidifier (0xC8) response.
80+
*
81+
* @param response The standard humidifier (0xC8) response from the device used to update properties.
82+
*/
83+
void updateChannels(A1Response a1Response);
7184
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (c) 2010-2026 Contributors to the openHAB project
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
*/
13+
package org.openhab.binding.mideaac.internal.callbacks;
14+
15+
import org.eclipse.jdt.annotation.NonNullByDefault;
16+
import org.openhab.binding.mideaac.internal.devices.a1.A1Response;
17+
import org.openhab.binding.mideaac.internal.devices.ac.EnergyResponse;
18+
import org.openhab.binding.mideaac.internal.devices.ac.HumidityResponse;
19+
import org.openhab.binding.mideaac.internal.devices.ac.Response;
20+
import org.openhab.binding.mideaac.internal.devices.ac.TemperatureResponse;
21+
import org.openhab.binding.mideaac.internal.devices.capabilities.CapabilitiesResponse;
22+
23+
/**
24+
*
25+
* @author Bob Eckhoff - Initial contribution
26+
*/
27+
@NonNullByDefault
28+
public interface HumidifierCallback extends Callback {
29+
/**
30+
* Updates dehumidifier channels with (0xC8) response.
31+
*
32+
* @param a1Response The humidifier (0xC8) response from the device used to update properties.
33+
*/
34+
void updateChannels(A1Response a1Response);
35+
36+
default void updateChannels(Response response) {
37+
// No implementation needed for humidifier
38+
}
39+
40+
/**
41+
* Updates dehumidifier channels with a capabilities response (0xB5).
42+
*
43+
*/
44+
void updateChannels(CapabilitiesResponse capabilitiesResponse);
45+
46+
default void updateChannels(EnergyResponse energyResponse) {
47+
// No implementation needed for humidifier
48+
}
49+
50+
default void updateHumidityFromEnergy(EnergyResponse energyResponse) {
51+
// No implementation needed for humidifier
52+
}
53+
54+
default void updateChannels(HumidityResponse humidityResponse) {
55+
// No implementation needed for humidifier
56+
}
57+
58+
default void updateChannels(TemperatureResponse temperatureResponse) {
59+
// No implementation needed for humidifier
60+
}
61+
}

bundles/org.openhab.binding.mideaac/src/main/java/org/openhab/binding/mideaac/internal/cloud/Cloud.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
package org.openhab.binding.mideaac.internal.cloud;
1414

1515
import java.nio.ByteOrder;
16+
import java.text.DateFormat;
1617
import java.text.SimpleDateFormat;
1718
import java.util.Date;
19+
import java.util.Locale;
1820
import java.util.Map;
1921
import java.util.Objects;
2022
import java.util.concurrent.ExecutionException;
@@ -102,7 +104,8 @@ public Cloud(String email, String password, CloudProvider cloudProvider, HttpCli
102104
data.addProperty("clientType", CLIENT_TYPE);
103105
data.addProperty("language", LANGUAGE);
104106
data.addProperty("src", cloudProvider.appid());
105-
data.addProperty("stamp", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()));
107+
DateFormat fmt = new SimpleDateFormat("yyyyMMddHHmmss", Locale.ROOT);
108+
data.addProperty("stamp", fmt.format(new Date()));
106109
}
107110

108111
// For the getLoginId() this adds the email account
@@ -262,7 +265,8 @@ public boolean login() {
262265
iotData.addProperty("pushToken", Utils.tokenUrlsafe(120));
263266
iotData.addProperty("reqId", StringUtils.getRandomHex(16));
264267
iotData.addProperty("src", cloudProvider.appid());
265-
iotData.addProperty("stamp", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()));
268+
DateFormat fmt = new SimpleDateFormat("yyyyMMddHHmmss", Locale.ROOT);
269+
iotData.addProperty("stamp", fmt.format(new Date()));
266270
newData.add("iotData", iotData);
267271

268272
@Nullable

0 commit comments

Comments
 (0)