DZvents power get negative at 00:00
Posted: Thursday 02 May 2024 9:41
I have the following script running with succes for calculate total usage for few seprated led strips. I use the script for different uses, but there is one problem I already play with a long time but didn't find any solution yet.
My scripting is not the best, but what i archieved already in domoticz i'm really proud on!
The script is:
You see, i already tried sending a 0 at midnight what doesn't work. Also different times around midnight, found that as solution but doesn't work.
In the picture below you see the total usage at midnight getting negative. Here some information about the switch where it's sending to:
Energy read is "from device" and not on "computed". It works on Computed, but the difference with the real calculation is for my purpose to big.
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!
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!