Local Tuya - Control Tuya devices locally (Fork from localtuya)

Thanks for the quick reply.

I removed the device and added it again and configured the climate entity manually and made sure Presets DP is empty.

Now the data shows up in Controls section of the device, but a blank UI when I click on it, which means no UI in dashboard.

Here is the new diagnostics log.

  "integration_manifest": {
    "domain": "localtuya",
    "name": "Local Tuya",
    "codeowners": [],
    "config_flow": true,
    "dependencies": [],
    "documentation": "https://github.com/xZetsubou/hass-localtuya/",
    "integration_type": "hub",
    "iot_class": "local_push",
    "issue_tracker": "https://github.com/xZetsubou/hass-localtuya/issues",
    "requirements": [],
    "version": "3.2.5",
    "is_built_in": false
  },
  "data": {
    "device_config": {
      "friendly_name": "Nav Panel Heater",
      "host": "10.0.2.157",
      "device_id": "5201XXXXXXXXXXf36c",
      "local_key": "257XXXXXXXXd",
      "protocol_version": "3.3",
      "enable_debug": false,
      "node_id": null,
      "model": "2400W Glass Panel Heater-Black",
      "product_key": "ijivuwpiraq4mkdz",
      "dps_strings": [
        "1 ( code: switch , value: False )",
        "2 ( code: temp_set , value: 23 )",
        "3 ( code: TempCurrent , value: 19 )",
        "4 ( code: Mode , value: low )",
        "5 ( code: ECO , value: False )",
        "6 ( code: ChildLock , value: False )",
        "10 ( code: Timer , value: 0 )",
        "11 ( code: Countdown , value: 0 )",
        "12 ( code: Fault , value: 0 )",
        "101 ( code: heat , value: False )",
        "102 ( code: sleep , value: False )",
        "103 ( code: switch , value: C )"
      ],
      "entities": [
        {
          "id": "1",
          "friendly_name": "Local Nav Panel Heater",
          "entity_category": "None",
          "min_temperature": 7.0,
          "max_temperature": 35.0,
          "precision": "1",
          "target_precision": "1",
          "hvac_mode_set": {
            "off": false,
            "auto": "auto",
            "cool": "cold",
            "heat": "hot",
            "heat_cool": "heat",
            "dry": "wet",
            "fan_only": "wind"
          },
          "hvac_action_set": {
            "heating": "opened",
            "idle": "closed"
          },
          "preset_set": {},
          "fan_speed_list": "low,high",
          "target_temperature_dp": "2",
          "current_temperature_dp": "3",
          "temperature_step": "1",
          "eco_dp": "5",
          "eco_value": "False",
          "fan_speed_dp": "4",
          "temperature_unit": "celsius",
          "platform": "climate"
        }
      ]
    },
    "device_cloud_info": {
      "active_time": 1659499382,
      "biz_type": 0,
      "category": "qn",
      "create_time": 1614725856,
      "icon": "smart/icon/1541578296zqm3146n9lm_0.jpg",
      "id": "5201XXXXXXXXf36c",
      "ip": "1...2",
      "lat": "-XX.XXXXX",
      "local_key": "25XXXXXXXXX3d",
      "lon": "145.2600",
      "model": "KASGSHT24BA",
      "name": "Nav Panel Heater",
      "online": true,
      "owner_id": "5XXXXXX86",
      "product_id": "ijivuwpiraq4mkdz",
      "product_name": "2400W Glass Panel Heater-Black",
      "status": [
        {
          "code": "switch",
          "value": false
        },
        {
          "code": "temp_set",
          "value": 23
        },
        {
          "code": "temp_current",
          "value": 19
        }
      ],
      "sub": false,
      "time_zone": "+10:00",
      "uid": "eu16XXXXXXXXmw",
      "update_time": 1713439737,
      "uuid": "52016XXXXXXXXf36c",
      "dps_data": {
        "1": {
          "code": "switch",
          "custom_name": "",
          "dp_id": 1,
          "time": 1714189374942,
          "value": false,
          "type": "Boolean",
          "values": "{\"type\": \"bool\"}",
          "id": 1,
          "accessMode": "rw"
        },
        "2": {
          "code": "temp_set",
          "custom_name": "",
          "dp_id": 2,
          "time": 1714188985545,
          "value": 23,
          "type": "Integer",
          "values": "{\"type\": \"value\", \"max\": 113, \"min\": 5, \"scale\": 0, \"step\": 1, \"unit\": \"\u2103/\u2109\"}",
          "id": 2,
          "accessMode": "rw"
        },
        "3": {
          "code": "TempCurrent",
          "custom_name": "",
          "dp_id": 3,
          "time": 1714210381565,
          "value": 19,
          "id": 3,
          "accessMode": "ro",
          "values": "{\"type\": \"value\", \"max\": 176, \"min\": -9, \"scale\": 0, \"step\": 1, \"unit\": \"\u2103\"}"
        },
        "4": {
          "code": "Mode",
          "custom_name": "",
          "dp_id": 4,
          "time": 1714090466702,
          "value": "low",
          "id": 4,
          "accessMode": "rw",
          "values": "{\"type\": \"enum\", \"range\": [\"high\", \"low\"]}"
        },
        "5": {
          "code": "ECO",
          "custom_name": "",
          "dp_id": 5,
          "time": 1711980238431,
          "value": false,
          "id": 5,
          "accessMode": "rw",
          "values": "{\"type\": \"bool\"}"
        },
        "6": {
          "code": "ChildLock",
          "custom_name": "",
          "dp_id": 6,
          "time": 1711980238431,
          "value": false,
          "id": 6,
          "accessMode": "rw",
          "values": "{\"type\": \"bool\"}"
        },
        "10": {
          "code": "Timer",
          "custom_name": "",
          "dp_id": 10,
          "time": 1711980238431,
          "value": "0",
          "id": 10,
          "accessMode": "rw",
          "values": "{\"type\": \"enum\", \"range\": [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\", \"13\", \"14\", \"15\", \"16\", \"17\", \"18\", \"19\", \"20\", \"21\", \"22\", \"23\", \"24\"]}"
        },
        "11": {
          "code": "Countdown",
          "custom_name": "",
          "dp_id": 11,
          "time": 1714210017225,
          "value": 0,
          "id": 11,
          "accessMode": "ro",
          "values": "{\"type\": \"value\", \"max\": 1440, \"min\": 0, \"scale\": 0, \"step\": 1, \"unit\": \"\u5206\u949f\"}"
        },
        "12": {
          "code": "Fault",
          "custom_name": "",
          "dp_id": 12,
          "time": 1711980238431,
          "value": 0,
          "id": 12,
          "accessMode": "ro",
          "values": "{\"type\": \"bitmap\", \"label\": [\"1\", \"2\"], \"maxlen\": 2}"
        },
        "101": {
          "code": "heat",
          "custom_name": "",
          "dp_id": 101,
          "time": 1714189375655,
          "value": false,
          "id": 101,
          "accessMode": "ro",
          "values": "{\"type\": \"bool\"}"
        },
        "102": {
          "code": "sleep",
          "custom_name": "",
          "dp_id": 102,
          "time": 1714189374576,
          "value": false,
          "id": 102,
          "accessMode": "rw",
          "values": "{\"type\": \"bool\"}"
        },
        "103": {
          "code": "switch",
          "custom_name": "",
          "dp_id": 103,
          "time": 1711980238431,
          "value": "C",
          "id": 103,
          "accessMode": "rw",
          "values": "{\"type\": \"enum\", \"range\": [\"C\", \"F\"]}"
        }
      }
    }
  }

Thanks umu_ugg again for a wonderful fork and keeping it alive!

I see that you have updated the main branch with the fix, I have removed the device, updated to main branch and readded the device (made sure Presets DP is empty) and still the same results.

The issue is not in Preset DP it’s in Preset Set it was adding auto/smart as the default value which is not the correct format anymore since preset set expected to be dict type.

not sure what happen to your device after you re-add with the latest changes if actaully update to master and yet raised the same issue post the device diagnostic after auto configure on the latest changes.
However you can’t add the device manually without Inserting the correct values.
You can Re-add the device manually and go with this config.

Config

DPID = 1
Target Temperature = 2
Current Temperature = 3
(Optional) Temperature Step = 1
Min Temperature = 5
Max Temperature = 113
Precision (optional, for DPs values) = 1
Target Precision (optional, for DP values) = 1
(Optional) HVAC Mode DP = 1
(Optional) HVAC Modes:

"off": false
heat: true

(Optional) HVAC Current Action DP = 101
(Optional) HVAC Actions:

heating: true
idle: false

(Optional) Eco DP = 5
(Optional) Eco value = true note this may not works now
(Optional) Presets DP = 4
(Optional) Presets:

low: Low
high: High

Edit: I made one more changes to heaters auto configure it should handle it better if you gonna test try with latest changes and something went wrong go to devices → localtuya → enable debug logging then re-add the device auto configure → disable debug logging and post log file.

1 Like

Thanks for the detailed update. Here are the steps that I did.

  1. Updated to the latest main branch.
  2. Removed existing device
  3. Restarted HA
  4. Enabled debugging in localtuya
  5. Re-Add the device and try to auto-configure and get this error when doing auto-configure and the device does not get added. So cannot get diag logs.

Then a clean up and does it manually again.

  1. Remove existing device
  2. Restart HA to ensure nothing is hanging around
  3. Re-add the device but configure it manually using the configuration you have provided above
  4. and it comes up as expected and works!!

So the manual steps are working fine without any issues. Thanks a lot for quick response everytime!

This is the device that I have: Buy Kogan SmarterHome™ 2.4kW Smart Glass Panel Heater (Black) Online | Kogan.com

If the error log still existed in “settings → system → logs → search for Tuya click on the error log” and paste here not sure what actually caused it. or later I can simulate the auto configure with your device diagnostics to see what causing it I may broke something :eyes:

