plugwise 1.7.1__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
@@ -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/legacy/smile.py CHANGED
@@ -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:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: plugwise
3
- Version: 1.7.1
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
@@ -1,4 +1,4 @@
1
- plugwise/__init__.py,sha256=hLwUqdGAo39LzTXYz6Lkua_9RelJx5k-uAeJSrZdfYk,17760
1
+ plugwise/__init__.py,sha256=3ewWm0PtaLgYsD4oHJ8BQ3DJMV3c-Qx2mWbdcJQkdAk,17770
2
2
  plugwise/common.py,sha256=_41FLLjgccaHjaV0Ndn1YEkxjB_qKev1k3ZnhSUzXjc,9305
3
3
  plugwise/constants.py,sha256=Vd8tvOHsRtZxtUUFXBXolZj3QiKnxRt0bnwDT9DoEqE,17073
4
4
  plugwise/data.py,sha256=ITGnS5RiRbd3O2KbYLc9_5okw81zLl7azXNXtuTwaoY,13022
@@ -10,9 +10,9 @@ plugwise/smilecomm.py,sha256=aQ2KkebDTou18k-flrVmTnFkgls33Xu8D9ZZQQt2R5k,5178
10
10
  plugwise/util.py,sha256=d3nOS9fzZ1MwJX8_77KOgW3CtQnGYc0oGcnqHrlxlLo,11015
11
11
  plugwise/legacy/data.py,sha256=s2WYjgxwcuAGS8UOxJVf7xLSxS38Zgr8GsjxlxfD98w,3574
12
12
  plugwise/legacy/helper.py,sha256=CjLGUhWRgNCOyooVyylLABdv0H2zoiKzjhQ-g7E8x9M,17059
13
- plugwise/legacy/smile.py,sha256=aCG5uaOCS4GOGfIbxTp8U-CFE3Cib-UspB4qSamm_eY,11659
14
- plugwise-1.7.1.dist-info/LICENSE,sha256=mL22BjmXtg_wnoDnnaqps5_Bg_VGj_yHueX5lsKwbCc,1144
15
- plugwise-1.7.1.dist-info/METADATA,sha256=Dnc7KdcTcDjT33JYXSkkDkHXkxKHXEet2gXQcQpSuyo,9148
16
- plugwise-1.7.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
17
- plugwise-1.7.1.dist-info/top_level.txt,sha256=MYOmktMFf8ZmX6_OE1y9MoCZFfY-L8DA0F2tA2IvE4s,9
18
- plugwise-1.7.1.dist-info/RECORD,,
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,,