瀏覽代碼

Move to a more generic tuya_local namespace.

Rename base device also to be more generic.
Update docs to separate this from upstream.
Jason Rumney 5 年之前
父節點
當前提交
f35065d59d

+ 1 - 1
LICENSE.md

@@ -1,4 +1,4 @@
-Copyright 2018 Nik Rolls
+Copyright 2018 Nik Rolls, 2020 Jason Rumney
 
 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 

+ 27 - 26
README.md

@@ -1,10 +1,11 @@
-Home Assistant Goldair WiFi Climate component
-=============================================
+Home Assistant Tuya Local component
+===================================
 
-The `goldair_climate` component integrates 
-[Goldair WiFi-enabled heaters](http://www.goldair.co.nz/product-catalogue/heating/wifi-heaters), WiFi-enabled [dehumidifiers](http://www.goldair.co.nz/product-catalogue/heating/dehumidifiers), and WiFi-enabled fans](http://www.goldair.co.nz/product-catalogue/cooling/pedestal-fans/40cm-dc-quiet-fan-with-wifi-and-remote-gcpf315) into Home Assistant, enabling control of setting the following parameters via the UI and the following services:
+The `tuya_local` component integrates 
+[Goldair WiFi-enabled heaters](http://www.goldair.co.nz/product-catalogue/heating/wifi-heaters), WiFi-enabled [dehumidifiers](http://www.goldair.co.nz/product-catalogue/heating/dehumidifiers), [WiFi-enabled fans](http://www.goldair.co.nz/product-catalogue/cooling/pedestal-fans/40cm-dc-quiet-fan-with-wifi-and-remote-gcpf315) and [Kogan WiFi-enabled heaters](https://www.kogan.com/au/c/smarterhome-range/shop/heating-cooling/) into Home Assistant, enabling control of setting the following parameters via the UI and the following services:
 
-**Heaters**
+### Climate devices
+**Goldair Heaters**
 * **power** (on/off)
 * **mode** (Comfort, Eco, Anti-freeze)
 * **target temperature** (`5`-`35` in Comfort mode, `5`-`21` in Eco mode, in °C)
@@ -12,26 +13,34 @@ The `goldair_climate` component integrates
 
 Current temperature is also displayed.
 
-**Demudifiers**
+**Goldair Demudifiers**
 * **power** (on/off)
 * **mode** (Normal, Low, High, Dry clothes, Air clean)
 * **target humidity** (`30`-`80`%)
 
 Current temperature is displayed, and current humidity is available as a property.
 
-**Fans**
+**Goldair Fans**
 * **power** (on/off)
 * **mode** (Normal, Eco, Sleep)
 * **fan mode** (`1`-`12`)
 * **swing** (on/off)
 
-**Light**
+**Kogan Heaters**
+* **power** (on/off)
+* **mode** (LOW/HIGH)
+* **target temperature** (`16`-`30` in °C)
+
+Current temperature is also displayed.
+
+### Additional features
+**Light** (Goldair devices)
 * **LED display** (on/off)
 
-**Lock** (heaters and dehumidifiers)
+**Lock** (Goldair heaters and dehumidifiers)
 * **Child lock** (on/off)
 
-**Binary Sensor** (dehumidifiers)
+**Binary Sensor** (Goldair dehumidifiers)
 * **Tank full** (on/off)
 
 There was previously a sensor option, however this is easily achieved using a [template sensor](https://www.home-assistant.io/integrations/template/) and therefore is no longer supported.
@@ -41,20 +50,10 @@ There was previously a sensor option, however this is easily achieved using a [t
 ### Warning
 Please note, this component has currently only been tested with the Goldair GPPH (inverter), GPDH420 (dehumidifier), and GCPF315 fan, however theoretically it should also work with GEPH and GPCV heater devices, may work with the GPDH440 dehumidifier and any other Goldair heaters, dehumidifiers or fans based on the Tuya platform.
 
----
-
-## Kogan Heater support
-
-Although these are not Goldair devices, they are based on the same Tuya platform, and sold in the same Australia/New Zealand market.
-Kogan heaters support the following parameters and services:
-* **power** (on/off)
-* **mode** (low/high)
-* **target temperature** (`16`-`30` in °C)
-
-Current temperature is also displayed.
-
 Kogan heater support is tested with the Kogan SmarterHome 1500W Smart Panel Heater.  If you have another type of Kogan SmarterHome heater, it may or may not work with the same configuration.
 
+---
+
 Installation
 ------------
 The preferred installation method is via [HACS](https://hacs.xyz/). Once you have HACS set up, simply follow the [instructions for adding a custom repository](https://hacs.xyz/docs/navigation/settings#custom-repositories) and then the integration will be available to install like any other.
@@ -62,7 +61,7 @@ The preferred installation method is via [HACS](https://hacs.xyz/). Once you hav
 You can also use [Custom Updater](https://github.com/custom-components/custom_updater). Once Custom Updater is  set up, go to the Developer Tools > Service page and call the `custom_updater.install` service with this service data:
 
 ```json
-{ "element": "goldair_climate" }
+{ "element": "tuya_local" }
 ```
 
 Alternatively you can copy the contents of this repository's `custom_components` directory to your `<config>/custom_components` directory, however you will not get automatic updates this way.
@@ -73,7 +72,7 @@ Add the following lines to your `configuration.yaml` file:
 
 ```yaml
 # Example configuration.yaml entry
-goldair_climate:
+tuya_local:
   - name: My heater
     host: 1.2.3.4
     device_id: <your device id>
@@ -154,13 +153,15 @@ You're looking for `uuid` (this is the device ID) and the `localKey` values.
 
 Next steps
 ----------
-This component needs specs! Once they're written I'm considering submitting it to the HA team for inclusion in standard 
-installations. Please report any issues and feel free to raise pull requests.
+# The devices need to be generalized so a new subdirectory with source code is not needed to add a new device.  Instead, device descriptors should be in a yaml file, which is referenced by the config.
+# Support for non-climate devices needs to be added.  For starters, I have some Kogan Power Monitoring Plugs that I haven't yet taken out of the box and converted to ESPHome, but this will probably need input from other users.
+# This component needs specs! Once they're written I'm considering submitting it to the HA team for inclusion in standard installations. Please report any issues and feel free to raise pull requests.
 
 Acknowledgements
 ----------------
 None of this would have been possible without some foundational discovery work to get me started:
 
+* [nikrolls](https://github.com/nikrolls)'s [homeassistant-goldair-climate](https://github.com/nikrolls/homeassistant-goldair-climate) was the starting point for expanding to non-Goldair devices as well
 * [TarxBoy](https://github.com/TarxBoy)'s [investigation using codetheweb/tuyapi](https://github.com/codetheweb/tuyapi/issues/31) to figure out the correlation of the cryptic DPS states 
 * [sean6541](https://github.com/sean6541)'s [tuya-homeassistant](https://github.com/sean6541/tuya-homeassistant) library giving an example of integrating Tuya devices with Home Assistant
 * [clach04](https://github.com/clach04)'s [python-tuya](https://github.com/clach04/python-tuya) library

+ 0 - 13
custom_components/goldair_climate/manifest.json

@@ -1,13 +0,0 @@
-{
-  "domain": "goldair_climate",
-  "name": "Goldair WiFi climate devices",
-  "documentation": "https://github.com/nikrolls/homeassistant-goldair-climate",
-  "dependencies": [],
-  "codeowners": [
-    "@nikrolls"
-  ],
-  "requirements": [
-    "pytuya>=7.0.5"
-  ],
-  "homeassistant": "0.96.0"
-}

+ 8 - 7
custom_components/goldair_climate/__init__.py → custom_components/tuya_local/__init__.py

@@ -1,6 +1,7 @@
 """
-Platform for Goldair WiFi-connected heaters and panels.
+Platform for Tuya WiFi-connected devices.
 
+Based on nikrolls/homeassistant-goldair-climate for Goldair branded devices.
 Based on sean6541/tuya-homeassistant for service call logic, and TarxBoy's
 investigation into Goldair's tuyapi statuses
 https://github.com/codetheweb/tuyapi/issues/31.
@@ -19,8 +20,8 @@ VERSION = '0.0.8'
 
 _LOGGER = logging.getLogger(__name__)
 
-DOMAIN = 'goldair_climate'
-DATA_GOLDAIR_CLIMATE = 'data_goldair_climate'
+DOMAIN = 'tuya_local'
+DATA_TUYA_LOCAL = 'data_tuya_local'
 
 API_PROTOCOL_VERSIONS = [3.3, 3.1]
 
@@ -58,7 +59,7 @@ def setup(hass, config):
     for device_config in config.get(DOMAIN, []):
         host = device_config.get(CONF_HOST)
 
-        device = GoldairTuyaDevice(
+        device = TuyaLocalDevice(
             device_config.get(CONF_NAME),
             device_config.get(CONF_DEVICE_ID),
             device_config.get(CONF_HOST),
@@ -79,10 +80,10 @@ def setup(hass, config):
     return True
 
 
-class GoldairTuyaDevice(object):
+class TuyaLocalDevice(object):
     def __init__(self, name, dev_id, address, local_key):
         """
-        Represents a Goldair Tuya-based device.
+        Represents a Tuya-based device.
 
         Args:
             dev_id (str): The device id.
@@ -100,7 +101,7 @@ class GoldairTuyaDevice(object):
 
         self._TEMPERATURE_UNIT = TEMP_CELSIUS
 
-        # API calls to update Goldair heaters are asynchronous and non-blocking. This means
+        # 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

+ 4 - 4
custom_components/goldair_climate/binary_sensor.py → custom_components/tuya_local/binary_sensor.py

@@ -1,14 +1,14 @@
 """
-Setup for different kinds of Goldair climate devices
+Setup for different kinds of Tuya climate devices
 """
 from homeassistant.const import CONF_HOST
-from custom_components.goldair_climate import (
+from custom_components.tuya_local import (
     DOMAIN, CONF_TYPE, CONF_TYPE_HEATER, CONF_TYPE_DEHUMIDIFIER, CONF_TYPE_FAN, CONF_TYPE_KOGAN_HEATER
 )
-from custom_components.goldair_climate.dehumidifier.binary_sensor import GoldairDehumidifierTankFullBinarySensor
+from custom_components.tuya_local.dehumidifier.binary_sensor import GoldairDehumidifierTankFullBinarySensor
 
 def setup_platform(hass, config, add_devices, discovery_info=None):
-    """Set up the Goldair climate device according to its type."""
+    """Set up the Tuya climate device according to its type."""
     device = hass.data[DOMAIN][discovery_info[CONF_HOST]]
     if discovery_info[CONF_TYPE] == CONF_TYPE_DEHUMIDIFIER:
         add_devices([GoldairDehumidifierTankFullBinarySensor(device)])

+ 7 - 7
custom_components/goldair_climate/climate.py → custom_components/tuya_local/climate.py

@@ -1,17 +1,17 @@
 """
-Setup for different kinds of Goldair climate devices
+Setup for different kinds of Tuya climate devices
 """
 from homeassistant.const import CONF_HOST
-from custom_components.goldair_climate import (
+from custom_components.tuya_local import (
     DOMAIN, CONF_TYPE, CONF_TYPE_HEATER, CONF_TYPE_DEHUMIDIFIER, CONF_TYPE_FAN, CONF_TYPE_KOGAN_HEATER
 )
-from custom_components.goldair_climate.heater.climate import GoldairHeater
-from custom_components.goldair_climate.dehumidifier.climate import GoldairDehumidifier
-from custom_components.goldair_climate.fan.climate import GoldairFan
-from custom_components.goldair_climate.kogan_heater.climate import KoganHeater
+from custom_components.tuya_local.heater.climate import GoldairHeater
+from custom_components.tuya_local.dehumidifier.climate import GoldairDehumidifier
+from custom_components.tuya_local.fan.climate import GoldairFan
+from custom_components.tuya_local.kogan_heater.climate import KoganHeater
 
 def setup_platform(hass, config, add_devices, discovery_info=None):
-    """Set up the Goldair climate device according to its type."""
+    """Set up the Tuya climate device according to its type."""
     device = hass.data[DOMAIN][discovery_info[CONF_HOST]]
     if discovery_info[CONF_TYPE] == CONF_TYPE_HEATER:
         add_devices([GoldairHeater(device)])

+ 0 - 0
custom_components/goldair_climate/dehumidifier/__init__.py → custom_components/tuya_local/dehumidifier/__init__.py


+ 3 - 3
custom_components/goldair_climate/dehumidifier/binary_sensor.py → custom_components/tuya_local/dehumidifier/binary_sensor.py

@@ -3,8 +3,8 @@ Platform to sense whether the dehumidifier tank is full.
 """
 
 from homeassistant.components.binary_sensor import (BinarySensorDevice, DEVICE_CLASS_PROBLEM)
-from custom_components.goldair_climate import GoldairTuyaDevice
-from custom_components.goldair_climate.dehumidifier.climate import (
+from custom_components.tuya_local import TuyaLocalDevice
+from custom_components.tuya_local.dehumidifier.climate import (
     ATTR_FAULT, FAULT_CODE_TO_DPS_CODE, PROPERTY_TO_DPS_ID
 )
 
@@ -18,7 +18,7 @@ class GoldairDehumidifierTankFullBinarySensor(BinarySensorDevice):
     def __init__(self, device):
         """Initialize the binary sensor.
         Args:
-            device (GoldairTuyaDevice): The device API instance."""
+            device (TuyaLocalDevice): The device API instance."""
         self._device = device
         self._fault = None
 

+ 6 - 6
custom_components/goldair_climate/dehumidifier/climate.py → custom_components/tuya_local/dehumidifier/climate.py

@@ -11,7 +11,7 @@ from homeassistant.components.climate.const import (
     HVAC_MODE_OFF, HVAC_MODE_DRY,
     SUPPORT_TARGET_HUMIDITY, SUPPORT_PRESET_MODE, SUPPORT_FAN_MODE
 )
-from custom_components.goldair_climate import GoldairTuyaDevice
+from custom_components.tuya_local import TuyaLocalDevice
 
 ATTR_TARGET_HUMIDITY = 'target_humidity'
 ATTR_AIR_CLEAN_ON = 'air_clean_on'
@@ -70,7 +70,7 @@ class GoldairDehumidifier(ClimateDevice):
         """Initialize the dehumidifier.
         Args:
             name (str): The device's name.
-            device (GoldairTuyaDevice): The device API instance."""
+            device (TuyaLocalDevice): The device API instance."""
         self._device = device
 
         self._support_flags = SUPPORT_FLAGS
@@ -149,7 +149,7 @@ class GoldairDehumidifier(ClimateDevice):
         dps_mode = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_HVAC_MODE])
 
         if dps_mode is not None:
-            return GoldairTuyaDevice.get_key_for_value(HVAC_MODE_TO_DPS_MODE, dps_mode)
+            return TuyaLocalDevice.get_key_for_value(HVAC_MODE_TO_DPS_MODE, dps_mode)
         else:
             return STATE_UNAVAILABLE
 
@@ -172,7 +172,7 @@ class GoldairDehumidifier(ClimateDevice):
         if air_clean_on:
             return PRESET_AIR_CLEAN
         elif dps_mode is not None:
-            return GoldairTuyaDevice.get_key_for_value(PRESET_MODE_TO_DPS_MODE, dps_mode)
+            return TuyaLocalDevice.get_key_for_value(PRESET_MODE_TO_DPS_MODE, dps_mode)
         else:
             return None
 
@@ -207,7 +207,7 @@ class GoldairDehumidifier(ClimateDevice):
         else:
             dps_mode = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_FAN_MODE])
             if dps_mode is not None:
-                return GoldairTuyaDevice.get_key_for_value(FAN_MODE_TO_DPS_MODE, dps_mode)
+                return TuyaLocalDevice.get_key_for_value(FAN_MODE_TO_DPS_MODE, dps_mode)
             else:
                 return None
 
@@ -243,7 +243,7 @@ class GoldairDehumidifier(ClimateDevice):
         if fault is None or fault == FAULT_NONE:
             return None
         else:
-            return GoldairTuyaDevice.get_key_for_value(FAULT_CODE_TO_DPS_CODE, fault)
+            return TuyaLocalDevice.get_key_for_value(FAULT_CODE_TO_DPS_CODE, fault)
 
     def update(self):
         self._device.refresh()

+ 3 - 3
custom_components/goldair_climate/dehumidifier/light.py → custom_components/tuya_local/dehumidifier/light.py

@@ -3,8 +3,8 @@ Platform to control the LED display light on Goldair WiFi-connected dehumidifier
 """
 from homeassistant.components.light import Light
 from homeassistant.const import STATE_UNAVAILABLE
-from custom_components.goldair_climate import GoldairTuyaDevice
-from custom_components.goldair_climate.dehumidifier.climate import (
+from custom_components.tuya_local import TuyaLocalDevice
+from custom_components.tuya_local.dehumidifier.climate import (
     ATTR_DISPLAY_ON, PROPERTY_TO_DPS_ID, HVAC_MODE_TO_DPS_MODE
 )
 from homeassistant.components.climate import (
@@ -18,7 +18,7 @@ class GoldairDehumidifierLedDisplayLight(Light):
     def __init__(self, device):
         """Initialize the light.
         Args:
-            device (GoldairTuyaDevice): The device API instance."""
+            device (TuyaLocalDevice): The device API instance."""
         self._device = device
 
     @property

+ 3 - 3
custom_components/goldair_climate/dehumidifier/lock.py → custom_components/tuya_local/dehumidifier/lock.py

@@ -3,8 +3,8 @@ Platform to control the child lock on Goldair WiFi-connected dehumidifiers.
 """
 from homeassistant.components.lock import (STATE_LOCKED, STATE_UNLOCKED, LockDevice)
 from homeassistant.const import STATE_UNAVAILABLE
-from custom_components.goldair_climate import GoldairTuyaDevice
-from custom_components.goldair_climate.dehumidifier.climate import (
+from custom_components.tuya_local import TuyaLocalDevice
+from custom_components.tuya_local.dehumidifier.climate import (
     ATTR_CHILD_LOCK, PROPERTY_TO_DPS_ID
 )
 
@@ -15,7 +15,7 @@ class GoldairDehumidifierChildLock(LockDevice):
     def __init__(self, device):
         """Initialize the lock.
         Args:
-            device (GoldairTuyaDevice): The device API instance."""
+            device (TuyaLocalDevice): The device API instance."""
         self._device = device
 
     @property

+ 0 - 0
custom_components/goldair_climate/fan/__init__.py → custom_components/tuya_local/fan/__init__.py


+ 6 - 6
custom_components/goldair_climate/fan/climate.py → custom_components/tuya_local/fan/climate.py

@@ -12,7 +12,7 @@ from homeassistant.components.climate.const import (
     SUPPORT_FAN_MODE, SUPPORT_PRESET_MODE, SUPPORT_SWING_MODE,
     SWING_OFF, SWING_HORIZONTAL
 )
-from custom_components.goldair_climate import GoldairTuyaDevice
+from custom_components.tuya_local import TuyaLocalDevice
 
 ATTR_TARGET_TEMPERATURE = 'target_temperature'
 ATTR_DISPLAY_ON = 'display_on'
@@ -57,7 +57,7 @@ class GoldairFan(ClimateDevice):
         """Initialize the fan.
         Args:
             name (str): The device's name.
-            device (GoldairTuyaDevice): The device API instance."""
+            device (TuyaLocalDevice): The device API instance."""
         self._device = device
 
         self._support_flags = SUPPORT_FLAGS
@@ -88,7 +88,7 @@ class GoldairFan(ClimateDevice):
         dps_mode = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_HVAC_MODE])
 
         if dps_mode is not None:
-            return GoldairTuyaDevice.get_key_for_value(HVAC_MODE_TO_DPS_MODE, dps_mode)
+            return TuyaLocalDevice.get_key_for_value(HVAC_MODE_TO_DPS_MODE, dps_mode)
         else:
             return STATE_UNAVAILABLE
 
@@ -107,7 +107,7 @@ class GoldairFan(ClimateDevice):
         """Return current preset mode, ie Comfort, Eco, Anti-freeze."""
         dps_mode = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_PRESET_MODE])
         if dps_mode is not None:
-            return GoldairTuyaDevice.get_key_for_value(PRESET_MODE_TO_DPS_MODE, dps_mode)
+            return TuyaLocalDevice.get_key_for_value(PRESET_MODE_TO_DPS_MODE, dps_mode)
         else:
             return None
 
@@ -126,7 +126,7 @@ class GoldairFan(ClimateDevice):
         """Return current swing mode: horizontal or off"""
         dps_mode = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_SWING_MODE])
         if dps_mode is not None:
-            return GoldairTuyaDevice.get_key_for_value(SWING_MODE_TO_DPS_MODE, dps_mode)
+            return TuyaLocalDevice.get_key_for_value(SWING_MODE_TO_DPS_MODE, dps_mode)
         else:
             return None
 
@@ -145,7 +145,7 @@ class GoldairFan(ClimateDevice):
         """Return current fan mode: 1-12"""
         dps_mode = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_FAN_MODE])
         if dps_mode is not None and self.preset_mode is not None:
-            return GoldairTuyaDevice.get_key_for_value(FAN_MODES[self.preset_mode], dps_mode)
+            return TuyaLocalDevice.get_key_for_value(FAN_MODES[self.preset_mode], dps_mode)
         else:
             return None
 

+ 3 - 3
custom_components/goldair_climate/fan/light.py → custom_components/tuya_local/fan/light.py

@@ -3,8 +3,8 @@ Platform to control the LED display light on Goldair WiFi-connected fans and pan
 """
 from homeassistant.components.light import Light
 from homeassistant.const import STATE_UNAVAILABLE
-from custom_components.goldair_climate import GoldairTuyaDevice
-from custom_components.goldair_climate.fan.climate import (
+from custom_components.tuya_local import TuyaLocalDevice
+from custom_components.tuya_local.fan.climate import (
     ATTR_DISPLAY_ON, PROPERTY_TO_DPS_ID, HVAC_MODE_TO_DPS_MODE
 )
 from homeassistant.components.climate import (
@@ -18,7 +18,7 @@ class GoldairFanLedDisplayLight(Light):
     def __init__(self, device):
         """Initialize the light.
         Args:
-            device (GoldairTuyaDevice): The device API instance."""
+            device (TuyaLocalDevice): The device API instance."""
         self._device = device
 
     @property

+ 0 - 0
custom_components/goldair_climate/heater/__init__.py → custom_components/tuya_local/heater/__init__.py


+ 5 - 5
custom_components/goldair_climate/heater/climate.py → custom_components/tuya_local/heater/climate.py

@@ -10,7 +10,7 @@ from homeassistant.components.climate.const import (
     HVAC_MODE_OFF, HVAC_MODE_HEAT,
     SUPPORT_TARGET_TEMPERATURE, SUPPORT_PRESET_MODE, SUPPORT_SWING_MODE
 )
-from custom_components.goldair_climate import GoldairTuyaDevice
+from custom_components.tuya_local import TuyaLocalDevice
 
 ATTR_TARGET_TEMPERATURE = 'target_temperature'
 ATTR_CHILD_LOCK = 'child_lock'
@@ -68,7 +68,7 @@ class GoldairHeater(ClimateDevice):
         """Initialize the heater.
         Args:
             name (str): The device's name.
-            device (GoldairTuyaDevice): The device API instance."""
+            device (TuyaLocalDevice): The device API instance."""
         self._device = device
 
         self._support_flags = SUPPORT_FLAGS
@@ -173,7 +173,7 @@ class GoldairHeater(ClimateDevice):
         dps_mode = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_HVAC_MODE])
 
         if dps_mode is not None:
-            return GoldairTuyaDevice.get_key_for_value(HVAC_MODE_TO_DPS_MODE, dps_mode)
+            return TuyaLocalDevice.get_key_for_value(HVAC_MODE_TO_DPS_MODE, dps_mode)
         else:
             return STATE_UNAVAILABLE
 
@@ -192,7 +192,7 @@ class GoldairHeater(ClimateDevice):
         """Return current preset mode, ie Comfort, Eco, Anti-freeze."""
         dps_mode = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_PRESET_MODE])
         if dps_mode is not None:
-            return GoldairTuyaDevice.get_key_for_value(PRESET_MODE_TO_DPS_MODE, dps_mode)
+            return TuyaLocalDevice.get_key_for_value(PRESET_MODE_TO_DPS_MODE, dps_mode)
         else:
             return None
 
@@ -213,7 +213,7 @@ class GoldairHeater(ClimateDevice):
         if dps_mode == ATTR_POWER_MODE_USER:
             return self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_POWER_LEVEL])
         elif dps_mode == ATTR_POWER_MODE_AUTO:
-            return GoldairTuyaDevice.get_key_for_value(POWER_LEVEL_TO_DPS_LEVEL, dps_mode)
+            return TuyaLocalDevice.get_key_for_value(POWER_LEVEL_TO_DPS_LEVEL, dps_mode)
         else:
             return None
 

+ 3 - 3
custom_components/goldair_climate/heater/light.py → custom_components/tuya_local/heater/light.py

@@ -3,8 +3,8 @@ Platform to control the LED display light on Goldair WiFi-connected heaters and
 """
 from homeassistant.components.light import Light
 from homeassistant.const import STATE_UNAVAILABLE
-from custom_components.goldair_climate import GoldairTuyaDevice
-from custom_components.goldair_climate.heater.climate import (
+from custom_components.tuya_local import TuyaLocalDevice
+from custom_components.tuya_local.heater.climate import (
     ATTR_DISPLAY_ON, PROPERTY_TO_DPS_ID, HVAC_MODE_TO_DPS_MODE
 )
 from homeassistant.components.climate import (
@@ -18,7 +18,7 @@ class GoldairHeaterLedDisplayLight(Light):
     def __init__(self, device):
         """Initialize the light.
         Args:
-            device (GoldairTuyaDevice): The device API instance."""
+            device (TuyaLocalDevice): The device API instance."""
         self._device = device
 
     @property

+ 3 - 3
custom_components/goldair_climate/heater/lock.py → custom_components/tuya_local/heater/lock.py

@@ -3,8 +3,8 @@ Platform to control the child lock on Goldair WiFi-connected heaters and panels.
 """
 from homeassistant.components.lock import (STATE_LOCKED, STATE_UNLOCKED, LockDevice)
 from homeassistant.const import STATE_UNAVAILABLE
-from custom_components.goldair_climate import GoldairTuyaDevice
-from custom_components.goldair_climate.heater.climate import (
+from custom_components.tuya_local import TuyaLocalDevice
+from custom_components.tuya_local.heater.climate import (
     ATTR_CHILD_LOCK, PROPERTY_TO_DPS_ID
 )
 
@@ -15,7 +15,7 @@ class GoldairHeaterChildLock(LockDevice):
     def __init__(self, device):
         """Initialize the lock.
         Args:
-            device (GoldairTuyaDevice): The device API instance."""
+            device (TuyaLocalDevice): The device API instance."""
         self._device = device
 
     @property

+ 0 - 0
custom_components/goldair_climate/kogan_heater/__init__.py → custom_components/tuya_local/kogan_heater/__init__.py


+ 4 - 4
custom_components/goldair_climate/kogan_heater/climate.py → custom_components/tuya_local/kogan_heater/climate.py

@@ -19,7 +19,7 @@ from homeassistant.components.climate.const import (
     HVAC_MODE_OFF, HVAC_MODE_HEAT,
     SUPPORT_TARGET_TEMPERATURE, SUPPORT_PRESET_MODE
 )
-from custom_components.goldair_climate import GoldairTuyaDevice
+from custom_components.tuya_local import TuyaLocalDevice
 
 ATTR_TARGET_TEMPERATURE = 'target_temperature'
 
@@ -53,7 +53,7 @@ class KoganHeater(ClimateDevice):
         """Initialize the heater.
         Args:
             name (str): The device's name.
-            device (GoldairTuyaDevice): The device API instance."""
+            device (TuyaLocalDevice): The device API instance."""
         self._device = device
 
         self._support_flags = SUPPORT_FLAGS
@@ -134,7 +134,7 @@ class KoganHeater(ClimateDevice):
         dps_mode = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_HVAC_MODE])
 
         if dps_mode is not None:
-            return GoldairTuyaDevice.get_key_for_value(HVAC_MODE_TO_DPS_MODE, dps_mode)
+            return TuyaLocalDevice.get_key_for_value(HVAC_MODE_TO_DPS_MODE, dps_mode)
         else:
             return STATE_UNAVAILABLE
 
@@ -153,7 +153,7 @@ class KoganHeater(ClimateDevice):
         """Return current preset mode, ie Low or High."""
         dps_mode = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_PRESET_MODE])
         if dps_mode is not None:
-            return GoldairTuyaDevice.get_key_for_value(PRESET_MODE_TO_DPS_MODE, dps_mode)
+            return TuyaLocalDevice.get_key_for_value(PRESET_MODE_TO_DPS_MODE, dps_mode)
         else:
             return None
 

+ 6 - 6
custom_components/goldair_climate/light.py → custom_components/tuya_local/light.py

@@ -1,17 +1,17 @@
 """
-Setup for different kinds of Goldair climate devices
+Setup for different kinds of Tuya climate devices
 """
 from homeassistant.const import CONF_HOST
-from custom_components.goldair_climate import (
+from custom_components.tuya_local import (
     DOMAIN, CONF_TYPE, CONF_TYPE_HEATER, CONF_TYPE_DEHUMIDIFIER, CONF_TYPE_FAN, CONF_TYPE_KOGAN_HEATER
 )
-from custom_components.goldair_climate.heater.light import GoldairHeaterLedDisplayLight
-from custom_components.goldair_climate.dehumidifier.light import GoldairDehumidifierLedDisplayLight
-from custom_components.goldair_climate.fan.light import GoldairFanLedDisplayLight
+from custom_components.tuya_local.heater.light import GoldairHeaterLedDisplayLight
+from custom_components.tuya_local.dehumidifier.light import GoldairDehumidifierLedDisplayLight
+from custom_components.tuya_local.fan.light import GoldairFanLedDisplayLight
 
 
 def setup_platform(hass, config, add_devices, discovery_info=None):
-    """Set up the Goldair climate device according to its type."""
+    """Set up the Tuya climate device according to its type."""
     device = hass.data[DOMAIN][discovery_info[CONF_HOST]]
     if discovery_info[CONF_TYPE] == CONF_TYPE_HEATER:
         add_devices([GoldairHeaterLedDisplayLight(device)])

+ 4 - 4
custom_components/goldair_climate/lock.py → custom_components/tuya_local/lock.py

@@ -1,12 +1,12 @@
 """
-Setup for different kinds of Goldair climate devices
+Setup for different kinds of Tuya climate devices
 """
 from homeassistant.const import CONF_HOST
-from custom_components.goldair_climate import (
+from custom_components.tuya_local import (
     DOMAIN, CONF_TYPE, CONF_TYPE_HEATER, CONF_TYPE_DEHUMIDIFIER, CONF_TYPE_FAN, CONF_TYPE_KOGAN_HEATER
 )
-from custom_components.goldair_climate.heater.lock import GoldairHeaterChildLock
-from custom_components.goldair_climate.dehumidifier.lock import GoldairDehumidifierChildLock
+from custom_components.tuya_local.heater.lock import GoldairHeaterChildLock
+from custom_components.tuya_local.dehumidifier.lock import GoldairDehumidifierChildLock
 
 
 def setup_platform(hass, config, add_devices, discovery_info=None):

+ 14 - 0
custom_components/tuya_local/manifest.json

@@ -0,0 +1,14 @@
+{
+  "domain": "tuya_local",
+  "name": "Tuya based devices local control",
+  "documentation": "https://github.com/make-all/tuya-local",
+  "dependencies": [],
+  "codeowners": [
+      "@make-all",
+      "@nikrolls"
+  ],
+  "requirements": [
+    "pytuya>=7.0.5"
+  ],
+  "homeassistant": "0.96.0"
+}

+ 21 - 22
custom_updater.json

@@ -1,27 +1,26 @@
-{
-    "goldair_climate": {
+    "tuya_local": {
         "version": "0.0.8",
-        "local_location": "/custom_components/goldair_climate/__init__.py",
-        "remote_location": "https://raw.githubusercontent.com/nikrolls/homeassistant-goldair-climate/master/custom_components/goldair_climate/__init__.py",
-        "visit_repo": "https://github.com/nikrolls/homeassistant-goldair-climate",
-        "changelog": "https://github.com/nikrolls/homeassistant-goldair-climate/releases/latest",
+        "local_location": "/custom_components/tuya_local/__init__.py",
+        "remote_location": "https://raw.githubusercontent.com/make-all/tuya-local/master/custom_components/tuya_local/__init__.py",
+        "visit_repo": "https://github.com/make-all/tuya-local",
+        "changelog": "https://github.com/make-all/tuya-local/releases/latest",
         "resources": [
-            "https://raw.githubusercontent.com/nikrolls/homeassistant-goldair-climate/master/custom_components/goldair_climate/manifest.json",
-            "https://raw.githubusercontent.com/nikrolls/homeassistant-goldair-climate/master/custom_components/goldair_climate/__init__.py",
-            "https://raw.githubusercontent.com/nikrolls/homeassistant-goldair-climate/master/custom_components/goldair_climate/climate.py",
-            "https://raw.githubusercontent.com/nikrolls/homeassistant-goldair-climate/master/custom_components/goldair_climate/light.py",
-            "https://raw.githubusercontent.com/nikrolls/homeassistant-goldair-climate/master/custom_components/goldair_climate/lock.py",
-            "https://raw.githubusercontent.com/nikrolls/homeassistant-goldair-climate/master/custom_components/goldair_climate/dehumidifier/__init__.py",
-            "https://raw.githubusercontent.com/nikrolls/homeassistant-goldair-climate/master/custom_components/goldair_climate/dehumidifier/climate.py",
-            "https://raw.githubusercontent.com/nikrolls/homeassistant-goldair-climate/master/custom_components/goldair_climate/dehumidifier/light.py",
-            "https://raw.githubusercontent.com/nikrolls/homeassistant-goldair-climate/master/custom_components/goldair_climate/dehumidifier/lock.py",
-            "https://raw.githubusercontent.com/nikrolls/homeassistant-goldair-climate/master/custom_components/goldair_climate/fan/__init__.py",
-            "https://raw.githubusercontent.com/nikrolls/homeassistant-goldair-climate/master/custom_components/goldair_climate/fan/climate.py",
-            "https://raw.githubusercontent.com/nikrolls/homeassistant-goldair-climate/master/custom_components/goldair_climate/fan/light.py",
-            "https://raw.githubusercontent.com/nikrolls/homeassistant-goldair-climate/master/custom_components/goldair_climate/heater/__init__.py",
-            "https://raw.githubusercontent.com/nikrolls/homeassistant-goldair-climate/master/custom_components/goldair_climate/heater/climate.py",
-            "https://raw.githubusercontent.com/nikrolls/homeassistant-goldair-climate/master/custom_components/goldair_climate/heater/light.py",
-            "https://raw.githubusercontent.com/nikrolls/homeassistant-goldair-climate/master/custom_components/goldair_climate/heater/lock.py"
+            "https://raw.githubusercontent.com/make-all/tuya-local/master/custom_components/tuya_local/manifest.json",
+            "https://raw.githubusercontent.com/make-all/tuya-local/master/custom_components/tuya_local/__init__.py",
+            "https://raw.githubusercontent.com/make-all/tuya-local/master/custom_components/tuya_local/climate.py",
+            "https://raw.githubusercontent.com/make-all/tuya-local/master/custom_components/tuya_local/light.py",
+            "https://raw.githubusercontent.com/make-all/tuya-local/master/custom_components/tuya_local/lock.py",
+            "https://raw.githubusercontent.com/make-all/tuya-local/master/custom_components/tuya_local/dehumidifier/__init__.py",
+            "https://raw.githubusercontent.com/make-all/tuya-local/master/custom_components/tuya_local/dehumidifier/climate.py",
+            "https://raw.githubusercontent.com/make-all/tuya-local/master/custom_components/tuya_local/dehumidifier/light.py",
+            "https://raw.githubusercontent.com/make-all/tuya-local/master/custom_components/tuya_local/dehumidifier/lock.py",
+            "https://raw.githubusercontent.com/make-all/tuya-local/master/custom_components/tuya_local/fan/__init__.py",
+            "https://raw.githubusercontent.com/make-all/tuya-local/master/custom_components/tuya_local/fan/climate.py",
+            "https://raw.githubusercontent.com/make-all/tuya-local/master/custom_components/tuya_local/fan/light.py",
+            "https://raw.githubusercontent.com/make-all/tuya-local/master/custom_components/tuya_local/heater/__init__.py",
+            "https://raw.githubusercontent.com/make-all/tuya-local/master/custom_components/tuya_local/heater/climate.py",
+            "https://raw.githubusercontent.com/make-all/tuya-local/master/custom_components/tuya_local/heater/light.py",
+            "https://raw.githubusercontent.com/make-all/tuya-local/master/custom_components/tuya_local/heater/lock.py"
         ]
     }
 }

+ 3 - 2
hacs.json

@@ -1,10 +1,11 @@
 {
-  "name": "Goldair WiFi climate devices",
+  "name": "Tuya local devices",
   "render_readme": true,
   "domains": [
     "climate",
     "light",
-    "lock"
+    "lock",
+    "binary_sensor",  
   ],
   "country": [
     "NZ",