Skip to content

Commit

Permalink
Fixed important deprecated warnings. (#933)
Browse files Browse the repository at this point in the history
Co-authored-by: J. Nick Koston <[email protected]>
  • Loading branch information
twrecked and bdraco authored May 3, 2024
1 parent 27869fe commit 26d55d5
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 32 deletions.
2 changes: 2 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
aarlo/pyaarlo
0.7.4.3:
Fix important deprecated warning and errors.
0.7.4.2:
Support 'synced' state
0.7.4.1:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/aarlo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
SIREN_STATE_KEY
)

__version__ = "0.7.4.2"
__version__ = "0.7.4.3"

_LOGGER = logging.getLogger(__name__)

Expand Down
8 changes: 3 additions & 5 deletions custom_components/aarlo/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,10 @@ def icon(self):
async def async_added_to_hass(self):
"""Register callbacks."""

@callback
def update_state(_device, attr, value):
_LOGGER.debug("callback:" + self._name + ":" + attr + ":" + str(value))
self._state = self._get_state_from_ha(self._base.attribute(MODE_KEY))
self.async_schedule_update_ha_state()
self.schedule_update_ha_state()()

self._state = self._get_state_from_ha(self._base.attribute(MODE_KEY, ARMED))
self._base.add_attr_callback(MODE_KEY, update_state)
Expand Down Expand Up @@ -316,7 +315,7 @@ def alarm_trigger(self, code=None):
duration=self._trigger_time.total_seconds(),
volume=self._alarm_volume,
)
self.async_schedule_update_ha_state()
self.schedule_update_ha_state()
track_point_in_time(
self.hass,
self.async_update_ha_state,
Expand Down Expand Up @@ -428,11 +427,10 @@ def icon(self):
async def async_added_to_hass(self):
"""Register callbacks."""

@callback
def update_state(_device, attr, value):
_LOGGER.debug("callback:" + self._name + ":" + attr + ":" + str(value))
self._state = self._get_state_from_ha(self._location.attribute(MODE_KEY))
self.async_schedule_update_ha_state()
self.schedule_update_ha_state()

self._state = self._get_state_from_ha(self._location.attribute(MODE_KEY, "Stand By"))
self._location.add_attr_callback(MODE_KEY, update_state)
Expand Down
3 changes: 1 addition & 2 deletions custom_components/aarlo/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,11 @@ def __init__(self, device, sensor_type):
async def async_added_to_hass(self):
"""Register callbacks."""

@callback
def update_state(_device, attr, value):
_LOGGER.debug("callback:" + self._name + ":" + attr + ":" + str(value)[:80])
if self._attr == attr:
self._state = self.map_value(attr, value)
self.async_schedule_update_ha_state()
self.schedule_update_ha_state()

if self._attr is not None:
self._state = self.map_value(self._attr, self._device.attribute(self._attr))
Expand Down
3 changes: 1 addition & 2 deletions custom_components/aarlo/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ def __init__(self, camera, config, arlo, hass):
async def async_added_to_hass(self):
"""Register callbacks."""

@callback
def update_state(_device, attr, value):
_LOGGER.debug("callback:" + self._name + ":" + attr + ":" + str(value)[:80])

Expand Down Expand Up @@ -425,7 +424,7 @@ def update_state(_device, attr, value):
img_file.write(value)

# Signal changes.
self.async_schedule_update_ha_state()
self.schedule_update_ha_state()

self._camera.add_attr_callback(ACTIVITY_STATE_KEY, update_state)
self._camera.add_attr_callback(CHARGER_KEY, update_state)
Expand Down
12 changes: 4 additions & 8 deletions custom_components/aarlo/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,13 @@ def __init__(self, light):
async def async_added_to_hass(self):
"""Register callbacks."""

@callback
def update_state(_light, attr, value):
_LOGGER.debug("callback:" + self._name + ":" + attr + ":" + str(value)[:80])
if attr == LAMP_STATE_KEY:
self._state = value
if attr == BRIGHTNESS_KEY:
self._brightness = value
self.async_schedule_update_ha_state()
self.schedule_update_ha_state()

_LOGGER.info("ArloLight: %s registering callbacks", self._name)
self._state = self._light.attribute(LAMP_STATE_KEY, default="off")
Expand Down Expand Up @@ -205,14 +204,13 @@ def _set_light_mode(self, light_mode):
async def async_added_to_hass(self):
"""Register callbacks."""

@callback
def update_attr(_light, attr, value):
_LOGGER.debug("callback:" + self._name + ":" + attr + ":" + str(value)[:80])
if attr == LIGHT_BRIGHTNESS_KEY:
self._brightness = value
if attr == LIGHT_MODE_KEY:
self._set_light_mode(value)
self.async_schedule_update_ha_state()
self.schedule_update_ha_state()

_LOGGER.info("ArloNightLight: %s registering callbacks", self._name)

Expand Down Expand Up @@ -331,11 +329,10 @@ def set_states(state):
self._sleep_time = None
self._sleep_time_rel = None

@callback
def update_attr(_light, attr, value):
_LOGGER.debug("callback:" + self._name + ":" + attr + ":" + str(value)[:80])
set_states(value)
self.async_schedule_update_ha_state()
self.schedule_update_ha_state()

_LOGGER.info("ArloFloodLight: %s registering callbacks", self._name)
floodlight = self._light.attribute(FLOODLIGHT_KEY, default={})
Expand Down Expand Up @@ -400,14 +397,13 @@ def __init__(self, camera):
async def async_added_to_hass(self):
"""Register callbacks."""

@callback
def update_attr(_light, attr, value):
_LOGGER.debug("callback:" + self._name + ":" + attr + ":" + str(value)[:80])
if attr == SPOTLIGHT_KEY:
self._state = value
if attr == SPOTLIGHT_BRIGHTNESS_KEY:
self._brightness = value / 100 * 255
self.async_schedule_update_ha_state()
self.schedule_update_ha_state()

_LOGGER.info("ArloSpotlight: %s registering callbacks", self._name)

Expand Down
2 changes: 1 addition & 1 deletion custom_components/aarlo/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"iot_class": "cloud_push",
"issue_tracker": "https://github.com/twrecked/hass-aarlo/issues",
"requirements": ["unidecode","cloudscraper>=1.2.71", "paho-mqtt"],
"version": "0.7.4.2"
"version": "0.7.4.3"
}
3 changes: 1 addition & 2 deletions custom_components/aarlo/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def __init__(self, name, device):
async def async_added_to_hass(self):
"""Register callbacks."""