Edit
After re-checking, you were correct it seems there was an issue with auto configure and was critical one, I did fix it in the latest master version and for sure it will works much better now you can try it if you don’t mind.

Thanks @umu_ugg a ton!! That worked perfectly and was able to auto-configure the heater now after updating to latest branch.

Firstly thankyou for the excellent work being done with Localtuya, it’s been a quite steep learning curve for me on how to use it, but getting there. My question:
I don’t quite understand when one using LocalTuya to edit an existing device, and are manually adding a new entity to that device (for random example say DPS 3 for a T & H battery sensor:
The first thing one is asked is the entity type selection via ‘choose entity*’ dropdown (I get why and no issues for me here). Depending on DPS one configures the new accordingly, to the very last question in setup which asks user (to me its already asked this) to Choose Entity (again a drop down selection).

What’s this last for as unless I’ve got myself confused hasn’t that question already been asked as the first question? Id greatly appreciate some guidance as I learn HA and this particular question as I work at trying to add a Dehumidifier to my HA with so far limited success. Thanks

Not sure if I understood your point correctly but do you mean why localtuya keeps asking you the same question choose entity? as long there is DPS that has not been configured yet localtuya will keeps asking if you want to add more entities.

Also this different from device to another device for example if you have switch with 3 buttons you will need to add “switch” entity 3 times; one for each button DP.

even Dehumidifier sometimes it may has more DPS for example “DP for timer” this will require you to add another entity with “number” platform to setup timer entity for the Dehumidifier

off-topic

Now that you mentioned it seems if you actually configured all the DPS the the checkbox Add new entity(s) should appear since there is no more DPS to configured, if this is what you mean.

Thanks. Firstly I’ll recheck my process (by deleting and redoing a device) to confirm my question is logically sound, and get back to you.

I understand multiple DPS and that differing devices will have multiple that may be configured. My question (which I’ll validate) was about entry workflow for a single DPS (or each when there are multiple, irrespective if automatically discovered or manually added by user).

Hi OP, if Cloud API account is expired, will this still work? Somehow one of my devices is broken and no local key now :frowning:

Same problem here… i am not able to reconnect the device again. even if the tuya status is online.

Localtuya will keep running even if the Cloud API expired, it just the cloud features will stops, if there is an error you can post it here. it will just shows the message.

Cloud API connection failed: Error 28841002: No permissions. Your subscription to cloud development plan has expired.

But it will keep running.

Hi umu_ugg,

I didn’t find this situation in docs.

I have new tuya device and I want to use it only locally. Also I have DMZ network without internet where HA and another (not tuya) devices located.

When I trying to initially config device by “tuya smart” or “smart life” apps it fails during this process. This is expectedly because no internet in DMZ for devices.

How I can setup and connect it to this integration without connect to tuya cloud?

If i understood correctly you want to pair this devices in “Tuya Smart or Smart Life” without internet it probably won’t works you will need to setup these device with internet then later you can block them from internet, however at first you will need to add these devices so they can retrieve “id and Localkey”

Hello everyone,
I wanted to share and document for others my configuration for a Kesser Glass Panel Heater. After fiddling with the datapoints via the IOT platform from Tuya, I managed to get the mode working:

  • Auto = ECO aka 1250 watts
  • Heating = 2500 watts
  • Preset ECO = Anti Freeze

Hope this helps someone.
Cheers.

1 Like

A few questions:

  • Can the integration work across different networks? HA is on a vlan and the Tuya devices are on another. Traffic initiated from HA to the devices vlan is permitted but only certain traffic initiated from the devices vlan to HA is.
  • Can the Tuya official integration be used simultaneously?
  • This integration does not require HA to be accessible from the Internet, correct?

I’m asking because I can add devices manually fine, but they all go unavailable 30 seconds later. If I reload the integration they come back online but the same occurs.

Ok, figured out. To answer my own questions:

  • Can the integration work across different networks? HA is on a vlan and the Tuya devices are on another. Traffic initiated from HA to the devices vlan is permitted but only certain traffic initiated from the devices vlan to HA is.
    • Yes, but device discovery won’t be possible.
  • Can the Tuya official integration be used simultaneously?
    • Yes, although I suspect it’s not a good idea long term.
  • This integration does not require HA to be accessible from the Internet, correct?
    • It does not.

I’m embarrassed at how long it took me to determine how to properly add gateway subdevices. In case someone passes by here later, you simply add the subdevice with its parameters, set the IP of the gateway and specify the subdevice node id down in the last field. The integration will detect the DPS’ with their description and current value, and add the entities automatically. You can manually add entities not included by the integration.

1 Like

You can actually discover devices across VLANs as well. You need to enable UDP broadcasts. See here: Separated network hassio from tuya devices. · Issue #216 · rospogrigio/localtuya · GitHub

True, but that is beyond the networking functionality level of many here.

Thanks for sharing :+1: