GoodWe solar inverter via SEMS API

Python and python framework

Moderator: leecollings

Post Reply
GerardWu
Posts: 2
Joined: Wednesday 08 December 2021 19:04
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Vorden, NL
Contact:

GoodWe solar inverter via SEMS API

Post by GerardWu »

Hello,
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
}

User avatar
waltervl
Posts: 5908
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: GoodWe solar inverter via SEMS API

Post by waltervl »

1. Please check the very complete dzVents documentation
https://www.domoticz.com/wiki/DzVents:_ ... _scripting

For KWh device you have several options, see https://www.domoticz.com/wiki/DzVents:_ ... counter.29


2. Inverter state on my setup is a selector switch. There you can use .level for level 0, 10, 20 etc or .levelName (Generating,. Offline etc). See the levels of your selector switch when you click on the edit button.

Names of devices can be used in between quotes eg 'name'. Devices should have a unique name else the dVents systems gets confused.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
GerardWu
Posts: 2
Joined: Wednesday 08 December 2021 19:04
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Vorden, NL
Contact:

Re: GoodWe solar inverter via SEMS API

Post by GerardWu »

Thanks a lot for your quick responce.
I will start reading first...
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest