Page 1 of 1
Total power use
Posted: Friday 26 October 2018 3:53
by tony5093
I have many Sonoff POW and Medion units.
Each sends power use to the Domoticz server.
Now I would like to have a total of all the power consumption and have this displayed on the Utility page.
How can this be done?
Does anyone have an example?
Thanks in advance
Re: Total power use
Posted: Friday 26 October 2018 7:14
by SweetPants
tony5093 wrote: ↑Friday 26 October 2018 3:53
How can this be done?
Just my 2 cents
1) Create a dummy device according your needs
2) Write a dz_Ventz script that gathers all data and update the dummy device
Re: Total power use
Posted: Friday 26 October 2018 7:34
by waaren
tony5093 wrote: ↑Friday 26 October 2018 3:53
I have many Sonoff POW and Medion units.
Each sends power use to the Domoticz server.
Now I would like to have a total of all the power consumption and have this displayed on the Utility page.
How can this be done?
Does anyone have an example?
Thanks in advance
What are the type / subtypes of the domoticz devices receiving the power usages ?
Did you name these devices according to a naming convention ? (something like SonoffPowerUsage_1 .... SonoffPowerUsage_many)
Do you want to have the total displayed on a text sensor or alert sensor (or both) ?
Re: Total power use
Posted: Monday 19 November 2018 13:56
by dospider
Toy5093,
Do you have allready a solution? I'm looking for a solution to show the total power use again. This is gone with the new version of domoticz.
When you go to devices the total is there, but you can't see it within the utility page.
Re: Total power use
Posted: Monday 19 November 2018 14:46
by michaldobrotka
This is my lua script - counting together power use from 3 Phases and updating dummy device IDX 705 (Total).
Code: Select all
----------------------------------------------------------------------------------------------------------
local DeviceName1 = "Faza1"
local DeviceName2 = "Faza2"
local DeviceName3 = "Faza3"
local ConsumptionIDX = 705 -- IDX of the energy device that shows calculated Consumption
local ConsumptionDeviceName = "Total" -- Name of the energy device that shows calculated Consumption
----------------------------------------------------------------------------------------------------------
-- Script parameters
----------------------------------------------------------------------------------------------------------
Energy1 = 0 -- in Watt hours
Power1 = 0 -- in Watts
Energy2 = 0 -- in Watt hours
Power2 = 0 -- in Watts
Energy3 = 0 -- in Watt hours
Power3 = 0 -- in Watts
EnergyConsumption = 0 -- in Watt hours
PowerConsumption = 0 -- in Watts
Debug = "NO" -- Turn debugging on ("YES") or off ("NO")
----------------------------------------------------------------------------------------------------------
-- Lua Functions
----------------------------------------------------------------------------------------------------------
function update(device, id, power, energy, index)
commandArray[index] = {['UpdateDevice'] = id .. "|0|" .. power .. ";" .. energy}
end
----------------------------------------------------------------------------------------------------------
-- CommandArray
----------------------------------------------------------------------------------------------------------
commandArray = {}
Power1, Energy1 = otherdevices_svalues[DeviceName1]:match("([^;]+);([^;]+)")
if Debug=="YES" then
print(" ----- ".. DeviceName1 .. "Power = " .. Power1 .. " W");
print(" ----- ".. DeviceName1 .. "Energy = " .. Energy1 .. " Wh");
end
Power2, Energy2 = otherdevices_svalues[DeviceName2]:match("([^;]+);([^;]+)")
if Debug=="YES" then
print(" ----- ".. DeviceName2 .. "Power = " .. Power2 .. " W");
print(" ----- ".. DeviceName2 .. "Energy = " .. Energy2 .. " Wh");
end
Power3, Energy3 = otherdevices_svalues[DeviceName3]:match("([^;]+);([^;]+)")
if Debug=="YES" then
print(" ----- ".. DeviceName3 .. "Power = " .. Power3 .. " W");
print(" ----- ".. DeviceName3 .. "Energy = " .. Energy3 .. " Wh");
end
-- Calculate consumption
PowerConsumption = Power1 + Power2 + Power3
if Debug=="YES" then
print(" ----- PowerConsumption = " .. PowerConsumption .. " W");
end
EnergyConsumption = Energy1 + Energy2 + Energy3
if Debug=="YES" then
print(" ----- EnergyConsumption = " .. EnergyConsumption .. " Wh");
end
-- Update comsumption device in Domoticz
if devicechanged[DeviceName1] or devicechanged[DeviceName2] or devicechanged[DeviceName3] then
update(ConsumptionDeviceName, ConsumptionIDX, PowerConsumption, EnergyConsumption, 1)
end
return commandArray
It is working, but Im geting Error message (needed some touchup) :
Code: Select all
2018-11-19 14:43:00.344 Error: EventSystem: in celkovaspotreba: [string "-- /home/pi/domoticz/scripts/lua/script_devic..."]:65: attempt to index global 'devicechanged' (a nil value)