Brak opisu

Jason Rumney bc0ccfea28 Add helper for parsing device configs. 4 lat temu
.devcontainer da1633e403 Full coverage for GoldairTuyaDevice 5 lat temu
.github e64be9dfdc Run checks at a more random time, once a week. 4 lat temu
.vscode 4980c8883a Completed tests for all light and lock components 5 lat temu
custom_components bc0ccfea28 Add helper for parsing device configs. 4 lat temu
tests bc0ccfea28 Add helper for parsing device configs. 4 lat temu
.coveragerc 25efc866a6 Initial pytest setup (#34) 5 lat temu
.gitignore 9c7da0e833 Add tests for Kogan Heater 5 lat temu
LICENSE.md f35065d59d Move to a more generic tuya_local namespace. 5 lat temu
README.md 0a5b600a98 Switch out the underlying library to tinytuya. 4 lat temu
hacs.json 8bf3ad30d4 Remove country filter from HACS config. 4 lat temu
requirements-dev.txt bc0ccfea28 Add helper for parsing device configs. 4 lat temu
requirements-first.txt b7afcb8c93 Add pycryptodome as a dependency 5 lat temu
requirements.txt 0a5b600a98 Switch out the underlying library to tinytuya. 4 lat temu
sonar-project.properties 8a6214b59d Fix sonar org. 5 lat temu

README.md

Home Assistant Tuya Local component

Reliability Rating Security Rating Maintainability Rating Lines of Code Coverage

This is a Home Assistant add-on to support Wi-fi devices running Tuya firmware without going via the Tuya cloud. Using this integration does not stop your devices from sending status to the Tuya cloud, so this should not be seen as a security measure, rather it improves speed and reliability by using local connections, and may unlock some features of your device, or even unlock whole devices, that are not supported by the Tuya cloud API. Currently the focus is mainly on climate devices, which are not well supported by other similar integrations. The long term plan is to overhaul the architecture to make adding new devices a matter of adding a single configuration file. Until that is done I will not be adding simpler devices like switches and lights which can be covered by rospogrigio/localtuya.

The tuya_local component integrates Goldair WiFi-enabled heaters, dehumidifiers and fans, Kogan WiFi-enabled heaters and plugs, Andersson heaters, Eurom heaters, Purline heaters and Garden PAC pool heatpumps into Home Assistant, enabling control of setting the following parameters via the UI and the following services:

Climate devices

Goldair GPPH Heaters

  • power (on/off)
  • mode (Comfort, Eco, Anti-freeze)
  • target temperature (5-35 in Comfort mode, 5-21 in Eco mode, in °C)
  • power level (via the swing mode setting because no appropriate HA option exists: Auto, 1-5, Stop)

Current temperature is also displayed.

Goldair GPCV Heaters

  • power (on/off)
  • mode (Low, High)
  • target temperature (15-35 in °C)

Current temperature is also displayed.

Goldair GECO Heaters

  • power (on/off)
  • target temperature (15-35 in °C)

Current temperature is also displayed.

Goldair Dehumidifiers

  • 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. The "tank full" state is available via the error attribute, and if you want to you can easily surface this to a top-level entity using a template sensor.

Goldair Fans

  • power (on/off)
  • mode (Normal, Eco, Sleep)
  • fan mode (1-12)
  • swing (on/off)

Kogan Heaters

  • power (on/off)
  • mode (LOW/HIGH)
  • target temperature (16-30 in °C)

Current temperature is also displayed.

Andersson Heaters

  • power (on/off)
  • mode (ANTI-FREEZE/LOW/HIGH)
  • target temperature (5-35 in °C)

Current temperature is also displayed.

Eurom Heaters

  • power (on/off)
  • target temperature (15-35 in °C)

Current temperature is also displayed.

Garden PAC Pool Heatpumps

  • power (on/off)
  • mode (silent/smart)
  • target temperature (18-45 in °C)

Current temperature is also displayed. Power level, operating mode are available as attributes.

Purline Hoti M100 Heaters

  • power (heat/fan-only/off)
  • mode (Fan, 1-5, Auto)
  • target temperature (16-35 in °C)
  • swing (on/off)

Additional features

Light (Goldair and Purline devices)

  • LED display (on/off)

Lock (Goldair heaters and dehumidifiers)

  • Child lock (on/off)

Open Window Detector (Purline devices)

  • Open Window Detect (on/off)

Switch devices

Kogan Energy monitoring Smart Plug

  • power (on/off)
  • current power consumption (Watts)
  • Additional non-standard attributes
    • current current draw (Amps)
    • current voltage (Volts)
    • timer (seconds) [provided as read only]

Newer models with a USB socket are also supported.


Device support

Please note, this component is actively tested with the Goldair GPPH (inverter), GPDH420 (dehumidifier), Kogan SmarterHome 1500W Smart Panel Heater and Kogan SmarterHome Energy Monitoring SmartPlug. Theoretically it should also work with GECO, GEPH and GPCV heater devices, and GCPF315 fan and may work with the GPDH440 dehumidifier and any other Goldair heaters, dehumidifiers or fans and Kogan heaters and smartplugs based on the Tuya platform.

GPCV support is based on feedback from @etamtlosz on upstream Issue #27. GECO support is based on work in KiLLeRRaT/homeassistant-goldair-climate and the feature set from the online manual for these heaters. GEPH heaters appear to be the same as the GECO270, so may also work with this setting. This heater is almost compatible with the GPCV but without the Low/High mode.

Support for newer Kogan Smartplugs with USB sockets on them is based on feedback from @botts7 on Issue #2.

A number of other brands of plug seem to match the DPS indexes of either the older or newer Kogan Smartplugs, so it is likely to work with other brands of single energy monitoring smartplug also.

Support for heaters visually matching Andersson GSH 3.2 was added based on information from @awaismun on Issue #5.

Support for Eurom Mon Soleil 600 ceiling heaters was added by @FeikoJoosten. It is possible that this support will also work for other models such as Mon Soleil 610 wall panel heaters, and others in the range.

Support for Purline Hoti M100 heaters and Garden PAC pool heatpumps were added based on information from @Xeovar on Issue #11.


Installation

Installation is via the Home Assistant Community Store (HACS), which is the best place to get third-party integrations for Home Assistant. Once you have HACS set up, simply follow the instructions for adding a custom repository and then the integration will be available to install like any other.

Configuration

You can easily configure your devices using the Integrations UI at Home Assistant > Configuration > Integrations > +. This is the preferred method as things will be unlikely to break as this integration is upgraded. You will need to provide your device's IP address, device ID and local key; the last two can be found using the instructions below.

If you would rather configure using yaml, add the following lines to your configuration.yaml file (but bear in mind that if the configuration options change your configuration may break until you update it to match the changes):

# Example configuration.yaml entry
tuya_local:
  - name: My heater
    host: 1.2.3.4
    device_id: <your device id>
    local_key: <your local key>

Configuration variables

name

    (string) (Required) Any unique name for the device; required because the Tuya API doesn't provide the one you set in the app.

host

    (string) (Required) IP or hostname of the device.

device_id

    (string) (Required) Device ID retrieved as per the instructions below.

local_key

    (string) (Required) Local key retrieved as per the instructions below.

type

    (string) (Optional) The type of Tuya device. auto to automatically detect the device type, or if that doesn't work, select from the available options heater, geco_heater gpcv_heater, dehumidifier, fan, kogan_heater, gsh_heater, eurom_heater, gardenpac_heatpump, purline_m100_heater or kogan_switch.

    Default value: auto

climate

    (boolean) (Optional) Whether to surface this appliance as a climate device. (not supported for switches)

    Default value: true

display_light

    (boolean) (Optional) Whether to surface this appliance's LED display control as a light (not supported for Kogan, Andersson, Eurom, GECO or GPCV Heaters, or switches).

    Default value: false

child_lock

    (boolean) (Optional) Whether to surface this appliances's child lock as a lock device (not supported for fans, switches, or Andersson ,Eurom, Purline heaters or Garden PAC heatpumps).

    Default value: false

switch

    (boolean) (Optional) Whether to surface this device as a switch device (supported only for switches and Purline heaters for the Open Window Detection)

Heater gotchas

Goldair GPPH heaters have individual target temperatures for their Comfort and Eco modes, whereas Home Assistant only supports a single target temperature. Therefore, when you're in Comfort mode you will set the Comfort temperature (5-35), and when you're in Eco mode you will set the Eco temperature (5-21), just like you were using the heater's own control panel. Bear this in mind when writing automations that change the operation mode and set a temperature at the same time: you must change the operation mode before setting the new target temperature, otherwise you will set the current thermostat rather than the new one.

When switching to Anti-freeze mode, the heater will set the current power level to 1 as if you had manually chosen it. When you switch back to other modes, you will no longer be in Auto and will have to set it again if this is what you wanted. This could be worked around in code however it would require storing state that may be cleared if HA is restarted and due to this unreliability it's probably best that you just factor it into your automations.

When child lock is enabled, the heater's display will flash with the child lock symbol ([]) whenever you change something in HA. This can be confusing because it's the same behaviour as when you try to change something via the heater's own control panel and the change is rejected due to being locked, however rest assured that the changes are taking effect.

When setting the target temperature, different heaters have different behaviour, which you may need to compensate for. From observation, GPPH heaters allow the temperature to reach 3 degrees higher than the set temperature before turning off, and 1 degree lower before turning on again. Kogan Heaters on the other hand turn off when the temperature reaches 1 degree over the targetin LOW mode, and turn on again 3 degrees below the target. To make these heaters act the same in LOW power mode, you need to set the Kogan thermostat 2 degrees higher than the GPPH thermostat. In HIGH power mode however, they seem to act the same as the GPPH heaters.

Fan gotchas

In my experience, fans can be a bit flaky. If they become unresponsive, give them about 60 seconds to wake up again.

Kogan Switch gotchas

While setting this up, I observed after a while that the current and power readings from the switch were returning 0 when there was clearly a load on the switch. After unplugging and replugging, the switch started returning only dps 1 and 2 (switch status and timer). If HomeAssistant is restarted in that state, the switch detection would fail, however as Home Assistant was left running, it continued to work with no readings for the current, power and voltage. I unplugged the switch overnight, and in the morning it was working correctly.

Finding your device ID and local key

You can find these keys the same way as you would for any Tuya local integration. You'll need the Goldair app or the Tuya Tuya Smart app (the Goldair app is just a rebranded Tuya app), then follow these instructions.

Next steps

  1. Fallback support for a simple switch device using only a boolean dps 1. As well as covering the failure mode of the Kogan Switch described in Kogan switch gotchas above, it can also cover basic operation of many other devices that use dps 1 for an on/off switch.
  2. Config flow improvement to offer only the options available to the detected device, and an indication of which device was detected.
  3. 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.
  4. Further config flow improvements to filter the available types to possibilities based on the known dps. When many device configurations are supported, this will be required, as not all devices will be distinguishable automatically.
  5. 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.
  6. This component is partially unit-tested thanks to the upstream project, but there are a few more to complete. Feel free to use existing specs as inspiration and the Sonar Cloud analysis to see where the gaps are.
  7. Once unit tests are complete, the next task is to complete the Home Assistant quality checklist before considering submission 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: