Fix implicit-return in konnected (#122915)

* Fix implicit-return in konnected

* Adjust

* Adjust

* Adjust tests
This commit is contained in:
epenet 2024-08-08 10:09:36 +02:00 committed by GitHub
parent 6a89080ce7
commit b7f5236a0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 4 deletions

View File

@ -102,13 +102,12 @@ class KonnectedSwitch(SwitchEntity):
if resp.get(ATTR_STATE) is not None:
self._set_state(self._boolean_state(resp.get(ATTR_STATE)))
def _boolean_state(self, int_state):
if int_state is None:
return False
def _boolean_state(self, int_state: int | None) -> bool | None:
if int_state == 0:
return self._activation == STATE_LOW
if int_state == 1:
return self._activation == STATE_HIGH
return None
def _set_state(self, state):
self._attr_is_on = state

View File

@ -700,4 +700,4 @@ async def test_connect_retry(hass: HomeAssistant, mock_panel) -> None:
async_fire_time_changed(hass, utcnow() + timedelta(seconds=21))
await hass.async_block_till_done()
await async_update_entity(hass, "switch.konnected_445566_actuator_6")
assert hass.states.get("switch.konnected_445566_actuator_6").state == "off"
assert hass.states.get("switch.konnected_445566_actuator_6").state == "unknown"