ihcsdk 2.8.9__py3-none-any.whl → 2.8.10__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.

Potentially problematic release.


This version of ihcsdk might be problematic. Click here for more details.

ihcsdk/ihcclient.py CHANGED
@@ -356,7 +356,7 @@ class IHCSoapClient:
356
356
  case "WSBooleanValue":
357
357
  result = resource_value.find("./ns2:value", IHCSoapClient.ihcns).text == "true"
358
358
  case "WSIntegerValue":
359
- result = int( resource_value.find("./ns2:integer", IHCSoapClient.ihcns).text)
359
+ result = int(resource_value.find("./ns2:integer", IHCSoapClient.ihcns).text)
360
360
  case "WSFloatingPointValue":
361
361
  result = round(float(resource_value.find("./ns2:floatingPointValue", IHCSoapClient.ihcns).text), 2)
362
362
  case "WSEnumValue":
ihcsdk/ihcconnection.py CHANGED
@@ -3,6 +3,7 @@
3
3
  # pylint: disable=too-few-public-methods
4
4
  import logging
5
5
  import requests
6
+ import time
6
7
  import xml.etree.ElementTree
7
8
 
8
9
  from urllib.parse import urlparse
@@ -10,8 +11,7 @@ from urllib3.util import Retry
10
11
  from requests.adapters import HTTPAdapter
11
12
 
12
13
  _LOGGER = logging.getLogger(__name__)
13
-
14
-
14
+
15
15
  class IHCConnection(object):
16
16
  """Implements a http connection to the controller"""
17
17
 
@@ -35,6 +35,10 @@ class IHCConnection(object):
35
35
  allowed_methods={"POST"},
36
36
  )
37
37
  self.session.mount("http://", HTTPAdapter(max_retries=self.retries))
38
+ # default minimum time between calls in seconds (0 will not rate limit)
39
+ self.min_interval: float = 0.0
40
+ self.last_call_time:float = 0
41
+ self.logtiming = False
38
42
 
39
43
  def cert_verify(self):
40
44
  return None
@@ -50,6 +54,7 @@ class IHCConnection(object):
50
54
  "SOAPAction": action,
51
55
  }
52
56
  try:
57
+ self.rateLimit()
53
58
  _LOGGER.debug("soap payload %s", payload)
54
59
  self.last_exception = None
