Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading