rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.92k stars 559 forks source link

Energy sensor devices are not available on new energy consumption panel #536

Open JesusRo opened 3 years ago

JesusRo commented 3 years ago

The problem

Energy sensor devices are not available on new energy consumption panel They don´t show on the list and refers to https://www.home-assistant.io/more-info/statistics/ https://developers.home-assistant.io/docs/core/entity/sensor#long-term-statistics

Environment

Steps to reproduce

Go to the new panel and try to add wifi plugs existing via local tuya integration

Additional information

Just opened with the info HA says as I didn´t found issue open already for this

hoodlumj3 commented 3 years ago

I can confirm this, I have a bucket load of the Kogan AU energy meter smart plugs (they have the WB25), have these in tuya cloud as well as in tuya local (18,19,20). image image I have noticed that this energy meter does have extra options (21,22,23,24,25,26,41,42) image What they corelate to in regards to KWh day totals or overall KWh totals is anybody's guess.

I also have a TP-Link Energy Monitor HS110(AU) and this is selectable in the Energy dash as i've include the sensor template to get the "Current Consumption" and "Total Consumption" image

gurudc commented 3 years ago

I'm using a work around using the Rieman sum integration and this code for each switch in my sesnors.yaml

MrSnakeSPb commented 3 years ago

homeassistant: customize: sensor.smart_plug_1_energy:
device_class: energy last_reset: '1970-01-01T00:00:00+00:00' state_class: measurement

sensor:

licheng5625 commented 3 years ago

another way is in the sensor.py add following

from homeassistant.components.sensor import DEVICE_CLASSES, DOMAIN, STATE_CLASS_MEASUREMENT, SensorEntity

class LocaltuyaSensor(LocalTuyaEntity, SensorEntity):

**@property
def state_class(self):
    return STATE_CLASS_MEASUREMENT**