LocalTuya - Using Tuya IoT Platform to obtain not only Local Keys, but also DP (data point) IDs

David,
I do not quite understand your comment the “TL does not let you add sensors”.
Do you mean a new device that has sensors?
Because obviously, all the devices that are currently supported have been added over time.
So a new device that is not currently supported may be requested to be added, by providing relevant device information. (see instruction that I provided to Anj-0110)
On the other hand, if you wish to create your own device file yourself and you fully understand the YAML configuration rules and device dpid, etc, then you can create your own files and take full control, but then it’s yours and no one else can then benefit from this new device file.

I have to say that I was a bit lost with sending messages to these forums. epajfl00, you have been most helpful and really the only one that has provided real context to get me past the issue. It might be easy for some understand HA and code but I’m learning.

One last question for now, I switched for LT to TL because the lights were turning on and off randomly and thought switching would eliminate the issue. This is happening in the system somehow, (imo) and through the logs I can’t tell what is causing random on or off commands. After switching devices over to TL, this morning all the lights were on. I don’t have any automations or triggers to run. Is this behavior a TL issue, a internet losing connection issue, alexa, smartlife? I have looked for a power on behavior or something of the sorts but I don’t know how to dig into this further?? Can you provide some feedback?

Thanks a ton!!

Thanks for your comments, I try to provide steps by step instructions that I would want from others to provide, if I can.
What I can say from my own experience, TL is super reliable, stable and effective.
So, I don’t believe your issues are TL related.
In my case, I don’t have WIFI repeaters, mains power is stable, and WIFI is stable.
So your case could be related to having WIFI repeaters as indicated by “Zagal” a couple of days ago.
What you could do is firstly look at the history of that entity.
This is an example of mine.
image

See what time it dropped out and then see what may have happened at that time, also try to turn off any repeaters (to make sure that is not the issue).

BTW, is the issue happening with both infibrite lights and carro fan/light, if not, then that should be investigated too, eg. the distance from your router to the device.

Start with this.

I am having random light on calls for most all the devices not just infibrite. I only have the modem/router that my rpi4 is connected via ethernet cable, I don’t have any repeaters. I tested this morning, I turned off the modem, waited and turned back on. Upon network reconnect no lights came on. however, when I restart HA i can duplicate the random “on” call. I just don’t know what is telling them to turn on. Also, when they turn on, the ones that do turn on all come on always at 56% brightness. I don’t know how to further troubleshoot this?? In the logbook, when I cycle a command it puts my username in the log and when these other light-on call happen there is nothing in the log that shows what turned it on.
image

That is interesting and most annoying.
Again in my case I can restart HA as many times as I want with absolutely no effect on any devices.
Obviously, there is something else going on with yours, since restarting HA causes the issue, but you have also previously indicated that in the morning you have found the lights on, meaning no manual restart was initiated. (noting, if a HA update was available and if you have auto update set, then a restart could occur overnight automatically) . If this is not the case, then at what time do the lights go on overnight, without a restart being initiated, is it always at the exact same time or totally random?
I don’t believe this is your case, but if the device lost power it would then reboot/restart, and depending on how it is set to handle power on state (ie, on, off, or last state) could be an issue.
Do you know if “power on state” is an available setting for your devices?
Some of my devices do have this setting and I always set to last state.

Do you have your lights set as groups?

What makes no sense to me is HA restart replicates the problem.
Are you sure you don’t have any other blueprints or other integrations that could be interfering with your config.? If you do, try disabling them, and then restart HA, to rule them out.

I’m running out of options here.

Let see here…

Random lights are coming on at random times, not just overnight. To my knowledge I do not have any auto updates or restarts set. All the lights are wired into a dumb outlet or wall switch for power. For the “power on state”, I can only see the “power on behavior” in the SmartLife app, I’m unaware of where to find this in HA. And for the power on state, I have set a custom color for the power on behavior so I know if this a power issue, however the lights turn on at 56% and not the custom setting.

I do have lights set up in groups. For the blueprints integrations, I don’t know which one could be interfering? I’ll look into this more. However, I thought the log would tell me what is turning on the device so I can troubleshoot.

Also, I looked in the system log, below, i’m getting a lot of errors.

This error originated from a custom integration.

Logger: custom_components.tuya_local.device
Source: custom_components/tuya_local/device.py:545
Integration: Tuya Local (documentation, issues)
First occurred: October 16, 2023 at 11:46:27 (18395 occurrences)
Last logged: 14:19:03

Failed to fetch device status for Galley 01
Failed to fetch device status for Living room 1
Failed to fetch device status for String TV
Failed to fetch device status for UCL 3
Failed to fetch device status for Living room 7

Also, when i look at the log within the device info window the device is unavailable or unknown for some reason then something turns it on. This is where I am in deeper than what I understand. Is the log telling me the service “Light: Turn on” is doing this? If so, how do I dig into this further?

image

I suggest that you raise a bug issue on TL, since the log is referring to;
Source: custom_components/tuya_local/device.py:545
This line in the code for device.py is;
entity.async_schedule_update_ha_state()

What I don’t understand is does this only happen with TL, what about TUYA (cloud based) on HA?
Also the groups I would try disabling, especially since scene is becoming unknown.

