From a7bcbc164fd927ab4681be3c41071b92393f24aa Mon Sep 17 00:00:00 2001 From: Mark Coombes Date: Thu, 13 Aug 2020 14:06:40 -0400 Subject: [PATCH] 9 (#27) * Fix deprecation warnings (#24) * Fix deprecation warning for binary sensor * Fix deprecation warning for switch * Fix camera (#25) Changed camera image method to async. * Fix translations (#26) Rename translations directory from .translations to translations. Closes #21. Closes #23. --- custom_components/kuna/binary_sensor.py | 4 ++-- custom_components/kuna/camera.py | 2 +- custom_components/kuna/switch.py | 4 ++-- .../kuna/{.translations => translations}/en.json | 0 4 files changed, 5 insertions(+), 5 deletions(-) rename custom_components/kuna/{.translations => translations}/en.json (100%) diff --git a/custom_components/kuna/binary_sensor.py b/custom_components/kuna/binary_sensor.py index 1af8ccd..507afac 100644 --- a/custom_components/kuna/binary_sensor.py +++ b/custom_components/kuna/binary_sensor.py @@ -4,7 +4,7 @@ """ import logging -from homeassistant.components.binary_sensor import BinarySensorDevice +from homeassistant.components.binary_sensor import BinarySensorEntity from .const import DOMAIN, MANUFACTURER @@ -31,7 +31,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(devices, True) -class KunaBinarySensor(BinarySensorDevice): +class KunaBinarySensor(BinarySensorEntity): def __init__(self, kuna, camera): self._account = kuna self._camera = camera diff --git a/custom_components/kuna/camera.py b/custom_components/kuna/camera.py index a0791a9..c33746f 100644 --- a/custom_components/kuna/camera.py +++ b/custom_components/kuna/camera.py @@ -118,7 +118,7 @@ async def async_added_to_hass(self): def _ready_for_snapshot(self, now): return self._next_snapshot_at is None or now > self._next_snapshot_at - async def camera_image(self): + async def async_camera_image(self): """Get and return an image from the camera, only once every stream_interval seconds.""" stream_interval = timedelta(seconds=self._config[CONF_STREAM_INTERVAL]) now = utcnow() diff --git a/custom_components/kuna/switch.py b/custom_components/kuna/switch.py index 6bade24..57e1684 100644 --- a/custom_components/kuna/switch.py +++ b/custom_components/kuna/switch.py @@ -4,7 +4,7 @@ """ import logging -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from .const import DOMAIN, MANUFACTURER @@ -31,7 +31,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(devices, True) -class KunaSwitch(SwitchDevice): +class KunaSwitch(SwitchEntity): def __init__(self, kuna, camera): self._account = kuna self._camera = camera diff --git a/custom_components/kuna/.translations/en.json b/custom_components/kuna/translations/en.json similarity index 100% rename from custom_components/kuna/.translations/en.json rename to custom_components/kuna/translations/en.json