Open molnarti opened 3 years ago
https://developers.home-assistant.io/blog/2021/05/25/sensor_attributes
I tried to play with it in sandbox and it works well. Basically just 2 attributes has to be added to sensor.py
- state_class
and last_reset
The question is do we really need to mark all of currently supported sensors as measurement
?
Another one - does any of currently supported sensors report the real reset timestamp or we can default it to None?
@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 Tuya engineer told me it's not a bug. However somewhat useless that way it is.
@mycrouch I don't have any but it seems bugged after https://github.com/tuya/tuya-home-assistant/commit/ececdc12cc1bed16c9e0a86a097538e350c1647d
Description of scale parameter
The following is an example of the constraint on the present voltage value. scale value is 1.
If the value obtained by querying the device status is {"cur_voltage":2230}, then the user-readable value is 2230/(10^1 )= 223V (the voltage is 223 volts).`
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
{ "active_time": 1591863995, "biz_type": 0, "category": "cz", "create_time": 1591863995, "icon": "smart/icon/1492863365_0.png", "id": "83767607a4cf12a3ef07", "ip": "xxx.xxx.xxx.xxx", "lat": "-27.65952312573868", "local_key": "xxxxxxxxxxxx", "lon": "xxxxxxxxxx", "model": "单色LED灯", "name": "Bathroom - Power Point", "online": true, "owner_id": "2286669", "product_id": "eeqdSYkbi9u2W3Kt", "product_name": "Double Power Point", "status": [ { "code": "countdown_1", "value": 0 }, { "code": "add_ele", "value": 23 }, { "code": "cur_current", "value": 0 }, { "code": "cur_power", "value": 0 }, { "code": "cur_voltage", "value": 2468 }, { "code": "test_bit", "value": 1 }, { "code": "voltage_coe", "value": 607 }, { "code": "electric_coe", "value": 26421 }, { "code": "power_coe", "value": 15407 }, { "code": "electricity_coe", "value": 1350 }, { "code": "switch_1", "value": false }, { "code": "switch_2", "value": true }, { "code": "countdown_2", "value": 0 } ], "sub": false, "time_zone": "+10:00", "uid": "xxxxxxxxxx", "update_time": 1627835446, "uuid": "xxxxxxxxxx" },
Log for light switch
{ "active_time": 1619146422, "biz_type": 0, "category": "kg", "create_time": 1559276275, "icon": "smart/product_icon2/kg_1.png", "id": "38042678840d8e9504db", "ip": "xxx.xxx.xxx.xxx", "lat": "-27.65952312573868", "local_key": "xxxxxxxxxx", "lon": "xxxxxxxxxxx", "model": "", "name": "Bathroom - Light Switch", "online": true, "owner_id": "2286669", "product_id": "XsB7wAYuXZRNPMcG", "product_name": "Three Switch", "status": [ { "code": "switch_1", "value": false }, { "code": "switch_2", "value": false }, { "code": "switch_3", "value": false }, { "code": "countdown_1", "value": 0 }, { "code": "countdown_2", "value": 0 }, { "code": "countdown_3", "value": 0 }, { "code": "add_ele", "value": 0 }, { "code": "cur_current", "value": 0 }, { "code": "cur_power", "value": 0 }, { "code": "cur_voltage", "value": 2474 } ], "sub": false, "time_zone": "+10:00", "uid": "xxxxxxxxxx", "update_time": 1627835452, "uuid": "xxxxxxxxxxx" },
@mycrouch I don't have any but it seems bugged after ececdc1
Description of scale parameter The following is an example of the constraint on the present voltage value. scale value is 1. If the value obtained by querying the device status is {"cur_voltage":2230}, then the user-readable value is 2230/(10^1 )= 223V (the voltage is 223 volts).`
Digged a bit deeper and seems like not all devices provide scale factor for integer value.
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?
@property
def state(self):
"""Return the state of the sensor."""
return str(self.tuya_device.status.get(self._code))
__value = self.tuya_device.status.get(self._code)
print(self.tuya_device.status_range.get(self._code).values)
if self.tuya_device.status_range.get(self._code).type == 'Integer':
__value_range = json.loads(self.tuya_device.status_range.get(self._code).values)
__state = (__value) * 1.0 / (10 ** __value_range.get('scale'))
if __value_range.get('scale') == 0:
return int(__state)
else:
return f"%.{__value_range.get('scale')}f" % __state
return ''
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.
@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
entry_lightswitch:
friendly_name: 'Entry - Light_power_w'
unit_of_measurement: 'w'
value_template: '{{(states.sensor.ty57210084500291442b65_2.state | float / 10 | round(1) )}}'
@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.
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
@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:
# Example configuration.yaml entry utility_meter: energy: source: sensor.energy_in_kwh
You will be able to do this with template sensor when HA devs add option to define last_reset attribute for it.
@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
So in Tuya i see the following:
However in HA the kWh is not coming through.
Logs attached. Tuya Logs.txt
@jstott1070 there is add_ele value in logs, that reports kWh
"code": "add_ele",
"type": "Integer",
"values": "{\"unit\":\"kwh\",\"min\":0,\"max\":100000000,\"scale\":3,\"step\":100}"
This is probably Today (kWh) but the value seems a bit strange 'add_ele': 22490
can you compare it with the value you see in app scaled to 1000?
@tsutsuku I don't see any information about add_ele
in Standard Status Set for cz. Do you know what is it?
@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 /config/custom_components/tuya_v2/sensor.py
and check if everything is ok, including new energy dashboard? It works ok with my energy meter.
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.
@jstott1070 I created a "dirty" fix there https://gist.github.com/skynetua/4bcb6640582a8a730aa48e228b8ad3f9
Can you replace it with your HA file
/config/custom_components/tuya_v2/sensor.py
and check if everything is ok, including new energy dashboard? It works ok with my energy meter.
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?
@mycrouch post your log for wrong devices.
This is the one that's showing very high
"active_time": 1619146940,
"biz_type": 0,
"category": "cz",
"create_time": 1618812084,
"icon": "smart/icon/ay15266175008440Qseh/2e27613c13fba9c5f64d1a44f34aa155.png",
"id": "xxxxxxxxxxxxxxxxxxxxxxxxx",
"ip": "***",
"lat": "***",
"local_key": "***",
"lon": "***",
"model": "双色LED Double Power Point",
"name": "Kitchen - Stove Power Point",
"online": true,
"owner_id": "2286669",
"product_id": "nma7ep8nzegzwyjh",
"product_name": "Double Power Point",
"status": [
{
"code": "countdown_1",
"value": 0
},
{
"code": "add_ele",
"value": 77
},
{
"code": "cur_current",
"value": 0
},
{
"code": "cur_power",
"value": 0
},
{
"code": "cur_voltage",
"value": 2272
},
{
"code": "test_bit",
"value": 1
},
{
"code": "voltage_coe",
"value": 627
},
{
"code": "electric_coe",
"value": 27888
},
{
"code": "power_coe",
"value": 15952
},
{
"code": "electricity_coe",
"value": 1305
},
{
"code": "switch_1",
"value": true
},
{
"code": "switch_2",
"value": false
},
{
"code": "countdown_2",
"value": 0
}
],
"sub": false,
"time_zone": "+10:00",
"uid": "***",
"update_time": 1629100922,
"uuid": "xxxxxxxxxxxxxxxxxxxxxxxxx"
This one negative value
"active_time": 1597284152,
"biz_type": 0,
"category": "cz",
"create_time": 1597284152,
"icon": "smart/icon/1492863365_0.png",
"id": "xxxxxxxxxxxxxxxxxxxxxxxxx",
"ip": "***",
"lat": "***",
"local_key": "***",
"lon": "***",
"model": "单色",
"name": "Bedroom - South Power Point",
"online": true,
"owner_id": "2286669",
"product_id": "fp8li5uzdsc1cbx9",
"product_name": "Single Power Point",
"status": [
{
"code": "countdown_1",
"value": 0
},
{
"code": "add_ele",
"value": 4
},
{
"code": "cur_current",
"value": 81
},
{
"code": "cur_power",
"value": 72
},
{
"code": "cur_voltage",
"value": 2314
}
],
"sub": false,
"time_zone": "+10:00",
"uid": "***",
"update_time": 1629100918,
"uuid": "xxxxxxxxxxxxxxxxxxxxxxxxx"
And this one not showing any data
"active_time": 1582854378,
"biz_type": 0,
"category": "cz",
"create_time": 1582854378,
"icon": "smart/icon/1492863365_0.png",
"id": "xxxxxxxxxxxxxxxxxxxxxxxxx",
"ip": "***",
"lat": "***",
"local_key": "***",
"lon": "***",
"model": "单色LED灯",
"name": "Garage - Power Point",
"online": true,
"owner_id": "2286669",
"product_id": "eeqdSYkbi9u2W3Kt",
"product_name": "Double Power Point",
"status": [
{
"code": "countdown_1",
"value": 0
},
{
"code": "add_ele",
"value": 39
},
{
"code": "cur_current",
"value": 486
},
{
"code": "cur_power",
"value": 682
},
{
"code": "cur_voltage",
"value": 2298
},
{
"code": "test_bit",
"value": 1
},
{
"code": "voltage_coe",
"value": 609
},
{
"code": "electric_coe",
"value": 30606
},
{
"code": "power_coe",
"value": 17866
},
{
"code": "electricity_coe",
"value": 1165
},
{
"code": "switch_1",
"value": false
},
{
"code": "switch_2",
"value": true
},
{
"code": "countdown_2",
"value": 0
}
],
"sub": false,
"time_zone": "+10:00",
"uid": "***",
"update_time": 1629100919,
"uuid": "xxxxxxxxxxxxxxxxxxxxxxxxx"
@mycrouch another part, where value metrics are shown, like this one: `"code": "add_ele",
"type": "Integer",
"values": "{\"unit\":\"kwh\",\"min\":0,\"max\":100000000,\"scale\":3,\"step\":100}"`
I matched the device ID for Kitchen - Stove Power Point to another part in the logs. This this what you need?
2021-08-16 19:39:53 DEBUG (SyncWorker_1) [tuya iot] Request: method = GET, url = https://openapi.tuyaeu.com/v1.0/devices/XXXXXXXXXXXXXXXXXXXX/specifications, params = None, body = None, t = 1629106793639
2021-08-16 19:39:53 DEBUG (Thread-13) [tuya iot] _on_log: Received PUBLISH (d0, q0, r0, m0), 'cloud/token/in/333f69e7c10b87e0b508659c0dceca69', ... (348 bytes)
2021-08-16 19:39:53 DEBUG (Thread-13) [tuya iot] payload-> b'{"data":"kZVTUv8ckfW1fJROEVXDmax1OPfnaqTEVpIvns0Rna9EShVtTh5sqMTrtFZ7PAzZraNif1cTrVyRL/0dBeo8bur/j9U3ATTyw7kjMNwQPevRDdn99sEGU1Rz7wwWVfAjtDF3okt3gR4Qgzf5n0jeSteQ/EaV/n+Hzil8VftMkOSkkJbtDdeOgsZcyQi+kyzShDjoIWEaN5MFF9q6/NYqkHFgg3zno0W6A6j02HOkJTCG8IuhsM6njC33X97ZfYET","protocol":4,"pv":"2.0","sign":"9bbd78bada7c68e617e211ae024cfc06","t":1629106792}'
2021-08-16 19:39:53 DEBUG (Thread-13) [tuya iot] on_message: {'data': {'dataId': 'b759442e-8a0e-49bf-9da6-cee5a59cb74d', 'devId': '38042678cc50e3cd1843', 'productKey': 'XdGCESvXTI5Mvfx2', 'status': [{'code': 'cur_voltage', 't': '1629106792', '104': 2304, 'value': 2304}]}, 'protocol': 4, 'pv': '2.0', 'sign': '9bbd78bada7c68e617e211ae024cfc06', 't': 1629106792}
2021-08-16 19:39:53 DEBUG (Thread-13) [tuya iot] mq receive-> {'data': {'dataId': 'b759442e-8a0e-49bf-9da6-cee5a59cb74d', 'devId': 'XXXXXXXXXXXXXXXXXXXX', 'productKey': 'XdGCESvXTI5Mvfx2', 'status': [{'code': 'cur_voltage', 't': '1629106792', '104': 2304, 'value': 2304}]}, 'protocol': 4, 'pv': '2.0', 'sign': '9bbd78bada7c68e617e211ae024cfc06', 't': 1629106792}
2021-08-16 19:39:53 DEBUG (Thread-13) [tuya iot] mq _on_device_report-> [{'code': 'cur_voltage', 't': '1629106792', '104': 2304, 'value': 2304}]
2021-08-16 19:39:53 DEBUG (Thread-13) [tuya iot] _on_log: Received PUBLISH (d0, q0, r0, m0), 'cloud/token/in/333f69e7c10b87e0b508659c0dceca69', ... (412 bytes)
2021-08-16 19:39:53 DEBUG (Thread-13) [tuya iot] payload-> b'{"data":"oDIRgFd79DqOY/j6YjYl8BGbOlQUzOkQ70XYQEIYhp0gSxrQdgdDBjvFlMS0iVlyqtHUeeza/wsHW5wqcqWyH4ui7/GzwItT9zSGZeLD1MOiyKG9TETW4JxXHiGXCtFzXX93DjA+esmhHQ/C9rkGtdeQ/EaV/n+Hzil8VftMkOQ/5z8WQt4ym652AdGP48e5eksKRFv+zqhHzjXLh1XhJK+Y8O5zpo7bNNsX2hprj2AKgJK0xZqtJufSgpHewsQpF7ayPRfwVEIRsC27ULh2Wkwbl3YiPuxfOR2oZwllcxiA+tsq6Ym7tZfiP83N4NVH","protocol":4,"pv":"2.0","sign":"4a73741bf0865d5ca906ede36fddea3a","t":1629106792}'
2021-08-16 19:39:53 DEBUG (Thread-13) [tuya iot] on_message: {'data': {'dataId': '9564aedc-748d-4f6a-ab2b-97ec64449781', 'devId': 'XXXXXXXXXXXXXXXXXXXX', 'productKey': 'eeqdSYkbi9u2W3Kt', 'status': [{'code': 'cur_current', '4': 21, 't': '1629106792', 'value': 21}, {'code': 'cur_power', 't': '1629106792', '5': 39, 'value': 39}]}, 'protocol': 4, 'pv': '2.0', 'sign': '4a73741bf0865d5ca906ede36fddea3a', 't': 1629106792}
2021-08-16 19:39:53 DEBUG (Thread-13) [tuya iot] mq receive-> {'data': {'dataId': '9564aedc-748d-4f6a-ab2b-97ec64449781', 'devId': 'XXXXXXXXXXXXXXXXXXXX', 'productKey': 'eeqdSYkbi9u2W3Kt', 'status': [{'code': 'cur_current', '4': 21, 't': '1629106792', 'value': 21}, {'code': 'cur_power', 't': '1629106792', '5': 39, 'value': 39}]}, 'protocol': 4, 'pv': '2.0', 'sign': '4a73741bf0865d5ca906ede36fddea3a', 't': 1629106792}
2021-08-16 19:39:53 DEBUG (Thread-13) [tuya iot] mq _on_device_report-> [{'code': 'cur_current', '4': 21, 't': '1629106792', 'value': 21}, {'code': 'cur_power', 't': '1629106792', '5': 39, 'value': 39}]
2021-08-16 19:39:53 DEBUG (SyncWorker_1) [tuya iot] Response: {
"result": {
"category": "cz",
"functions": [
{
"code": "switch_1",
"type": "Boolean",
"values": "{}"
},
{
"code": "switch_2",
"type": "Boolean",
"values": "{}"
},
{
"code": "countdown_1",
"type": "Integer",
"values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
},
{
"code": "countdown_2",
"type": "Integer",
"values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
}
],
"status": [
{
"code": "switch_1",
"type": "Boolean",
"values": "{}"
},
{
"code": "switch_2",
"type": "Boolean",
"values": "{}"
},
{
"code": "countdown_1",
"type": "Integer",
"values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
},
{
"code": "add_ele",
"type": "Integer",
"values": "{\"min\":0,\"unit\":\"度\",\"scale\":0,\"max\":50000,\"step\":100}"
},
{
"code": "cur_current",
"type": "Integer",
"values": "{\"min\":0,\"unit\":\"mA\",\"scale\":0,\"max\":30000,\"step\":1}"
},
{
"code": "cur_power",
"type": "Integer",
"values": "{\"min\":0,\"unit\":\"W\",\"scale\":0,\"max\":50000,\"step\":1}"
},
{
"code": "cur_voltage",
"type": "Integer",
"values": "{\"min\":0,\"scale\":0,\"unit\":\"V\",\"max\":2500,\"step\":1}"
},
{
"code": "countdown_2",
"type": "Integer",
"values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
},
{
"code": "test_bit",
"type": "Integer",
"values": "{\"unit\":\"\",\"min\":0,\"max\":5,\"scale\":0,\"step\":1}"
},
{
"code": "voltage_coe",
"type": "Integer",
"values": "{\"unit\":\"\",\"min\":0,\"max\":1000000,\"scale\":0,\"step\":1}"
},
{
"code": "electric_coe",
"type": "Integer",
"values": "{\"unit\":\"\",\"min\":0,\"max\":1000000,\"scale\":0,\"step\":1}"
},
{
"code": "power_coe",
"type": "Integer",
"values": "{\"unit\":\"\",\"min\":0,\"max\":1000000,\"scale\":0,\"step\":1}"
},
{
"code": "electricity_coe",
"type": "Integer",
"values": "{\"unit\":\"\",\"min\":0,\"max\":1000000,\"scale\":0,\"step\":1}"
@mycrouch Yes, as you can see scale
is 0 for all integer sensors. This is the reason of overscaled values. I believe you should create separate issue to discuss correct solution for this.
I've logged tickets via Tuya cloud console and I've been told my power data is not a bug, it's how the device reports it.
As per my previous posts here I've had to create a template for each entity to divide by ten percent to show correct power figures in the dashboard.
entry_lightswitch:
friendly_name: 'Entry - Light_power_w'
unit_of_measurement: 'w'
value_template: '{{(states.sensor.ty57210084500291442b65_2.state | float / 10 | round(1) )}}'
Yet my devices show correctly in Tuya Smart. If Tuya engineers tell me I don't have a problem that I clearly do have, I'm not sure what else I can do except find a hack or workaround. There are others on the HA forums reporting the same issues.
For energy values scale: 3 is usually used, so you should divide it to 1000 like workaround.
There is issue #102 registered with the same problem
There is upcoming changes in state classes https://github.com/home-assistant/core/pull/54523 needed for monitoring. Lets wait for the next ha release.
@skynetua I integrated your gist but energy is not cumulative
and / or HA energy dashboard is not able to make sum. What should be done?
@lahayeg could you post logs for this device? Seems like there is some standardization issue with add_ele
component,
@skynetua yes of course: { "active_time":1619082108, "biz_type":18, "category":"cz", "create_time":1619082108, "icon":"smart/icon/15324342875tjvmpp9uw8_0.png", "id":"bfd67ca60788a7f3b995ls", "ip":"", "lat":"", "local_key":"", "lon":"", "name":"Smart socket 4", "online":true, "owner_id":"7772026", "product_id":"vnya2spfopsh9lro", "product_name":"Smart socket", "status":[ { "code":"switch_1", "value":true }, { "code":"countdown_1", "value":0 }, { "code":"add_ele", "value":23 }, { "code":"cur_current", "value":7 }, { "code":"cur_power", "value":7 }, { "code":"cur_voltage", "value":2370 } ], "sub":false, "time_zone":"+02:00", "uid":"***", "update_time":1629311369, "uuid":"8c2abe7a62764c4f" }
@lahayeg let's test it in the next HA release. Changes in calculation and reset time have been already made.
Unfortunately I can see the sensors, but I cannot add them in the energy menu, they are not present in the drop-down menu. Any idea?
@ripperhack this hasn't been fixed yet, please wait for the next update.
Hello sorry to ask I was wondering and stumbling in this comments, I have bought 8 Tuya plugs for the only reson to have them added into my energy dashboard, but cna get it done , they show only up as simpe switches using the tuya integration , if i try to integrate in Local Tuya i see different optins but none of it show KWH? so any help would be great..
@msteingr assuming your running Tuya V2 then you should apply @skynetua's "dirty fix" for now until it's fully incorporated into an update.
"@jstott1070 I created a "dirty" fix there https://gist.github.com/skynetua/4bcb6640582a8a730aa48e228b8ad3f9
Can you replace it with your HA file /config/custom_components/tuya_v2/sensor.py and check if everything is ok, including new energy dashboard? It works ok with my energy meter."
After applying @skynetua's "dirty fix" only one model of smart sockets shows accumulative power consumption, while the other ones don't (both did report real time power consumption). EDIT: The one working is: https://amzn.to/2WvT2tG The one is not is: https://amzn.to/3BgyEM7 (Looking at generic model names atm)
@msteingr assuming your running Tuya V2 then you should apply @skynetua's "dirty fix" for now until it's fully incorporated into an update.
"@jstott1070 I created a "dirty" fix there https://gist.github.com/skynetua/4bcb6640582a8a730aa48e228b8ad3f9
Can you replace it with your HA file /config/custom_components/tuya_v2/sensor.py and check if everything is ok, including new energy dashboard? It works ok with my energy meter."
Thanks a lot it worked!!!!
After running it for some time, the energy consumption is fix and is not changing.
@jstott1070 I created a "dirty" fix there https://gist.github.com/skynetua/4bcb6640582a8a730aa48e228b8ad3f9
Can you replace it with your HA file
/config/custom_components/tuya_v2/sensor.py
and check if everything is ok, including new energy dashboard? It works ok with my energy meter.
nice !!! thanks a lot !!!!!
@msteingr assuming your running Tuya V2 then you should apply @skynetua's "dirty fix" for now until it's fully incorporated into an update.
"@jstott1070 I created a "dirty" fix there https://gist.github.com/skynetua/4bcb6640582a8a730aa48e228b8ad3f9
Can you replace it with your HA file /config/custom_components/tuya_v2/sensor.py and check if everything is ok, including new energy dashboard? It works ok with my energy meter."
Hello @jstott1070 i copied the dirtyfix and was able to add the tuya into my energy dasbard , but the value looks faulty, for example the tuya app shows me a consumption of 2 KWH for yesterday (30/8) and the intehgration in home assistante shows 0.03 KWH for the same date..
Any suggestion?
@msteingr assuming your running Tuya V2 then you should apply @skynetua's "dirty fix" for now until it's fully incorporated into an update. "@jstott1070 I created a "dirty" fix there https://gist.github.com/skynetua/4bcb6640582a8a730aa48e228b8ad3f9 Can you replace it with your HA file /config/custom_components/tuya_v2/sensor.py and check if everything is ok, including new energy dashboard? It works ok with my energy meter."
Hello @jstott1070 i copied the dirtyfix and was able to add the tuya into my energy dasbard , but the value looks faulty, for example the tuya app shows me a consumption of 2 KWH for yesterday (30/8) and the intehgration in home assistante shows 0.03 KWH for the same date..
Any suggestion?
I have the same problem,
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