Skip to content

Commit

Permalink
Remove deprecated device_state_attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
niceboy committed Dec 12, 2021
1 parent 942b937 commit 80003b7
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 24 deletions.
5 changes: 0 additions & 5 deletions custom_components/aqara_gateway/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,6 @@ def available(self) -> bool:
""" return available """
return self.device.get('online', True)

@property
def device_state_attributes(self):
""" return attrs """
return self._attrs

@property
def device_info(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions custom_components/aqara_gateway/air_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(self, gateway, device, attr):
self.is_metric = False

@property
def device_state_attributes(self):
def extra_state_attributes(self):
"""Return the state attributes."""
attrs = {
ATTR_BATTERY_LEVEL: self._battery,
Expand Down Expand Up @@ -189,7 +189,7 @@ def __init__(self, gateway, device, attr):
self._state = 0

@property
def device_state_attributes(self):
def extra_state_attributes(self):
"""Return the state attributes."""
attrs = {
ATTR_BATTERY_LEVEL: self._battery,
Expand Down
14 changes: 7 additions & 7 deletions custom_components/aqara_gateway/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def __init__(
super().__init__(gateway, device, attr)

@property
def device_state_attributes(self):
def extra_state_attributes(self):
"""Return the state attributes."""
attrs = {
ATTR_CHIP_TEMPERATURE: self._chip_temperature,
Expand Down Expand Up @@ -187,7 +187,7 @@ async def async_added_to_hass(self):
await super().async_added_to_hass()

@property
def device_state_attributes(self):
def extra_state_attributes(self):
"""Return the state attributes."""
self._attrs[ATTR_BATTERY_LEVEL] = self._battery
self._attrs[ATTR_CHIP_TEMPERATURE] = self._chip_temperature
Expand Down Expand Up @@ -321,7 +321,7 @@ def __init__(
super().__init__(gateway, device, attr)

@property
def device_state_attributes(self):
def extra_state_attributes(self):
"""Return the state attributes."""
attrs = {
ATTR_BATTERY_LEVEL: self._battery,
Expand Down Expand Up @@ -387,7 +387,7 @@ def __init__(
super().__init__(gateway, device, attr)

@property
def device_state_attributes(self):
def extra_state_attributes(self):
"""Return the state attributes."""
attrs = {
ATTR_BATTERY_LEVEL: self._battery,
Expand Down Expand Up @@ -450,7 +450,7 @@ def __init__(
super().__init__(gateway, device, attr)

@property
def device_state_attributes(self):
def extra_state_attributes(self):
"""Return the state attributes."""
attrs = {
ATTR_CHIP_TEMPERATURE: self._chip_temperature,
Expand Down Expand Up @@ -518,7 +518,7 @@ def icon(self):
return 'hass:radiobox-blank'

@property
def device_state_attributes(self):
def extra_state_attributes(self):
"""Return the state attributes."""
attrs = {
ATTR_BATTERY_LEVEL: self._battery,
Expand Down Expand Up @@ -619,7 +619,7 @@ def icon(self):
return 'hass:radiobox-blank'

@property
def device_state_attributes(self):
def extra_state_attributes(self):
"""Return the state attributes."""
self._attrs[ATTR_BATTERY_LEVEL] = self._battery
self._attrs[ATTR_CHIP_TEMPERATURE] = self._chip_temperature
Expand Down
10 changes: 5 additions & 5 deletions custom_components/aqara_gateway/core/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, hass, host: str, config: dict, **options):
self.devices = {}
self.updates = {}
self.setups = {}
self._device_state_attributes = {}
self._extra_state_attributes = {}
self._info_ts = None
self._gateway_did = ''
self._model = options.get(CONF_MODEL, '') # long model, will replace to short later
Expand Down Expand Up @@ -324,21 +324,21 @@ def setup_devices(self, devices: list):

def add_stats(self, ieee: str, handler):
""" add gateway stats """
self._device_state_attributes[ieee] = handler
self._extra_state_attributes[ieee] = handler

if self.parent_scan_interval > 0:
self._info_ts = time.time() + 5

def remove_stats(self, ieee: str, handler):
""" remove gateway stats """
self._device_state_attributes.pop(ieee)
self._extra_state_attributes.pop(ieee)

def process_gateway_stats(self, payload: dict = None):
""" process gateway status """
# empty payload - update available state
self.debug(f"gateway <= {payload or self.available}")

if 'lumi.0' not in self._device_state_attributes:
if 'lumi.0' not in self._extra_state_attributes:
return

if payload:
Expand Down Expand Up @@ -384,7 +384,7 @@ def process_gateway_stats(self, payload: dict = None):
value = json.loads(raw)
data.update(value)

self._device_state_attributes['lumi.0'](data)
self._extra_state_attributes['lumi.0'](data)

def on_connect(self, client, userdata, flags, ret):
# pylint: disable=unused-argument
Expand Down
2 changes: 1 addition & 1 deletion custom_components/aqara_gateway/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def set_cover_position(self, **kwargs):
self.gateway.send(self.device, {'position': position})

@property
def device_state_attributes(self):
def extra_state_attributes(self):
"""Return the state attributes."""
self._attrs[ATTR_CURRENT_POSITION] = self._pos
self._attrs[ATTR_CHIP_TEMPERATURE] = self._chip_temperature
Expand Down
2 changes: 1 addition & 1 deletion custom_components/aqara_gateway/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def supported_features(self):
return features

@property
def device_state_attributes(self):
def extra_state_attributes(self):
"""Return the state attributes."""
if self.device['type'] == 'zigbee':
self._attrs[ATTR_CHIP_TEMPERATURE] = self._chip_temperature
Expand Down
4 changes: 2 additions & 2 deletions custom_components/aqara_gateway/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def icon(self):
return ICONS.get(self._attr)

@property
def device_state_attributes(self):
def extra_state_attributes(self):
"""Return the state attributes."""
if self.with_attr:
attrs = {
Expand Down Expand Up @@ -349,7 +349,7 @@ def device_class(self):
return "lock_state"

@property
def device_state_attributes(self):
def extra_state_attributes(self):
"""Return the state attributes."""
attrs = {
ATTR_BATTERY_LEVEL: self._battery,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/aqara_gateway/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def icon(self):
return 'mdi:power-socket'

@property
def device_state_attributes(self):
def extra_state_attributes(self):
"""Return the state attributes."""
self._attrs[ATTR_CHIP_TEMPERATURE] = self._chip_temperature
self._attrs[ATTR_FW_VER] = self._fw_ver
Expand Down

0 comments on commit 80003b7

Please sign in to comment.