Page 1 of 1

Reset actual power pv panels

Posted: Wednesday 16 December 2020 19:50
by steef27
Hi Guys,

I connected my pv system (SolarEdge) to Domoticz, but sometimes the API connection gets lost.
I wrote scome scripts to connect my room lights te the actual power generation.
When it is dark (no actual generation) my lights will switch on.
In cases the actual power generation will not be updated my light will not switch on. So I wrote a script to reset te actual power generation when the actual generation is greater than 0 and the the last update of the device is more than 15 minutes ago.

The problem is the log shows an error "attempt to call a nil value (field 'updateEnergy')"
Does anyone have an idea?

Code: Select all


local pv = 114

return {
	on = {
		timer = {
			'every 5 minutes',				
		}
	},    
    logging = { level = domoticz.LOG_DEBUG },
    execute = function(dz, item)
        
            local pvActual        = dz.devices(pv).actualWatt
            local pvLastupdated   = dz.devices(pv).lastUpdate.minutesAgo
            
            if 	(pvLastupdated > 15 and pvActual > 0) 
                then 
                    dz.devices(pv).updateEnergy('0')
                    dz.log('Actuele opwekking: ' .. pvActual .. ' watt',LOG_DEBUG)
                    dz.log('Laatst bijgewerkt: ' .. pvLastupdated .. ' minuten geleden',LOG_DEBUG)
                    dz.log('Bijgewerkt: Ja',LOG_DEBUG)
                else 
                    dz.log('Actuele opwekking: ' .. pvActual .. ' watt',LOG_DEBUG)
                    dz.log('Laatst bijgewerkt: ' .. pvLastupdated .. ' minuten geleden',LOG_DEBUG)
                    dz.log('Bijgewerkt: Niet nodig',LOG_DEBUG)
            end            

    end
    }


Re: Reset actual power pv panels

Posted: Wednesday 16 December 2020 21:27
by waaren
steef27 wrote: Wednesday 16 December 2020 19:50 The problem is the log shows an error "attempt to call a nil value (field 'updateEnergy')"
updateEnergy is only available for Electric usage device types. I expect that pv is a KwH device type and there you need the updateElectricity(power, energy) method.

Something like

Code: Select all

dz.devices(pv).updateElectricity(0, dz.devices(pv).WhTotal )

Re: Reset actual power pv panels

Posted: Thursday 17 December 2020 8:44
by steef27
attempt to call a nil value (field 'updateElekricity')

Re: Reset actual power pv panels

Posted: Thursday 17 December 2020 8:50
by steef27
ah .... dz.devices(pv).updateElectricity(0, dz.devices(pv).WhTotal)