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:
Raman Gupta 2021-02-20 03:50:00 -05:00 committed by GitHub
parent 26ce316c18
commit 788134cbc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 63 additions and 27 deletions

View file

@ -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

View file

@ -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:

View file

@ -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

View file

@ -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"]
}