Skip to content

Commit 3b955c8

Browse files
committed
Move helper-functions
1 parent 87a015a commit 3b955c8

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

plugwise/helper.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,37 @@
6161
}
6262

6363

64+
def device_state_updater(data, devs, d_id, d_dict):
65+
"""Helper-function for _update_gw_devices().
66+
Update the Device_State sensor state.
67+
"""
68+
for idx, item in enumerate(d_dict["sensors"]):
69+
if item[ATTR_ID] == "device_state":
70+
result = update_device_state(data, d_dict)
71+
devs[d_id]["sensors"][idx][ATTR_STATE] = result[0]
72+
devs[d_id]["sensors"][idx][ATTR_ICON] = result[1]
73+
74+
75+
def pw_notification_updater(devs, d_id, d_dict, notifs):
76+
"""Helper-function for _update_gw_devices().
77+
Update the PW_Notification binary_sensor state.
78+
"""
79+
for idx, item in enumerate(d_dict["binary_sensors"]):
80+
if item[ATTR_ID] == "plugwise_notification":
81+
devs[d_id]["binary_sensors"][idx][ATTR_STATE] = notifs != {}
82+
83+
84+
def update_helper(data, devs, d_dict, d_id, e_type, key):
85+
"""Helper-function for _update_gw_devices()."""
86+
for dummy in d_dict[e_type]:
87+
if key != dummy[ATTR_ID]:
88+
continue
89+
for idx, item in enumerate(devs[d_id][e_type]):
90+
if key != item[ATTR_ID]:
91+
continue
92+
devs[d_id][e_type][idx][ATTR_STATE] = data[key]
93+
94+
6495
def check_model(name, v_name):
6596
"""Model checking before using version_to_model."""
6697
if v_name in ["Plugwise", "Plugwise B.V."]:

plugwise/smile.py

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

4646

47-
def device_state_updater(data, devs, d_id, d_dict):
48-
"""Helper-function for _update_gw_devices().
49-
Update the Device_State sensor state.
50-
"""
51-
for idx, item in enumerate(d_dict["sensors"]):
52-
if item[ATTR_ID] == "device_state":
53-
result = update_device_state(data, d_dict)
54-
devs[d_id]["sensors"][idx][ATTR_STATE] = result[0]
55-
devs[d_id]["sensors"][idx][ATTR_ICON] = result[1]
56-
57-
58-
def pw_notification_updater(devs, d_id, d_dict, notifs):
59-
"""Helper-function for _update_gw_devices().
60-
Update the PW_Notification binary_sensor state.
61-
"""
62-
for idx, item in enumerate(d_dict["binary_sensors"]):
63-
if item[ATTR_ID] == "plugwise_notification":
64-
devs[d_id]["binary_sensors"][idx][ATTR_STATE] = notifs != {}
65-
66-
6747
def update_device_state(data, d_dict):
6848
"""Helper-function for _device_state_updater()."""
6949
_cooling_state = False
@@ -99,17 +79,6 @@ def update_device_state(data, d_dict):
9979
return [state, icon]
10080

10181

102-
def update_helper(data, devs, d_dict, d_id, e_type, key):
103-
"""Helper-function for _update_gw_devices()."""
104-
for dummy in d_dict[e_type]:
105-
if key != dummy[ATTR_ID]:
106-
continue
107-
for idx, item in enumerate(devs[d_id][e_type]):
108-
if key != item[ATTR_ID]:
109-
continue
110-
devs[d_id][e_type][idx][ATTR_STATE] = data[key]
111-
112-
11382
class Smile(SmileHelper):
11483
"""The Plugwise Smile main class."""
11584

0 commit comments

Comments
 (0)