Skip to content

Commit c40bc23

Browse files
authored
Merge pull request #43 from mundschenk-at/programs-by-device-type
Programs by device type
2 parents b5a4950 + 81d9ffc commit c40bc23

File tree

4 files changed

+423
-255
lines changed

4 files changed

+423
-255
lines changed

custom_components/miele/const.py

+144-69
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,61 @@
77
OAUTH2_AUTHORIZE = "https://api.mcs3.miele.com/thirdparty/login"
88
OAUTH2_TOKEN = "https://api.mcs3.miele.com/thirdparty/token"
99

10+
11+
# Define appliance types
12+
WASHING_MACHINE = 1
13+
TUMBLE_DRYER = 2
14+
DISHWASHER = 7
15+
OVEN = 12
16+
OVEN_MICROWAVE = 13
17+
HOB_HIGHLIGHT = 14
18+
STEAM_OVEN = 15
19+
MICROWAVE = 16
20+
COFFEE_SYSTEM = 17
21+
HOOD = 18
22+
FRIDGE = 19
23+
FREEZER = 20
24+
FRIDGE_FREEZER = 21
25+
ROBOT_VACUUM_CLEANER = 23
26+
WASHER_DRYER = 24
27+
DISH_WARMER = 25
28+
HOB_INDUCTION = 27
29+
STEAM_OVEN_COMBI = 31
30+
WINE_CABINET = 32
31+
WINE_CONDITIONING_UNIT = 33
32+
WINE_STORAGE_CONDITIONING_UNIT = 34
33+
STEAM_OVEN_MICRO = 45
34+
DIALOG_OVEN = 67
35+
WINE_CABINET_FREEZER = 68
36+
37+
APPLIANCE_TYPES = {
38+
WASHING_MACHINE: "washing_machine",
39+
TUMBLE_DRYER: "tumble_dryer",
40+
DISHWASHER: "dishwasher",
41+
OVEN: "oven",
42+
OVEN_MICROWAVE: "oven_microwave",
43+
HOB_HIGHLIGHT: "hob_highlight",
44+
STEAM_OVEN: "steam_oven",
45+
MICROWAVE: "microwave",
46+
COFFEE_SYSTEM: "coffee_system",
47+
HOOD: "hood",
48+
FRIDGE: "fridge",
49+
FREEZER: "freezer",
50+
FRIDGE_FREEZER: "fridge_freezer",
51+
ROBOT_VACUUM_CLEANER: "robot_vacuum_cleaner",
52+
WASHER_DRYER: "washer_dryer",
53+
DISH_WARMER: "dish_warmer",
54+
HOB_INDUCTION: "hob_induction",
55+
STEAM_OVEN_COMBI: "steam_oven_combi",
56+
WINE_CABINET: "wine_cabinet",
57+
WINE_CONDITIONING_UNIT: "wine_conditioning_unit",
58+
WINE_STORAGE_CONDITIONING_UNIT: "wine_storage_conditioning_unit",
59+
STEAM_OVEN_MICRO: "steam_oven_micro",
60+
DIALOG_OVEN: "dialog_oven",
61+
WINE_CABINET_FREEZER: "wine_cabinet_freezer",
62+
}
63+
64+
# Define various states
1065
STATE_STATUS = {
1166
0: "reserved",
1267
1: "off",
@@ -35,26 +90,6 @@
3590
3: "cleaning_care_program",
3691
}
3792

38-
STATE_PROGRAM_ID = {
39-
1: "cottons",
40-
3: "minimum_iron",
41-
4: "delicates",
42-
8: "woollens",
43-
9: "silk",
44-
21: "drain_spin",
45-
23: "shirts",
46-
27: "proofing",
47-
29: "sportswear",
48-
31: "automatic_plus",
49-
37: "outerwear",
50-
38: "quick_power_wash",
51-
48: "rinse_out_lint",
52-
50: "dark_garments",
53-
52: "only_rinse_starch",
54-
122: "express",
55-
123: "denim",
56-
}
57-
5893
STATE_PROGRAM_PHASE = {
5994
# Washing Machine
6095
0: "not_running", # Returned by the API when the machine is switched off entirely.
@@ -117,58 +152,98 @@
117152
1801: "pre_dishwash",
118153
}
119154

