Add raw values to zwave_js value notification event (#47258)
* add value_raw to value notification event that always shows the untranslated state value * add property key and property to event params
This commit is contained in:
parent
d20659d2ee
commit
42af775f53
3 changed files with 13 additions and 1 deletions
|
@ -30,10 +30,13 @@ from .const import (
|
|||
ATTR_LABEL,
|
||||
ATTR_NODE_ID,
|
||||
ATTR_PARAMETERS,
|
||||
ATTR_PROPERTY,
|
||||
ATTR_PROPERTY_KEY,
|
||||
ATTR_PROPERTY_KEY_NAME,
|
||||
ATTR_PROPERTY_NAME,
|
||||
ATTR_TYPE,
|
||||
ATTR_VALUE,
|
||||
ATTR_VALUE_RAW,
|
||||
CONF_INTEGRATION_CREATED_ADDON,
|
||||
DATA_CLIENT,
|
||||
DATA_UNSUBSCRIBE,
|
||||
|
@ -213,7 +216,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
def async_on_value_notification(notification: ValueNotification) -> None:
|
||||
"""Relay stateless value notification events from Z-Wave nodes to hass."""
|
||||
device = dev_reg.async_get_device({get_device_id(client, notification.node)})
|
||||
value = notification.value
|
||||
raw_value = value = notification.value
|
||||
if notification.metadata.states:
|
||||
value = notification.metadata.states.get(str(value), value)
|
||||
hass.bus.async_fire(
|
||||
|
@ -228,9 +231,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
ATTR_COMMAND_CLASS: notification.command_class,
|
||||
ATTR_COMMAND_CLASS_NAME: notification.command_class_name,
|
||||
ATTR_LABEL: notification.metadata.label,
|
||||
ATTR_PROPERTY: notification.property_,
|
||||
ATTR_PROPERTY_NAME: notification.property_name,
|
||||
ATTR_PROPERTY_KEY: notification.property_key,
|
||||
ATTR_PROPERTY_KEY_NAME: notification.property_key_name,
|
||||
ATTR_VALUE: value,
|
||||
ATTR_VALUE_RAW: raw_value,
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
@ -26,12 +26,15 @@ ATTR_HOME_ID = "home_id"
|
|||
ATTR_ENDPOINT = "endpoint"
|
||||
ATTR_LABEL = "label"
|
||||
ATTR_VALUE = "value"
|
||||
ATTR_VALUE_RAW = "value_raw"
|
||||
ATTR_COMMAND_CLASS = "command_class"
|
||||
ATTR_COMMAND_CLASS_NAME = "command_class_name"
|
||||
ATTR_TYPE = "type"
|
||||
ATTR_DEVICE_ID = "device_id"
|
||||
ATTR_PROPERTY_NAME = "property_name"
|
||||
ATTR_PROPERTY_KEY_NAME = "property_key_name"
|
||||
ATTR_PROPERTY = "property"
|
||||
ATTR_PROPERTY_KEY = "property_key"
|
||||
ATTR_PARAMETERS = "parameters"
|
||||
|
||||
# service constants
|
||||
|
|
|
@ -47,6 +47,7 @@ async def test_scenes(hass, hank_binary_switch, integration, client):
|
|||
assert events[0].data["command_class_name"] == "Basic"
|
||||
assert events[0].data["label"] == "Event value"
|
||||
assert events[0].data["value"] == 255
|
||||
assert events[0].data["value_raw"] == 255
|
||||
|
||||
# Publish fake Scene Activation value notification
|
||||
event = Event(
|
||||
|
@ -82,6 +83,7 @@ async def test_scenes(hass, hank_binary_switch, integration, client):
|
|||
assert events[1].data["command_class_name"] == "Scene Activation"
|
||||
assert events[1].data["label"] == "Scene ID"
|
||||
assert events[1].data["value"] == 16
|
||||
assert events[1].data["value_raw"] == 16
|
||||
|
||||
# Publish fake Central Scene value notification
|
||||
event = Event(
|
||||
|
@ -128,6 +130,7 @@ async def test_scenes(hass, hank_binary_switch, integration, client):
|
|||
assert events[2].data["command_class_name"] == "Central Scene"
|
||||
assert events[2].data["label"] == "Scene 001"
|
||||
assert events[2].data["value"] == "KeyPressed3x"
|
||||
assert events[2].data["value_raw"] == 4
|
||||
|
||||
|
||||
async def test_notifications(hass, hank_binary_switch, integration, client):
|
||||
|
|
Loading…
Add table
Reference in a new issue