Updated for HA 110.0 (CoverEntity and SwitchEntity instead of CoverDevice and SwitchDevice)
This commit is contained in:
@@ -20,7 +20,7 @@ import requests
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.cover import (
|
||||
CoverDevice,
|
||||
CoverEntity,
|
||||
PLATFORM_SCHEMA,
|
||||
SUPPORT_CLOSE,
|
||||
SUPPORT_OPEN,
|
||||
@@ -28,7 +28,7 @@ from homeassistant.components.cover import (
|
||||
)
|
||||
|
||||
"""from . import DATA_TUYA, TuyaDevice"""
|
||||
from homeassistant.components.cover import ENTITY_ID_FORMAT, CoverDevice, PLATFORM_SCHEMA
|
||||
from homeassistant.components.cover import ENTITY_ID_FORMAT, CoverEntity, PLATFORM_SCHEMA
|
||||
from homeassistant.const import (CONF_HOST, CONF_ID, CONF_FRIENDLY_NAME, CONF_ICON, CONF_NAME)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from time import time, sleep
|
||||
@@ -66,7 +66,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
from . import pytuya
|
||||
|
||||
covers = []
|
||||
localtuyadevice = pytuya.CoverDevice(config.get(CONF_DEVICE_ID), config.get(CONF_HOST), config.get(CONF_LOCAL_KEY))
|
||||
localtuyadevice = pytuya.CoverEntity(config.get(CONF_DEVICE_ID), config.get(CONF_HOST), config.get(CONF_LOCAL_KEY))
|
||||
localtuyadevice.set_version(float(config.get(CONF_PROTOCOL_VERSION)))
|
||||
|
||||
cover_device = TuyaCoverCache(localtuyadevice)
|
||||
@@ -86,7 +86,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
|
||||
|
||||
class TuyaCoverCache:
|
||||
"""Cache wrapper for pytuya.CoverDevice"""
|
||||
"""Cache wrapper for pytuya.CoverEntity"""
|
||||
|
||||
def __init__(self, device):
|
||||
"""Initialize the cache."""
|
||||
@@ -135,7 +135,7 @@ class TuyaCoverCache:
|
||||
finally:
|
||||
self._lock.release()
|
||||
|
||||
class TuyaDevice(CoverDevice):
|
||||
class TuyaDevice(CoverEntity):
|
||||
"""Tuya cover devices."""
|
||||
|
||||
def __init__(self, device, name, friendly_name, icon, switchid):
|
||||
|
@@ -436,7 +436,7 @@ class OutletDevice(Device):
|
||||
super(OutletDevice, self).__init__(dev_id, address, local_key, dev_type)
|
||||
|
||||
|
||||
class CoverDevice(Device):
|
||||
class CoverEntity(Device):
|
||||
DPS_INDEX_MOVE = '1'
|
||||
DPS_INDEX_BL = '101'
|
||||
|
||||
@@ -455,7 +455,7 @@ class CoverDevice(Device):
|
||||
else:
|
||||
print('Using PyCrypto ', Crypto.version_info)
|
||||
print('Using PyCrypto from ', Crypto.__file__)
|
||||
super(CoverDevice, self).__init__(dev_id, address, local_key, dev_type)
|
||||
super(CoverEntity, self).__init__(dev_id, address, local_key, dev_type)
|
||||
|
||||
def open_cover(self, switch=1):
|
||||
"""Turn the device on"""
|
||||
|
@@ -27,7 +27,7 @@ switch:
|
||||
import logging
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.switch import ENTITY_ID_FORMAT, SwitchDevice, PLATFORM_SCHEMA
|
||||
from homeassistant.components.switch import ENTITY_ID_FORMAT, SwitchEntity, PLATFORM_SCHEMA
|
||||
from homeassistant.const import (CONF_HOST, CONF_ID, CONF_SWITCHES, CONF_FRIENDLY_NAME, CONF_ICON, CONF_NAME)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from time import time, sleep
|
||||
@@ -173,7 +173,7 @@ class TuyaCache:
|
||||
finally:
|
||||
self._lock.release()
|
||||
|
||||
class TuyaDevice(SwitchDevice):
|
||||
class TuyaDevice(SwitchEntity):
|
||||
"""Representation of a Tuya switch."""
|
||||
|
||||
def __init__(self, device, name, friendly_name, icon, switchid, attr_current, attr_consumption, attr_voltage):
|
||||
|
Reference in New Issue
Block a user