Seeking help with simple LUA -> Scene


Trying to automate the monthly reset of the usage stats on my home energy monitor (AeonLabs HEM v1).

I know from the excellent guide provided by l8nighter that the LUA script to do this is:

local meterID = ##
local kwh = luup.variable_get("urn:micasaverde-com:serviceId:EnergyMetering1", "KWH", meterID)

luup.call_action("urn:micasaverde-com:serviceId:EnergyMetering1", "ResetKWH", {}, meterID)

I’ve validated that it resets the KWH counter on my meter.

Where I’m struggling with this (I’m a n00b): how do I turn this snippet into something I can call from a manual scene? Or is that even the correct approach? Basically, I’d like to be able to call this function both manually and as part of a scene triggered by day of month.


If you paste the Lua code into a scene’s LUUP (UI5) or Luup Code (UI7) tab, it will be executed when the scene runs. You can run the scene manually or triggered by a schedule.

BTW: If you only want to reset the kWh counter, you can omit the second line (local kwh = …).

Awesome, thank you! :slight_smile:

How to amend this code to reset main device + 3 clamps (each has it’s own device number)?