Skip to content

Commit aedb000

Browse files
authored
Add support for reversing horizontal swing angle (#320)
* Add config option to reverse labels on horizontal swing angle * Add icon translation * Update readme * Add translations for RTL swing angle
1 parent f2ef159 commit aedb000

27 files changed

+264
-14
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ Name | Default | Description
137137
**Additional Operation Modes** | Empty | Additional HVAC modes to make available in case the device's capabilities are incorrect.
138138
**Maximum Connection Lifetime** | Empty | Limit the time (in seconds) a connection to the device will be used before reconnecting. If left blank, the connection will persist indefinitely. If your device disconnects at regular intervals, set this to a value below the interval.
139139
**Energy Format** | Default | Select alternative data formats for decoding energy and power data from the device.<br> Options: <ul><li>`Default` - BCD format</li><li>`Alternate A` - Binary format</li><li>`Alternate B` - Binary format, energy scaled by 1/10</li></ul>
140-
140+
**Reverse Horizontal Swing Angle** | False | Reverse the order of horizontal swing angles from left-to-right to right-to-left.
141141

142142
## Resolving Connectivity Issues
143143
Some users have reported issue with their devices periodically becoming unavailable, and with logs full of warnings and errors. This is almost always due to the device terminating the existing connection and briefly rejecting new connections.

custom_components/midea_ac/config_flow.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
CONF_CLOUD_COUNTRY_CODES, CONF_DEFAULT_CLOUD_COUNTRY,
2929
CONF_ENERGY_FORMAT, CONF_FAN_SPEED_STEP, CONF_KEY,
3030
CONF_MAX_CONNECTION_LIFETIME, CONF_SHOW_ALL_PRESETS,
31-
CONF_TEMP_STEP, CONF_USE_FAN_ONLY_WORKAROUND, DOMAIN,
32-
UPDATE_INTERVAL, EnergyFormat)
31+
CONF_SWING_ANGLE_RTL, CONF_TEMP_STEP,
32+
CONF_USE_FAN_ONLY_WORKAROUND, DOMAIN, UPDATE_INTERVAL,
33+
EnergyFormat)
3334

3435
_DEFAULT_OPTIONS = {
3536
CONF_BEEP: True,
@@ -40,6 +41,7 @@
4041
CONF_ADDITIONAL_OPERATION_MODES: None,
4142
CONF_MAX_CONNECTION_LIFETIME: None,
4243
CONF_ENERGY_FORMAT: EnergyFormat.DEFAULT,
44+
CONF_SWING_ANGLE_RTL: False
4345
}
4446

4547
_CLOUD_CREDENTIALS = {
@@ -289,6 +291,7 @@ async def async_step_init(self, user_input=None) -> FlowResult:
289291
mode=SelectSelectorMode.DROPDOWN,
290292
)
291293
),
294+
vol.Optional(CONF_SWING_ANGLE_RTL): cv.boolean,
292295
}), self.config_entry.options)
293296

294297
return self.async_show_form(step_id="init", data_schema=data_schema)

custom_components/midea_ac/const.py

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
CONF_ENERGY_FORMAT = "energy_format"
1515
CONF_CLOUD_COUNTRY_CODES = ["DE", "KR", "US"]
1616
CONF_DEFAULT_CLOUD_COUNTRY = "US"
17+
CONF_SWING_ANGLE_RTL = "swing_angle_rtl"
1718

1819
PRESET_IECO = "ieco"
1920

custom_components/midea_ac/icons.json

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
"horizontal_swing_angle": {
2929
"default": "mdi:angle-acute"
3030
},
31+
"horizontal_swing_angle_rtl": {
32+
"default": "mdi:angle-acute"
33+
},
3134
"rate_select": {
3235
"default": "mdi:slope-downhill"
3336
},

custom_components/midea_ac/select.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from msmart.device import AirConditioner as AC
1212
from msmart.utils import MideaIntEnum
1313

14-
from .const import DOMAIN
14+
from .const import CONF_SWING_ANGLE_RTL, DOMAIN
1515
from .coordinator import MideaCoordinatorEntity, MideaDeviceUpdateCoordinator
1616

1717
_LOGGER = logging.getLogger(__name__)
@@ -34,28 +34,30 @@ async def async_setup_entry(
3434
if coordinator.device.supports_vertical_swing_angle:
3535
entities.append(MideaEnumSelect(coordinator,
3636
"vertical_swing_angle",
37-
AC.SwingAngle,
38-
"vertical_swing_angle"))
37+
AC.SwingAngle
38+
))
3939

4040
if coordinator.device.supports_horizontal_swing_angle:
4141
entities.append(MideaEnumSelect(coordinator,
4242
"horizontal_swing_angle",
4343
AC.SwingAngle,
44-
"horizontal_swing_angle"))
44+
translation_key="horizontal_swing_angle_rtl" if config_entry.options.get(
45+
CONF_SWING_ANGLE_RTL) else None
46+
))
4547

4648
if (supported_rates := coordinator.device.supported_rate_selects) != [AC.RateSelect.OFF]:
4749
entities.append(MideaEnumSelect(coordinator,
4850
"rate_select",
4951
AC.RateSelect,
50-
"rate_select",
51-
options=supported_rates))
52+
options=supported_rates
53+
))
5254

5355
if (supported_aux_modes := coordinator.device.supported_aux_modes) != [AC.AuxHeatMode.OFF]:
5456
entities.append(MideaEnumSelect(coordinator,
5557
"aux_mode",
5658
AC.AuxHeatMode,
57-
"aux_mode",
58-
options=supported_aux_modes))
59+
options=supported_aux_modes
60+
))
5961

6062
add_entities(entities)
6163

@@ -67,14 +69,14 @@ def __init__(self,
6769
coordinator: MideaDeviceUpdateCoordinator,
6870
prop: str,
6971
enum_class: MideaIntEnum,
70-
translation_key: Optional[str] = None,
7172
*,
73+
translation_key: Optional[str] = None,
7274
options: Optional[List[MideaIntEnum]] = None) -> None:
7375
MideaCoordinatorEntity.__init__(self, coordinator)
7476

7577
self._prop = prop
7678
self._enum_class = enum_class
77-
self._attr_translation_key = translation_key
79+
self._attr_translation_key = translation_key if translation_key is not None else prop
7880
self._options = options
7981

8082
@property

custom_components/midea_ac/translations/bg.json

