From 816afdd4f6d8cf0bae090525c02962942d99851b Mon Sep 17 00:00:00 2001 From: Seb Ruiz Date: Thu, 21 May 2020 10:45:17 +1000 Subject: [PATCH] Fix deprecation warnings in the log Closes #12 --- custom_components/bhyve/binary_sensor.py | 10 ++++++++-- custom_components/bhyve/switch.py | 12 ++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/custom_components/bhyve/binary_sensor.py b/custom_components/bhyve/binary_sensor.py index 4131bd5..418c808 100644 --- a/custom_components/bhyve/binary_sensor.py +++ b/custom_components/bhyve/binary_sensor.py @@ -1,7 +1,13 @@ """Support for Orbit BHyve binary sensors ().""" import logging -from homeassistant.components.binary_sensor import BinarySensorDevice +try: + from homeassistant.components.binary_sensor import BinarySensorEntity +except ImportError: + from homeassistant.components.binary_sensor import ( + BinarySensorDevice as BinarySensorEntity, + ) + from homeassistant.helpers.event import async_call_later from . import BHyveEntity @@ -39,7 +45,7 @@ async def async_setup_platform(hass, config, async_add_entities, _discovery_info async_add_entities(binary_sensors, True) -class BHyveRainDelayBinarySensor(BHyveEntity, BinarySensorDevice): +class BHyveRainDelayBinarySensor(BHyveEntity, BinarySensorEntity): """Define a BHyve binary sensor.""" def _setup(self, device): diff --git a/custom_components/bhyve/switch.py b/custom_components/bhyve/switch.py index 9bbf1e2..470ef40 100644 --- a/custom_components/bhyve/switch.py +++ b/custom_components/bhyve/switch.py @@ -3,7 +3,15 @@ import logging from datetime import timedelta -from homeassistant.components.switch import DEVICE_CLASS_SWITCH, SwitchDevice + +try: + from homeassistant.components.switch import DEVICE_CLASS_SWITCH, SwitchEntity +except ImportError: + from homeassistant.components.switch import ( + DEVICE_CLASS_SWITCH, + SwitchDevice as SwitchEntity, + ) + from homeassistant.util import dt from . import BHyveEntity @@ -49,7 +57,7 @@ async def async_setup_platform(hass, config, async_add_entities, _discovery_info async_add_entities(switches, True) -class BHyveZoneSwitch(BHyveEntity, SwitchDevice): +class BHyveZoneSwitch(BHyveEntity, SwitchEntity): """Define a BHyve switch.""" def __init__(self, hass, bhyve, device, zone, name, programs, icon):