Reset actual power pv panels

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
steef27
Posts: 30
Joined: Friday 26 August 2016 9:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Reset actual power pv panels

Post 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
    }

User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Reset actual power pv panels

Post 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 )
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
steef27
Posts: 30
Joined: Friday 26 August 2016 9:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Reset actual power pv panels

Post by steef27 »

attempt to call a nil value (field 'updateElekricity')
steef27
Posts: 30
Joined: Friday 26 August 2016 9:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Reset actual power pv panels

Post by steef27 »

ah .... dz.devices(pv).updateElectricity(0, dz.devices(pv).WhTotal)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest