I have several Tplink hs110 ( meters ) in my house.
Each meter tracks this kind of data
Code: Select all
{
"ActTime" : 1619516296,
"AstrTwilightEnd" : "21:46",
"AstrTwilightStart" : "04:16",
"CivTwilightEnd" : "20:29",
"CivTwilightStart" : "05:33",
"DayLength" : "13:55",
"NautTwilightEnd" : "21:06",
"NautTwilightStart" : "04:56",
"ServerTime" : "2021-04-27 11:38:16",
"SunAtSouth" : "13:01",
"Sunrise" : "06:03",
"Sunset" : "19:58",
"app_version" : "2021.1",
"result" :
[
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 255,
"CounterToday" : "0.002 kWh",
"CustomImage" : 0,
"Data" : "8.884 kWh",
"Description" : "",
"EnergyMeterMode" : "",
"Favorite" : 1,
"HardwareDisabled" : false,
"HardwareID" : 15,
"HardwareName" : "Lavastoviglie",
"HardwareType" : "TP-Link Wi-Fi Smart Plug HS100/HS110",
"HardwareTypeVal" : 94,
"HaveTimeout" : false,
"ID" : "000F0004",
"LastUpdate" : "2021-04-27 11:37:41",
"Name" : "Lavastoviglie - kWh",
"Notifications" : "false",
"PlanID" : "0",
"PlanIDs" :
[
0
],
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : "-",
"SubType" : "kWh",
"SwitchTypeVal" : 0,
"Timers" : "false",
"Type" : "General",
"TypeImg" : "current",
"Unit" : 4,
"Usage" : "0.3 Watt",
"Used" : 1,
"XOffset" : "0",
"YOffset" : "0",
"idx" : "133"
}
],
"status" : "OK",
"title" : "Devices"
}
Code: Select all
return {
on = {
timer = { 'every 1 minutes' }
},
execute = function(domoticz, item)
local APower = domoticz.devices(129) -- Acquario Ciano luce frontale - kWh -- IDX 129
local BPower = domoticz.devices(133) -- Lavastoviglie - kWh -- IDX 133
local CPower = domoticz.devices(137) -- Forno - kWh -- IDX 137
local DPower = domoticz.devices(141) -- Acquario Fluval Amtra Orion - kWh -- IDX 141
local EPower = domoticz.devices(146) -- Acquario Fluval Fitostimolante - kWh -- IDX 146
local FPower = domoticz.devices(150) -- Acquario Ciano Luce Bianca - kWh -- IDX 150
local GPower = domoticz.devices(154) -- Servizio - kWh -- IDX 154 usato per l'acquario Caridine
local HPower = domoticz.devices(158) -- Acquario Ciano Flusso - kWh IDX 158
local IPower = domoticz.devices(890) -- Daiking Living Heat kWh -- IDX 890
local LPower = domoticz.devices(891) -- Daiking Living Cool kWh -- IDX 891
local MPower = domoticz.devices(892) -- Daiking Bedroom Heat kWh -- IDX 892
local NPower = domoticz.devices(892) -- Daiking Bedroom Cool kWh -- IDX 893
local totalUsage = domoticz.devices(909) -- total of All IDX DEVICES power meter
print ('######################################################')
print ('Device value:' .. APower.WhActual + BPower.WhActual + CPower.WhActual + DPower.WhActual + EPower.WhActual + FPower.WhActual + GPower.WhActual + HPower.WhActual + IPower.WhActual + LPower.WhActual + MPower.WhActual + NPower.WhActual)
totalUsage.updateCustomSensor( APower.WhActual + BPower.WhActual + CPower.WhActual + DPower.WhActual + EPower.WhActual + FPower.WhActual + GPower.WhActual + HPower.WhActual + IPower.WhActual + LPower.WhActual + MPower.WhActual + NPower.WhActual)
print ('######################################################')
print ('Device value:' .. totalUsage)
print ('######################################################')
end
}
Code: Select all
2021-04-27 11:47:00.288 Error: dzVents: Error: (3.1.7) An error occurred when calling event handler CalcoloUsagePerCustom
2021-04-27 11:47:00.288 Error: dzVents: Error: (3.1.7) ...ipts/dzVents/generated_scripts/CalcoloUsagePerCustom.lua:27: attempt to concatenate a table value (local 'totalUsage')