Tuya energy monitoring only updating when app is open?

Hi there, got the same problem and tried the workaround with the localtuya integration, without success. What did end up working for me was the Tuya local custom integration!

I know localtuya and the Tuya (devices & services) integration, but, what do you mean by ‘tuya local custom integration’?.. thanks!..

Edited: I respond to myself in case someone is interested…:
Some hours later I see that there is another integration called ‘tuya local’. I suppose you are refering to that one. Correct me if I’m wrong:

Hi. It’s been months but just in case it can be useful : I had exactly the same problem (with Tuya Local all my devices only updated when the app was open, so I switched to LocalTuya for the scan interval - it worked, but only for my 3.3 devices, not the 3.4).

So I figured the fix (that forces the update at the interval) must be used with 3.3 devices, but not with the 3.4 devices, I searched the python files in LocalTuya, and I was right ! (thank God it was obvious, as I am completely unfamiliar with python).

In the “_init.py” file - the one in the pytuya folder, not the one in the root of localtuya - at line 813, is the update_dps function, which only did something
“if self.version in [3.2, 3.3]:” (line 820) - so with 3.4 devices, it did … nothing.

So by simply adding 3.4 in the list (so we have “if self.version in [3.2, 3.3, 3.4]:” on line 820), it started working !! (I did need a restart of HA of course to reload localtuya properly)

Now all my tuya devices - 3.3 and 3.4 - update using the “Scan interval” value !!

I hope it can help someone (I spent so much time trying to make it work …)

8 Likes

Thanks Matt, seem a very nice trick.

I’m not going to try it, because my solution was the contrary. I have localtuya and devices didn’t update (maybe for the software version, now that you say it). But I tried Tuya-Local and it worked perfectly on all my devices. So now I’m staying with Tuya-Local. Just my experience.

…but thanks for the trick, sure it serve others.

I have experienced the same issue (thermostat that reports current_temp only when the Smart Life app is opened on the thermostat).

I have found a workaround that works for me.

I saw through the devive debug on IOT TUYA API that the smart life app sends an event named 唤醒通知 to trigger the thermostat response.

Using the IOT TUYA API, I have discovered all the device properties and found out that 唤醒通知 is a property called “week_up_btn” (probably misspelled wake).

If you set that property to true, it triggers the device to report the status and then reset to default.

The workaround is setting this property to true every x seconds, making the device report regularly.

I’m not sure if this applies to other devices, but for my thermostat works.

2 Likes

It works!!!
Thank you for sharing!

Could you tell me how you did that? I have same problem and localtuya and tuya-local not refresh every x seconds in my case.

Hello, I’m having the same issue and I would like to know how you set that, please.
@mistrello96

Looks like my subscription on Tuya IOT has expired. How do you guys get this to work? The cheapest option for payed subscription is 25000 dollar?? What am I doing wrong?

Edit: found extending the trial option :slight_smile:

Chipping here in again, what I found to be the most reliable is to use the tuya-local integration to have all the sensors and entities easily available as I suggested earlier. When you have issues with updating even then, I suggest to add the localtuya integration with the dps set to 10 seconds (and using the trick of @matt3003 for 3.4 devices) and have the two integrations work in parallel, whilst hiding the entity of localtuya. This should solve the updating issue.

I stopped foolin around with the Tuya plugs and ordered these:
Smart Power Plugs:Zigbee Smart Plug with Measure and Timer Function, Tuya App Control, Push Notification, Zigbee Hub Required, 16A Zigbee Plug,Compatible with Alexa and Google Home,Pack of (4 Pack) : Amazon.nl: DIY & Tools

Works perfectly and gives live data!
It has the following sensors (top 4 are my own Helpers for periodic data).

are you setting that property through Local Tuya ? calling the api externally to HASS ?

Thanks a LOTTTTT it works!

1 Like

Hi Matt, thanks for your contribute. I’am spending a lot of time on this whitout a solution. I tried your fix but unfortunately it doesn’t work for me. Do you have any suggestion ? anything else to check ?

Somehow this worked…
I wonder if they didn’t change it because it’s not exactly reliable? Anyway, it saved my smart plug from being a paper weight lol

