Skip to content

Commit

Permalink
fix: switch attrs unsupported operand type(s) for /: 'NoneType' and '…
Browse files Browse the repository at this point in the history
…int' (#345)

* TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'

* amended absed on review
  • Loading branch information
ilankas authored Sep 9, 2024
1 parent 882623e commit e23d2c4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions custom_components/localtuya/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ def extra_state_attributes(self):
if self.has_config(CONF_CURRENT):
attrs[ATTR_CURRENT] = self.dp_value(self._config[CONF_CURRENT])
if self.has_config(CONF_CURRENT_CONSUMPTION):
attrs[ATTR_CURRENT_CONSUMPTION] = (
self.dp_value(self._config[CONF_CURRENT_CONSUMPTION]) / 10
)
val_cc = self.dp_value(self._config[CONF_CURRENT_CONSUMPTION])
attrs[ATTR_CURRENT_CONSUMPTION] = None if val_cc is None else val_cc / 10
if self.has_config(CONF_VOLTAGE):
attrs[ATTR_VOLTAGE] = self.dp_value(self._config[CONF_VOLTAGE]) / 10
val_vol = self.dp_value(self._config[CONF_VOLTAGE])
attrs[ATTR_VOLTAGE] = None if val_vol is None else val_vol / 10

# Store the state
if self._state is not None:
Expand Down

0 comments on commit e23d2c4

Please sign in to comment.