Skip to content

Commit

Permalink
fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
bramstroker committed Jul 8, 2023
1 parent 146ac8d commit 839ffb1
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions custom_components/powercalc/sensors/power.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,8 @@ def _has_valid_state(self, state: State | None) -> bool:
async def calculate_power(self, state: State) -> Decimal | None:
"""Calculate power consumption using configured strategy."""
entity_state = state
if state.entity_id != self._source_entity.entity_id:
entity_state = self.hass.states.get(self._source_entity.entity_id)
if entity_state is None:
return None
if state.entity_id != self._source_entity.entity_id and (entity_state := self.hass.states.get(self._source_entity.entity_id)) is None:
return None

unavailable_power = self._sensor_config.get(CONF_UNAVAILABLE_POWER)
if entity_state.state == STATE_UNAVAILABLE and unavailable_power is not None:
Expand Down

0 comments on commit 839ffb1

Please sign in to comment.