I was having the same issue with LT and thought that moving over to TL would fix the issue. I only used TUYA for a short time and do not recall issues but I switched to LT to get away from the cloud.

Curious, how is myTL code any different from everyone elses that uses TL? I haven’t gone into file editor to change anything?

I tend to agree with you, so it can’t be TL or SL or even Tuya, there must be something with your setup, again try disabling other integration, groups, any schedules, etc…
Is it still happening at random times or is there a pattern/time on a regular basis?

Hi,

Yes, the GitHub page for LocalTuya says that standalone sensors are not currently supported and (as far as I can remember) the sensors.py file isn’t part of the custom component download file. Yes, I could add the relevant code to either in the HA Config files or via downloading the Tuya SDK and adding the sensors.py file to LocalTuya file, or contact the developer and ask them to add each of the different devices. However, given that the Tuya integration automatically adds everything from your Tuya/Smart Life app, including all standalone sensors (such as my temp and humidity sensors), without any setup work or hassle, means that all of the above seems like LocalTuya is more hassle than it’s worth to have things run locally, for me at least.

**Update - The Tuya developers (at Tuya itself) are currently beta testing a new Smart Life integration that works exactly like the current Tuya integration (as in adds every device and scene automatically) but DOESN’T require a Tuya IoT account and the 6 monthly requests for IoT Core access. You only need to enter your User Code (from your Tuya/Smart Life app security settings page) and all devices in the app get added to HA. While it is still in Beta testing you can download it as a custom repository from…

https://github.com/tuya/tuya-smart-life?search=1#smart-life-beta-home-assistant-integration

…I’ve already installed it and it works perfectly.

You can easily get device id’s and local keys with only your account credentials using this python script

LOL…Easy for you…? Are there any instructions on how to use tuya-uncover from a Homeassistant instalation? Yes it would be very helpful to use with Tuya-Local.

You run it from any computer that has python and the instructions are in the readme file

Hello,

It’s been awhile…

So far, the conclusion to my issue has been to turn off the SMARTLIFE app running in the background in the permissions on my phone.

FINGERS CROSSED!!

Still don’t understand why TinyTuya isn’t just built into this integration somehow. Make it prompt for the one key from the Tuya cloud API, have it do all the scanning and fetching of local keys…etc.

1 Like

I don’t get any "dp_id" keys returned in the json when I make this call. I do get a key with chinese text which google translate confirms it matches the name of the action - eg “docking”. Is there something else I need to do? This is on a Lubluelu sl60d.

@umu_ugg has created an excellent LocalTuya fork which allows full auto discovery and local control of sub-devices behind a gateway too!

I can’t get my light working despite acquiring all the data points. The values return with (value:-1), despite this not showing in the tuya developer portal against the data points.

{
  "result": {
    "properties": [
      {
        "code": "switch_led",
        "custom_name": "",
        "dp_id": 20,
        "time": 1705434823728,
        "value": true
      },
      {
        "code": "work_mode",
        "custom_name": "",
        "dp_id": 21,
        "time": 1705434785014,
        "value": "scene"
      },
      {
        "code": "bright_value",
        "custom_name": "",
        "dp_id": 22,
        "time": 1705431400653,
        "value": 701
      },
      {
        "code": "temp_value",
        "custom_name": "",
        "dp_id": 23,
        "time": 1705431402915,
        "value": 758
      },
      {
        "code": "colour_data",
        "custom_name": "",
        "dp_id": 24,
        "time": 1705431364516,
        "value": "00b403e803e8"
      },
      {
        "code": "scene_data",
        "custom_name": "",
        "dp_id": 25,
        "time": 1705412782630,
        "value": "000e0d0000000000000000c80000"
      },
      {
        "code": "countdown",
        "custom_name": "",
        "dp_id": 26,
        "time": 1705412782630,
        "value": 0
      },
      {
        "code": "music_data",
        "custom_name": "",
        "dp_id": 27,
        "time": 1705412780833,
        "value": ""
      },
      {
        "code": "control_data",
        "custom_name": "",
        "dp_id": 28,
        "time": 1705412780833,
        "value": ""
      },
      {
        "code": "power_memory",
        "custom_name": "",
        "dp_id": 33,
        "time": 1705412782734,
        "value": "AAEAAAPoA+gD6AAA"
      },
      {
        "code": "mic_music_data",
        "custom_name": "",
        "dp_id": 42,
        "time": 1705412782630,
        "value": "010000016432000003e8007803e800f003e8003c03e800b403e8012c03e8"
      }
    ]
  },
  "success": true,
  "t": 1705438188949,
  "tid": "c9de147cb4b011ee847d96852008b4f4"

I get permission issue although I am logged into Tuya IoT account. Is there a separate subscription for this logging service?

IMO, like others have said, use the “Tuya” app that comes with HASS if you do not mind using a chinese cloud based app. It works pretty seemlessly and for me was very reliable.
If that bothers you and if you want to try to use a local tuya integration, use “TUYALOCAL” not “localTuya” .
The “Tuya Local” solution has good support and supports many of the Tuya devices and is much much easier to implement. If you have trouvle implementing your device, open a ticket and they are very good at righting a new driver pretty quickly.
I would not use “Local Tuya” in short it is very dificult to set up each device.