mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Fix Z-Wave JS discovery schema for thermostat devices (#47087)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
8971ab2edc
commit
7ca148f65d
@ -75,6 +75,8 @@ class ZWaveDiscoverySchema:
|
|||||||
device_class_specific: Optional[Set[Union[str, int]]] = None
|
device_class_specific: Optional[Set[Union[str, int]]] = None
|
||||||
# [optional] additional values that ALL need to be present on the node for this scheme to pass
|
# [optional] additional values that ALL need to be present on the node for this scheme to pass
|
||||||
required_values: Optional[List[ZWaveValueDiscoverySchema]] = None
|
required_values: Optional[List[ZWaveValueDiscoverySchema]] = None
|
||||||
|
# [optional] additional values that MAY NOT be present on the node for this scheme to pass
|
||||||
|
absent_values: Optional[List[ZWaveValueDiscoverySchema]] = None
|
||||||
# [optional] bool to specify if this primary value may be discovered by multiple platforms
|
# [optional] bool to specify if this primary value may be discovered by multiple platforms
|
||||||
allow_multi: bool = False
|
allow_multi: bool = False
|
||||||
|
|
||||||
@ -186,36 +188,30 @@ DISCOVERY_SCHEMAS = [
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
# climate
|
# climate
|
||||||
|
# thermostats supporting mode (and optional setpoint)
|
||||||
ZWaveDiscoverySchema(
|
ZWaveDiscoverySchema(
|
||||||
platform="climate",
|
platform="climate",
|
||||||
device_class_generic={"Thermostat"},
|
|
||||||
device_class_specific={
|
|
||||||
"Setback Thermostat",
|
|
||||||
"Thermostat General",
|
|
||||||
"Thermostat General V2",
|
|
||||||
"General Thermostat",
|
|
||||||
"General Thermostat V2",
|
|
||||||
},
|
|
||||||
primary_value=ZWaveValueDiscoverySchema(
|
primary_value=ZWaveValueDiscoverySchema(
|
||||||
command_class={CommandClass.THERMOSTAT_MODE},
|
command_class={CommandClass.THERMOSTAT_MODE},
|
||||||
property={"mode"},
|
property={"mode"},
|
||||||
type={"number"},
|
type={"number"},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
# climate
|
# thermostats supporting setpoint only (and thus not mode)
|
||||||
# setpoint thermostats
|
|
||||||
ZWaveDiscoverySchema(
|
ZWaveDiscoverySchema(
|
||||||
platform="climate",
|
platform="climate",
|
||||||
device_class_generic={"Thermostat"},
|
|
||||||
device_class_specific={
|
|
||||||
"Setpoint Thermostat",
|
|
||||||
"Unused",
|
|
||||||
},
|
|
||||||
primary_value=ZWaveValueDiscoverySchema(
|
primary_value=ZWaveValueDiscoverySchema(
|
||||||
command_class={CommandClass.THERMOSTAT_SETPOINT},
|
command_class={CommandClass.THERMOSTAT_SETPOINT},
|
||||||
property={"setpoint"},
|
property={"setpoint"},
|
||||||
type={"number"},
|
type={"number"},
|
||||||
),
|
),
|
||||||
|
absent_values=[ # mode must not be present to prevent dupes
|
||||||
|
ZWaveValueDiscoverySchema(
|
||||||
|
command_class={CommandClass.THERMOSTAT_MODE},
|
||||||
|
property={"mode"},
|
||||||
|
type={"number"},
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
# binary sensors
|
# binary sensors
|
||||||
ZWaveDiscoverySchema(
|
ZWaveDiscoverySchema(
|
||||||
@ -436,6 +432,13 @@ def async_discover_values(node: ZwaveNode) -> Generator[ZwaveDiscoveryInfo, None
|
|||||||
for val_scheme in schema.required_values
|
for val_scheme in schema.required_values
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
# check for values that may not be present
|
||||||
|
if schema.absent_values is not None:
|
||||||
|
if any(
|
||||||
|
any(check_value(val, val_scheme) for val in node.values.values())
|
||||||
|
for val_scheme in schema.absent_values
|
||||||
|
):
|
||||||
|
continue
|
||||||
# all checks passed, this value belongs to an entity
|
# all checks passed, this value belongs to an entity
|
||||||
yield ZwaveDiscoveryInfo(
|
yield ZwaveDiscoveryInfo(
|
||||||
node=value.node,
|
node=value.node,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user