I spend some time to show the output of my two GoodWe Inversters in Domoticz on a Pi using the GoodWe solar inverter via SEMS API. Once I got the hang of it this base works fine. Nice!
Since I own two inverters I would like to sum up the totals: current power (Watt) and the total energy (kWh) generated per day of both the inverters.
I used dzVentz to try doing this. I set up two dummy sensors (TotalPower and TotalEnergy) and wanted to do some adding.
Question 1 came up:
What calls/methods can I use on the API given just the device: domoticz.devices('GoodWe1'').NNNNN.
What to put on the NNNNN place? I found "Usage" and "CounterToday" in code of other more cunning people.
==> Is there an API call which gives this info?
Question 2 Practical:
If the suns goes down, this call returns nil:
PowerInverter1 = domoticz.devices('Solar Voor - Watt').Usage.
I would like to set something like:
If domoticz.devices('GoodWe1'').State == '1- Generating' then UpdateDummySensors else KeepLastValue.
I saw two states in the log : 0- Offline and 1- Generating. Can I get the state from the API?
The code so far (any tips for this newbie (other than use English variable names in the future)?)
Code: Select all
return {
on = {
timer = {
'every minute'
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'GW:',
},
execute = function(domoticz, timer)
-- Dummy sensors
-- Why can't I Use the name here, spaces forbidden? Used Idx instead.
targetDevice1 = domoticz.devices(71) -- custom sensor: Solar Totaal Power (W)
targetDevice2 = domoticz.devices(72) -- custom sensor: Solar Totaal Energy (kwH)
-- Usage (W) Voor
local VermogenVoor = domoticz.devices('Solar Voor - Watt').Usage
if (VermogenVoor == nil) then
VermogenVoor = 0.0
end
-- Usage (W) Achter
local VermogenAchter = domoticz.devices('Solar Achter - Watt').Usage
if (VermogenAchter == nil) then
VermogenAchter = 0.0
end
-- Vermogen (W) optellen
local TotaalVermogen = (VermogenVoor + VermogenAchter)
--CounterToday (kWh) Voor
local TotaalOpgewektVoor = domoticz.devices('Solar Voor - Watt').counterToday
--CounterToday (kWh) Achter
local TotaalOpgewektVoor = domoticz.devices('Solar Achetr - Watt').counterToday
-- Opbrengst kWh optellen
local TotaalOpgewekt = TotaalOpgewektVoor + TotaalOpgewektAchter
-- Dummy semnsors updaten
targetDevice1.updateCustomSensor(TotaalVermogen)
targetDevice2.updateCustomSensor(TotaalOpgewekt)
--'Solar Totaal Vandaag'.updateCustomSensor(TotaalOpgewektVoor + TotaalOpgewektAchter)
end
}