120-
WASHING_MACHINE = 1
121-
TUMBLE_DRYER = 2
122-
DISHWASHER = 7
123-
OVEN = 12
124-
OVEN_MICROWAVE = 13
125-
HOB_HIGHLIGHT = 14
126-
STEAM_OVEN = 15
127-
MICROWAVE = 16
128-
COFFEE_SYSTEM = 17
129-
HOOD = 18
130-
FRIDGE = 19
131-
FREEZER = 20
132-
FRIDGE_FREEZER = 21
133-
ROBOT_VACUUM_CLEANER = 23
134-
WASHER_DRYER = 24
135-
DISH_WARMER = 25
136-
HOB_INDUCTION = 27
137-
STEAM_OVEN_COMBI = 31
138-
WINE_CABINET = 32
139-
WINE_CONDITIONING_UNIT = 33
140-
WINE_STORAGE_CONDITIONING_UNIT = 34
141-
STEAM_OVEN_MICRO = 45
142-
DIALOG_OVEN = 67
143-
WINE_CABINET_FREEZER = 68
155+
WASHING_MACHINE_PROGRAM_ID = {
156+
1: "cottons",
157+
3: "minimum_iron",
158+
4: "delicates",
159+
8: "woollens",
160+
9: "silks",
161+
17: "starch",
162+
18: "rinse",
163+
21: "drain_spin",
164+
22: "curtains",
165+
23: "shirts",
166+
24: "denim",
167+
27: "proofing",
168+
29: "sportswear",
169+
31: "automatic_plus",
170+
37: "outerwear",
171+
39: "pillows",
172+
48: "rinse_out_lint", # washer-dryer
173+
50: "dark_garments",
174+
52: "separate_rinse_starch",
175+
53: "first_wash",
176+
69: "cottons_hygiene",
177+
75: "steam_care", # washer-dryer
178+
76: "freshen_up", # washer-dryer
179+
77: "trainers",
180+
91: "clean_machine",
181+
95: "down_duvets",
182+
122: "express_20",
183+
123: "denim",
184+
129: "down_filled_items",
185+
133: "cottons_eco",
186+
146: "quick_power_wash",
187+
}
188+
DISHWASHER_PROGRAM_ID = {
189+
26: "intensive",
190+
27: "maintenance", # or maintenance_program?
191+
28: "eco",
192+
30: "normal",
193+
31: "automatic",
194+
32: "automatic", # sources disagree on ID
195+
34: "solar_save",
196+
35: "gentle",
197+
36: "extra_quiet",
198+
37: "hygiene",
199+
38: "quick_power_wash",
200+
42: "tall_items",
201+
}
202+
TUMBLE_DRYER_PROGRAM_ID = {
203+
10: "automatic_plus",
204+
20: "cottons",
205+
23: "cottons_hygiene",
206+
30: "minimum_iron",
207+
31: "gentle_minimum_iron",
208+
40: "woollens_handcare",
209+
50: "delicates",
210+
60: "warm_air",
211+
70: "cool_air",
212+
80: "express_20",
213+
90: "cottons",
214+
100: "gentle_smoothing",
215+
120: "proofing",
216+
130: "denim",
217+
131: "gentle_denim",
218+
150: "sportswear",
219+
160: "outerwear",
220+
170: "silks_handcare",
221+
190: "standard_pillows",
222+
220: "basket_program",
223+
240: "smoothing",
224+
}
225+
OVEN_PROGRAM_ID = {
226+
6: "eco_fan_heat",
227+
7: "auto_roast",
228+
10: "full_grill",
229+
11: "economy_grill",
230+
13: "fan_plus",
231+
14: "intensive_bake",
232+
24: "conventional_heat",
233+
25: "top_heat",
234+
29: "fan_grill",
235+
31: "bottom_heat",
236+
}
144237

