-
Notifications
You must be signed in to change notification settings - Fork 569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Energy monitoring not refreshing #87
Comments
Make sure you are running version 3.0.0 of this component. All versions prior to that polls the device every 30s (I think it's every 60s for 1.2.0 and earlier). That makes it quite unreliable. |
I AM using the latest version, but it doesn't solve it... I was hoping this one would solve it, as it didn't work well before :) |
Can you enable some logs and provide us? |
Which logs do you have in mind, HA general logs or plugin specific? If plugin specific, how do I enable them? |
The ones for localtuya I would say. Should be something like: logger:
default: warning
logs:
custom_components.localtuya: debug |
Done... I kept it running for a few minutes and tried to switch on and off some of the plugs. Shall I post the log here (privacy concerns because of IP number, MAC adresses, ID's,...) or shall I send it to some email address? |
You can send the logs to me by email, probably better from privacy perspective 👍 |
Just to make sure... did you receive my mail with the log and is the log long enough? I sent it to the mail address from your profile... |
@AdmiralStipe Ah, yes, sorry for not givning any feedback. I have received it and will have a look at it ASAP. |
I sent you an e-mail with more detailed description, as I'm afraid, I didn't explain my issue properly. |
So, If you don't mind I would like to try to fiddle with the code myself a little bit (I'm no programmer, but I can do some light customisation stuff). I would like to try to force my smartplugs to send full status report (all available dps) whenever the switch status (dps 1) changes.
|
I got the same issue. Any progress on this? :) |
I will try to get back on this horse soon, but I have a few other matters I need to attend first. @AdmiralStipe I will try to give a short explanation once I'm done with what I'm working on. |
I got the same issue as well. |
I have exactly the same issue! Hope this gets resolved soon. Keep up the good work :) |
If anyone has any idea on how to move forward, feel free to try them out. I don't have any clues at the moment😕 |
@AdmiralStipe OK, so, fiddle away and see what happens 🙂 The initial status update (where an entity requests the state of all datapoints) is done here:
Whenever a status update is received from the device (by pytuya), this callback method is called:
The It's also worth knowing that all this logic is handled by an instance of
It's of course possible to hook directly into pytuya and fiddle around, but the external interface is what recommend that you use. My last two cents here are that I don't think it's gonna work to request all datapoints at this point as I believe that it will just respond with whatever has already been reported. But who knows. |
Oh, I see... I thought I will be able to detect whether only dps1 or also other datapoints are included in a variable.... |
It's possible to do that from within pytuya, but I changed it to keep a cache of every DP and just pass that along to the listener because of some problems we had. Can't remember which issue number it was related to now. But that's how it works currently. |
I think the issue is that the device does not automatically report changes to any of the “measurements” like voltage, current and power. This is logic as these values change very often and would otherwise flood the communication channel. Probably we need to actively poll these values from the device (e.g. every 10s). No idea how to do it though. I however know that other devices in Home Assistant allow to define a polling interval in their configuration. |
I tried a few different things and I failed, as expected :). |
@AdmiralStipe It's possible, I made a prototype in #117. When adding a Feel free to try this out, maybe it can help us getting further (it's not a complete solution, just a PoC). You will need to remove and re-add and previous devices having a |
Tried it with great hope and expectations :), but unfortunately my report is not so cheer. |
I was kinda expecting that result. Found this issue which sounds exactly what you are experiencing: However, it was closed with the "solution" to kill the app and never open it again. Not sure that makes any difference... Try to put some additional effort into sniffing the app traffic with be a good step. Another thing that I would personally recommend trying is to set up a developer account at tuya and re-pair the device that way (that's how I do it). This will prevent you from using smartlife though, but I wouldn't be surprised if it worked. |
I agree, sniffing traffic and finding out what exactly happens when the app demands status update would be good - unfortunately I don't know how to perform it effectively... I've heard of Wireshark and similar stuff, but I don't have an idea how exactly to set everything up and furthermore, what and how to capture then. If I only capture some encrypted garbage, it will be of no help for sure. |
@postlund, by the way, if I open developer account and re-pair the devices (and you said I won't be able to use the app anymore) - how do I get the localkey then? Now I got it from the android app, so are there other ways to get it as "developer" - maybe directly in the develoepr profile somewhere? |
@AdmiralStipe I followed this and used tuya-cli to register my devices: https://github.com/codetheweb/tuyapi/blob/master/docs/SETUP.md |
OK, great, but I have another question - after following the guide and registering as developer, already in Step 1 I only have the possibility to use Cloud develompent as free trial (until July 2021). What happens after that, will everything continue to work or will I be forced to pay for Premium to use these functions? |
I think that everything you need to register new devices will still work after that. Seems to work fine for me. |
Anyone tried the new tuya V2 yet? It should have local support real soon. But I don't know if this will fix it. Going to try it tonight to see if it works. |
Didn't try it yet, as I really don't want to edit all my automations and everything with new plug names, however I'm really interested in knowing, if energy monitoring works for my plugs (Robaxo) and how big is status-change delay when switching the plugs. In any case, I will remain with localtuya for sure until official Tuya supports local mode. Then it depends... if energy reporting on demand still won't be supported here (it now seems that it won't), I will most likely switch. |
What is this Tuya V2 you are talking about? |
|
Too bad. Doesn't work. It's even worse now. Power measurements don't change even if I have the smart life app open. And if I turn it off via smart life it doesn't change on home assistant. Already pushed out an Issue for this. |
Ok so I got a tip to make it work. And for me the Tuya V2 works like a charm. Every 30 seconds the power consumption is refreshed. No way to edit it but 30 seconds is fine for me. Now we just have to wait until they make local Tuya available |
So, would you mind sharing this tip you got? I'm keen on using it, as 30secs refresh is enough for me too, no need to have it more frequently, but unfortunately all my devices become unavailable when using Tuya v2... |
First of all. You can use local tuya and tuya v2 next to each other. So testing should be easy. Now restart HA and the tuya devices should refresh every 30 seconds. |
Great, thx a lot, will try it as soon as I come home (on vacation atm). |
I tested it and switched off the TV. When I went to integrations/tuyav2/TV plug it was off. So not more then 10 seconds |
Perfect, can't wait to try it... if this will work, then we only have to wait for them to enable local mode and then we have the native improved Localtuya 😁 |
Works!!! Thank you very much for the help. Tested for 24 hours with a washing machine and home assistant records the variations without the need for the application from the mobile. Tested with LocalTuya. However, I do not have functions such as daily consumption, while with tasmota I do. So I'm waiting for my ESP8266s to arrive to change the WB2S chip that it brings. |
Same here.... only it didn't last couple of hours, but minutes instead :(. Or probably better to toss these shitty Chinese plugs to garbage and get some proper (not Tuya) ones... |
@AdmiralStipe Sorry to hear you are having so much trouble but i want to see if I summarize your situation. You
please correct me i am just trying to make the situation clearer to diagnose the issue. I am not a programmer either. I however got 2 plugs working very reliably.Bn-link plugs
I have 3 brands of "tuya" devices Feit dimmer, BNLink power monitoring plugs, Feit plugs(most unstable maybe wifi issue with aimesh). As of 2021.7.3 all of them are working very reliably. With exception of the monitoring plugs I disable all their internet. Edit I remember a few extra things:
|
The answer to all questions is Yes :). As already stated, obviously my plugs are shitty and I'm getting sick of trying, experimenting and waiting for partial solutions and it it will be better (at least for my mind peace :) ) to just replace them with something better. |
Sad to notice that at least my own smartplugs with energy consuption will not update at all without Tuya App. This is not only LocalTuya issue. I did remove one of my smartplugs from LocalTuya and followed the 18,19,20 values with tuya-cli and noticed that values will not update at all (load or without) in the smartplug. Only when smartplug was connected to internet and I was using Tuya App, those values was changing in DPS @ smartplug. |
I've recently purchased some Kogan SmarterHome Plugs with Energy Monitoring (same as a few in this thread). Is there any need for diagnostics like Wireshark, or do we know what the commands being sent are and are waiting for coding and PRs? My devices are NOT local-only, and my Android device is not rooted so my ability to get Wireshark captures may be limited, but I'm an IT engineer (infrastructure, not coding) so I'm not inexperienced. |
I have the Kogan SmarterHome Smart Plug With Energy Meter & 5V 2.4A USB Ports and have the energy monitoring data working with both localtuya and Tuya v2. With localtuya, there is the patch to apply UpdateDPS at each heartbeat interval and with Tuya v2, I used the tinytuya script that sends the UpdateDPS command at a configurable interval (set in the script). |
PR #491 does not appear to fix my issue for getting power/energy data with the same "Kogan SmarterHome Smart Plug With Energy Meter & 5V 2.4A USB Ports" devices. DP 19 |
I used PR#549. There are 2 files involved. |
Working perfectly, thanks @joe-sydney |
This is working awesome! I've put the details here: #549 |
Solved with #549 :). |
Energy monitoring sometimes refreshes the very second the switch toggles, but sometimes it doesn't refresh at all. Heater in the smartplug is running, but the current and current consumption show 0, or vice-versa (heater is off, but the consumption shows 10A / 2300W). Restarting HA may or may not help resolving it (cca 50% success rate).
Additional issue for me: status changes (from physical buttons) are not instant, instead they take from 10 to 30 seconds (as before the last release).
System
Operating system
Raspbian GNU/Linux 10 (buster) on Raspberry PI 4B
Docker version
19.03.13
Supervisor version: 247
Host system version: Home Assistant 0.116.3, running on Raspberry Pi 4B in Docker (Supervised install)
The text was updated successfully, but these errors were encountered: