Bump zwave-js-server-python to 0.18.0 (#46787)
* updates to support changes in zwave-js-server-python * bump lib version * use named arguments for optional args * re-add lost commits
This commit is contained in:
parent
26ce316c18
commit
788134cbc4
8 changed files with 63 additions and 27 deletions
|
@ -125,10 +125,18 @@ class ZWaveClimate(ZWaveBaseEntity, ClimateEntity):
|
|||
)
|
||||
self._setpoint_values: Dict[ThermostatSetpointType, ZwaveValue] = {}
|
||||
for enum in ThermostatSetpointType:
|
||||
# Some devices don't include a property key so we need to check for value
|
||||
# ID's, both with and without the property key
|
||||
self._setpoint_values[enum] = self.get_zwave_value(
|
||||
THERMOSTAT_SETPOINT_PROPERTY,
|
||||
command_class=CommandClass.THERMOSTAT_SETPOINT,
|
||||
value_property_key_name=enum.value,
|
||||
value_property_key=enum.value.key,
|
||||
value_property_key_name=enum.value.name,
|
||||
add_to_watched_value_ids=True,
|
||||
) or self.get_zwave_value(
|
||||
THERMOSTAT_SETPOINT_PROPERTY,
|
||||
command_class=CommandClass.THERMOSTAT_SETPOINT,
|
||||
value_property_key_name=enum.value.name,
|
||||
add_to_watched_value_ids=True,
|
||||
)
|
||||
# Use the first found setpoint value to always determine the temperature unit
|
||||
|
|
|
@ -134,6 +134,7 @@ class ZWaveBaseEntity(Entity):
|
|||
value_property: Union[str, int],
|
||||
command_class: Optional[int] = None,
|
||||
endpoint: Optional[int] = None,
|
||||
value_property_key: Optional[int] = None,
|
||||
value_property_key_name: Optional[str] = None,
|
||||
add_to_watched_value_ids: bool = True,
|
||||
check_all_endpoints: bool = False,
|
||||
|
@ -146,16 +147,14 @@ class ZWaveBaseEntity(Entity):
|
|||
if endpoint is None:
|
||||
endpoint = self.info.primary_value.endpoint
|
||||
|
||||
# Build partial event data dictionary so we can change the endpoint later
|
||||
partial_evt_data = {
|
||||
"commandClass": command_class,
|
||||
"property": value_property,
|
||||
"propertyKeyName": value_property_key_name,
|
||||
}
|
||||
|
||||
# lookup value by value_id
|
||||
value_id = get_value_id(
|
||||
self.info.node, {**partial_evt_data, "endpoint": endpoint}
|
||||
self.info.node,
|
||||
command_class,
|
||||
value_property,
|
||||
endpoint=endpoint,
|
||||
property_key=value_property_key,
|
||||
property_key_name=value_property_key_name,
|
||||
)
|
||||
return_value = self.info.node.values.get(value_id)
|
||||
|
||||
|
@ -166,7 +165,11 @@ class ZWaveBaseEntity(Entity):
|
|||
if endpoint_.index != self.info.primary_value.endpoint:
|
||||
value_id = get_value_id(
|
||||
self.info.node,
|
||||
{**partial_evt_data, "endpoint": endpoint_.index},
|
||||
command_class,
|
||||
value_property,
|
||||
endpoint=endpoint_.index,
|
||||
property_key=value_property_key,
|
||||
property_key_name=value_property_key_name,
|
||||
)
|
||||
return_value = self.info.node.values.get(value_id)
|
||||
if return_value:
|
||||
|
|
|
@ -3,7 +3,7 @@ import logging
|
|||
from typing import Any, Callable, Optional, Tuple
|
||||
|
||||
from zwave_js_server.client import Client as ZwaveClient
|
||||
from zwave_js_server.const import CommandClass
|
||||
from zwave_js_server.const import ColorComponent, CommandClass
|
||||
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS,
|
||||
|
@ -200,10 +200,18 @@ class ZwaveLight(ZWaveBaseEntity, LightEntity):
|
|||
|
||||
async def _async_set_color(self, color_name: str, new_value: int) -> None:
|
||||
"""Set defined color to given value."""
|
||||
try:
|
||||
property_key = ColorComponent[color_name.upper().replace(" ", "_")].value
|
||||
except KeyError:
|
||||
raise ValueError(
|
||||
"Illegal color name specified, color must be one of "
|
||||
f"{','.join([color.name for color in ColorComponent])}"
|
||||
) from None
|
||||
cur_zwave_value = self.get_zwave_value(
|
||||
"currentColor",
|
||||
CommandClass.SWITCH_COLOR,
|
||||
value_property_key_name=color_name,
|
||||
value_property_key=property_key.key,
|
||||
value_property_key_name=property_key.name,
|
||||
)
|
||||
# guard for unsupported command
|
||||
if cur_zwave_value is None:
|
||||
|
@ -212,7 +220,8 @@ class ZwaveLight(ZWaveBaseEntity, LightEntity):
|
|||
target_zwave_value = self.get_zwave_value(
|
||||
"targetColor",
|
||||
CommandClass.SWITCH_COLOR,
|
||||
value_property_key_name=color_name,
|
||||
value_property_key=property_key.key,
|
||||
value_property_key_name=property_key.name,
|
||||
)
|
||||
if target_zwave_value is None:
|
||||
return
|
||||
|
@ -276,13 +285,22 @@ class ZwaveLight(ZWaveBaseEntity, LightEntity):
|
|||
|
||||
# RGB support
|
||||
red_val = self.get_zwave_value(
|
||||
"currentColor", CommandClass.SWITCH_COLOR, value_property_key_name="Red"
|
||||
"currentColor",
|
||||
CommandClass.SWITCH_COLOR,
|
||||
value_property_key=ColorComponent.RED.value.key,
|
||||
value_property_key_name=ColorComponent.RED.value.name,
|
||||
)
|
||||
green_val = self.get_zwave_value(
|
||||
"currentColor", CommandClass.SWITCH_COLOR, value_property_key_name="Green"
|
||||
"currentColor",
|
||||
CommandClass.SWITCH_COLOR,
|
||||
value_property_key=ColorComponent.GREEN.value.key,
|
||||
value_property_key_name=ColorComponent.GREEN.value.name,
|
||||
)
|
||||
blue_val = self.get_zwave_value(
|
||||
"currentColor", CommandClass.SWITCH_COLOR, value_property_key_name="Blue"
|
||||
"currentColor",
|
||||
CommandClass.SWITCH_COLOR,
|
||||
value_property_key=ColorComponent.BLUE.value.key,
|
||||
value_property_key_name=ColorComponent.BLUE.value.name,
|
||||
)
|
||||
if red_val and green_val and blue_val:
|
||||
self._supports_color = True
|
||||
|
@ -300,12 +318,14 @@ class ZwaveLight(ZWaveBaseEntity, LightEntity):
|
|||
ww_val = self.get_zwave_value(
|
||||
"currentColor",
|
||||
CommandClass.SWITCH_COLOR,
|
||||
value_property_key_name="Warm White",
|
||||
value_property_key=ColorComponent.WARM_WHITE.value.key,
|
||||
value_property_key_name=ColorComponent.WARM_WHITE.value.name,
|
||||
)
|
||||
cw_val = self.get_zwave_value(
|
||||
"currentColor",
|
||||
CommandClass.SWITCH_COLOR,
|
||||
value_property_key_name="Cold White",
|
||||
value_property_key=ColorComponent.COLD_WHITE.value.key,
|
||||
value_property_key_name=ColorComponent.COLD_WHITE.value.name,
|
||||
)
|
||||
if ww_val and cw_val:
|
||||
# Color temperature (CW + WW) Support
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"name": "Z-Wave JS",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/zwave_js",
|
||||
"requirements": ["zwave-js-server-python==0.17.2"],
|
||||
"requirements": ["zwave-js-server-python==0.18.0"],
|
||||
"codeowners": ["@home-assistant/z-wave"],
|
||||
"dependencies": ["http", "websocket_api"]
|
||||
}
|
||||
|
|
|
@ -2385,4 +2385,4 @@ zigpy==0.32.0
|
|||
zm-py==0.5.2
|
||||
|
||||
# homeassistant.components.zwave_js
|
||||
zwave-js-server-python==0.17.2
|
||||
zwave-js-server-python==0.18.0
|
||||
|
|
|
@ -1222,4 +1222,4 @@ zigpy-znp==0.3.0
|
|||
zigpy==0.32.0
|
||||
|
||||
# homeassistant.components.zwave_js
|
||||
zwave-js-server-python==0.17.2
|
||||
zwave-js-server-python==0.18.0
|
||||
|
|
|
@ -456,7 +456,6 @@ async def test_setpoint_thermostat(hass, client, climate_danfoss_lc_13, integrat
|
|||
"commandClass": 67,
|
||||
"endpoint": 0,
|
||||
"property": "setpoint",
|
||||
"propertyKey": 1,
|
||||
"propertyKeyName": "Heating",
|
||||
"propertyName": "setpoint",
|
||||
"newValue": 23,
|
||||
|
|
|
@ -203,17 +203,21 @@ async def test_light(hass, client, bulb_6_multi_color, integration):
|
|||
"property": "currentColor",
|
||||
"newValue": 255,
|
||||
"prevValue": 0,
|
||||
"propertyKey": 2,
|
||||
"propertyKeyName": "Red",
|
||||
},
|
||||
},
|
||||
)
|
||||
green_event = deepcopy(red_event)
|
||||
green_event.data["args"].update({"newValue": 76, "propertyKeyName": "Green"})
|
||||
green_event.data["args"].update(
|
||||
{"newValue": 76, "propertyKey": 3, "propertyKeyName": "Green"}
|
||||
)
|
||||
blue_event = deepcopy(red_event)
|
||||
blue_event.data["args"]["propertyKey"] = 4
|
||||
blue_event.data["args"]["propertyKeyName"] = "Blue"
|
||||
warm_white_event = deepcopy(red_event)
|
||||
warm_white_event.data["args"].update(
|
||||
{"newValue": 0, "propertyKeyName": "Warm White"}
|
||||
{"newValue": 0, "propertyKey": 0, "propertyKeyName": "Warm White"}
|
||||
)
|
||||
node.receive_event(warm_white_event)
|
||||
node.receive_event(red_event)
|
||||
|
@ -316,23 +320,25 @@ async def test_light(hass, client, bulb_6_multi_color, integration):
|
|||
"property": "currentColor",
|
||||
"newValue": 0,
|
||||
"prevValue": 255,
|
||||
"propertyKey": 2,
|
||||
"propertyKeyName": "Red",
|
||||
},
|
||||
},
|
||||
)
|
||||
green_event = deepcopy(red_event)
|
||||
green_event.data["args"].update(
|
||||
{"newValue": 0, "prevValue": 76, "propertyKeyName": "Green"}
|
||||
{"newValue": 0, "prevValue": 76, "propertyKey": 3, "propertyKeyName": "Green"}
|
||||
)
|
||||
blue_event = deepcopy(red_event)
|
||||
blue_event.data["args"]["propertyKey"] = 4
|
||||
blue_event.data["args"]["propertyKeyName"] = "Blue"
|
||||
warm_white_event = deepcopy(red_event)
|
||||
warm_white_event.data["args"].update(
|
||||
{"newValue": 20, "propertyKeyName": "Warm White"}
|
||||
{"newValue": 20, "propertyKey": 0, "propertyKeyName": "Warm White"}
|
||||
)
|
||||
cold_white_event = deepcopy(red_event)
|
||||
cold_white_event.data["args"].update(
|
||||
{"newValue": 235, "propertyKeyName": "Cold White"}
|
||||
{"newValue": 235, "propertyKey": 1, "propertyKeyName": "Cold White"}
|
||||
)
|
||||
node.receive_event(red_event)
|
||||
node.receive_event(green_event)
|
||||
|
|
Loading…
Add table
Reference in a new issue