jasonacox/tuyapower

Power Usage

Macfresno opened this issue · 2 comments

Hello,

I'm getting a bit mad on the power usage reported, using the example you show on the readme you get this values:

Device 03200160dc4f2216ff61 at 10.0.1.5 key 0123456789abcdef protocol 3.1:
Switch On: True
Power (W): 1.200000
Current (mA): 70.000000
Voltage (V): 122.100000
Projected usage (kWh): Day: 0.028800 Week: 0.201600 Month: 0.873600

But as far as I know W=I*V but 122,1V * 0,070A does not equal 1,2W, what am I missing?

Thanks,
Mac Fresno

Hi Mac, you are correct. However, this data is actually coming back from the tuya device as part of the response payload. The tuyapower code is simply passing it along, not doing the calculation. Yes, it seems wrong, however it may not be. For alternating current there is also a power factor (PF) based on the type of load:

P(W) = PF × I(A) × V(V)

The example above seems bad because the PF is so low (0.14). This is indicative of no-load or high inductive load on the circuit. A PF of 1.0 (similar to the direct current equation) would be for a pure resistive load but most loads are below that (e.g. a fluorescent lamp PF 0.95, inductive motor full load PF 0.85).

Now, the truth is the tuya device can be sending us bad data. From simple test, most of my plugs do seem accurate enough for trending.

Here are some examples where I show different PF values...

FOUND Device [Valid payload]: 10.0.1.x
    ID = xx, product = xx, Version = 3.1
    Stats: on=True, W=12.2, mA=105.0, V=121.0 [OK]

PF = P(W) / ( I(A) × V(V) ) = 12.2 / (0.105 * 121.0) = 0.96

FOUND Device [Valid payload]: 10.0.1.x
    ID = xx, product = xx, Version = 3.1
    Stats: on=True, W=53.7, mA=446.0, V=121.7 [OK]

PF = P(W) / ( I(A) × V(V) ) = 53.7 / (0.446 * 121.7) = 0.99

I also tried a resistive load (25w soldering iron):

TuyaPower (Tuya Power Stats) [0.0.25] tinytuya [1.0.4]

Device xx at 10.0.1.37 key xx protocol 3.3:
    Response Data: {u'devId': u'xx', u'dps': {u'1': True, u'2': 0, u'5': 238, u'4': 195, u'6': 1217}}
    Switch On: True
    Power (W): 23.800000
    Current (mA): 195.000000
    Voltage (V): 121.700000
    Projected usage (kWh):  Day: 0.571200 Week: 3.998400  Month: 17.326400

PF = P(W) / ( I(A) × V(V) ) = 23.8 / (0.195 * 121.7) = 1.00

And same plug but using low power LED Christmas lights:

TuyaPower (Tuya Power Stats) [0.0.25] tinytuya [1.0.4]

Device xx at 10.0.1.37 key xx protocol 3.3:
    Response Data: {u'devId': u'xx', u'dps': {u'1': True, u'2': 0, u'5': 63, u'4': 91, u'6': 1221}}
    Switch On: True
    Power (W): 6.300000
    Current (mA): 91.000000
    Voltage (V): 122.100000
    Projected usage (kWh):  Day: 0.151200 Week: 1.058400  Month: 4.586400

{ "datetime": "2020-11-18T04:38:46Z", "switch": "True", "power": "6.3", "current": "91.0", "voltage": "122.1" }

PF = P(W) / ( I(A) × V(V) ) = 6.3 / (0.091 * 122.1) = 0.57

Ohhhh you're totally right, I forgot about the PF, I'm not used to working with AC circuits. Many thanks for all the examples.