Skip to main content

Time Based Electrolyser Control

What We Control?

We want to start electrolyser for 1 hour every day. We want to automate this.

Objective of Automation

Produce constant amount of hydrogen daily.

Requirements

At least one electrolyser is needed.

Rule

local electrolysers = {
'D4416F63D6F029A6D88855F157E01CB9',
'4D6DC302EA88E381A56C15A450F3EDFA',
}

function main()
if time.is_now_between('15:05', '16:05', TIMEZONE) then
start_electrolysers(electrolysers)
else
stop_electrolysers(electrolysers)
end
end

function start_electrolysers(els)
local CAN_START_STATES = {'idle'}

for _, id in pairs(els) do
local el = enapter.device(id)
if el then
if table.contains(CAN_START_STATES, el.telemetry.now('electrolyser')) then
enapter.log("Starting electrolyser: " .. el.id)
el.commands.execute("start")
end
else
enapter.log("Electrolyser `" .. id .. "` not found", "error")
end
end
end

function stop_electrolysers(els)
local CAN_STOP_STATES = {'steady', 'standby'}

for _, id in pairs(els) do
local el = enapter.device(id)
if el then
if table.contains(CAN_STOP_STATES, el.telemetry.now('electrolyser')) then
enapter.log("Stopping electrolyser: " .. el.id)
el.commands.execute("stop")
end
else
enapter.log("Electrolyser `" .. id .. "` not found", "error")
end
end
end

main()

All Rights Reserved © 2024 Enapter AG.