I have 2 kind of plugs. The EU reports automatically every 5 minutes. The US only report when I open Tuya app. I think this is a firmware/manufacturer problem.

EU plug


The US plug

I found a link somewhere also said US plug doesn’t work.

I have only EU plugs and had the problem on some plugs. As Matt said, probably version of firmware… 3.3 vs 3.4, etc

I use latetly offical tuya addon for HA, and tuya-local (not localtuya which is different), with good results… only one plug from certain brand is giving problems of turning as unavailable sometimes.

@Va-na : Sorry that it didn’t work for you - appart for some obvious checks (Did you restart HA after the edit ? Did you edit the correct _init .py ? (Carreful there are two of them - one in the root of the “localtuya” folder, and one in the “pytuya” folder - that’s the one you need to edit, the second one) I am not sure I can help.
(Do you know if your device(s) are 3.3 or 3.4 firmware ?)

To everyone else : just for information, after 7 months of using my “fix”, it still works, perfectly (no “unavailable” problems, it updates at the interval I specified, and after checking my electricity usage bills and details, it’s exactly the same values as measured in HA, so it doesn’t “miss” any power values - or at least not enough to me measurable).

(For more information : I mostly use “ANTELA” brand plugs - EU ones, and a few TONGU (or other brands but same device) TO-Q-SY1-JWT

The TO-Q-SY1-JWT are all 3.4 - the ANTELA EU plugs are 3.3 or 3.4 (the first one I purchased in october / december where 3.3, but since the begining of the year 2024 all the one I received seem to have the 3.4 firmware)

Ok more information about “my” “fix” of including “3.4” in the list of supported firmwares for the “update_dps” function in localtuya.

I was curious if I should say something to the localtuya integration creators on github to ask them if they should include 3.4 in the update_dps function back in january, but I thought it was so obvious it was likely just a question of time - they would obviously do it so I would not bother them (I don’t even really know how to do it “the right way” lol).

But this thread got me curious, so I went to github and looked at the code for the update_dps function, and … they did it already … more than 18 months ago ?
(the line 820 is already “if self.version in [3.2, 3.3, 3.4]:” - you can go look it up https://github.com/rospogrigio/localtuya/blob/87d61eea6f4189bf1dc01614534e1fff84db4a7f/custom_components/localtuya/pytuya/init.py - the change is dated Jan 18th 2023

So it’s not “my” fix at all lol (not that I thought I was the only one who found and edited the line, but it’s official : they already did it before I even bought my Pi and was confronted with the “bug” of 3.4 devices not updating

But … my install of HA was end of 2023, then I reinstalled everything on a new Pi 4 in march … and I still had to edit it myself …
And less than a month ago, I installed a new HA on a new Pi 4 on a new location, and still … the update_dps did not include 3.4 …

So I just checked a few minutes ago - made a completely new install of HA, then SSH addon to install HACS, then install HACS, then install localtuya, then File Editor, and I used it to go look at line 820 and … the update_dps function does NOT include 3.4 !!

So I checked if maybe HACS directed me to a different depot of localtuya - but no, it’s the “rospogrigio” one, the same one I just checked on github - it should include 3.4 in the update_dps function !

I’m relatively new to HA and HACS, and I only ever used HACS to install localtuya, so maybe there is something I don’t understand - can someone explain it to me ? It looks like HACS doesn’t install the latest version of localtuya - or at least not the latest version of the “pytuya” part (the custom_components/localtuya/pytuya/__init__.py file)

Bottomline : localtuya SHOULD update 3.4 devices at the specified interval out of the box - the code on github has been updated more than 18 months ago - you should never have / had this problem with localtuya … but for some reason if you install localtuya from HACS, you don’t get the latest version of the code.

Can someone tell me if they know why ? Is it normal and I am just not understanding how HACS install integrations and get the last version of them, or should I mention something to someone ?

Hi Matt. Sorry, not answering your question. But was wondering if you have tried Tuya-Local from hacs (not localtuya). The one here:

…it works for me. Probably with firmwares 3.2, 3.3 and 3.4 (at least all my devices are updating), and last version is from last month. Seems better updated.

It will be good to know from you, that knows this problem deeply, if Tuya-Local works for you out of the box. It will help others to know which hacs addon to install preferably.