python-selve-new 2.2.9__tar.gz → 2.2.11__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 (32) hide show
  1. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/PKG-INFO +1 -1
  2. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/python_selve_new.egg-info/PKG-INFO +1 -1
  3. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/__init__.py +113 -100
  4. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/util/__init__.py +20 -20
  5. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/setup.py +1 -1
  6. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/LICENSE +0 -0
  7. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/README.md +0 -0
  8. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/python_selve_new.egg-info/SOURCES.txt +0 -0
  9. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/python_selve_new.egg-info/dependency_links.txt +0 -0
  10. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/python_selve_new.egg-info/requires.txt +0 -0
  11. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/python_selve_new.egg-info/top_level.txt +0 -0
  12. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/commands/__init__.py +0 -0
  13. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/commands/command.py +0 -0
  14. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/commands/device.py +0 -0
  15. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/commands/event.py +0 -0
  16. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/commands/group.py +0 -0
  17. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/commands/iveo.py +0 -0
  18. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/commands/param.py +0 -0
  19. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/commands/senSim.py +0 -0
  20. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/commands/sender.py +0 -0
  21. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/commands/sensor.py +0 -0
  22. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/commands/service.py +0 -0
  23. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/device.py +0 -0
  24. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/gateway.py +0 -0
  25. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/group.py +0 -0
  26. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/iveo.py +0 -0
  27. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/senSim.py +0 -0
  28. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/sender.py +0 -0
  29. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/sensor.py +0 -0
  30. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/util/errors.py +0 -0
  31. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/selve/util/protocol.py +0 -0
  32. {python-selve-new-2.2.9 → python-selve-new-2.2.11}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-selve-new
3
- Version: 2.2.9
3
+ Version: 2.2.11
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.9
3
+ Version: 2.2.11
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
@@ -89,28 +89,14 @@ class Selve:
89
89
  if not self._pauseWorker.is_set():
90
90
  if not self._serial.is_open:
91
91
  self._serial.open()
92
- async with self._writeLock:
93
- async with self._readLock:
94
- if not self.txQ.empty():
95
- data: Command = await self.txQ.get()
96
- await self._sendCommandToGateway(data)
97
- start_time = time.time()
98
- while True:
99
- if self._serial.in_waiting > 0:
100
- msg = ""
101
- while True:
102
- response = self._serial.readline().strip()
103
- msg += response.decode()
104
- if response.decode() == '':
105
- break
106
- self._LOGGER.debug(f'Received: {msg}')
107
- await self.processResponse(msg)
108
- break
109
- # When no data is waiting in the input buffer after 10s we can assume, the message was not correctly sent or no input is necessary
110
- if time.time() - start_time > 10:
111
- break
112
- # When no data is waiting in the input buffer after 10s we can assume, the message was not correctly sent or no input is necessary
113
- else:
92
+ if not self.txQ.empty():
93
+ data: Command = await self.txQ.get()
94
+ await self.executeCommandSyncWithResponsefromWorker(data)
95
+ self.txQ.task_done()
96
+ # When no data is waiting in the input buffer after 10s we can assume, the message was not correctly sent or no input is necessary
97
+ else:
98
+ async with self._writeLock:
99
+ async with self._readLock:
114
100
  if self._serial.in_waiting > 0:
115
101
  msg = ""
116
102
  while True:
@@ -127,7 +113,7 @@ class Selve:
127
113
  if self._stopThread.is_set():
128
114
  self._LOGGER.debug("(Selve Worker): " + 'Exiting worker loop...')
129
115
  break
130
- await asyncio.sleep(0.5)
116
+ await asyncio.sleep(0.1)
131
117
  return True
132
118
  # serial port exceptions, all of these notify that we are in some
133
119
  # serious trouble
@@ -212,14 +198,18 @@ class Selve:
212
198
 
213
199
  async def startWorker(self):
214
200
  self._LOGGER.debug("Starting worker")
215
- if self.workerTask is not None:
216
- self._LOGGER.debug("Running worker detected")
217
- await self.stopWorker()
218
201
  self._pauseWorker.clear()
219
202
  self._stopThread.clear()
220
- self._LOGGER.debug("Set variables")
221
- self.workerTask = asyncio.create_task(self._worker())
222
- self._LOGGER.debug("created task")
203
+ if self.workerTask is not None:
204
+ self._LOGGER.debug("Running worker detected")
205
+ if self.workerTask.cancelled() or self.workerTask.done():
206
+ self.workerTask = None
207
+ self.workerTask = asyncio.create_task(self._worker())
208
+ else:
209
+ self._LOGGER.debug("Let running worker live")
210
+ else:
211
+ self.workerTask = asyncio.create_task(self._worker())
212
+
223
213
 
224
214
  async def stopWorker(self):
225
215
  self._LOGGER.debug("Stopping worker")
@@ -268,7 +258,7 @@ class Selve:
268
258
  self._serial.write(commandstr)
269
259
  self._serial.flush()
270
260
  #always sleep after writing
271
- #await asyncio.sleep(0.5)
261
+ await asyncio.sleep(0.5)
272
262
  except Exception as e:
273
263
  self._LOGGER.error("error communicating: " + str(e))
274
264
 
@@ -308,6 +298,7 @@ class Selve:
308
298
  or isinstance(response, LogEventResponse) \
309
299
  or isinstance(response, DutyCycleResponse):
310
300
  await self.processEventResponse(response)
301
+ return True
311
302
  if isinstance(response, CommandResultResponse)\
312
303
  or isinstance(response, IveoResultResponse):
313
304
  #update device values
@@ -318,9 +309,13 @@ class Selve:
318
309
  or isinstance(response, SensorTeachResultResponse)\
319
310
  or isinstance(response, DeviceScanResultResponse):
320
311
  self.processTeachResponse(response)
312
+ return True
321
313
 
314
+ for callback in self._callbacks:
315
+ callback()
322
316
  return response
323
317
 
318
+
324
319
  except Exception as e:
325
320
  self._LOGGER.error("Error in response processing: " + str(e) + " : " + xmlstr)
326
321
  return False
@@ -350,7 +345,9 @@ class Selve:
350
345
  if hasattr(array, "string"):
351
346
  if methodName == "":
352
347
  methodName = list(array.string)[0].cdata
353
- str_params_tmp = list(array.string)[1:]
348
+ str_params_tmp = list(array.string)[1:]
349
+ else:
350
+ str_params_tmp = list(array.string)[0:]
354
351
  str_params = [(ParameterType.STRING, v.cdata) for v in str_params_tmp]
355
352
  int_params = []
356
353
  if hasattr(array, str(ParameterType.INT.value)):
@@ -550,23 +547,29 @@ class Selve:
550
547
 
551
548
 
552
549
  async def executeCommandSyncWithResponse(self, command: Command):
550
+ await self.stopWorker()
553
551
  resp = await self._executeCommandSyncWithResponse(command)
554
- await asyncio.sleep(0.5)
555
552
  if (resp == False):
556
553
  #something went wrong, try again
557
554
  resp = await self._executeCommandSyncWithResponse(command)
558
- await asyncio.sleep(0.5)
559
555
 
556
+ await self.startWorker()
560
557
  return resp
561
558
 
562
- async def _executeCommandSyncWithResponse(self, command: Command):
563
559
 
564
- await self.stopWorker()
560
+ async def executeCommandSyncWithResponsefromWorker(self, command: Command):
565
561
 
566
- if not self._serial.is_open:
567
- self._serial.open()
562
+ resp = await self._executeCommandSyncWithResponse(command)
563
+ if (resp == False):
564
+ #something went wrong, try again
565
+ resp = await self._executeCommandSyncWithResponse(command)
566
+ return resp
567
+
568
+ async def _executeCommandSyncWithResponse(self, command: Command):
568
569
  async with self._writeLock:
569
570
  async with self._readLock:
571
+ if not self._serial.is_open:
572
+ self._serial.open()
570
573
  await self._sendCommandToGateway(command)
571
574
  start_time = time.time()
572
575
  while True:
@@ -579,23 +582,19 @@ class Selve:
579
582
  break
580
583
  # if msg.rstrip() == b' ':
581
584
  self._LOGGER.debug(f'Received: {msg}')
582
- await self.startWorker()
583
585
 
584
586
  resp = await self.processResponse(msg)
585
587
 
586
- if (resp == False):
587
- #something went wrong, try again
588
- return False
589
-
590
588
  if isinstance(resp, ErrorResponse):
591
589
  self._LOGGER.error(resp.message)
592
590
  # retry
593
591
  return False
592
+ if resp is None:
593
+ return False
594
594
 
595
595
  return resp
596
596
  # When no data is waiting in the input buffer after 10s we can assume, the message was not correctly sent or no input is necessary
597
597
  if time.time() - start_time > 10:
598
- await self.startWorker()
599
598
  return False
600
599
 
601
600
 
@@ -772,7 +771,7 @@ class Selve:
772
771
  self._LOGGER.info("Time left for teaching: " + str(response.timeLeft) + "s")
773
772
  self._LOGGER.debug("Current teaching state: " + str(response.teachState.name))
774
773
  self._LOGGER.info("Last event: " + str(response.senderEvent.name))
775
-
774
+
776
775
  if isinstance(response, SensorTeachResultResponse):
777
776
  if response.foundId == -1:
778
777
  self._LOGGER.info("No Senders found yet...")
@@ -780,7 +779,7 @@ class Selve:
780
779
  self._LOGGER.info("Sensor found: " + str(response.foundId))
781
780
  self._LOGGER.info("Time left for teaching: " + str(response.timeLeft) + "s")
782
781
  self._LOGGER.debug("Current teaching state: " + str(response.teachState.name))
783
-
782
+
784
783
  if isinstance(response, DeviceScanResultResponse):
785
784
  if response.noNewDevices <= 0:
786
785
  self._LOGGER.info("No Senders found yet...")
@@ -867,7 +866,21 @@ class Selve:
867
866
  self.utilization = response.traffic
868
867
 
869
868
 
870
- def commandResult(self, response):
869
+ def commandResult(self, response: IveoResultResponse | CommandResultResponse):
870
+
871
+ # if isinstance(response, IveoResultResponse):
872
+ # for id in response.executedIds:
873
+ # dev = self.getDevice(id, SelveTypes.IVEO)
874
+
875
+ # if response.command is DriveCommandIveo.DOWN:
876
+ # dev.state = MovementState.DOWN_ON
877
+ # if response.command is DriveCommandIveo.UP:
878
+ # dev.state = MovementState.UP_ON
879
+ # if response.command is DriveCommandIveo.STOP:
880
+ # dev.state = MovementState.STOPPED_OFF
881
+
882
+ # self.addOrUpdateDevice(dev, SelveTypes.IVEO)
883
+
871
884
  for callback in self._callbacks:
872
885
  callback()
873
886
 
@@ -976,7 +989,7 @@ class Selve:
976
989
  command = ServiceSetLed(state)
977
990
  response: ServiceSetLedResponse = await self.executeCommandSyncWithResponse(command)
978
991
  return response.executed
979
-
992
+
980
993
  async def getLED(self):
981
994
  command = ServiceGetLed()
982
995
  response: ServiceGetLedResponse = await self.executeCommandSyncWithResponse(command)
@@ -996,37 +1009,37 @@ class Selve:
996
1009
  async def setEvents(self, eventDevice = False, eventSensor = False, eventSender = False, eventLogging = False, eventDuty = False):
997
1010
  command = ParamSetEvent(eventDevice, eventSensor, eventSender, eventLogging, eventDuty)
998
1011
  return await self.executeCommandSyncWithResponse(command)
999
-
1000
-
1012
+
1013
+
1001
1014
  async def getEvents(self):
1002
1015
  command = ParamGetEvent()
1003
1016
  response: ParamGetEventResponse = await self.executeCommandSyncWithResponse(command)
1004
1017
  return response
1005
-
1006
-
1018
+
1019
+
1007
1020
  async def getDuty(self):
1008
1021
  command = ParamGetDuty()
1009
1022
  response: ParamGetDutyResponse = await self.executeCommandSyncWithResponse(command)
1010
1023
  return response
1011
-
1024
+
1012
1025
  async def getRF(self):
1013
1026
  command = ParamGetRf()
1014
1027
  response: ParamGetRfResponse = await self.executeCommandSyncWithResponse(command)
1015
1028
  return response
1016
1029
 
1017
-
1030
+
1018
1031
 
1019
1032
  ##Device functions
1020
1033
  async def scanStart(self):
1021
1034
  command = DeviceScanStart()
1022
1035
  response: DeviceScanStartResponse = await self.executeCommandSyncWithResponse(command)
1023
1036
  return response.executed
1024
-
1037
+
1025
1038
  async def scanStop(self):
1026
1039
  command = DeviceScanStop()
1027
1040
  response: DeviceScanStopResponse = await self.executeCommandSyncWithResponse(command)
1028
1041
  return response.executed
1029
-
1042
+
1030
1043
  async def scanResult(self):
1031
1044
  """ manually polls the scan state, but the states are being reported automatically by the gateway itself"""
1032
1045
  command = DeviceScanResult()
@@ -1037,12 +1050,12 @@ class Selve:
1037
1050
  command = DeviceSave(id)
1038
1051
  response: DeviceSaveResponse = await self.executeCommandSyncWithResponse(command)
1039
1052
  return response.executed
1040
-
1053
+
1041
1054
  async def deviceGetIds(self):
1042
1055
  command = DeviceGetIds()
1043
1056
  response: DeviceGetIdsResponse = await self.executeCommandSyncWithResponse(command)
1044
1057
  return response
1045
-
1058
+
1046
1059
  async def deviceGetInfo(self, id: int):
1047
1060
  command = DeviceGetInfo(id)
1048
1061
  response: DeviceGetInfoResponse = await self.executeCommandSyncWithResponse(command)
@@ -1052,12 +1065,12 @@ class Selve:
1052
1065
  command = DeviceGetValues(id)
1053
1066
  response: DeviceGetValuesResponse = await self.executeCommandSyncWithResponse(command)
1054
1067
  return response
1055
-
1068
+
1056
1069
  async def deviceSetFunction(self, id: int, function: DeviceFunctions):
1057
1070
  command = DeviceSetFunction(id, function)
1058
1071
  response: DeviceSetFunctionResponse = await self.executeCommandSyncWithResponse(command)
1059
1072
  return response.executed
1060
-
1073
+
1061
1074
  async def deviceSetLabel(self, id: int, label: str):
1062
1075
  command = DeviceSetLabel(id, label)
1063
1076
  response: DeviceSetLabelResponse = await self.executeCommandSyncWithResponse(command)
@@ -1072,12 +1085,12 @@ class Selve:
1072
1085
  command = DeviceDelete(id)
1073
1086
  response: DeviceDeleteResponse = await self.executeCommandSyncWithResponse(command)
1074
1087
  return response.executed
1075
-
1088
+
1076
1089
  async def deviceWriteManual(self, id: int, address: int, name: str, config: DeviceType):
1077
1090
  command = DeviceWriteManual(id, address, name, config)
1078
1091
  response: DeviceWriteManualResponse = await self.executeCommandSyncWithResponse(command)
1079
1092
  return response.executed
1080
-
1093
+
1081
1094
  async def updateCommeoDeviceValues(self, id: int):
1082
1095
  response: DeviceGetValuesResponse = await self.executeCommandSyncWithResponse(DeviceGetValues(id))
1083
1096
  self.updateCommeoDeviceValuesFromResponse(id, response)
@@ -1121,70 +1134,70 @@ class Selve:
1121
1134
 
1122
1135
  async def moveDeviceUp(self, device: SelveDevice | IveoDevice, type=DeviceCommandType.MANUAL):
1123
1136
  if device.communicationType is CommunicationType.COMMEO:
1124
- await self.executeCommandSyncWithResponse(CommandDriveUp(device.id, type))
1137
+ await self.executeCommand(CommandDriveUp(device.id, type))
1125
1138
  device.state = MovementState.UP_ON
1126
1139
  self.addOrUpdateDevice(device, SelveTypes.DEVICE)
1127
1140
  await self.updateCommeoDeviceValuesAsync(device.id)
1128
1141
  else:
1129
1142
  self.setDeviceState(device.id, MovementState.UP_ON, SelveTypes.IVEO)
1130
- await self.executeCommandSyncWithResponse(IveoManual(device.id, DriveCommandIveo.UP))
1143
+ await self.executeCommand(IveoManual(device.id, DriveCommandIveo.UP))
1131
1144
  self.setDeviceState(device.id, MovementState.STOPPED_OFF, SelveTypes.IVEO)
1132
1145
  self.setDeviceValue(device.id, 0, SelveTypes.IVEO)
1133
1146
  self.setDeviceTargetValue(device.id, 0, SelveTypes.IVEO)
1134
1147
 
1135
1148
  async def moveDeviceDown(self, device: SelveDevice | IveoDevice, type=DeviceCommandType.MANUAL):
1136
1149
  if device.communicationType is CommunicationType.COMMEO:
1137
- await self.executeCommandSyncWithResponse(CommandDriveDown(device.id, type))
1150
+ await self.executeCommand(CommandDriveDown(device.id, type))
1138
1151
  device.state = MovementState.DOWN_ON
1139
1152
  self.addOrUpdateDevice(device, SelveTypes.DEVICE)
1140
1153
  await self.updateCommeoDeviceValuesAsync(device.id)
1141
1154
  else:
1142
1155
  self.setDeviceState(device.id, MovementState.DOWN_ON, SelveTypes.IVEO)
1143
- await self.executeCommandSyncWithResponse(IveoManual(device.id, DriveCommandIveo.DOWN))
1156
+ await self.executeCommand(IveoManual(device.id, DriveCommandIveo.DOWN))
1144
1157
  self.setDeviceState(device.id, MovementState.STOPPED_OFF, SelveTypes.IVEO)
1145
1158
  self.setDeviceValue(device.id, 100, SelveTypes.IVEO)
1146
1159
  self.setDeviceTargetValue(device.id, 100, SelveTypes.IVEO)
1147
1160
 
1148
1161
  async def moveDevicePos1(self, device: SelveDevice | IveoDevice, type=DeviceCommandType.MANUAL):
1149
1162
  if device.communicationType is CommunicationType.COMMEO:
1150
- await self.executeCommandSyncWithResponse(CommandDrivePos1(device.id, type))
1163
+ await self.executeCommand(CommandDrivePos1(device.id, type))
1151
1164
  await self.updateCommeoDeviceValuesAsync(device.id)
1152
1165
  else:
1153
1166
  self.setDeviceState(device.id, MovementState.UP_ON, SelveTypes.IVEO)
1154
- await self.executeCommandSyncWithResponse(IveoManual(device.id, DriveCommandIveo.POS1))
1167
+ await self.executeCommand(IveoManual(device.id, DriveCommandIveo.POS1))
1155
1168
  self.setDeviceState(device.id, MovementState.STOPPED_OFF, SelveTypes.IVEO)
