Set default value for endpoint in zwave device automations (#94445)
* Set default value for endpoint in zwave device automations * add test casepull/94621/head
parent
25a4679266
commit
fa8e952324
|
@ -101,7 +101,7 @@ RESET_METER_SCHEMA = cv.DEVICE_ACTION_BASE_SCHEMA.extend(
|
|||
SET_CONFIG_PARAMETER_SCHEMA = cv.DEVICE_ACTION_BASE_SCHEMA.extend(
|
||||
{
|
||||
vol.Required(CONF_TYPE): SERVICE_SET_CONFIG_PARAMETER,
|
||||
vol.Required(ATTR_ENDPOINT): vol.Coerce(int),
|
||||
vol.Required(ATTR_ENDPOINT, default=0): vol.Coerce(int),
|
||||
vol.Required(ATTR_CONFIG_PARAMETER): vol.Any(int, str),
|
||||
vol.Required(ATTR_CONFIG_PARAMETER_BITMASK): vol.Any(None, int, str),
|
||||
vol.Required(ATTR_VALUE): vol.Coerce(int),
|
||||
|
|
|
@ -161,7 +161,7 @@ BASE_VALUE_UPDATED_SCHEMA = DEVICE_TRIGGER_BASE_SCHEMA.extend(
|
|||
vol.Required(ATTR_COMMAND_CLASS): vol.In([cc.value for cc in CommandClass]),
|
||||
vol.Required(ATTR_PROPERTY): vol.Any(int, str),
|
||||
vol.Optional(ATTR_PROPERTY_KEY): vol.Any(None, vol.Coerce(int), str),
|
||||
vol.Optional(ATTR_ENDPOINT): vol.Any(None, vol.Coerce(int)),
|
||||
vol.Optional(ATTR_ENDPOINT, default=0): vol.Any(None, vol.Coerce(int)),
|
||||
vol.Optional(ATTR_FROM): VALUE_SCHEMA,
|
||||
vol.Optional(ATTR_TO): VALUE_SCHEMA,
|
||||
}
|
||||
|
|
|
@ -196,6 +196,21 @@ async def test_actions(
|
|||
"value": 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
"trigger": {
|
||||
"platform": "event",
|
||||
"event_type": "test_event_set_config_parameter_no_endpoint",
|
||||
},
|
||||
"action": {
|
||||
"domain": DOMAIN,
|
||||
"type": "set_config_parameter",
|
||||
"device_id": device.id,
|
||||
"parameter": 1,
|
||||
"bitmask": None,
|
||||
"subtype": "3 (Beeper)",
|
||||
"value": 1,
|
||||
},
|
||||
},
|
||||
]
|
||||
},
|
||||
)
|
||||
|
@ -245,6 +260,18 @@ async def test_actions(
|
|||
assert args[1] == 1
|
||||
assert args[2] == 1
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.zwave_js.services.async_set_config_parameter"
|
||||
) as mock_call:
|
||||
hass.bus.async_fire("test_event_set_config_parameter_no_endpoint")
|
||||
await hass.async_block_till_done()
|
||||
mock_call.assert_called_once()
|
||||
args = mock_call.call_args_list[0][0]
|
||||
assert len(args) == 3
|
||||
assert args[0].node_id == 13
|
||||
assert args[1] == 1
|
||||
assert args[2] == 1
|
||||
|
||||
|
||||
async def test_actions_multiple_calls(
|
||||
hass: HomeAssistant,
|
||||
|
|
Loading…
Reference in New Issue