@callback
def update_state(_device, attr, props):
_LOGGER.info("callback:" + self._name + ":" + attr + ":" + str(props)[:80])
if attr == "status":
Expand All @@ -117,7 +116,7 @@ def update_state(_device, attr, props):
elif attr == "playlist":
self._playlist = props

self.async_schedule_update_ha_state()
self.schedule_update_ha_state()

self._device.add_attr_callback("config", update_state)
self._device.add_attr_callback("speaker", update_state)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/aarlo/pyaarlo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

_LOGGER = logging.getLogger("pyaarlo")

__version__ = "0.7.4.2"
__version__ = "0.7.4.3"


class PyArlo(object):
Expand Down
3 changes: 1 addition & 2 deletions custom_components/aarlo/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,10 @@ def __init__(self, arlo, device, sensor_type):
async def async_added_to_hass(self):
"""Register callbacks."""

@callback
def update_state(_device, attr, value):
_LOGGER.debug("callback:" + self._name + ":" + attr + ":" + str(value)[:80])
self._state = value
self.async_schedule_update_ha_state()
self.schedule_update_ha_state()

if self._attr is not None:
self._state = self._device.attribute(self._attr)
Expand Down
12 changes: 4 additions & 8 deletions custom_components/aarlo/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,12 @@ def __init__(self, config, device):
async def async_added_to_hass(self):
"""Register callbacks."""

@callback
def update_state(_device, attr, value):
_LOGGER.debug(
"siren-callback:" + self._name + ":" + attr + ":" + str(value)[:80]
)
self._state = value
self.async_schedule_update_ha_state()
self.schedule_update_ha_state()

_LOGGER.debug("register siren callbacks for {}".format(self._device.name))
self._device.add_attr_callback(SIREN_STATE_KEY, update_state)
Expand Down Expand Up @@ -280,7 +279,6 @@ def __init__(self, config, arlo, devices):
async def async_added_to_hass(self):
"""Register callbacks."""

@callback
def update_state(_device, attr, value):
_LOGGER.debug(
"all-siren-callback:" + self._name + ":" + attr + ":" + str(value)[:80]
Expand All @@ -292,7 +290,7 @@ def update_state(_device, attr, value):
state = "on"
self._state = state

self.async_schedule_update_ha_state()
self.schedule_update_ha_state()

for device in self._devices:
_LOGGER.debug("register all siren callbacks for {}".format(device.name))
Expand Down Expand Up @@ -331,10 +329,9 @@ def __init__(self, config, camera):
async def async_added_to_hass(self):
"""Register callbacks."""

@callback
def update_state(_device, attr, value):
_LOGGER.debug("callback:" + self._name + ":" + attr + ":" + str(value)[:80])
self.async_schedule_update_ha_state()
self.schedule_update_ha_state()

self._device.add_attr_callback(ACTIVITY_STATE_KEY, update_state)

Expand Down Expand Up @@ -381,7 +378,6 @@ def turn_off(self, **kwargs):
async def async_added_to_hass(self):
"""Register callbacks."""

@callback
def update_state(_device, attr, value):
_LOGGER.debug(
"silent-callback:" + self._name + ":" + attr + ":" + str(value)[:100]
Expand All @@ -393,7 +389,7 @@ def update_state(_device, attr, value):
else:
self._state = self._doorbell.is_silenced

self.async_schedule_update_ha_state()
self.schedule_update_ha_state()

self._doorbell.add_attr_callback(SILENT_MODE_KEY, update_state)

Expand Down

0 comments on commit 26d55d5

Please sign in to comment.