Help with script to control heat pump when price is high

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

Moderator: leecollings

Post Reply
Hellrazr
Posts: 7
Joined: Monday 10 May 2021 14:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Help with script to control heat pump when price is high

Post by Hellrazr »

Heya. During the day sometimes we get some insane spikes in the energy price. I wan't to lower the heat pump setpoint during those spikes.
I wan't to activate a switch (which lowers the set point on the heat pump) when the current price is above average for that day +10. So if the average for the day is 100, then I wan't to activate the switch if the current price is above 110.


The heat pump switch has idx 348.
The current price has idx 358.
The mean price has idx 361.
heatpump switch.JPG
heatpump switch.JPG (65.35 KiB) Viewed 407 times
Apreciate any help, thanks.
Hellrazr
Posts: 7
Joined: Monday 10 May 2021 14:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Help with script to control heat pump when price is high

Post by Hellrazr »

nvm :) I think I got it working with this script.

Code: Select all

return
{
    on =
    {
        devices =
        {
            'Tibber - Current Price', 
        }
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,
        marker = 'heatpump control',
    },

    execute = function(dz, domoticz, variables)
        local heatpump = dz.devices('heat pump switch') 
        local meanprice = dz.devices('Tibber - Mean Price')
        local currentprice = dz.devices('Tibber - Current Price')
        
        if (currentprice.sensorValue > meanprice.sensorValue + 10) then
            heatpump.switchOn().checkFirst()
        elseif (currentprice.sensorValue < meanprice.sensorValue + 10) then
            heatpump.switchOff().checkFirst()
        end
end
}
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest