jasonacox / tinytuya

Python API for Tuya WiFi smart devices using a direct local area network (LAN) connection or the cloud (TuyaCloud API).
MIT License
879 stars 159 forks source link

How does the smartplug calculate power? #340

Open stephanpcpeters opened 1 year ago

stephanpcpeters commented 1 year ago

Question not directly related to tinytuya, but I noticed in the frontend that the power reported does not seem to directly relate to the current and voltage. I would expect P=V*I, but there seems to be a delta. Based on this math, I would expect 81.4W instead of the 49.5W.

power

I did the same extraction using tinytuya (triggering the DPS update on 18,19 and 20 first), but I'm still seeing the same result. The ratio doesn't seem to be completely stable, but hovers around 0.6.

Is there some AC/DC conversion factor that I should be using here?

Thanks.

jasonacox commented 1 year ago

Hi @stephanpcpeters - as you rightly state, you need to include the power factor to compute wattage in an AC circuit.

For single-phase AC circuits, the relationship between wattage ($W$), voltage ($V$), and current ($A$) is stated as :

$W = V A pf$

Where $pf$ is the power factor:

A $pf$ of 0.6 would indicate a capacitive or an inductive load in the circuit (likely a fan, motor, etc).

uzlonewolf commented 1 year ago

Simply multiplying V*I gives you VA (volt-amperes), not watts. To get watts you need to include the power factor as @jasonacox wonderfully explained.