With solar panels installed there is an advantage to schedule events when solar generation is likely at a maximimum.
There are advanced approaches using solar forecasts, but a simple approach is to use a scheduler event to run at SolarNoon +/- offset, similar to current run at Sunrise +/- offset.
I realise this can be done wholly by scripting but would prefer to retain the ability to use the scheduler gui.
If an event is configured to run at Sunrise +/- offset via the GUI, is it possible to script an replacement of the start time with some other value such as a simplified solarNoon = (sunrise + sunset)/2?
Any ideas?
This is a little clumsy, but using event name is one way of adding solarNoon by the existing gui.
What would be the equivalent of ' io.writefile('/tmp/lm-scheduler-clear', '')' for the clipsal/schneider firmware?
There are advanced approaches using solar forecasts, but a simple approach is to use a scheduler event to run at SolarNoon +/- offset, similar to current run at Sunrise +/- offset.
I realise this can be done wholly by scripting but would prefer to retain the ability to use the scheduler gui.
If an event is configured to run at Sunrise +/- offset via the GUI, is it possible to script an replacement of the start time with some other value such as a simplified solarNoon = (sunrise + sunset)/2?
Any ideas?
This is a little clumsy, but using event name is one way of adding solarNoon by the existing gui.
What would be the equivalent of ' io.writefile('/tmp/lm-scheduler-clear', '')' for the clipsal/schneider firmware?
Code:
local name = 'solarNoon%'
local maxOffsetHours = 6 -- avoid 24hr boundaries
for _, evt in ipairs(db:getall('SELECT * FROM scheduler_events WHERE name LIKE ?', name)) do
if evt then
local _, _, plusMinus, offsetHour, offsetMin = string.find(evt.name, "^solarNoon%s*([+-])%s*(0[0-"..maxOffsetHours.."])([0-5]%d)%D*")
if plusMinus and offsetHour and offsetMin and evt.type == '' then
local sunrise, sunset = rscalc(latitudeMel, longitudeMel)
local solarNoon = math.floor(((sunset + sunrise) / 2) + 0.5)
local offsetMinutes = (offsetHour * 60) + offsetMin
local eventMinutes
if plusMinus == '+' then
eventMinutes = solarNoon + offsetMinutes
else
eventMinutes = solarNoon - offsetMinutes
end
local eventStartHour = math.floor(eventMinutes / 60)
local eventStartMin = math.floor(eventMinutes % 60)
db:update('scheduler_events', {
start_hour = eventStartHour,
start_min = eventStartMin
}, { id = evt.id })
-- io.writefile('/tmp/lm-scheduler-clear', '')
else
log("Error. '"..evt.name.."' event name must begin with 'solarNoon[+-]HHMM ...' where max HH = 0"..maxOffsetHours..", and event setting 'Run at:' = 'Specific time'")
end
end
end