mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Bugfix and small refactor for zwave_js.device_action (#93261)
Improve test coverage for zwave_js.device_action
This commit is contained in:
parent
e1dd7118e0
commit
03300c24da
@ -186,8 +186,9 @@ async def async_get_actions(
|
|||||||
# underlying value is not being monitored by HA so we shouldn't allow
|
# underlying value is not being monitored by HA so we shouldn't allow
|
||||||
# actions against it.
|
# actions against it.
|
||||||
if (
|
if (
|
||||||
state := hass.states.get(entry.entity_id)
|
not (state := hass.states.get(entry.entity_id))
|
||||||
) and state.state == STATE_UNAVAILABLE:
|
or state.state == STATE_UNAVAILABLE
|
||||||
|
):
|
||||||
continue
|
continue
|
||||||
entity_action = {**base_action, CONF_ENTITY_ID: entry.entity_id}
|
entity_action = {**base_action, CONF_ENTITY_ID: entry.entity_id}
|
||||||
actions.append({**entity_action, CONF_TYPE: SERVICE_REFRESH_VALUE})
|
actions.append({**entity_action, CONF_TYPE: SERVICE_REFRESH_VALUE})
|
||||||
@ -209,9 +210,7 @@ async def async_get_actions(
|
|||||||
# If the value has the meterType CC specific value, we can add a reset_meter
|
# If the value has the meterType CC specific value, we can add a reset_meter
|
||||||
# action for it
|
# action for it
|
||||||
if CC_SPECIFIC_METER_TYPE in value.metadata.cc_specific:
|
if CC_SPECIFIC_METER_TYPE in value.metadata.cc_specific:
|
||||||
endpoint_idx = value.endpoint
|
endpoint_idx = value.endpoint or 0
|
||||||
if endpoint_idx is None:
|
|
||||||
endpoint_idx = 0
|
|
||||||
meter_endpoints[endpoint_idx].setdefault(
|
meter_endpoints[endpoint_idx].setdefault(
|
||||||
CONF_ENTITY_ID, entry.entity_id
|
CONF_ENTITY_ID, entry.entity_id
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user