-
Notifications
You must be signed in to change notification settings - Fork 543
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
Allow energy entity from switch #932
Comments
The problem with add_ele is that it resets to 0 every time it connects to Tuya and uploads the usage data you would need to block the device from connecting to Tuya to use it. |
Oh, well now it makes sense that it's not used. That's pretty inconvenient! |
Mine (an Arlec 'Grid Connect' switch from Bunnings Australia) doesn't seem to work the way jasonwragg describes. As best I can determine, dp_id 17 "add_ele" consistently seems to hold the most recent value that was sent to the Tuya cloud (which it does every half an hour). Unfortunately, asking the device to 'update_dps' with dp_id 17 never results in it returning an updated value - only asking for 'status' (i.e. of all dp_ids) seems to give a current value. And therefore it looks like it contains useful data when adding a device - the figure shown matches the reported 'Add Electricity' figure in the Tuya cloud history. But it is never updated when asked using update_dps. In theory, at least, if I could retrieve the value of dp_id 17 every half hour (using 'status', perhaps?), I could sum the results to determine energy usage with reduced risk of error. (My use case is thermostat-controlled espresso machine, which when idle has a short on cycle and a long off cycle.) |
I'm seeing the same behaviour as @biffel describes using a Mirabella Genio Smart Plug with energy monitoring (the newer ones with the power button on the same face as the plug itself, the older ones with the power button on the top of the plug do not appear to have dp_id 17 at all, only 18-20). I thought maybe setting a scan interval would force it to refresh, but no dice. Would be nice to have proper energy monitoring of tuya plugs. |
I have a box of four from Bunnings, purchased about two months ago - and it looks like two of the units in the box produce dp_id 17 (the first two I configured), and two don't (which I configured later). I can't explain this, or whether there is something I have done accidentally to reach this outcome. All four have the power button on top. Regardless, I agree with the point @nvx makes: 'Would be nice to have proper energy monitoring of tuya plugs.' |
I have same issue that dp_id 17 is not decoded. Turned on debug level logging, removed all localtuya devices from the integration, and try to re-establish connection to one of them. This is the result:
The messages are decoded correctly so the local key is ok, but DPS 17 is not on the decoded list. When I compare what can be decoded (say - DPS=18) and what is not (DPS=17)
there is one (and only one) thing that stands out to me: that "kW·h" with that dot between "W" and "h" - I wonder if the current code cannot handle this character and so abandons dp_id = 17. I dont know what character that is but it is clearly not a "fullstop . ". The same dot exists in @alexeiw123 message above. The units I have are also "Arlec White Grid Connect Smart Plug In Socket With Energy Meter" with model PC191HA, also bought from Bunnings. Edit: I have isolated my ESP32/Tuya WiFi AP so devices on that network do not have access to cloud (thats one good reason to have LocalTuya) so the problem mentioned by @jasonwragg is (should?) not be relevant to me |
ooh, I'm guessing that's a unicode character. Is something breaking when non-ascii characters are encountered perhaps? |
spent some time looking at some of the code, based on my very limited knowledge it appears the segment like mentioned (obtained from Tuya's website) seems to only describe the DPD:
And so the "kW·h" has nothing to do with what the device sends out as regular updates. In all likeliness the actual update just contains something like the log above sample what that means is: my suspicion above is probably wrong, and the device is in fact not sending out DPD=17 within its updates, and needs some sort of triggering for it to be sent. |
I know this is sort of old / perhaps stale, but why not just move on and create your own energy consumption sensors using Reimann Sum Integration integration and then use the utility_meter integration to create daily/monthly values for energy use? I trust HA to do this better than Tuya anyway... I use a split config so if you don't then need to fix indentations. I also create separate power, current and voltage sensor entities for all my devices in LocalTuya as I like it this way. Can do this pulling attributes if you don't do it this way. inside sensors.yaml
inside utility_meter.yaml
|
That is how I'm doing it, and it works 'ok'. The issue is that the some of these tuya smart plugs have pretty crude power update intervals. My assumption is that the built in register for energy accumulation will be more accurate than an integration of a very coarse plot of power every few minutes. |
oh wow - can't believe I haven't played with this.
From documentation: "Setting the scan interval is optional, it is only
needed if energy/power values are not updating frequently enough by
default. Values less than 10 seconds may cause stability issues"
Have you tried lower than 30s? I've got a pile of tuya energy monitors,
I'll give this a shot.
…On Thu, 8 Dec 2022 at 11:44, tbgoose ***@***.***> wrote:
When setting up any power monitoring device in Local Tuya, force 30s for
the update interval. Can do this without having to set the whole device up
again.
[image: Screenshot 2022-12-08 10 41 55]
<https://user-images.githubusercontent.com/11631657/206328378-fd7442cc-b671-4c50-b178-a6c64073ab6c.png>
—
Reply to this email directly, view it on GitHub
<#932 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASRURBLA7FNCQ76MUFZDU4DWMEVNXANCNFSM52RK6SRQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Nope I just read the docs and picked the default. I think thats probably fine grained enough to get a pretty good idea. Although I guess you could argue that it might miss a whole kettle brewing if its only 2 cups... Maybe I should try reduce to 15s... |
I'll take a backup, start at 15 and work my way up. The other DPs aren't showing up when I edit the configuration so I'm mindful that something might break! |
15s seems to work fine. Probably a worthwhile change as it effectively doubles the accuracy of the consumption values. |
The problem
Using smart switch PC191HA, have set up and created energy entity using Riemann sum integral method. Issue is that polling frequency is very low and this likely to introduce inaccuracies.
From Tuya developer account, one of the available "dp_id" is the device's own register of energy (see below).
Having a field in entity set up to declare energy would be both easier and likely more accurate. I assume other tuya smart switches have the same.
-->
Environment
The text was updated successfully, but these errors were encountered: