Merge branch 'main' into set_multiple_values

This commit is contained in:
Meatballs1
2024-03-20 23:47:43 +00:00
2 changed files with 20 additions and 19 deletions

View File

@@ -119,13 +119,14 @@ class HCDevice:
f" program - {feature['name']}." f" program - {feature['name']}."
) )
if "options" in data: if "options" in data:
for option_uid in data["options"]: for option in data["options"]:
if str(option_uid) not in self.features: option_uid = option["uid"]
raise ValueError( if str(option_uid) not in self.features:
f"Unable to configure appliance. Option UID {uid} is not" raise ValueError(
" valid for this device." f"Unable to configure appliance. Option UID {option_uid} is not"
) " valid for this device."
)
# Test the feature of an appliance agains a data object # Test the feature of an appliance agains a data object
def test_feature(self, data_array): def test_feature(self, data_array):
@@ -165,18 +166,18 @@ class HCDevice:
if "values" in feature: if "values" in feature:
if isinstance(data["value"], int) is False: if isinstance(data["value"], int) is False:
raise Exception( raise Exception(
f"Unable to configure appliance. The value {data['value']} must" f"Unable to configure appliance. The value {data['value']} must be an integer."
f" be an integer. Allowed values are {feature['values']}." f" Allowed values are {feature['values']}."
)
value = str(data["value"])
# values are strings in the feature list,
# but always seem to be an integer. An integer must be provided
if value not in feature["values"]:
raise Exception(
"Unable to configure appliance. "
f"Value {data['value']} is not a valid value. "
f"Allowed values are {feature['values']}. "
) )
value = str(data["value"])
# values are strings in the feature list,
# but always seem to be an integer. An integer must be provided
if value not in feature["values"]:
raise Exception(
"Unable to configure appliance. "
f"Value {data['value']} is not a valid value. "
f"Allowed values are {feature['values']}. "
)
if "min" in feature: if "min" in feature:
min = int(feature["min"]) min = int(feature["min"])

View File

@@ -116,7 +116,7 @@ def client_connect(client, device, mqtt_topic):
print(now(), device_name, "ERROR", e, file=sys.stderr) print(now(), device_name, "ERROR", e, file=sys.stderr)
host = device["host"] host = device["host"]
device_topics = topics device_topics = topics.copy()
active_program = False active_program = False
for value in device["features"]: for value in device["features"]: