Skip to content

Commit

Permalink
Set Switch as default class for switches
Browse files Browse the repository at this point in the history
  • Loading branch information
xZetsubou committed Nov 10, 2023
1 parent b5243ab commit b3c5776
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion custom_components/localtuya/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ def entity_category(self) -> str:
@property
def device_class(self):
"""Return the class of this device."""
return self._config.get(CONF_DEVICE_CLASS, None)
return self._config.get(CONF_DEVICE_CLASS, self._attr_device_class)

def has_config(self, attr) -> bool:
"""Return if a config parameter has a valid value."""
Expand Down
2 changes: 2 additions & 0 deletions custom_components/localtuya/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def flow_schema(dps):
class LocaltuyaSwitch(LocalTuyaEntity, SwitchEntity):
"""Representation of a Tuya switch."""

_attr_device_class = SwitchDeviceClass.SWITCH

def __init__(
self,
device,
Expand Down

0 comments on commit b3c5776

Please sign in to comment.