From 03300c24da49a5cbe0fd32fb2e9d1fce58c5d64f Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Mon, 22 May 2023 12:04:04 -0400 Subject: [PATCH] Bugfix and small refactor for zwave_js.device_action (#93261) Improve test coverage for zwave_js.device_action --- homeassistant/components/zwave_js/device_action.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/zwave_js/device_action.py b/homeassistant/components/zwave_js/device_action.py index 3a585b44f58..bfb7956432b 100644 --- a/homeassistant/components/zwave_js/device_action.py +++ b/homeassistant/components/zwave_js/device_action.py @@ -186,8 +186,9 @@ async def async_get_actions( # underlying value is not being monitored by HA so we shouldn't allow # actions against it. if ( - state := hass.states.get(entry.entity_id) - ) and state.state == STATE_UNAVAILABLE: + not (state := hass.states.get(entry.entity_id)) + or state.state == STATE_UNAVAILABLE + ): continue entity_action = {**base_action, CONF_ENTITY_ID: entry.entity_id} 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 # action for it if CC_SPECIFIC_METER_TYPE in value.metadata.cc_specific: - endpoint_idx = value.endpoint - if endpoint_idx is None: - endpoint_idx = 0 + endpoint_idx = value.endpoint or 0 meter_endpoints[endpoint_idx].setdefault( CONF_ENTITY_ID, entry.entity_id )