albertogeniola / MerossIot

Async Python library for controlling Meross devices
https://albertogeniola.github.io/MerossIot/
MIT License
488 stars 89 forks source link

Meross architecture clarification - recording electricity consumption #366

Closed cbreezier closed 4 months ago

cbreezier commented 8 months ago

Hi, you've done some amazing work reverse engineering the protocols here.

I'm interested in collecting electricity consumption data (in Wh or kWh), and I was curious how the Meross app does it. I know of async_get_instant_metrics() from ElectricityMixin, as well as async_get_daily_power_consumption() from ConsumptionXMixin.

The former reports the current live usage in W, not Wh. The latter retrieves daily kWh as recorded by the Meross servers. Could anyone provide any insights as to how the Meross servers collect total consumption as kWh?

Does each Meross device submit periodic usage data over MQTT to the servers? If so, does it send it as W or does it internally collect Wh? Or do the Meross servers periodically poll each device? And if so, do they essentially read async_get_instant_metrics() (W) or is there another API to collect Wh over a time range?

How frequently might the device submit this data, or how frequently would the server poll the device?

I might have to pull out the sniffer if nobody knows off the top of their head here :)

If i were to implement the software on these plugs, I would have the devices internally collect Wh by sampling W at a much much much higher frequency (eg, every 100ms), and then submit Wh to MQTT periodically (maybe once a minute). The reason is because if you poll each device once every, say, 5 minutes for the current consumption in W and assume that W is consistently consumed for a 5 minute period, your accuracy may go out the window for rapidly changing consumption.

Thanks in advance!

MaierJuerg commented 7 months ago

It would be great to have a solution for getting power consumption either historically for each hour of a date or the total consumption within the current day at the time of querying the smartplug (as shown in the meross app when selecting a plug as the "today" value).

stale[bot] commented 4 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.