Page 1 of 1

Help with script to control heat pump when price is high

Posted: Tuesday 14 December 2021 9:01
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 386 times
Apreciate any help, thanks.

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

Posted: Tuesday 14 December 2021 12:24
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
}