wren node takes switches (plug, socket, appliances), refused when the model lacks the kind

This commit is contained in:
Melvin Strobl
2026-10-22 17:48:41 +02:00
parent 6b575a4989
commit 613eb8a744
4 changed files with 43 additions and 7 deletions
+25 -1
View File
@@ -57,6 +57,10 @@ KIND_WORDS = {
"water": "water",
"watering": "water",
"sprinkler": "water",
"switch": "switch",
"plug": "switch",
"socket": "switch",
"appliances": "switch",
}
#: What the node reads, and the types each may be. Only the prompt wakes it.
@@ -85,6 +89,7 @@ _TOOLS = {
"heat": "heating",
"shutter": "shutters",
"water": "watering",
"switch": "switches",
}
#: What a call sets a target to, by the target's type: (bool, number, text).
@@ -102,6 +107,8 @@ _VALUES: dict[str, tuple[bool | None, float | None, str | None]] = {
"shutters.stop": (None, None, "stop"),
"watering.start": (True, None, "on"),
"watering.stop": (False, None, "off"),
"switches.on": (True, 1, "on"),
"switches.off": (False, 0, "off"),
}
#: An applied call, said: "kitchen light on". `heating.set` says its number.
@@ -117,6 +124,8 @@ _SAID = {
"shutters.stop": "shutters stopped",
"watering.start": "watering on",
"watering.stop": "watering off",
"switches.on": "switch on",
"switches.off": "switch off",
}
#: What every area held in training: a light, and in the living room, which
@@ -160,15 +169,24 @@ _GROUP_KINDS = {
"heating": "heat",
"watering": "water",
"sprinklers": "water",
"switches": "switch",
"plugs": "switch",
"appliances": "switch",
}
#: The call a group command makes on each kind, by its action word.
_GROUP_TOOLS = {
"on": {"light": "lights.on", "media": "media.play", "water": "watering.start"},
"on": {
"light": "lights.on",
"media": "media.play",
"water": "watering.start",
"switch": "switches.on",
},
"off": {
"light": "lights.off",
"media": "media.stop",
"heat": "heating.off",
"water": "watering.stop",
"switch": "switches.off",
},
"open": {"shutter": "shutters.up"},
"up": {"shutter": "shutters.up"},
@@ -194,6 +212,8 @@ _GROUP_SAID = {
"shutters.stop": "shutters stopped",
"watering.start": "watering on",
"watering.stop": "watering off",
"switches.on": "switches on",
"switches.off": "switches off",
}
@@ -426,6 +446,10 @@ class WrenNode(Node):
f"<area>_<kind>, the area one of {', '.join(areas)}, the kind "
f"one of {', '.join(KIND_WORDS)}."
)
if device[1] not in wren.KINDS: # switches came with wren's s10
raise ValueError(
f"'{spec.port}' is a {device[1]}, which this wren does not know."
)
if spec.dtype not in _TARGET_TYPES:
raise ValueError(
f"'{spec.port}' is {spec.dtype.value}; a target is bool, int, "