Skip to content

Commit aecc27a

Browse files
committed
Improve tracing of voltage
1 parent 2eb03d8 commit aecc27a

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "pystuderxcom"
3-
version = "3.3.0"
3+
version = "3.3.1"
44
authors = [
55
{ name="Anko Hanse", email="[email protected]" },
66
]

src/pystuderxcom/factory_async.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,19 @@ async def create_dataset(voltageAC:str=XcomVoltage.AC240, voltageDC:str=XcomVolt
6464
# start with the 240v list as base
6565
datapoints = datapoints_240vac
6666

67-
if voltageAC == XcomVoltage.AC120:
68-
# Merge the 120v list into the 240v one by replacing duplicates. This maintains the order of menu items
69-
for dp120 in datapoints_120vac:
70-
# already in result?
71-
index = next( (idx for idx,dp240 in enumerate(datapoints) if dp120.nr == dp240.nr and dp120.family_id == dp240.family_id ), None)
72-
if index is not None:
73-
datapoints[index] = dp120
74-
75-
_LOGGER.info(f"Using {len(datapoints)} datapoints for 120 Vac")
76-
77-
elif voltageAC == XcomVoltage.AC240:
78-
_LOGGER.info(f"Using {len(datapoints)} datapoints for 240 Vac")
79-
80-
else:
81-
msg = f"Unknown AC voltage: '{voltageAC}'"
82-
raise Exception(msg)
67+
match voltageAC:
68+
case XcomVoltage.AC240:
69+
pass
70+
case XcomVoltage.AC120:
71+
# Merge the 120v list into the 240v one by replacing duplicates. This maintains the order of menu items
72+
for dp120 in datapoints_120vac:
73+
# already in result?
74+
index = next( (idx for idx,dp240 in enumerate(datapoints) if dp120.nr == dp240.nr and dp120.family_id == dp240.family_id ), None)
75+
if index is not None:
76+
datapoints[index] = dp120
77+
case _:
78+
msg = f"Unknown AC voltage: '{voltageAC}'"
79+
raise Exception(msg)
8380

8481
# Standard list is for 48vdc. Adapt for 12 or 24vdc if needed.
8582
match voltageDC:
@@ -103,6 +100,7 @@ async def create_dataset(voltageAC:str=XcomVoltage.AC240, voltageDC:str=XcomVolt
103100
dp.max = round(mult * dp.max , digits) if dp.max is not None else None
104101
datapoints[idx] = dp
105102

103+
_LOGGER.info(f"Using {len(datapoints)} datapoints for {str(voltageAC)} and {str(voltageDC)}")
106104
return XcomDataset(datapoints)
107105

108106

0 commit comments

Comments
 (0)