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
Support for Home Assistant Energy dashboard #307
Comments
https://developers.home-assistant.io/blog/2021/05/25/sensor_attributes The question is do we really need to mark all of currently supported sensors as |
@molnarti & @skynetua do your Tuya power devices (entities) show the correct wattage and volts? All my power devices (light switches and power points) show incorrectly. For example Volts show as 2314V instead of 321.4V and watts show as 2341W instead of 234.1 |
@mycrouch I don't have any but it seems bugged after ececdc1
Digged a bit deeper and seems like not all devices provide scale factor for integer value. |
@mycrouch i have no problem with my tuya devices, they show the correct voltage even with version 1.4.2 |
@mycrouch Can you provide your device info and device specification from the logs? |
This is the log for a power point { Log for light switch { |
I've been digging through the code and in the sensor.py there is the following, should the code __state = (__value) * 1.0 / (10 ** __value_range.get('scale')) divide the power data by 10 thus giving the correct output?
|
Be great to get power monitoring plugs available in HA Energy Dashboard - they are currently reading correctly within Tuya2 however not available to HA Energy. |
@jstott1070 unfortunately HA devs limited it to work only with energy monitoring devices. Power is not supported right now. I haven't seen energy reporting plugs by Tuya so far, only energy meters and circuit breakers. |
I would love to see Tuya update the integration to support HA's new energy dashboard. All my Tuya light switches and PowerPoints give me power consumption (even if it is currently wrong data) |
I've corrected the power data by creating a sensor template for each device. It was painful but the data is now showing with a decimal point. ie 36.2 w
|
Not sure i really understand. Currently in Tuya i can see Watts, Current and Amps but also kwhs - in HA i dont get the kwh which is really the valuable part of the monitoring. |
@jstott1070 yeah, kWh is needed in HA. Could you post your logs from ha? https://github.com/tuya/tuya-home-assistant/wiki/How-to-Get-the-Log?_source=f75a22f47cc75545545c239077c07e53 |
I wonder if you can track the kWh using the HA Utility Meter. https://www.home-assistant.io/integrations/utility_meter/ After all kWh is just power over time. |
No, utility_meter just follows what you set in source and not convert it: You will be able to do this with template sensor when HA devs add option to define last_reset attribute for it. |
So in Tuya i see the following: However in HA the kWh is not coming through. Logs attached. |
@jstott1070 there is add_ele value in logs, that reports kWh
This is probably Today (kWh) but the value seems a bit strange @tsutsuku I don't see any information about |
@skynetua the 22490 value is the total power usage which is indicated next to the right of the voltage in the app. This is a sum of the previous months values. I see this as 22.50 kWhs |
@jstott1070 that's nice, I'll add it in the next PR for energy monitoring. |
Will this mean that this value will be calculated in Tuya but passed to HA or will HA be able to use the deltas between the opening value and the current/live value to get a measure of usage within a time period (controlled by HA)? Sorry if this is a silly question - just trying to get my head around how this works. BIG Thank you for all your hard work on this!. |
Yes, HA will handle all calculations based on sensor updates delta as soon as we add support for new energy statistics. |
Great stuff - thank you!.. |
@jstott1070 I created a "dirty" fix there https://gist.github.com/skynetua/4bcb6640582a8a730aa48e228b8ad3f9 Can you replace it with your HA file |
Installed and sensors now available to HA Energy - no readings showing as yet but it can take some time to update so will check back tomorrow. The sensors are pulling though the total KWhs however i expect the Energy module to interpret the data. Oddly, i cant see anyway in the Tuya App to reset the log period but thats probably for another thread elsewhere. |
I've added the updated sensor.py Seeing new energy sensors now |
Yeah, new sensors now available and pulling info into HA Energy dash👍🏻 |
@skynetua I'm seeing data in the energy dashboard now. However, the figures are nowhere near accurate. One PowerPoint is reporting 100kWh. I'm certain this is a result of the previous issue of the integration not reporting the correct power data. Even if the figure is divided by 10% it's still way higher than it should be. 28kWh for a single PowerPoint is more than my daily household use. Even 2.8 would'nt be accurate. Any ideas? |
Hi @msteingr I just updated the discussion topic here -> https://github.com/AlexxIT/SonoffLAN/discussions/569 - hope it helps. |
From what i observed about the add_ele DP Code, the device on a regular basis (from my graphs - every ten mins when on i think) reports the delta consumed energy (from previous reporting time) to be added to the total energy. I suppose the Tuya API adds this delta energy to the total energy that you see in the app (and also adds under daily and monthly counters). To implement the same in HA, one can create a MQTT sensor (says Total_ele) and add an automation (on state change of add_ele) to the add the add_ele to the Total_ele and publish to Total_ele MQTT sensor. Then use a utility meter based on Total_ele sensor to create daily/weekly/monthly sensors as needed. The only problem i see with the automation is that if the delta energy between two reporting period is same, HA will not see it as a state change, the automation will not be triggered. While defining the Total_ele MQTT sensor, you should include the state class as "total_increasing", so it will be included for long term stats and can be added to energy dashboard. |
@madtech360 The issue is that different mnufactures use Tuya documentation states:
@tsutsuku do you have any thoughts about standartizing this? |
@madtech360 : I concluded the same yesterday and implemented it using a slightly different approach to an MQTT sensor - it appears that the update interval for the add_ele entry in the device log is different - based on how much energy the devices connected to the plug are utilizing. I can also confirm that the problem you highlighted of automation not always triggering - this was visible on 1 device with a more or less standard power draw did not trigger on 2 occasions and thus total values were different. It did however work well / accurately on another plug where the connected device's energy consumption fluctuates. |
@skynetua : It is possible there is non-standardization here. I see for the few of the users, the add_ele seems to be reporting the delta energy. It seems to be working fine for now for me. I am going to wait and observe for few more days to check if HA calculated consumption is same as the total reported in the app. @nduzaone: Thanks for confirming. Curious about your different approach to MQTT sensor. My HA knowledge is limited. BTW with the current code in the master branch, i had to tweak the sensor.py to be able to add all the sensors to HA ( see issue #449) |
@JinksKid i have the same issue - the dirty fix makes the smart plugs (gosuna UP111 in my case) show up, but i get the same error "The following entities do not have the expected state class 'total_increasing" "sensor.ty16005218c4dd572f4c50_4 (measurement)" |
@skynetua utiliy_meter is not suming sensor value when it's decreasing. |
What I ended up doing is to follow what was done here: 2021.8.0: Feel the energy <https://community.home-assistant.io/t/2021-8-0-feel-the-energy/326853/407> ⚡️ - Blog - Home Assistant Community (home-assistant.io)
So add this to your config yaml
sensor:
- platform: integration
source: sensor.dryer_power
name: energy_dryer_kwh
unit_prefix: k
round: 2
Change the sensor to be the power sensor from tuya
Then I can add this into my energy monitor no issue
From: Guillaume Lahaye ***@***.***>
Sent: 13 September 2021 10:35
To: tuya/tuya-home-assistant ***@***.***>
Cc: aberkeley ***@***.***>; Comment ***@***.***>
Subject: Re: [tuya/tuya-home-assistant] Support for Home Assistant Energy dashboard (#307)
@skynetua <https://github.com/skynetua> utiliy_meter is not suming sensor value when it's decreasing.
Reading the STATE_CLASS_TOTAL_INCREASING documentation <https://developers.home-assistant.io/blog/2021/08/16/state_class_total/> seems covering it. How could I modify the "dirty fixe" in order to test?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#307 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/ARQGZX4GSM3OP476O3HRWFLUBXATPANCNFSM5BR75LMQ> .
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub> . <https://github.com/notifications/beacon/ARQGZXYGDJRK45S42F7GKETUBXATPA5CNFSM5BR75LM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOG234C5A.gif>
|
@lahayeg you can change line 523 to Probably it will not work as you want anyway. The better solution in this case is Statistics integration |
Already tried (with the 3 methods) and does not report same result that app |
I will try but seems that already implement it in your PR !! |
@lahayeg : Did you try to approach i have mentioned here? Works without issues for me and for @nduzaone #307 (comment) Some screenshots here: If you need yaml of my setup, I can share. |
@The-IcEDFiRE it will, the feature hasn't been merged yet to the master version. |
Awesome, thanks! |
@madtech360 yaml gist -> Yes please! |
@madtech360 Apologies for the late reply, my approach was probably more roundabout and likely not the most efficient but I get results. Just 2 things I have noted - which can help some people -
I have concluded that my readings may not match up completely because of the 2 items above - but they're still close enough for my information tracking purposes. Approach Step 1 Step 2 —> copy the value from (3) into (2) Step 3 Step 4 Step 5 |
@lahayeg MQTT Sensor to keep track of Total Consumed Energy -> Equivalent to Total Ele(kWh) in the Smart Life App
Note: I have set the state class of this MQTT sensor to total_increasing. This makes the sensor eligible for long term statistics and also makes it available in the energy dashboard. Automation to add the Add Ele to Total Consumed Energy
Note: Replace sensor.Fridge_Add_Ele with the Add Ele sensor created from the dirty fix. I am not using the dirty fix, i created my own fix which i have included in the PR #452 Known Issues:
Utility Meter to keep track of Daily and Montly Consumed Energy -> Equivalent to the Monthly Counter and Daily Counter(graph) in the Samrt Life App
|
Please look at #495 |
since the commits regarding energy haven't made it to a new release yet, I overrode sensors.py from master to HA but it breaks everything. Before the plugs were reporting W, A, V whereas with new sensor.py those sensors become completely unavailable and no new sensors for kWh are created |
@drthanwho you can replace it with this till the next update |
thanks a lot @skynetua that seems to work perfectly! Are we ever going to see that in the Core version that was just added in HA? That one seems to be even more behind since my plugs don't even show power, voltage and current when I tried to migrate to that one Also is the energy added in the new entity supposed to be today's ele? As I don't the value reflect the value from the app |
I believe it will be merged to the core before the next release. |
I am guessing this wasn't merged to the core (official) version? Migrated from V2 to official and lost all power data on the plugs, only showing a On/Off toggle now |
I saw the same thing as well. And if this repo is no longer being maintained not sure why the functionality hasn't made it to Core Tuya yet. Also even though with Tuya V2 power/current/voltage show up correctly, even though an energy sensor is now available its value is not correct |
It has, will be released with Home Assistant 2021.11 |
Looks like there's voltage/current/power information in 2021.11, but not not energy consumption information (ie, kWh). I thought the new Tuya HA integration was just pulling in this Tuya v2, but I'm guessing it's not quite that simple since #464 looks like it added energy consumption back in September to this repo but it's nowhere to be seen in the HA/core repo. |
Home Assistant added a new Energy dashboard in version 2021.8, but it seems the devices provided via the Tuya v2 integration are not supporting it, as they are not visible when trying to add a device to the dashboard.
More info about the issue here: https://www.home-assistant.io/more-info/statistics/ and here https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics
edit: it seems I accidently tagged this issue as a bug and can't change it. should be enhancement
The text was updated successfully, but these errors were encountered: