plugwise 1.7.0__py3-none-any.whl → 1.7.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
plugwise/__init__.py CHANGED
@@ -80,7 +80,7 @@ class Smile(SmileComm):
80
80
  self.smile_model_id: str | None = None
81
81
  self.smile_name: str = NONE
82
82
  self.smile_type: str = NONE
83
- self.smile_version: Version | None = None
83
+ self.smile_version: Version = Version("0.0.0")
84
84
  self.smile_zigbee_mac_address: str | None = None
85
85
 
86
86
  @property
@@ -115,7 +115,7 @@ class Smile(SmileComm):
115
115
  """
116
116
  return not self.smile_legacy
117
117
 
118
- async def connect(self) -> Version | None:
118
+ async def connect(self) -> Version:
119
119
  """Connect to the Plugwise Gateway and determine its name, type, version, and other data."""
120
120
  result = await self._request(DOMAIN_OBJECTS)
121
121
  # Work-around for Stretch fw 2.7.18
@@ -296,7 +296,7 @@ class Smile(SmileComm):
296
296
  ):
297
297
  system = await self._request(SYSTEM)
298
298
  self.smile_version = parse(system.find("./gateway/firmware").text)
299
- return_model = system.find("./gateway/product").text
299
+ return_model = str(system.find("./gateway/product").text)
300
300
  self.smile_hostname = system.find("./gateway/hostname").text
301
301
  # If wlan0 contains data it's active, so eth0 should be checked last
302
302
  for network in ("wlan0", "eth0"):
@@ -307,7 +307,7 @@ class Smile(SmileComm):
307
307
  elif dsmrmain is not None:
308
308
  status = await self._request(STATUS)
309
309
  self.smile_version = parse(status.find("./system/version").text)
310
- return_model = status.find("./system/product").text
310
+ return_model = str(status.find("./system/product").text)
311
311
  self.smile_hostname = status.find("./network/hostname").text
312
312
  self.smile_mac_address = status.find("./network/mac_address").text
313
313
  else: # pragma: no cover
plugwise/helper.py CHANGED
@@ -86,7 +86,7 @@ class SmileHelper(SmileCommon):
86
86
  self.smile_mac_address: str | None
87
87
  self.smile_model: str
88
88
  self.smile_model_id: str | None
89
- self.smile_version: version.Version | None
89
+ self.smile_version: version.Version
90
90
  SmileCommon.__init__(self)
91
91
 
92
92
  def _all_appliances(self) -> None:
@@ -786,7 +786,7 @@ class SmileHelper(SmileCommon):
786
786
 
787
787
  # Handle missing control_state in regulation_mode off for firmware >= 3.2.0 (issue #776)
788
788
  # In newer firmware versions, default to "off" when control_state is not present
789
- if self.smile_version is not None:
789
+ if self.smile_version != version.Version("0.0.0"):
790
790
  if self.smile_version >= version.parse("3.2.0"):
791
791
  return "off"
792
792
 
plugwise/legacy/helper.py CHANGED
@@ -72,7 +72,7 @@ class SmileLegacyHelper(SmileCommon):
72
72
  self.gw_entities: dict[str, GwEntityData] = {}
73
73
  self.smile_mac_address: str | None
74
74
  self.smile_model: str
75
- self.smile_version: Version | None
75
+ self.smile_version: Version
76
76
  self.smile_zigbee_mac_address: str | None
77
77
  SmileCommon.__init__(self)
78
78
 
@@ -306,7 +306,7 @@ class SmileLegacyHelper(SmileCommon):
306
306
  search = self._modules
307
307
  mod_logs = search.findall("./module/services")
308
308
  for loc.measurement, loc.attrs in P1_LEGACY_MEASUREMENTS.items():
309
- loc.meas_list = loc.measurement.split("_")
309
+ loc.meas_list = loc.measurement.partition("_")[0::2]
310
310
  for loc.logs in mod_logs:
311
311
  for loc.log_type in mod_list:
312
312
  collect_power_values(data, loc, t_string, legacy=True)
plugwise/legacy/smile.py CHANGED
@@ -50,7 +50,7 @@ class SmileLegacyAPI(SmileLegacyData):
50
50
  smile_model: str,
51
51
  smile_name: str,
52
52
  smile_type: str,
53
- smile_version: Version | None,
53
+ smile_version: Version,
54
54
  smile_zigbee_mac_address: str | None,
55
55
  ) -> None:
56
56
  """Set the constructor for this class."""
@@ -231,21 +231,50 @@ class SmileLegacyAPI(SmileLegacyData):
231
231
  async def set_switch_state(
232
232
  self, appl_id: str, members: list[str] | None, model: str, state: str
233
233
  ) -> None:
234
- """Set the given State of the relevant Switch."""
234
+ """Set the given state of the relevant switch.
235
+
236
+ For individual switches, sets the state directly.
237
+ For group switches, sets the state for each member in the group separately.
238
+ For switch-locks, sets the lock state using a different data format.
239
+ """
235
240
  switch = Munch()
236
241
  switch.actuator = "actuator_functionalities"
237
242
  switch.func_type = "relay_functionality"
238
243
  if self._stretch_v2:
239
244
  switch.actuator = "actuators"
240
245
  switch.func_type = "relay"
241
- switch.func = "state"
242
246
 
247
+ # Handle switch-lock
248
+ if model == "lock":
249
+ state = "false" if state == "off" else "true"
250
+ appliance = self._appliances.find(f'appliance[@id="{appl_id}"]')
251
+ appl_name = appliance.find("name").text
252
+ appl_type = appliance.find("type").text
253
+ data = f'''
254
+ <appliances>
255
+ <appliance id="{appl_id}">
256
+ <name><![CDATA[{appl_name}]]></name>
257
+ <description><![CDATA[]]></description>
258
+ <type><![CDATA[{appl_type}]]></type>
259
+ <{switch.actuator}>
260
+ <{switch.func_type}>
261
+ <lock>{state}</lock>
262
+ </{switch.func_type}>
263
+ </{switch.actuator}>
264
+ </appliance>
265
+ </appliances>'''.strip()
266
+ await self.call_request(APPLIANCES, method="post", data=data)
267
+ return
268
+
269
+ # Handle group of switches
270
+ data = f"<{switch.func_type}><state>{state}</state></{switch.func_type}>"
243
271
  if members is not None:
244
- return await self._set_groupswitch_member_state(members, state, switch)
245
-
246
- data = f"<{switch.func_type}><{switch.func}>{state}</{switch.func}></{switch.func_type}>"
247
- uri = f"{APPLIANCES};id={appl_id}/{switch.func_type}"
272
+ return await self._set_groupswitch_member_state(
273
+ data, members, state, switch
274
+ )
248
275
 
276
+ # Handle individual relay switches
277
+ uri = f"{APPLIANCES};id={appl_id}/relay"
249
278
  if model == "relay":
250
279
  locator = (
251
280
  f'appliance[@id="{appl_id}"]/{switch.actuator}/{switch.func_type}/lock'
@@ -257,16 +286,14 @@ class SmileLegacyAPI(SmileLegacyData):
257
286
  await self.call_request(uri, method="put", data=data)
258
287
 
259
288
  async def _set_groupswitch_member_state(
260
- self, members: list[str], state: str, switch: Munch
289
+ self, data: str, members: list[str], state: str, switch: Munch
261
290
  ) -> None:
262
291
  """Helper-function for set_switch_state().
