def __init__(self, name, dev_id, address, local_key, hass: HomeAssistant): """ Represents a Tuya-based device. Args: dev_id (str): The device id. address (str): The network address. local_key (str): The encryption key. """ import pytuya self._name = name self._api_protocol_version_index = None self._api_protocol_working = False self._api = pytuya.Device(dev_id, address, local_key, "device") self._refresh_task = None self._rotate_api_protocol_version() self._reset_cached_state() self._TEMPERATURE_UNIT = TEMP_CELSIUS self._hass = hass # API calls to update Tuya devices are asynchronous and non-blocking. This means # you can send a change and immediately request an updated state (like HA does), # but because it has not yet finished processing you will be returned the old state. # The solution is to keep a temporary list of changed properties that we can overlay # onto the state while we wait for the board to update its switches. self._FAKE_IT_TIL_YOU_MAKE_IT_TIMEOUT = 10 self._CACHE_TIMEOUT = 20 self._CONNECTION_ATTEMPTS = 4 self._lock = Lock()
def __init__(self, name, device_id, device_key, device_ip): """Initialize the thermostat.""" self._name = name self._id = device_id self._key = device_key self._ip = device_ip self._enabled = None self._mode = None self._floorTemp = None self._target_temperature = None self._current_temperature = None self._lock = None self._pulling_lock = False self._device = pytuya.Device(self._id, self._ip, self._key, "device") self._device.set_version(3.3) self._get_data()
def __init__(self, name, dev_id, address, local_key): """ Represents a Goldair Heater device. Args: dev_id (str): The device id. address (str): The network address. local_key (str): The encryption key. """ import pytuya self._name = name self._api = pytuya.Device(dev_id, address, local_key, 'device') self._fixed_properties = {} self._reset_cached_state() self._TEMPERATURE_UNIT = TEMP_CELSIUS self._TEMPERATURE_STEP = 1 self._TEMPERATURE_LIMITS = { STATE_COMFORT: { 'min': 5, 'max': 35 }, STATE_ECO: { 'min': 5, 'max': 21 } } # API calls to update Goldair heaters are asynchronous and non-blocking. This means # you can send a change and immediately request an updated state (like HA does), # but because it has not yet finished processing you will be returned the old state. # The solution is to keep a temporary list of changed properties that we can overlay # onto the state while we wait for the board to update its switches. self._FAKE_IT_TIL_YOU_MAKE_IT_TIMEOUT = 10 self._CACHE_TIMEOUT = 20 self._CONNECTION_ATTEMPTS = 2 self._lock = Lock()