55
60
  response = self.session.post(
@@ -75,3 +80,17 @@ class IHCConnection(object):
75
80
  self.last_exception = exp
76
81
  self.last_response = response
77
82
  return False
83
+
84
+ def rateLimit( self):
85
+ """ Rate limit the calls to this function."""
86
+ current_time: float = time.time()
87
+ time_since_last_call: float = current_time - self.last_call_time
88
+ if self.logtiming:
89
+ _LOGGER.warning("time since last call %f sec", time_since_last_call)
90
+ # If not enough time has passed, sleep for the remaining time
91
+ if time_since_last_call < self.min_interval:
92
+ sleep_time:float = self.min_interval - time_since_last_call
93
+ _LOGGER.debug("Ratelimiting for %f sec", sleep_time)
94
+ time.sleep(sleep_time)
95
+ # Update the last call time and call the function
96
+ self.last_call_time = time.time()
ihcsdk/ihccontroller.py CHANGED
@@ -70,6 +70,10 @@ class IHCController:
70
70
  TODO call disconnect on ihcclient
71
71
  """
72
72
  self._notifyrunning = False
73
+ # wait for notify thread to finish
74
+ while self._notifythread.is_alive():
75
+ time.sleep(0.1) # Optional sleep to prevent busy waiting
76
+ self.client.connection.session.close()
73
77
 
74
78
  def get_runtime_value(self, ihcid: int):
75
79
  """Get runtime value with re-authenticate if needed"""
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: ihcsdk
3
- Version: 2.8.9
3
+ Version: 2.8.10
4
4
  Summary: IHC Python SDK
5
5
  Home-page: https://github.com/dingusdk/PythonIhcSdk
6
6
  Author: Jens Nielsen
@@ -8,5 +8,11 @@ License: GPL-3.0
8
8
  License-File: license.txt
9
9
  Requires-Dist: requests
10
10
  Requires-Dist: cryptography
11
+ Dynamic: author
12
+ Dynamic: description
13
+ Dynamic: home-page
14
+ Dynamic: license
15
+ Dynamic: requires-dist
16
+ Dynamic: summary
11
17
 
12
18
  SDK for connection to the LK IHC Controller. Made for interfacing to home assistant
@@ -0,0 +1,12 @@
1
+ ihcsdk/__init__.py,sha256=ocAoa28ZKxGgMlDEHWEsd7n00OtGB0R9N7XQfRlih9Q,28
2
+ ihcsdk/ihcclient.py,sha256=bARciki9Aw2bTt9dAz8ovUar1aOoP4tzTcrL7ahv1dA,24307
3
+ ihcsdk/ihcconnection.py,sha256=T6Jw2cBB_jP8B5nWADCZHPUT9aTvkmlQ8eQvwGUJX7E,3845
4
+ ihcsdk/ihccontroller.py,sha256=OFz8vZhRSWXtB3rnGXC6XGH6xvCUhEwYICv3Pa-CNe0,9389
5
+ ihcsdk/ihcsslconnection.py,sha256=q7gDchCN2_SXItp2T3dMvlXmHC7zVO5M0bqGnepiKiU,2079
6
+ ihcsdk/certs/ihc.crt,sha256=VYY_DiHrctlXBTNXGdJ2FN4TYuVnwnpVZ1i8t2_0cec,1002
7
+ ihcsdk/certs/ihc3.crt,sha256=Ka2L8zQ06A76W6fZc0ckScdrj1Cn-mhgqdhc61-cCrk,1398
8
+ ihcsdk-2.8.10.dist-info/METADATA,sha256=RtGjFqMUHSfBwSXfSr8nr_eD85UNJBuPrlY_bwlPHNI,459
9
+ ihcsdk-2.8.10.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
10
+ ihcsdk-2.8.10.dist-info/license.txt,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
11
+ ihcsdk-2.8.10.dist-info/top_level.txt,sha256=QgKE7TWblC-uXe5-7MVO5JtzvrPiMoVmGgKKsVR43hU,7
12
+ ihcsdk-2.8.10.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,12 +0,0 @@
1
- ihcsdk/__init__.py,sha256=ocAoa28ZKxGgMlDEHWEsd7n00OtGB0R9N7XQfRlih9Q,28
2
- ihcsdk/ihcclient.py,sha256=UWXxa5dPh80Bi9InrK8VfBswCS5qDBLMZQ4i5WGEz8A,24308
3
- ihcsdk/ihcconnection.py,sha256=qCFhU4cAWYnqgiXWF-xjUZj1TMBZ83caDj8jEE1qaoc,2889
4
- ihcsdk/ihccontroller.py,sha256=9D97RX8DrFMLMxDBcIrhoYY-QEeKNjbVv_PiRW0wNyU,9180
5
- ihcsdk/ihcsslconnection.py,sha256=q7gDchCN2_SXItp2T3dMvlXmHC7zVO5M0bqGnepiKiU,2079
6
- ihcsdk/certs/ihc.crt,sha256=VYY_DiHrctlXBTNXGdJ2FN4TYuVnwnpVZ1i8t2_0cec,1002
7
- ihcsdk/certs/ihc3.crt,sha256=Ka2L8zQ06A76W6fZc0ckScdrj1Cn-mhgqdhc61-cCrk,1398
8
- ihcsdk-2.8.9.dist-info/METADATA,sha256=EQsoHVGo9EvSx7pZ5Q06vHNAgCY2DhbvEM84KYe73Hc,339
9
- ihcsdk-2.8.9.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
10
- ihcsdk-2.8.9.dist-info/license.txt,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
11
- ihcsdk-2.8.9.dist-info/top_level.txt,sha256=QgKE7TWblC-uXe5-7MVO5JtzvrPiMoVmGgKKsVR43hU,7
12
- ihcsdk-2.8.9.dist-info/RECORD,,