1156
1169
  self.setDeviceValue(device.id, 66, SelveTypes.IVEO)
1157
1170
  self.setDeviceTargetValue(device.id, 66, SelveTypes.IVEO)
1158
1171
 
1159
1172
  async def moveDevicePos2(self, device: SelveDevice | IveoDevice, type=DeviceCommandType.MANUAL):
1160
1173
  if device.communicationType is CommunicationType.COMMEO:
1161
- await self.executeCommandSyncWithResponse(CommandDrivePos2(device.id, type))
1174
+ await self.executeCommand(CommandDrivePos2(device.id, type))
1162
1175
  await self.updateCommeoDeviceValuesAsync(device.id)
1163
1176
  else:
1164
1177
  self.setDeviceState(device.id, MovementState.DOWN_ON, SelveTypes.IVEO)
1165
- await self.executeCommandSyncWithResponse(IveoManual(device.id, DriveCommandIveo.POS2))
1178
+ await self.executeCommand(IveoManual(device.id, DriveCommandIveo.POS2))
1166
1179
  self.setDeviceState(device.id, MovementState.STOPPED_OFF, SelveTypes.IVEO)
1167
1180
  self.setDeviceValue(device.id, 33, SelveTypes.IVEO)
1168
1181
  self.setDeviceTargetValue(device.id, 33, SelveTypes.IVEO)
1169
1182
 
1170
1183
  async def moveDevicePos(self, device: SelveDevice, pos: int = 0, type=DeviceCommandType.MANUAL):
1171
- await self.executeCommandSyncWithResponse(CommandDrivePos(device.id, type, param=Util.percentageToValue(pos)))
1184
+ await self.executeCommand(CommandDrivePos(device.id, type, param=Util.percentageToValue(pos)))
1172
1185
  await self.updateCommeoDeviceValuesAsync(device.id)
1173
1186
 
1174
1187
  async def moveDeviceStepUp(self, device: SelveDevice, degrees: int = 0, type=DeviceCommandType.MANUAL):
1175
- await self.executeCommandSyncWithResponse(CommandDriveStepUp(device.id, type, param=Util.degreesToValue(degrees)))
1188
+ await self.executeCommand(CommandDriveStepUp(device.id, type, param=Util.degreesToValue(degrees)))
1176
1189
  await self.updateCommeoDeviceValuesAsync(device.id)
1177
1190
 
1178
1191
  async def moveDeviceStepDown(self, device: SelveDevice, degrees: int = 0, type=DeviceCommandType.MANUAL):
1179
- await self.executeCommandSyncWithResponse(CommandDriveStepDown(device.id, type, param=Util.degreesToValue(degrees)))
1192
+ await self.executeCommand(CommandDriveStepDown(device.id, type, param=Util.degreesToValue(degrees)))
1180
1193
  await self.updateCommeoDeviceValuesAsync(device.id)
1181
1194
 
1182
1195
  async def stopDevice(self, device: SelveDevice | IveoDevice, type=DeviceCommandType.MANUAL):
1183
1196
  if device.communicationType is CommunicationType.COMMEO:
1184
- await self.executeCommandSyncWithResponse(CommandStop(device.id, type))
1197
+ await self.executeCommand(CommandStop(device.id, type))
1185
1198
  await self.updateCommeoDeviceValuesAsync(device.id)
1186
1199
  else:
1187
- await self.executeCommandSyncWithResponse(IveoManual(device.id, DriveCommandIveo.STOP))
1200
+ await self.executeCommand(IveoManual(device.id, DriveCommandIveo.STOP))
1188
1201
  self.setDeviceState(device.id, MovementState.STOPPED_OFF, SelveTypes.IVEO)
1189
1202
  self.setDeviceValue(device.id, 50, SelveTypes.IVEO)
1190
1203
  self.setDeviceTargetValue(device.id, 50, SelveTypes.IVEO)
@@ -1195,17 +1208,17 @@ class Selve:
1195
1208
  command = GroupRead(id)
1196
1209
  response: GroupReadResponse = await self.executeCommandSyncWithResponse(command)
1197
1210
  return response
1198
-
1211
+
1199
1212
  async def groupWrite(self, id: int, actorIds: dict, name: str):
1200
1213
  command = GroupWrite(id, actorIds, name)
1201
1214
  response: GroupWriteResponse = await self.executeCommandSyncWithResponse(command)
1202
1215
  return response.executed
1203
-
1216
+
1204
1217
  async def groupGetIds(self):
1205
1218
  command = GroupGetIds()
1206
1219
  response: GroupGetIdsResponse = await self.executeCommandSyncWithResponse(command)
1207
1220
  return response
1208
-
1221
+
1209
1222
  async def groupDelete(self, id: int):
1210
1223
  command = GroupDelete(id)
1211
1224
  response: GroupDeleteResponse = await self.executeCommandSyncWithResponse(command)
@@ -1229,7 +1242,7 @@ class Selve:
1229
1242
 
1230
1243
  ### Iveo
1231
1244
  async def iveoSetRepeater(self, repeaterInstalled: int):
1232
- """
1245
+ """
1233
1246
  Sets the repeater level. \n
1234
1247
  repeaterInstalled: int can be \n
1235
1248
  0 = no repeater installed\n
@@ -1239,9 +1252,9 @@ class Selve:
1239
1252
  command = IveoSetRepeater(repeaterInstalled)
1240
1253
  response: IveoSetRepeaterResponse = await self.executeCommandSyncWithResponse(command)
1241
1254
  return response.executed
1242
-
1255
+
1243
1256
  async def iveoGetRepeater(self):
1244
- """
1257
+ """
1245
1258
  Gets the repeater level. \n
1246
1259
  response.repeaterState: int can be \n
1247
1260
  0 = no repeater installed\n
@@ -1251,7 +1264,7 @@ class Selve:
1251
1264
  command = IveoGetRepeater()
1252
1265
  response: IveoGetRepeaterResponse = await self.executeCommandSyncWithResponse(command)
1253
1266
  return response
1254
-
1267
+
1255
1268
  async def iveoSetLabel(self, id: int, label: str):
1256
1269
  command = IveoSetLabel(id, label)
1257
1270
  response: IveoSetLabelResponse = await self.executeCommandSyncWithResponse(command)
@@ -1263,7 +1276,7 @@ class Selve:
1263
1276
  id: Iveo device id
1264
1277
  activity: 0 = channel deactivated, 1 = channel active
1265
1278
  type: DeviceType
1266
-
1279
+
1267
1280
  """
1268
1281
  command = IveoSetConfig(id, activity, type)
1269
1282
  response: IveoSetConfigResponse = await self.executeCommandSyncWithResponse(command)
@@ -1280,7 +1293,7 @@ class Selve:
1280
1293
  name: Name of device
1281
1294
  activity: 0 = channel deactivated, 1 = channel active
1282
1295
  type: DeviceType
1283
-
1296
+
1284
1297
  """
1285
1298
  command = IveoGetConfig(id)
1286
1299
  response: IveoGetConfigResponse = await self.executeCommandSyncWithResponse(command)
@@ -1290,56 +1303,56 @@ class Selve:
1290
1303
  command = IveoGetIds()
1291
1304
  response: IveoGetIdsResponse = await self.executeCommandSyncWithResponse(command)
1292
1305
  return response
1293
-
1306
+
1294
1307
  async def iveoFactoryReset(self):
1295
1308
  command = IveoFactory()
1296
1309
  response: IveoFactoryResponse = await self.executeCommandSyncWithResponse(command)
1297
1310
  return response.executed
1298
-
1311
+
1299
1312
  async def iveoTeach(self):
1300
1313
  command = IveoTeach()
1301
1314
  response: IveoTeachResponse = await self.executeCommandSyncWithResponse(command)
1302
1315
  return response.executed
1303
-
1316
+
1304
1317
  async def iveoLearn(self, id: int):
1305
1318
  command = IveoLearn(id)
1306
1319
  response: IveoLearnResponse = await self.executeCommandSyncWithResponse(command)
1307
1320
  return response.executed
1308
-
1321
+
1309
1322
  async def iveoCommandManual(self, actorId: int, command: DriveCommandIveo):
1310
1323
  command = IveoManual(actorId, command)
1311
1324
  response: IveoManualResponse = await self.executeCommandSyncWithResponse(command)
1312
1325
  return response.executed
1313
-
1326
+
1314
1327
  async def iveoCommandAutomatic(self, actorId: int, command: DriveCommandIveo):
1315
1328
  command = IveoAutomatic(actorId, command)
1316
1329
  response: IveoAutomaticResponse = await self.executeCommandSyncWithResponse(command)
1317
1330
  return response.executed
1318
-
1319
-
1331
+
1332
+
1320
1333
 
1321
1334
  ### Sensor
1322
1335
  async def sensorTeachStart(self):
1323
1336
  command = SensorTechStart()
1324
1337
  response: SensorTeachStartResponse = await self.executeCommandSyncWithResponse(command)
1325
1338
  return response.executed
1326
-
1339
+
1327
1340
  async def sensorTeachStop(self):
1328
1341
  command = SensorTeachStop()
1329
1342
  response: SensorTeachStopResponse = await self.executeCommandSyncWithResponse(command)
1330
1343
  return response.executed
1331
-
1344
+
1332
1345
  async def sensorTeachResult(self):
1333
1346
  """ manually polls the teach result state, but the states are being reported automatically by the gateway itself"""
