My scripting is not the best, but what i archieved already in domoticz i'm really proud on!
The script is:
Code: Select all
return {
-- on = {
-- timer = { 'at 00:00' }
-- },
on = {
devices = {
'$Aquarium verlichting Rood',
}
},
execute = function(dz, item)
local RoodToday = dz.devices(451).WhToday
local GroenToday = dz.devices(454).WhToday
local BlauwToday = dz.devices(457).WhToday
local WitToday = dz.devices(460).WhToday
local TotaalToday = RoodToday + GroenToday + BlauwToday + WitToday
local RoodPower = dz.devices(451).actualWatt
local GroenPower = dz.devices(454).actualWatt
local BlauwPower = dz.devices(457).actualWatt
local WitPower = dz.devices(460).actualWatt
local Power = RoodPower + GroenPower + BlauwPower + WitPower
if dz.time.matchesRule('at 00:05-23:59') then
dz.devices(1174).updateElectricity(Power,TotaalToday)
end
-- if dz.time.matchesRule('at 00:00') then
-- dz.devices(1174).updateElectricity(0,0)
-- end
end
}
In the picture below you see the total usage at midnight getting negative. Here some information about the switch where it's sending to:
Code: Select all
{
"ActTime": 1714635427,
"AstrTwilightEnd": "23:50",
"AstrTwilightStart": "03:26",
"CivTwilightEnd": "21:50",
"CivTwilightStart": "05:27",
"DayLength": "15:03",
"NautTwilightEnd": "22:42",
"NautTwilightStart": "04:35",
"ServerTime": "2024-05-02 09:37:07",
"SunAtSouth": "13:38",
"Sunrise": "06:07",
"Sunset": "21:10",
"app_version": "2024.2",
"result": [
{
"AddjMulti": 1,
"AddjMulti2": 1,
"AddjValue": 0,
"AddjValue2": 0,
"BatteryLevel": 255,
"CounterToday": "0.005 kWh",
"CustomImage": 101,
"Data": "0.005 kWh",
"Description": "",
"EnergyMeterMode": "0",
"Favorite": 1,
"HardwareDisabled": false,
"HardwareID": 6,
"HardwareName": "Dummy",
"HardwareType": "Dummy (Does nothing, use for virtual switches only)",
"HardwareTypeVal": 15,
"HaveTimeout": false,
"ID": "00083174",
"Image": "Aquarium",
"LastUpdate": "2024-05-02 09:37:06",
"Name": "Aquarium verlichting verbruik",
"Notifications": "false",
"PlanID": "0",
"PlanIDs": [
0
],
"Protected": false,
"ShowNotifications": true,
"SignalLevel": "-",
"SubType": "kWh",
"SwitchTypeVal": 0,
"Timers": "false",
"Type": "General",
"TypeImg": "current",
"Unit": 1,
"Usage": "0.46 Watt",
"Used": 1,
"XOffset": "0",
"YOffset": "0",
"idx": "1174"
}
],
"status": "OK",
"title": "Devices"
}
For now, i delete the value and the day value get's correct. But doing this every day is a little bit to mucht work so I hope someone can help me with the script to make it workable!