python-selve-new 2.2.16__tar.gz → 2.2.18__tar.gz

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.
Files changed (46) hide show
  1. {python_selve_new-2.2.16/python_selve_new.egg-info → python_selve_new-2.2.18}/PKG-INFO +1 -1
  2. {python_selve_new-2.2.16 → python_selve_new-2.2.18/python_selve_new.egg-info}/PKG-INFO +1 -1
  3. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/__init__.py +26 -6
  4. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/setup.py +1 -1
  5. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/test.py +1 -1
  6. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/.github/FUNDING.yml +0 -0
  7. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/.github/workflows/python-publish.yml +0 -0
  8. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/.gitignore +0 -0
  9. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/.idea/.gitignore +0 -0
  10. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/.idea/inspectionProfiles/profiles_settings.xml +0 -0
  11. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/.idea/misc.xml +0 -0
  12. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/.idea/modules.xml +0 -0
  13. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/.idea/python-selve-new.iml +0 -0
  14. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/.idea/vcs.xml +0 -0
  15. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/.vscode/settings.json +0 -0
  16. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/LICENSE +0 -0
  17. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/README.md +0 -0
  18. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/package.sh +0 -0
  19. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/pyproject.toml +0 -0
  20. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/python_selve_new.egg-info/SOURCES.txt +0 -0
  21. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/python_selve_new.egg-info/dependency_links.txt +0 -0
  22. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/python_selve_new.egg-info/entry_points.txt +0 -0
  23. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/python_selve_new.egg-info/requires.txt +0 -0
  24. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/python_selve_new.egg-info/top_level.txt +0 -0
  25. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/commands/__init__.py +0 -0
  26. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/commands/command.py +0 -0
  27. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/commands/device.py +0 -0
  28. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/commands/event.py +0 -0
  29. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/commands/group.py +0 -0
  30. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/commands/iveo.py +0 -0
  31. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/commands/param.py +0 -0
  32. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/commands/senSim.py +0 -0
  33. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/commands/sender.py +0 -0
  34. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/commands/sensor.py +0 -0
  35. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/commands/service.py +0 -0
  36. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/device.py +0 -0
  37. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/gateway.py +0 -0
  38. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/group.py +0 -0
  39. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/iveo.py +0 -0
  40. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/senSim.py +0 -0
  41. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/sender.py +0 -0
  42. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/sensor.py +0 -0
  43. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/util/__init__.py +0 -0
  44. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/util/errors.py +0 -0
  45. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/selve/util/protocol.py +0 -0
  46. {python_selve_new-2.2.16 → python_selve_new-2.2.18}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-selve-new
3
- Version: 2.2.16
3
+ Version: 2.2.18
4
4
  Summary: Python library for interfacing with selve devices using the USB-RF controller. Written completely new.
5
5
  Home-page: https://github.com/Kannix2005/python-selve-new
6
6
  Author: Stefan Altheimer
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-selve-new
3
- Version: 2.2.16
3
+ Version: 2.2.18
4
4
  Summary: Python library for interfacing with selve devices using the USB-RF controller. Written completely new.
5
5
  Home-page: https://github.com/Kannix2005/python-selve-new
6
6
  Author: Stefan Altheimer
@@ -9,6 +9,7 @@ from typing import Callable
9
9
 
10
10
  import serial
11
11
  from serial.tools import list_ports
12
+ from serial import SerialException
12
13
  import untangle
13
14
 
14
15
  from selve.commands import param, service
@@ -39,12 +40,13 @@ from selve.util.protocol import ParameterType
39
40
  class Selve:
40
41
  """Implementation of the serial communication to the Selve Gateway"""
41
42
 
42
- def __init__(self, port=None, discover=True, develop=False, logger=None):
43
+ def __init__(self, port=None, discover=True, develop=False, logger=None, loop=None):
43
44
  # Gateway state
44
45
  self._callbacks = set()
45
46
  self._eventCallbacks = set()
46
47
  self.lastLogEvent = None
47
48
  self.state = None
49
+ self.loop = loop
48
50
 
49
51
  # Data from Duty Cycle Event
50
52
  self.utilization = 0
@@ -216,8 +218,6 @@ class Selve:
216
218
  self._LOGGER.debug("(Selve Worker): " + "Waiting 5 seconds before trying...")
217
219
  await asyncio.sleep(5)
218
220
  self._LOGGER.debug("(Selve Worker): " + "Recovering")
219
-
220
-
221
221
 
222
222
  if self._port is not None:
223
223
  try:
@@ -238,8 +238,11 @@ class Selve:
238
238
  except Exception as e:
239
239
  self._LOGGER.error("(Selve Worker): " + "Unknown exception: " + str(e))
240
240
 
241
-
242
- available_ports = list_ports.comports()
241
+ if self.loop is not None:
242
+ available_ports = await self.loop.run_in_executor(None, list_ports.comports())
243
+ else:
244
+ available_ports = list_ports.comports()
245
+
243
246
  self._LOGGER.debug("(Selve Worker): " + "available comports: " + str(available_ports))
244
247
 
245
248
  if len(available_ports) == 0:
@@ -348,8 +351,25 @@ class Selve:
348
351
  self._serial.flush()
349
352
  #always sleep after writing
350
353
  await asyncio.sleep(0.5)
354
+
355
+ except SerialException as se:
356
+ self._LOGGER.info('Serial error, trying to reconnect once... ' + str(se))
357
+ await self.recover()
358
+
359
+ try:
360
+ self._LOGGER.debug('Trying again...')
361
+ if not self._serial.is_open:
362
+ self._serial.open()
363
+ self._serial.write(commandstr)
364
+ self._serial.flush()
365
+ #always sleep after writing
366
+ await asyncio.sleep(0.5)
367
+
368
+ except Exception as e:
369
+ self._LOGGER.error("error communicating: " + str(e) + " ; Please restart the integration!")
370
+
351
371
  except Exception as e:
352
- self._LOGGER.error("error communicating: " + str(e))
372
+ self._LOGGER.error("error communicating: " + str(e) + " ; Please restart the integration!")
353
373
 
354
374
  async def processResponse(self, xmlstr):
355
375
  """Processes an XML String into a response object. Returns False if something went wrong or the gateway returned an error."""
@@ -15,7 +15,7 @@ with open(path.join(here, 'README.md'), encoding='utf-8') as f:
15
15
  setup(
16
16
 
17
17
  name='python-selve-new', # Required
18
- version='2.2.16', # Required
18
+ version='2.2.18', # Required
19
19
  description='Python library for interfacing with selve devices using the USB-RF controller. Written completely new.', # Required
20
20
  long_description=long_description, # Optional
21
21
  long_description_content_type="text/markdown",
@@ -19,7 +19,7 @@ handler.setFormatter(formatter)
19
19
  logger.addHandler(handler)
20
20
 
21
21
 
22
- selve = selve.Selve(portname, develop=True, discover=False, logger=logger)
22
+ selve = selve.Selve(portname, develop=True, discover=False, logger=logger, loop=loop)
23
23
  loop.run_until_complete(selve.setup())
24
24
 
25
25
  loop.run_until_complete(selve.discover())