Washing machine cost after running a load
Posted: Thursday 30 April 2020 13:59
I've created a Washing Machine done DzVents script and with the help of waaren also got a beautiful PushOver notification when it's done running
The script senses that a load has started and sets a variable that the washing machine in use, when the power usage is below 6 Watt it will send a PushOver notification. So far so good
What I would like to add is a way to include the energie cost of that run but haven't figured out how to do that. I'm using a FIBARO System FGWPE/F Wall Plug Gen5+ to monitor power usage.
The idea is likely that I will need to capture the kWh when a load starts and the kWh when a load is finished and calculate the difference and the cost.
Any pointers would be really welcome, also any feedback on the current script is also welcome as I'm really novice in this.
Current script
The script senses that a load has started and sets a variable that the washing machine in use, when the power usage is below 6 Watt it will send a PushOver notification. So far so good

What I would like to add is a way to include the energie cost of that run but haven't figured out how to do that. I'm using a FIBARO System FGWPE/F Wall Plug Gen5+ to monitor power usage.
The idea is likely that I will need to capture the kWh when a load starts and the kWh when a load is finished and calculate the difference and the cost.
Any pointers would be really welcome, also any feedback on the current script is also welcome as I'm really novice in this.
Current script
Code: Select all
local scriptVar = 'Wasmachine'
return
{
on =
{
timer =
{
'every 1 minutes',
},
httpResponses =
{
scriptVar,
},
},
logging =
{
--level = domoticz.LOG_DEBUG,
marker = scriptVar,
},
data =
{
WasmachineTimeout = { initial = 1 },
WasmachineInUse = { initial = 0 },
},
execute = function(domoticz, item)
if item.isHTTPResponse then
domoticz.log(item.data,domoticz.LOG_DEBUG)
return
end
local function pushover(PushoverUser, PushoverApp, title, message, priority, sound)
domoticz.openURL({
url = 'https://api.pushover.net/1/messages.json',
method = 'POST',
callback = scriptVar,
postData =
{
token = PushoverApp.token,
user = PushoverUser.key,
message = message,
title = title or 'Pushover from dzVents',
priority = priority or 0,
sound = sound or 'echo',
},
})
end
local PushoverUsers =
{
['User1'] = { ['key'] = 'aaaaaaaaaaaaaaaaaaaaaaaaa' },
['User2'] = { ['key'] = 'bbbbbbbbbbbbbbbbbbbbbbbbbbb'},
['Familie'] = { ['key'] = 'ccccccccccccccccccccccccccccccc'},
}
local PushoverApps =
{
['Domoticz'] = { ['token'] = 'dddddddddddddddddddddd' },
['Huis'] = { ['token'] = 'eeeeeeeeeeeeeeeeeeeeee' },
['Test'] = { ['token'] = 'ffffffffffffffffffffffffffff' },
['Was'] = { ['token'] = 'ggggggggggggggggggggggggg' },
}
local WasmachineUsage = domoticz.devices(275)
local WasmachineStandbyUsage = 6.0
local WasmachineStartUsage = 10.0
if (WasmachineUsage.actualWatt >= WasmachineStartUsage) and (domoticz.data.WasmachineInUse == 0) then
domoticz.data.WasmachineInUse = 1
domoticz.log("Setting Wasmachine in use to yes", domoticz.LOG_INFO)
domoticz.log("Timeout = " .. domoticz.data.WasmachineTimeout, domoticz.LOG_DEBUG)
domoticz.log("In use = " .. domoticz.data.WasmachineInUse, domoticz.LOG_DEBUG)
end
if (WasmachineUsage.actualWatt >= WasmachineStandbyUsage) and (domoticz.data.WasmachineInUse == 1) and (domoticz.data.WasmachineTimeout == 0) then
domoticz.data.WasmachineTimeout = 1
domoticz.log("Reseting counter, not done yet.", domoticz.LOG_DEBUG)
domoticz.log("Timeout = " .. domoticz.data.WasmachineTimeout, domoticz.LOG_DEBUG)
domoticz.log("In use = " .. domoticz.data.WasmachineInUse, domoticz.LOG_DEBUG)
end
if (WasmachineUsage.actualWatt <= WasmachineStandbyUsage) and (domoticz.data.WasmachineInUse == 1) then
if (domoticz.data.WasmachineTimeout > 0) then
domoticz.data.WasmachineTimeout = domoticz.data.WasmachineTimeout - 1
domoticz.log(WasmachineUsage.actualWatt .. ' Watt usage, below standby usage, timout minus 1', domoticz.LOG_DEBUG)
domoticz.log('Timeout = ' .. domoticz.data.WasmachineTimeout, domoticz.LOG_DEBUG)
domoticz.log('In use = ' .. domoticz.data.WasmachineInUse, domoticz.LOG_DEBUG)
elseif (domoticz.data.WasmachineTimeout == 0) then
domoticz.log(''.. WasmachineUsage.actualWatt .. ' Watt verbruik, dus is klaar', domoticz.LOG_INFO)
domoticz.data.WasmachineInUse = 0
domoticz.data.WasmachineTimeout = 1
pushover(PushoverUsers.Familie, PushoverApps.Was, 'Was', 'De was is klaar.', 0, 'magic' )
domoticz.log('Timeout = ' .. domoticz.data.WasmachineTimeout, domoticz.LOG_DEBUG)
domoticz.log('In use = ' .. domoticz.data.WasmachineInUse, domoticz.LOG_DEBUG)
end
end
end
}