+10
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@
107107
"pos_5": "Вдясно"
108108
}
109109
},
110+
"horizontal_swing_angle_rtl": {
111+
"state": {
112+
"off": "Изключен",
113+
"pos_1": "Вдясно",
114+
"pos_2": "Вдясно - в центъра",
115+
"pos_3": "В центъра",
116+
"pos_4": "Вляво - в центъра",
117+
"pos_5": "Вляво"
118+
}
119+
},
110120
"vertical_swing_angle": {
111121
"state": {
112122
"off": "Изключен",

custom_components/midea_ac/translations/ca.json

+11
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,17 @@
139139
"pos_5": "Dreta"
140140
}
141141
},
142+
"horizontal_swing_angle_rtl": {
143+
"name": "Angle d'oscil·lació horitzontal",
144+
"state": {
145+
"off": "Apagat",
146+
"pos_1": "Dreta",
147+
"pos_2": "Centre-dreta",
148+
"pos_3": "Centre",
149+
"pos_4": "Centre-esquerra",
150+
"pos_5": "Esquerra"
151+
}
152+
},
142153
"rate_select": {
143154
"name": "Sel·lecció de taxa",
144155
"state": {

custom_components/midea_ac/translations/cs.json

+11
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@
127127
"pos_5": "Vpravo"
128128
}
129129
},
130+
"horizontal_swing_angle_rtl": {
131+
"name": "Horizontální úhel výkyvu",
132+
"state": {
133+
"off": "Vypnuto",
134+
"pos_1": "Vpravo",
135+
"pos_2": "Vpravo-střed",
136+
"pos_3": "Střed",
137+
"pos_4": "Vlevo-střed",
138+
"pos_5": "Vlevo"
139+
}
140+
},
130141
"vertical_swing_angle": {
131142
"name": "Vertikální úhel výkyvu",
132143
"state": {

custom_components/midea_ac/translations/de.json

+10
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@
107107
"pos_5": "Rechts"
108108
}
109109
},
110+
"horizontal_swing_angle_rtl": {
111+
"state": {
112+
"off": "Aus",
113+
"pos_1": "Rechts",
114+
"pos_2": "Rechts-mitte",
115+
"pos_3": "Mitte",
116+
"pos_4": "Links-mitte",
117+
"pos_5": "Links"
118+
}
119+
},
110120
"vertical_swing_angle": {
111121
"state": {
112122
"off": "Aus",

custom_components/midea_ac/translations/en.json

+13-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
"show_all_presets": "Show All Presets",
5656
"additional_operation_modes": "Additional Operation Modes",
5757
"max_connection_lifetime": "Maximum Connection Lifetime",
58-
"energy_format": "Energy Format"
58+
"energy_format": "Energy Format",
59+
"swing_angle_rtl": "Reverse Horizontal Swing Angle"
5960
},
6061
"data_description": {
6162
"temp_step": "Step size for temperature set point",
@@ -156,6 +157,17 @@
156157
"pos_5": "Right"
157158
}
158159
},
160+
"horizontal_swing_angle_rtl": {
161+
"name": "Horizontal swing angle",
162+
"state": {
163+
"off": "Off",
164+
"pos_1": "Right",
165+
"pos_2": "Right-center",
166+
"pos_3": "Center",
167+
"pos_4": "Left-center",
168+
"pos_5": "Left"
169+
}
170+
},
159171
"rate_select": {
160172
"name": "Rate select",
161173
"state": {

custom_components/midea_ac/translations/es.json

+11
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,17 @@
118118
"pos_5": "Derecha"
119119
}
120120
},
121+
"horizontal_swing_angle_rtl": {
122+
"name": "Ángulo de oscilación horizontal",
123+
"state": {
124+
"off": "Apagado",
125+
"pos_1": "Derecha",
126+
"pos_2": "Centro-derecha",
127+
"pos_3": "Centro",
128+
"pos_4": "Centro-izquierda",
129+
"pos_5": "Izquierda"
130+
}
131+
},
121132
"vertical_swing_angle": {
122133
"name": "Angulo de oscilación vertical",
123134
"state": {

custom_components/midea_ac/translations/eu.json

+11
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,17 @@
139139
"pos_5": "Eskubi"
140140
}
141141
},
142+
"horizontal_swing_angle_rtl": {
143+
"name": "Swing angelu horizontala",
144+
"state": {
145+
"off": "Itzalita",
146+
"pos_1": "Eskubi",
147+
"pos_2": "Eskubi-zentro",
148+
"pos_3": "Zentro",
149+
"pos_4": "Ezker-zentro",
150+
"pos_5": "Ezker"
151+
}
152+
},
142153
"rate_select": {
143154
"name": "Hautatu tasa",
144155
"state": {

custom_components/midea_ac/translations/fr.json

+11
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,17 @@
135135
"pos_5": "Droite"
136136
}
137137
},
138+
"horizontal_swing_angle_rtl": {
139+
"name": "Angle de balancement horizontal",
140+
"state": {
141+
"off": "Arrêt",
142+
"pos_1": "Droite",
143+
"pos_2": "Droite-centre",
144+
"pos_3": "Centre",
145+
"pos_4": "Gauche-centre",
146+
"pos_5": "Gauche"
147+
}
148+
},
138149
"rate_select": {
139150
"name": "Sélection du taux",
140151
"state": {

custom_components/midea_ac/translations/hr.json

+11
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,17 @@
146146
"pos_5": "Desno"
147147
}
148148
},
149+
"horizontal_swing_angle_rtl": {
150+
"name": "Horizontalni kut zakretanja",
151+
"state": {
152+
"off": "Off",
153+
"pos_1": "Desno",
154+
"pos_2": "Desno-centar",
155+
"pos_3": "Centar",
156+
"pos_4": "Lijevo-centar",
157+
"pos_5": "Lijevo"
158+
}
159+
},
149160
"rate_select": {
150161
"name": "Odabir brzine",
151162
"state": {

custom_components/midea_ac/translations/hu.json

+11
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,17 @@
139139
"pos_5": "Jobb"
140140
}
141141
},
142+
"horizontal_swing_angle_rtl": {
143+
"name": "Vízszintes lengési szög",
144+
"state": {
145+
"off": "Ki",
146+
"pos_1": "Jobb",
147+
"pos_2": "Jobb-közép",
148+
"pos_3": "Közép",
149+
"pos_4": "Bal-közép",
150+
"pos_5": "Bal"
151+
}
152+
},
142153
"rate_select": {
143154
"name": "Teljesítmény kiválasztása",
144155
"state": {

custom_components/midea_ac/translations/it.json

+11
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,17 @@
130130
"pos_5": "Destra"
131131
}
132132
},
133+
"horizontal_swing_angle_rtl": {
134+
"name": "Angolo di oscillazione orizzontale",
135+
"state": {
136+
"off": "Spento",
137+
"pos_1": "Destra",
138+
"pos_2": "Destra-centrale",
139+
"pos_3": "Centrale",
140+
"pos_4": "Sinistra-centrale",
141+
"pos_5": "Sinistra"
142+
}
143+
},
133144
"rate_select": {
134145
"name": "Selezione livello",
135146
"state": {

custom_components/midea_ac/translations/nb.json

+11
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,17 @@
148148
"pos_5": "Høyre"
149149
}
150150
},
151+
"horizontal_swing_angle_rtl": {
152+
"name": "Horisontal svingvinkel",
153+
"state": {
154+
"off": "Av",
155+
"pos_1": "Høyre",
156+
"pos_2": "Høyre-midt",
157+
"pos_3": "Midtstilt",
158+
"pos_4": "Venstre-midt",
159+
"pos_5": "Venstre"
160+
}
161+
},
151162
"rate_select": {
152163
"name": "Velg modus",
153164
"state": {

custom_components/midea_ac/translations/nl.json

+11
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,17 @@
118118
"pos_5": "Rechts"
119119
}
120120
},
121+
"horizontal_swing_angle_rtl": {
122+
"name": "Horizontale blaasrichting",
123+
"state": {
124+
"off": "Uit",
125+
"pos_1": "Rechts",
126+
"pos_2": "Rechts-midden",
127+
"pos_3": "Midden",
128+
"pos_4": "Links-midden",
129+
"pos_5": "Links"
130+
}
131+
},
121132
"vertical_swing_angle": {
122133
"name": "Verticale blaasrichting",
123134
"state": {

custom_components/midea_ac/translations/pl.json

+11
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,17 @@
139139
"pos_5": "Prawo"
140140
}
141141
},
142+
"horizontal_swing_angle_rtl": {
143+
"name": "Zakres ruchu w poziomie",
144+
"state": {
145+
"off": "Wyłączony",
146+
"pos_1": "Prawo",
147+
"pos_2": "Prawo-środek",
148+
"pos_3": "środek",
149+
"pos_4": "Lewo-środek",
150+
"pos_5": "Lewo"
151+
}
152+
},
142153
"rate_select": {
143154
"name": "Rate select",
144155
"state": {

custom_components/midea_ac/translations/ro.json

+11
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,17 @@
118118
"pos_5": "Dreapta"
119119
}
120120
},
121+
"horizontal_swing_angle_rtl": {
122+
"name": "Baleiere orizontală",
123+
"state": {
124+
"off": "Oprit",
125+
"pos_1": "Dreapta",
126+
"pos_2": "Centru-dreapta",
127+
"pos_3": "Centru",
128+
"pos_4": "Centru-stânga",
129+
"pos_5": "Stânga"
130+
}
131+
},
121132
"vertical_swing_angle": {
122133
"name": "Baleiere verticală",
123134
"state": {

0 commit comments

Comments
 (0)