1334
1347
  command = SensorTeachResult()
1335
1348
  response: SensorTeachResultResponse = await self.executeCommandSyncWithResponse(command)
1336
1349
  return response
1337
-
1350
+
1338
1351
  async def sensorGetIds(self):
1339
1352
  command = SensorGetIds()
1340
1353
  response: SensorGetIdsResponse = await self.executeCommandSyncWithResponse(command)
1341
1354
  return response
1342
-
1355
+
1343
1356
  async def sensorGetInfo(self, id: int):
1344
1357
  command = SensorGetInfo(id)
1345
1358
  response: SensorGetInfoResponse = await self.executeCommandSyncWithResponse(command)
@@ -1349,7 +1362,7 @@ class Selve:
1349
1362
  command = SensorGetValues(id)
1350
1363
  response: SensorGetValuesResponse = await self.executeCommandSyncWithResponse(command)
1351
1364
  return response
1352
-
1365
+
1353
1366
  async def sensorSetLabel(self, id: int, label: str):
1354
1367
  command = SensorSetLabel(id, label)
1355
1368
  response: SensorSetLabelResponse = await self.executeCommandSyncWithResponse(command)
@@ -1379,23 +1392,23 @@ class Selve:
1379
1392
  command = SenderTeachStart()
1380
1393
  response: SenderTeachStartResponse = await self.executeCommandSyncWithResponse(command)
1381
1394
  return response.executed
1382
-
1395
+
1383
1396
  async def senderTeachStop(self):
1384
1397
  command = SenderTeachStop()
1385
1398
  response: SenderTeachStopResponse = await self.executeCommandSyncWithResponse(command)
1386
1399
  return response.executed
1387
-
1400
+
1388
1401
  async def senderTeachResult(self):
1389
1402
  """ manually polls the teach result state, but the states are being reported automatically by the gateway itself"""
1390
1403
  command = SenderTeachResult()
1391
1404
  response: SenderTeachResultResponse = await self.executeCommandSyncWithResponse(command)
1392
1405
  return response
1393
-
1406
+
1394
1407
  async def senderGetIds(self):
1395
1408
  command = SenderGetIds()
1396
1409
  response: SenderGetIdsResponse = await self.executeCommandSyncWithResponse(command)
1397
1410
  return response
1398
-
1411
+
1399
1412
  async def senderGetInfo(self, id: int):
1400
1413
  command = SenderGetInfo(id)
1401
1414
  response: SenderGetInfoResponse = await self.executeCommandSyncWithResponse(command)
@@ -1405,7 +1418,7 @@ class Selve:
1405
1418
  command = SenderGetValues(id)
1406
1419
  response: SenderGetValuesResponse = await self.executeCommandSyncWithResponse(command)
1407
1420
  return response
1408
-
1421
+
1409
1422
  async def senderSetLabel(self, id: int, label: str):
1410
1423
  command = SenderSetLabel(id, label)
1411
1424
  response: SenderSetLabelResponse = await self.executeCommandSyncWithResponse(command)
@@ -16,7 +16,7 @@ class Command():
16
16
  xmlstr += "</array>"
17
17
  xmlstr+= "</methodCall>"
18
18
  return xmlstr.encode('utf-8')
19
-
19
+
20
20
 
21
21
  class GatewayCommand(Command):
22
22
 
@@ -39,7 +39,7 @@ class MethodResponse:
39
39
  def __init__(self, name, parameters):
40
40
  self.name = name
41
41
  self.parameters = parameters
42
-
42
+
43
43
  class CommeoCommandResult(MethodResponse):
44
44
  def __init__(self, name, parameters):
45
45
  super().__init__(name, parameters)
@@ -52,13 +52,13 @@ class CommeoCommandResult(MethodResponse):
52
52
  class CommeoDeviceEventResponse(MethodResponse):
53
53
  def __init__(self, name, parameters):
54
54
  super().__init__(name, parameters)
55
- #self.name = parameters[0][1] if parameters[0][1] else ""
56
- self.id = int(parameters[0][1])
57
- self.actorState = MovementState(int(parameters[1][1])) if int(parameters[1][1]) and int(parameters[1][1]) < 4 else MovementState(0)
58
- self.value = Util.valueToPercentage(int(parameters[2][1]))
59
- self.targetValue = Util.valueToPercentage(int(parameters[3][1]))
60
-
61
- bArr = Util.intToBoolarray(int(parameters[4][1]))
55
+ self.name = parameters[0][1] if parameters[0][1] else ""
56
+ self.id = int(parameters[1][1])
57
+ self.actorState = MovementState(int(parameters[2][1])) if int(parameters[2][1]) and int(parameters[2][1]) < 4 else MovementState(0)
58
+ self.value = Util.valueToPercentage(int(parameters[3][1]))
59
+ self.targetValue = Util.valueToPercentage(int(parameters[4][1]))
60
+
61
+ bArr = Util.intToBoolarray(int(parameters[5][1]))
62
62
  self.unreachable = bArr[0]
63
63
  self.overload = bArr[1]
64
64
  self.obstructed = bArr[2]
@@ -69,8 +69,8 @@ class CommeoDeviceEventResponse(MethodResponse):
69
69
  self.windAlarm = bArr[7]
70
70
  self.rainAlarm = bArr[8]
71
71
  self.freezingAlarm = bArr[9]
72
- self.dayMode = DayMode(int(parameters[5][1]))
73
- self.deviceType = DeviceType(int(parameters[6][1]))
72
+ self.dayMode = DayMode(int(parameters[6][1]))
73
+ self.deviceType = DeviceType(int(parameters[7][1]))
74
74
 
75
75
  class LogEventResponse(MethodResponse):
76
76
  def __init__(self, name, parameters):
@@ -122,7 +122,7 @@ class Util():
122
122
  #Obtains a base64 encoded to modify just one index
123
123
  mask = 64 * [0]
124
124
  #need to transform the position
125
- newid = int((int(id) // 8) * 8 + 7 - (int(id) % 8))
125
+ newid = int((int(id) // 8) * 8 + 7 - (int(id) % 8))
126
126
  mask[newid] = 1
127
127
  bitstring = "".join(str(x) for x in mask)
128
128
  return base64.b64encode(self.bitstring_to_bytes(bitstring)).decode('utf8')
@@ -131,7 +131,7 @@ class Util():
131
131
  def multimask(self, ids):
132
132
  mask = 64 * [0]
133
133
  for id in ids:
134
- newid = int((int(id) // 8) * 8 + 7 - (int(id) % 8))
134
+ newid = int((int(id) // 8) * 8 + 7 - (int(id) % 8))
135
135
  mask[newid] = 1
136
136
  bitstring = "".join(str(x) for x in mask)
137
137
  return base64.b64encode(self.bitstring_to_bytes(bitstring)).decode('utf8')
@@ -182,7 +182,7 @@ class CommeoServiceCommand(Enum):
182
182
  FACTORYRESET = "service.factoryReset"
183
183
  SETLED = "service.setLED"
184
184
  GETLED = "service.getLED"
185
-
185
+
186
186
  class CommeoParamCommand(Enum):
187
187
  SETFORWARD = "param.setForward"
188
188
  GETFORWARD = "param.getForward"
@@ -204,7 +204,7 @@ class CommeoDeviceCommand(Enum):
204
204
  SETTYPE = "device.setType"
205
205
  DELETE = "device.delete"
206
206
  WRITEMANUAL = "device.writeManual"
207
-
207
+
208
208
  class CommeoSensorCommand(Enum):
209
209
  TEACHSTART = "sensor.teachStart"
210
210
  TEACHSTOP = "sensor.teachStop"
@@ -229,7 +229,7 @@ class CommeoSenSimCommand(Enum):
229
229
  DRIVE = "senSim.drive"
230
230
  SETTEST = "senSim.setTest"
231
231
  GETTEST = "senSim.getTest"
232
-
232
+
233
233
  class CommeoSenderCommand(Enum):
234
234
  TEACHSTART = "sender.teachStart"
235
235
  TEACHSTOP = "sender.teachStop"
@@ -252,7 +252,7 @@ class CommeoCommandCommand(Enum):
252
252
  GROUP = "command.group"
253
253
  GROUPMAN = "command.groupMan"
254
254
  RESULT = "command.result"
255
-
255
+
256
256
  class CommeoEventCommand(Enum):
257
257
  DEVICE = "event.device"
258
258
  SENSOR = "event.sensor"
@@ -273,14 +273,14 @@ class IveoCommand(Enum):
273
273
  MANUAL = "iveo.commandManual"
274
274
  AUTOMATIC = "iveo.commandAutomatic"
275
275
  RESULT = "iveo.commandResult"
276
-
276
+
277
277
 
278
278
  class CommandType(Enum):
279
279
  def __getattr__(self, item):
280
280
  if item != '_value_':
281
281
  return getattr(self.value, item).value
282
282
  raise AttributeError
283
- SERVICE = CommeoServiceCommand
283
+ SERVICE = CommeoServiceCommand
284
284
  PARAM = CommeoParamCommand
285
285
  DEVICE = CommeoDeviceCommand
286
286
  SENSOR = CommeoSensorCommand
@@ -292,6 +292,6 @@ class CommandType(Enum):
292
292
  IVEO = IveoCommand
293
293
 
294
294
  ### Responses
295
-
295
+
296
296
  class ResponseTypes(Enum):
297
297
  COMMANDRESULT = "selve.gw.command.result"
@@ -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.9', # Required
18
+ version='2.2.11', # 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",