tinytoolslib 0.6.1__tar.gz → 0.7.2__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.
- {tinytoolslib-0.6.1 → tinytoolslib-0.7.2}/PKG-INFO +1 -1
- {tinytoolslib-0.6.1 → tinytoolslib-0.7.2}/pyproject.toml +1 -1
- tinytoolslib-0.7.2/tinytoolslib/__version__.py +1 -0
- {tinytoolslib-0.6.1 → tinytoolslib-0.7.2}/tinytoolslib/constants.py +1 -0
- {tinytoolslib-0.6.1 → tinytoolslib-0.7.2}/tinytoolslib/models.py +163 -4
- {tinytoolslib-0.6.1 → tinytoolslib-0.7.2}/tinytoolslib.egg-info/PKG-INFO +1 -1
- tinytoolslib-0.6.1/tinytoolslib/__version__.py +0 -1
- {tinytoolslib-0.6.1 → tinytoolslib-0.7.2}/README.md +0 -0
- {tinytoolslib-0.6.1 → tinytoolslib-0.7.2}/setup.cfg +0 -0
- {tinytoolslib-0.6.1 → tinytoolslib-0.7.2}/tinytoolslib/__init__.py +0 -0
- {tinytoolslib-0.6.1 → tinytoolslib-0.7.2}/tinytoolslib/discovery.py +0 -0
- {tinytoolslib-0.6.1 → tinytoolslib-0.7.2}/tinytoolslib/exceptions.py +0 -0
- {tinytoolslib-0.6.1 → tinytoolslib-0.7.2}/tinytoolslib/flash.py +0 -0
- {tinytoolslib-0.6.1 → tinytoolslib-0.7.2}/tinytoolslib/parsers.py +0 -0
- {tinytoolslib-0.6.1 → tinytoolslib-0.7.2}/tinytoolslib/requests.py +0 -0
- {tinytoolslib-0.6.1 → tinytoolslib-0.7.2}/tinytoolslib.egg-info/SOURCES.txt +0 -0
- {tinytoolslib-0.6.1 → tinytoolslib-0.7.2}/tinytoolslib.egg-info/dependency_links.txt +0 -0
- {tinytoolslib-0.6.1 → tinytoolslib-0.7.2}/tinytoolslib.egg-info/requires.txt +0 -0
- {tinytoolslib-0.6.1 → tinytoolslib-0.7.2}/tinytoolslib.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tinytoolslib
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.2
|
|
4
4
|
Summary: Set of tools for use with tinycontrol devices like LK2.X, LK3.X, LK4.X or tcPDU.
|
|
5
5
|
Author-email: Bartek Barszczewski <tinycontrol.software@gmail.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.7.2'
|
|
@@ -246,6 +246,22 @@ class DeviceModel(ABC):
|
|
|
246
246
|
f"{self.__class__.__name__} does not support controlling PWMs"
|
|
247
247
|
)
|
|
248
248
|
|
|
249
|
+
async def async_set_pwm_duty(self, index, value):
|
|
250
|
+
"""Async set_pwm_duty."""
|
|
251
|
+
if callable(getattr(self, "_set_pwm_duty", None)):
|
|
252
|
+
return await self.async_get(self._set_pwm_duty(index, value))
|
|
253
|
+
raise TinyToolsUnsupported(
|
|
254
|
+
f"{self.__class__.__name__} does not support controlling PWMs duty"
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
async def async_set_pwm_freq(self, index, value):
|
|
258
|
+
"""Async set_pwm_freq."""
|
|
259
|
+
if callable(getattr(self, "_set_pwm_freq", None)):
|
|
260
|
+
return await self.async_get(self._set_pwm_freq(index, value))
|
|
261
|
+
raise TinyToolsUnsupported(
|
|
262
|
+
f"{self.__class__.__name__} does not support controlling PWMs frequency"
|
|
263
|
+
)
|
|
264
|
+
|
|
249
265
|
async def async_set_var(self, index, value):
|
|
250
266
|
"""Async set_var."""
|
|
251
267
|
if callable(getattr(self, "_set_var", None)):
|
|
@@ -254,6 +270,14 @@ class DeviceModel(ABC):
|
|
|
254
270
|
f"{self.__class__.__name__} does not support controlling VARs"
|
|
255
271
|
)
|
|
256
272
|
|
|
273
|
+
async def async_set_ds(self, index, value):
|
|
274
|
+
"""Async set_ds."""
|
|
275
|
+
if callable(getattr(self, "_set_ds", None)):
|
|
276
|
+
return await self.async_get(self._set_ds(index, value))
|
|
277
|
+
raise TinyToolsUnsupported(
|
|
278
|
+
f"{self.__class__.__name__} does not support setting DSs"
|
|
279
|
+
)
|
|
280
|
+
|
|
257
281
|
async def async_get_all(self, remove_mapped_keys: bool = False) -> Dict[str, Any]:
|
|
258
282
|
"""Async get_all."""
|
|
259
283
|
if callable(getattr(self, "_get_all", None)):
|
|
@@ -265,6 +289,22 @@ class DeviceModel(ABC):
|
|
|
265
289
|
f"{self.__class__.__name__} does not support get_all command"
|
|
266
290
|
)
|
|
267
291
|
|
|
292
|
+
async def async_reset_to_defaults(self):
|
|
293
|
+
"""Async reset_to_defaults."""
|
|
294
|
+
if callable(getattr(self, "_reset_to_defaults", None)):
|
|
295
|
+
return await self.async_get(self._reset_to_defaults())
|
|
296
|
+
raise TinyToolsUnsupported(
|
|
297
|
+
f"{self.__class__.__name__} does not support reset to defaults"
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
async def async_restart(self):
|
|
301
|
+
"""Async restart."""
|
|
302
|
+
if callable(getattr(self, "_restart", None)):
|
|
303
|
+
return await self.async_get(self._restart())
|
|
304
|
+
raise TinyToolsUnsupported(
|
|
305
|
+
f"{self.__class__.__name__} does not support restart command"
|
|
306
|
+
)
|
|
307
|
+
|
|
268
308
|
# endregion
|
|
269
309
|
|
|
270
310
|
|
|
@@ -691,6 +731,11 @@ class LK_HW_20(LK_HW_20_PS):
|
|
|
691
731
|
self.get("/ind.cgi?ds=0")
|
|
692
732
|
return self.get("/board.xml").get("ds_read_id")
|
|
693
733
|
|
|
734
|
+
async def async_get_ds_id(self) -> str:
|
|
735
|
+
"""Get ID of detected DS."""
|
|
736
|
+
await self.async_get("/ind.cgi?ds=0")
|
|
737
|
+
return await self.async_get("/board.xml").get("ds_read_id")
|
|
738
|
+
|
|
694
739
|
|
|
695
740
|
@dataclass
|
|
696
741
|
class LK_HW_25(LK_HW_20):
|
|
@@ -1140,6 +1185,11 @@ class LK_HW_30(DeviceModel):
|
|
|
1140
1185
|
self.get("/stm.cgi?dswrite=0")
|
|
1141
1186
|
return self.get("/json/dsi2c.json").get("ds_read_id")
|
|
1142
1187
|
|
|
1188
|
+
async def async_get_ds_id(self) -> str:
|
|
1189
|
+
"""Get ID of detected DS."""
|
|
1190
|
+
await self.async_get("/stm.cgi?dswrite=0")
|
|
1191
|
+
return await self.async_get("/json/dsi2c.json").get("ds_read_id")
|
|
1192
|
+
|
|
1143
1193
|
def _get_all(self) -> List[str]:
|
|
1144
1194
|
"""Prepare list of URLs to fetch data from."""
|
|
1145
1195
|
urls = ["/json/all.json", "/json/pwmpid.json"]
|
|
@@ -1157,14 +1207,14 @@ class LK_HW_30(DeviceModel):
|
|
|
1157
1207
|
"""Prepare command to restart device."""
|
|
1158
1208
|
return "/stm.cgi?lk3restart=1"
|
|
1159
1209
|
|
|
1160
|
-
def
|
|
1210
|
+
def _set_analog_input(
|
|
1161
1211
|
self,
|
|
1162
1212
|
index: Union[int, List[int]],
|
|
1163
1213
|
sensor: Union[int, List[int]],
|
|
1164
1214
|
calibration: Union[int, List[int], None] = None,
|
|
1165
1215
|
multiplier: Union[float, List[float], None] = None,
|
|
1166
|
-
) ->
|
|
1167
|
-
"""
|
|
1216
|
+
) -> str:
|
|
1217
|
+
"""Prepare command for setting sensor, calibration and multiplier for analog input.
|
|
1168
1218
|
|
|
1169
1219
|
Arguments:
|
|
1170
1220
|
index: 1-6 (analog input index)
|
|
@@ -1206,7 +1256,27 @@ class LK_HW_30(DeviceModel):
|
|
|
1206
1256
|
False,
|
|
1207
1257
|
"{cmd_param}={index}{value}",
|
|
1208
1258
|
)
|
|
1209
|
-
return
|
|
1259
|
+
return cmd
|
|
1260
|
+
|
|
1261
|
+
def set_analog_input(
|
|
1262
|
+
self,
|
|
1263
|
+
index: Union[int, List[int]],
|
|
1264
|
+
sensor: Union[int, List[int]],
|
|
1265
|
+
calibration: Union[int, List[int], None] = None,
|
|
1266
|
+
multiplier: Union[float, List[float], None] = None,
|
|
1267
|
+
) -> Dict[str, Any]:
|
|
1268
|
+
"""Set sensor, calibration and multiplier for analog input."""
|
|
1269
|
+
return self.get(self._set_analog_input(index, sensor, calibration, multiplier))
|
|
1270
|
+
|
|
1271
|
+
async def async_set_analog_input(
|
|
1272
|
+
self,
|
|
1273
|
+
index: Union[int, List[int]],
|
|
1274
|
+
sensor: Union[int, List[int]],
|
|
1275
|
+
calibration: Union[int, List[int], None] = None,
|
|
1276
|
+
multiplier: Union[float, List[float], None] = None,
|
|
1277
|
+
) -> Dict[str, Any]:
|
|
1278
|
+
"""Set sensor, calibration and multiplier for analog input."""
|
|
1279
|
+
return await self.async_get(self._set_analog_input(index, sensor, calibration, multiplier))
|
|
1210
1280
|
|
|
1211
1281
|
|
|
1212
1282
|
@dataclass
|
|
@@ -1456,6 +1526,11 @@ class LK_HW_40(DeviceModel):
|
|
|
1456
1526
|
self.get("/api/v1/save/?dsReadID=0")
|
|
1457
1527
|
return self.get("/api/v1/read/status/?dsValues").get("dsReadID")
|
|
1458
1528
|
|
|
1529
|
+
async def async_get_ds_id(self) -> str:
|
|
1530
|
+
"""Get ID of detected DS."""
|
|
1531
|
+
await self.async_get("/api/v1/save/?dsReadID=0")
|
|
1532
|
+
return await self.async_get("/api/v1/read/status/?dsValues").get("dsReadID")
|
|
1533
|
+
|
|
1459
1534
|
def _get_all(self) -> List[str]:
|
|
1460
1535
|
"""Prepare list of URLs to fetch data from."""
|
|
1461
1536
|
return [
|
|
@@ -1549,7 +1624,91 @@ class LK_HW_40_mini(LK_HW_40):
|
|
|
1549
1624
|
]
|
|
1550
1625
|
|
|
1551
1626
|
|
|
1627
|
+
@dataclass
|
|
1628
|
+
class LK_EM(LK_HW_40):
|
|
1629
|
+
"""Device model for LK Energy Monitor.
|
|
1630
|
+
|
|
1631
|
+
It has most of LK4 functions with following differences:
|
|
1632
|
+
- built in 3 phase power/energy meter
|
|
1633
|
+
- 5 outputs instead of 6, 2-4 have PWM mode, 5th has 0-10V mode, no negation
|
|
1634
|
+
- no PWMs
|
|
1635
|
+
- no INPAs
|
|
1636
|
+
- no INPDs
|
|
1637
|
+
- built in energy meter calibration in Power and energy
|
|
1638
|
+
- no Watchdog
|
|
1639
|
+
- no remote control
|
|
1640
|
+
- no serial port
|
|
1641
|
+
- no LTE modem
|
|
1642
|
+
"""
|
|
1643
|
+
|
|
1644
|
+
info: ClassVar[Union[DeviceInfo, None]] = DeviceInfo(
|
|
1645
|
+
"LK Energy Monitor",
|
|
1646
|
+
DeviceFamily.EM,
|
|
1647
|
+
"lkem",
|
|
1648
|
+
"https://tinycontrol.pl/en/lkem/downloads/#firmware",
|
|
1649
|
+
fw_update_method=FWUpdateMethod.HTTP,
|
|
1650
|
+
extras={"number_of_outputs": 5},
|
|
1651
|
+
)
|
|
1652
|
+
parsers: ClassVar[List[str]] = []
|
|
1653
|
+
|
|
1654
|
+
@classmethod
|
|
1655
|
+
def check_version(
|
|
1656
|
+
cls, hardware_version: Union[str, None], software_version: str
|
|
1657
|
+
) -> bool:
|
|
1658
|
+
return hardware_version in ["1.0"] and software_version.endswith("EM")
|
|
1659
|
+
|
|
1660
|
+
# Unset few commands - there are no PWM in LK EM (well OUT have PWM mode)
|
|
1661
|
+
_set_pwm = None
|
|
1662
|
+
|
|
1663
|
+
def _set_pwm_duty(
|
|
1664
|
+
self, index: Union[int, List[int]], value: Union[int, List[int]]
|
|
1665
|
+
) -> str:
|
|
1666
|
+
"""Prepare command for setting PWM duty for OUT2-4 in PWM mode (outModeX=1).
|
|
1667
|
+
|
|
1668
|
+
Arguments:
|
|
1669
|
+
index: 2-4 (single or list)
|
|
1670
|
+
value: 0-100 (single or list)
|
|
1671
|
+
"""
|
|
1672
|
+
cmd = set_cmd_helper(self, "/api/v1/save/?", "outDuty", index, value, False, False)
|
|
1673
|
+
return cmd
|
|
1674
|
+
|
|
1675
|
+
def _set_pwm_freq(self, index: Union[int, List[int]], value: Union[int, List[int]]) -> str:
|
|
1676
|
+
"""Prepare command for setting PWM freq for OUT2-4 and OUT5.
|
|
1677
|
+
|
|
1678
|
+
Arguments:
|
|
1679
|
+
index: 1-2 (single or list; 1 - OUT2-4, 2 - OUT5)
|
|
1680
|
+
value: 1-1_000_000
|
|
1681
|
+
"""
|
|
1682
|
+
cmd = set_cmd_helper(self, "/api/v1/save/?", "outFrequency", index, value, False, False)
|
|
1683
|
+
return cmd
|
|
1684
|
+
|
|
1685
|
+
def _set_out_level(self, value: float) -> str:
|
|
1686
|
+
"""Set OUT5 level (indirectly by PWM duty) to value.
|
|
1687
|
+
|
|
1688
|
+
Arguments:
|
|
1689
|
+
value: 0.0-10.0 with 0.1 step
|
|
1690
|
+
"""
|
|
1691
|
+
cmd = "/api/v1/save/?outLevel5={:.1f}".format(value)
|
|
1692
|
+
return cmd
|
|
1693
|
+
|
|
1694
|
+
def _get_all(self) -> List[str]:
|
|
1695
|
+
"""Prepare list of URLs to fetch data from."""
|
|
1696
|
+
return [
|
|
1697
|
+
"/api/v1/read/set/?generalConfig&outConfig&powerConfig&networkConfig",
|
|
1698
|
+
"/api/v1/read/status/?boardValues&statusValues&timeValues&outValues&dsValues&i2cValues&otherSensorsValues&diffValues&powerValues&mrValues&varValues&meterValues",
|
|
1699
|
+
]
|
|
1700
|
+
|
|
1701
|
+
def set_out_level(self, value):
|
|
1702
|
+
"""Set out level for PWM mode."""
|
|
1703
|
+
return self.get(self._set_out_level(value))
|
|
1704
|
+
|
|
1705
|
+
async def async_set_out_level(self, value):
|
|
1706
|
+
"""Async set_out_level."""
|
|
1707
|
+
return await self.async_get(self._set_out_level(value))
|
|
1708
|
+
|
|
1709
|
+
|
|
1552
1710
|
DEVICE_MODELS = [
|
|
1711
|
+
LK_EM,
|
|
1553
1712
|
LK_HW_40_mini,
|
|
1554
1713
|
TCPDU,
|
|
1555
1714
|
LK_HW_40,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tinytoolslib
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.2
|
|
4
4
|
Summary: Set of tools for use with tinycontrol devices like LK2.X, LK3.X, LK4.X or tcPDU.
|
|
5
5
|
Author-email: Bartek Barszczewski <tinycontrol.software@gmail.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '0.6.1'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|