263
292
 
264
- Set the given State of the relevant Switch within a group of members.
293
+ Set the given State of the relevant Switch (relay) within a group of members.
265
294
  """
266
295
  for member in members:
267
- uri = f"{APPLIANCES};id={member}/{switch.func_type}"
268
- data = f"<{switch.func_type}><{switch.func}>{state}</{switch.func}></{switch.func_type}>"
269
-
296
+ uri = f"{APPLIANCES};id={member}/relay"
270
297
  await self.call_request(uri, method="put", data=data)
271
298
 
272
299
  async def set_temperature(self, _: str, items: dict[str, float]) -> None:
plugwise/smile.py CHANGED
@@ -59,7 +59,7 @@ class SmileAPI(SmileData):
59
59
  smile_model_id: str | None,
60
60
  smile_name: str,
61
61
  smile_type: str,
62
- smile_version: Version | None,
62
+ smile_version: Version,
63
63
  ) -> None:
64
64
  """Set the constructor for this class."""
65
65
  self._cooling_present = _cooling_present
plugwise/util.py CHANGED
@@ -218,7 +218,7 @@ def get_vendor_name(module: etree, model_data: ModuleData) -> ModuleData:
218
218
  if (vendor_name := module.find("vendor_name").text) is not None:
219
219
  model_data["vendor_name"] = vendor_name
220
220
  if "Plugwise" in vendor_name:
221
- model_data["vendor_name"] = vendor_name.split(" ", 1)[0]
221
+ model_data["vendor_name"] = vendor_name.partition(" ")[0]
222
222
 
223
223
  return model_data
224
224
 
@@ -275,9 +275,9 @@ def power_data_peak_value(loc: Munch, legacy: bool) -> Munch:
275
275
  if not loc.found:
276
276
  return loc
277
277
 
278
- if (peak := loc.peak_select.split("_")[1]) == "offpeak":
278
+ if (peak := loc.peak_select.partition("_")[2]) == "offpeak":
279
279
  peak = "off_peak"
280
- log_found = loc.log_type.split("_")[0]
280
+ log_found = loc.log_type.partition("_")[0]
281
281
  loc.key_string = f"{loc.measurement}_{peak}_{log_found}"
282
282
  if "gas" in loc.measurement or loc.log_type == "point_meter":
283
283
  loc.key_string = f"{loc.measurement}_{log_found}"
@@ -314,7 +314,7 @@ def skip_obsolete_measurements(xml: etree, measurement: str) -> bool:
314
314
  measurement in OBSOLETE_MEASUREMENTS
315
315
  and (updated_date_key := xml.find(locator)) is not None
316
316
  ):
317
- updated_date = updated_date_key.text.split("T")[0]
317
+ updated_date = updated_date_key.text.partition("T")[0]
318
318
  date_1 = dt.datetime.strptime(updated_date, "%Y-%m-%d")
319
319
  date_2 = dt.datetime.now()
320
320
  return int((date_2 - date_1).days) > 7
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: plugwise
3
- Version: 1.7.0
3
+ Version: 1.7.2
4
4
  Summary: Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3.
5
5
  Home-page: https://github.com/plugwise/python-plugwise
6
6
  Author: Plugwise device owners
@@ -0,0 +1,18 @@
1
+ plugwise/__init__.py,sha256=3ewWm0PtaLgYsD4oHJ8BQ3DJMV3c-Qx2mWbdcJQkdAk,17770
2
+ plugwise/common.py,sha256=_41FLLjgccaHjaV0Ndn1YEkxjB_qKev1k3ZnhSUzXjc,9305
3
+ plugwise/constants.py,sha256=Vd8tvOHsRtZxtUUFXBXolZj3QiKnxRt0bnwDT9DoEqE,17073
4
+ plugwise/data.py,sha256=ITGnS5RiRbd3O2KbYLc9_5okw81zLl7azXNXtuTwaoY,13022
5
+ plugwise/exceptions.py,sha256=Ce-tO9uNsMB-8FP6VAxBvsHNJ-NIM9F0onUZOdZI4Ys,1110
6
+ plugwise/helper.py,sha256=v8qXFau2bXnJ4xGde9NuljA-LLEWSL1SJVcnXQX-jiE,39397
7
+ plugwise/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ plugwise/smile.py,sha256=J8_CevN7FSYnAccYv4Hp_H3o9lfHGM_fYlLYAvuqJKw,18921
9
+ plugwise/smilecomm.py,sha256=aQ2KkebDTou18k-flrVmTnFkgls33Xu8D9ZZQQt2R5k,5178
10
+ plugwise/util.py,sha256=d3nOS9fzZ1MwJX8_77KOgW3CtQnGYc0oGcnqHrlxlLo,11015
11
+ plugwise/legacy/data.py,sha256=s2WYjgxwcuAGS8UOxJVf7xLSxS38Zgr8GsjxlxfD98w,3574
12
+ plugwise/legacy/helper.py,sha256=CjLGUhWRgNCOyooVyylLABdv0H2zoiKzjhQ-g7E8x9M,17059
13
+ plugwise/legacy/smile.py,sha256=zPIuOBUfhjaOZqMR0T5lw3-qB_9KHhAaBMW06tR1NT8,12836
14
+ plugwise-1.7.2.dist-info/LICENSE,sha256=mL22BjmXtg_wnoDnnaqps5_Bg_VGj_yHueX5lsKwbCc,1144
15
+ plugwise-1.7.2.dist-info/METADATA,sha256=NBEB-iLRSihQX8UuHyVQmg2hIZCU1gf_8aximWzJ3K0,9148
16
+ plugwise-1.7.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
17
+ plugwise-1.7.2.dist-info/top_level.txt,sha256=MYOmktMFf8ZmX6_OE1y9MoCZFfY-L8DA0F2tA2IvE4s,9
18
+ plugwise-1.7.2.dist-info/RECORD,,
@@ -1,18 +0,0 @@
1
- plugwise/__init__.py,sha256=fyot91I4cMkgo_8fL1hycRXwGBDecUq9ltxLAfSY-2U,17762
2
- plugwise/common.py,sha256=_41FLLjgccaHjaV0Ndn1YEkxjB_qKev1k3ZnhSUzXjc,9305
3
- plugwise/constants.py,sha256=Vd8tvOHsRtZxtUUFXBXolZj3QiKnxRt0bnwDT9DoEqE,17073
4
- plugwise/data.py,sha256=ITGnS5RiRbd3O2KbYLc9_5okw81zLl7azXNXtuTwaoY,13022
5
- plugwise/exceptions.py,sha256=Ce-tO9uNsMB-8FP6VAxBvsHNJ-NIM9F0onUZOdZI4Ys,1110
6
- plugwise/helper.py,sha256=dsdPpwJHiZ3DQoTc7kWoOiFVPvRda5u1GRJwAEDxuBk,39388
7
- plugwise/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- plugwise/smile.py,sha256=I8lssyqmq_PF8ptLxk3daS7lf20kXr5Z3L7SYg3S9j4,18928
9
- plugwise/smilecomm.py,sha256=aQ2KkebDTou18k-flrVmTnFkgls33Xu8D9ZZQQt2R5k,5178
10
- plugwise/util.py,sha256=7OPtC4FDbAweAqad6b-6tKtMlSSQd3OU7g5-0lplF34,11002
11
- plugwise/legacy/data.py,sha256=s2WYjgxwcuAGS8UOxJVf7xLSxS38Zgr8GsjxlxfD98w,3574
12
- plugwise/legacy/helper.py,sha256=GslPqZL0gAAnqJVy-Ydp_U-eGQ5jYhz9F_Y15BfQgt4,17056
13
- plugwise/legacy/smile.py,sha256=TxjqRf7KIecECt48iHgSFI7bIOEHNkf4desSBVo1l-M,11666
14
- plugwise-1.7.0.dist-info/LICENSE,sha256=mL22BjmXtg_wnoDnnaqps5_Bg_VGj_yHueX5lsKwbCc,1144
15
- plugwise-1.7.0.dist-info/METADATA,sha256=ZWR9Mhkp1CknISTs1adzs9jePeIWqW9M89qMnUyvGI8,9148
16
- plugwise-1.7.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
17
- plugwise-1.7.0.dist-info/top_level.txt,sha256=MYOmktMFf8ZmX6_OE1y9MoCZFfY-L8DA0F2tA2IvE4s,9
18
- plugwise-1.7.0.dist-info/RECORD,,