PV power switcher script

2 replies [Last post]
allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011

Here is a simple (perhaps simplistic) script for controlling an electrical appliance connected to an RF device.

This script takes a simplistic approach to using excess PV solar output. Basically is assumes that if you have more than 1400 watts of output that you can switch on the appliance connected to an RF plug. When the output drops below 1100 watts the device is switched off again.

The script builds in a delay of 60 seconds to stop the device being repeatedly switched if the solar output is changing rapidly in an attempt to prevent damage to the device which is attached.

The script is written to test for current cost sensor 1 as the PV output source and to use the new Lidl remote control socket (B) as the RF device. Obviously these devices should be changed to suit your setup.

Any comments would be most welcome.

AttachmentSize
pvplug.lua1.55 KB
brett
Offline
Providence, United States
Joined: 9 Jan 2010
Feedback

If you where to convert this code into an applet you'd have a problem in that when this applet waits for 60sec before enabling changes and it will prevent any other applet from firing or recieving messages. This is bad behaviour as you are locking up the system.
You'd need to recode this to be asynchronously and start Timer() event that fires in 60sec to set this flag instead.

oktochange="no"
while os.difftime(os.time(),delay) < 60 do
oktochange="no"
end
oktochange="yes"

Change the above code to be this.

oktochange="no"        
xap.Timer(function(t)
oktochange="yes"
t:delete()
end, 60):start()

What you are trying to say is "Setup timer that fires in 60 seconds and changes the 'oktochange' variable to YES and only fire this once".    We need to use t:delete() to prevent the timer from firing again in 60sec time.   As this is a one shot timer.

There are other changes I'd make but this is the crucial one.

Brett

g7pkf
Offline
United Kingdom
Joined: 11 Jan 2011
Hate to ask

How easy would it be to add into script sensor.3 on current cost xap thingy=500 then allow sitch on of rf if =0 then not.

 

reason

If you have a cooker on drawing 2.5Kw but your solar is generating 2Kw your script would switch it on let say "it" is a tumble dryer (you know woman thing white small box in corner of her kitchen) this draws for example 1Kw your total "draw" off grid=1.5Kw (a lot) so you need a way of ensuring it is excess power you are utilizing hence the digital dev board idea i have done (detect when feeding or drawing off grid), I was hoping someone would do a script ;)

You could do a math script as well ie solar-house=-veanswer greaterthan 1Kw(or whatever this device draws) and ccsensor3=500 you are definately utilizing excess power to the best of your ability

 

and don't worry as soon as your eleccy company realize you have solar "if" you have an old whizzy meter that goes backwards they WILL be round to change it quickly!! then you get a nice new meter with a nice red led on it.

 

Dean

 

Dean

Hardware Info