Skip to content

Commit 32ce597

Browse files
committed
Move remaining function, import needed consts
1 parent b6f189d commit 32ce597

File tree

2 files changed

+40
-35
lines changed

2 files changed

+40
-35
lines changed

plugwise/helper.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,23 @@
1515

1616
from .constants import (
1717
APPLIANCES,
18+
ATTR_ICON,
1819
ATTR_ID,
1920
ATTR_NAME,
2021
ATTR_STATE,
2122
ATTR_TYPE,
2223
ATTR_UNIT_OF_MEASUREMENT,
2324
BINARY_SENSORS,
25+
COOLING_ICON,
2426
DEVICE_MEASUREMENTS,
2527
DOMAIN_OBJECTS,
2628
ENERGY_KILO_WATT_HOUR,
2729
ENERGY_WATT_HOUR,
30+
FLAME_ICON,
2831
HEATER_CENTRAL_MEASUREMENTS,
32+
HEATING_ICON,
2933
HOME_MEASUREMENTS,
34+
IDLE_ICON,
3035
LOCATIONS,
3136
POWER_WATT,
3237
SENSORS,
@@ -72,6 +77,41 @@ def device_state_updater(data, devs, d_id, d_dict):
7277
devs[d_id]["sensors"][idx][ATTR_ICON] = result[1]
7378

7479

80+
def update_device_state(data, d_dict):
81+
"""Helper-function for _device_state_updater()."""
82+
_cooling_state = False
83+
_dhw_state = False
84+
_heating_state = False
85+
state = "idle"
86+
icon = IDLE_ICON
87+
88+
for _, item in enumerate(d_dict["binary_sensors"]):
89+
if item[ATTR_ID] == "dhw_state":
90+
if item[ATTR_STATE]:
91+
state = "dhw-heating"
92+
icon = FLAME_ICON
93+
_dhw_state = True
94+
95+
if "heating_state" in data:
96+
if data["heating_state"]:
97+
state = "heating"
98+
icon = HEATING_ICON
99+
_heating_state = True
100+
if _heating_state and _dhw_state:
101+
state = "dhw and heating"
102+
icon = HEATING_ICON
103+
if "cooling_state" in data:
104+
if data["cooling_state"]:
105+
state = "cooling"
106+
icon = COOLING_ICON
107+
_cooling_state = True
108+
if _cooling_state and _dhw_state:
109+
state = "dhw and cooling"
110+
icon = COOLING_ICON
111+
112+
return [state, icon]
113+
114+
75115
def pw_notification_updater(devs, d_id, d_dict, notifs):
76116
"""Helper-function for _update_gw_devices().
77117
Update the PW_Notification binary_sensor state.

plugwise/smile.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -44,41 +44,6 @@
4444
_LOGGER = logging.getLogger(__name__)
4545

4646

47-
def update_device_state(data, d_dict):
48-
"""Helper-function for _device_state_updater()."""
49-
_cooling_state = False
50-
_dhw_state = False
51-
_heating_state = False
52-
state = "idle"
53-
icon = IDLE_ICON
54-
55-
for _, item in enumerate(d_dict["binary_sensors"]):
56-
if item[ATTR_ID] == "dhw_state":
57-
if item[ATTR_STATE]:
58-
state = "dhw-heating"
59-
icon = FLAME_ICON
60-
_dhw_state = True
61-
62-
if "heating_state" in data:
63-
if data["heating_state"]:
64-
state = "heating"
65-
icon = HEATING_ICON
66-
_heating_state = True
67-
if _heating_state and _dhw_state:
68-
state = "dhw and heating"
69-
icon = HEATING_ICON
70-
if "cooling_state" in data:
71-
if data["cooling_state"]:
72-
state = "cooling"
73-
icon = COOLING_ICON
74-
_cooling_state = True
75-
if _cooling_state and _dhw_state:
76-
state = "dhw and cooling"
77-
icon = COOLING_ICON
78-
79-
return [state, icon]
80-
81-
8247
class Smile(SmileHelper):
8348
"""The Plugwise Smile main class."""
8449

0 commit comments

Comments
 (0)