145-
APPLIANCE_TYPES = {
146-
WASHING_MACHINE: "washing_machine",
147-
TUMBLE_DRYER: "tumble_dryer",
148-
DISHWASHER: "dishwasher",
149-
OVEN: "oven",
150-
OVEN_MICROWAVE: "oven_microwave",
151-
HOB_HIGHLIGHT: "hob_highlight",
152-
STEAM_OVEN: "steam_oven",
153-
MICROWAVE: "microwave",
154-
COFFEE_SYSTEM: "coffee_system",
155-
HOOD: "hood",
156-
FRIDGE: "fridge",
157-
FREEZER: "freezer",
158-
FRIDGE_FREEZER: "fridge_freezer",
159-
ROBOT_VACUUM_CLEANER: "robot_vacuum_cleaner",
160-
WASHER_DRYER: "washer_dryer",
161-
DISH_WARMER: "dish_warmer",
162-
HOB_INDUCTION: "hob_induction",
163-
STEAM_OVEN_COMBI: "steam_oven_combi",
164-
WINE_CABINET: "wine_cabinet",
165-
WINE_CONDITIONING_UNIT: "wine_conditioning_unit",
166-
WINE_STORAGE_CONDITIONING_UNIT: "wine_storage_conditioning_unit",
167-
STEAM_OVEN_MICRO: "steam_oven_micro",
168-
DIALOG_OVEN: "dialog_oven",
169-
WINE_CABINET_FREEZER: "wine_cabinet_freezer",
238+
STATE_PROGRAM_ID = {
239+
WASHING_MACHINE: WASHING_MACHINE_PROGRAM_ID,
240+
TUMBLE_DRYER: TUMBLE_DRYER_PROGRAM_ID,
241+
DISHWASHER: DISHWASHER_PROGRAM_ID,
242+
OVEN: OVEN_PROGRAM_ID,
243+
WASHER_DRYER: WASHING_MACHINE_PROGRAM_ID,
170244
}
171245

246+
# Possible actions
172247
PROCESS_ACTIONS = {
173248
"start": 1,
174249
"stop": 2,

custom_components/miele/sensor.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class MieleSensorDefinition:
104104
name="Temperature",
105105
native_unit_of_measurement=TEMP_CELSIUS,
106106
state_class=SensorStateClass.MEASUREMENT,
107-
convert=lambda x: x / 100.0,
107+
convert=lambda x, t: x / 100.0,
108108
),
109109
),
110110
MieleSensorDefinition(
@@ -132,7 +132,7 @@ class MieleSensorDefinition:
132132
name="Temperature Zone 2",
133133
native_unit_of_measurement=TEMP_CELSIUS,
134134
state_class=SensorStateClass.MEASUREMENT,
135-
convert=lambda x: x / 100.0,
135+
convert=lambda x, t: x / 100.0,
136136
entity_registry_enabled_default=False,
137137
),
138138
),
@@ -161,7 +161,7 @@ class MieleSensorDefinition:
161161
name="Temperature Zone 3",
162162
native_unit_of_measurement=TEMP_CELSIUS,
163163
state_class=SensorStateClass.MEASUREMENT,
164-
convert=lambda x: x / 100.0,
164+
convert=lambda x, t: x / 100.0,
165165
entity_registry_enabled_default=False,
166166
),
167167
),
@@ -193,7 +193,7 @@ class MieleSensorDefinition:
193193
native_unit_of_measurement=TEMP_CELSIUS,
194194
state_class=SensorStateClass.MEASUREMENT,
195195
entity_category=EntityCategory.DIAGNOSTIC,
196-
convert=lambda x: x / 100.0,
196+
convert=lambda x, t: x / 100.0,
197197
),
198198
),
199199
MieleSensorDefinition(
@@ -224,7 +224,7 @@ class MieleSensorDefinition:
224224
native_unit_of_measurement=TEMP_CELSIUS,
225225
state_class=SensorStateClass.MEASUREMENT,
226226
entity_category=EntityCategory.DIAGNOSTIC,
227-
convert=lambda x: x / 100.0,
227+
convert=lambda x, t: x / 100.0,
228228
entity_registry_enabled_default=False,
229229
),
230230
),
@@ -256,7 +256,7 @@ class MieleSensorDefinition:
256256
native_unit_of_measurement=TEMP_CELSIUS,
257257
state_class=SensorStateClass.MEASUREMENT,
258258
entity_category=EntityCategory.DIAGNOSTIC,
259-
convert=lambda x: x / 100.0,
259+
convert=lambda x, t: x / 100.0,
260260
entity_registry_enabled_default=False,
261261
),
262262
),
@@ -294,7 +294,7 @@ class MieleSensorDefinition:
294294
name="Status",
295295
device_class="miele__state_status",
296296
icon="mdi:state-machine",
297-
convert=lambda x: STATE_STATUS.get(x, x),
297+
convert=lambda x, t: STATE_STATUS.get(x, x),
298298
extra_attributes={"Raw value": 0},
299299
),
300300
),
@@ -322,7 +322,7 @@ class MieleSensorDefinition:
322322
name="Program",
323323
device_class="miele__state_program_id",
324324
icon="mdi:state-machine",
325-
convert=lambda x: STATE_PROGRAM_ID.get(x, x),
325+
convert=lambda x, t: STATE_PROGRAM_ID.get(t, {}).get(x, x),
326326
extra_attributes={"Raw value": 0},
327327
),
328328
),
@@ -349,7 +349,7 @@ class MieleSensorDefinition:
349349
name="Program Type",
350350
device_class="miele__state_program_type",
351351
icon="mdi:state-machine",
352-
convert=lambda x: STATE_PROGRAM_TYPE.get(x, x),
352+
convert=lambda x, t: STATE_PROGRAM_TYPE.get(x, x),
353353
extra_attributes={"Raw value": 0},
354354
),
355355
),
@@ -376,7 +376,7 @@ class MieleSensorDefinition:
376376
name="Program Phase",
377377
device_class="miele__state_program_phase",
378378
icon="mdi:state-machine",
379-
convert=lambda x: STATE_PROGRAM_PHASE.get(x, x),
379+
convert=lambda x, t: STATE_PROGRAM_PHASE.get(x, x),
380380
extra_attributes={"Raw value": 0},
381381
),
382382
),
@@ -582,7 +582,8 @@ def native_value(self):
582582
return self.coordinator.data[self._ent][self.entity_description.data_tag]
583583
else:
584584
return self.entity_description.convert(
585-
self.coordinator.data[self._ent][self.entity_description.data_tag]
585+
self.coordinator.data[self._ent][self.entity_description.data_tag],
586+
self.coordinator.data[self._ent]["ident|type|value_raw"]
586587
)
587588

588589
@property

0 commit comments

Comments
 (0)