Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!
Moderators: leecollings , remb0
Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.
Use the following template when posting here:
Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....
If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly
If you are replying, please do not quote images/code from the first post
Please mark your topic as Solved when the problem is solved.
pgas37
Posts: 99 Joined: Wednesday 06 December 2017 19:44
Target OS: -
Domoticz version:
Contact:
Post
by pgas37 » Saturday 04 May 2024 15:43
Hi,
I have created a script to compare the gross/net supply of solar panels to the electricity consumption from the grid, resulting in the net supply/consumption of a day. Because there is a constant change in supply and consumption, the script generates an up-to-date report every few seconds and therefore a very large log file. I wanted to limit that somewhat by building in a timer (2 minutes), but the timer function does nothing.
Can anyone tell me what i'm doing wrong here?
Thanks
Paul
Code: Select all
return {
on = {
timer = {
'every 2 minutes'
},
devices = {
'Energy xxx60',
--'kWh Meter Inverter 1', -- 'Power L1 Inverter 1' -- solar kwh bruto
'ModbusTcp - Total Energy',
}
},
logging = {
level = domoticz.LOG_INFO,
marker = '2solar=====================',
},
execute = function(domoticz,device)
-- domoticz.log('Device ' .. device.name .. ' was changed', domoticz.LOG_INFO)
local usage = domoticz.devices('Energy xxx60').usage
local LeveringNetVandaag = domoticz.devices('Energy xxx60').counterDeliveredToday
--local SolarVandaag = domoticz.devices('kWh Meter Inverter 1').counterToday
local SolarVandaag = domoticz.devices('ModbusTcp - Total Energy').counterToday
local VerbruikNetVandaag = domoticz.devices('Energy xxx60').counterToday
domoticz.log('Device60 usage actualWatt ................... = ' ..usage, domoticz.LOG_INFO)
domoticz.log('Device Solaredge: Bruto levering zonnepanelen = ' ..SolarVandaag, domoticz.LOG_INFO)
domoticz.log('Device60: Verbruik uit electriciteitsnet..... = ' ..VerbruikNetVandaag, domoticz.LOG_INFO)
domoticz.log('Device60: Netto Levering aan electiciteitsnet = ' ..LeveringNetVandaag, domoticz.LOG_INFO)
local nettoInternverbruik = SolarVandaag - LeveringNetVandaag
--local eigenverbruik60 = countertoday60 - LeveringNetto
local nettoverbruik_levering = VerbruikNetVandaag - LeveringNetVandaag
-- domoticz.log('nettoverbruik ............................... = ' ..nettoverbruik, domoticz.LOG_INFO)
T1 = ('+ Bruto levering zonnepanelen. = '..SolarVandaag.. '</u><br>')
T2 = ('- Device60: Netto levering net ... = '..LeveringNetVandaag..'</u><br>')
T3 = ('= Netto intern verbruikt ..............= '..nettoInternverbruik..'</u><br><br>')
T4 = ('.........Device60: Verbruik uit net......= '..VerbruikNetVandaag.. '</u><br>')
T5 = ('....................= Device60: Netto levering net = '..LeveringNetVandaag..'</u><br>')
T6 = ('.....................+ Netto verbruik/levering........ = '..nettoverbruik_levering.. '</u><br>')
--T5 = ('........................nettoverbruik in kWh......................... = '..nettoverbruik..'</u><br>')
domoticz.devices('Netto energie verbruik').updateText(T1 ..T2 ..T3 ..T4 ..T5 ..T6)
domoticz.devices('Netto Energie opbr/verbr').updateEnergy(nettoverbruik_levering)
end
}
--]]
Attachments
Schermafbeelding Netto energieverbruik.png (29.22 KiB) Viewed 306 times
waltervl
Posts: 5148 Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:
Post
by waltervl » Saturday 04 May 2024 15:51
If you only want the script to run every 2 minutes you have to delete the on devices trigger section ( devices= {} ) else the script will run on every device change and every 2 minutes.
pgas37
Posts: 99 Joined: Wednesday 06 December 2017 19:44
Target OS: -
Domoticz version:
Contact:
Post
by pgas37 » Saturday 04 May 2024 16:55
Oké,
That simple.
I thought that the timer function, that is first in the script would also be executed first and thus first pause the script for 2 minutes.
Thanks
RonkA
Posts: 95 Joined: Tuesday 14 June 2022 12:57
Target OS: NAS (Synology & others)
Domoticz version: 2023.2
Location: Harlingen
Contact:
Post
by RonkA » Saturday 04 May 2024 17:53
Hi, i saw you are using points trying to align your text.
Try this; replace:
Code: Select all
domoticz.devices('Netto energie verbruik').updateText(T1 ..T2 ..T3 ..T4 ..T5 ..T6)
With this in your script;
Code: Select all
local message = T1 .. T2 .. T3 .. T4 .. T5 .. T6
local style = '<span style="font-family: Consolas; font-weight: bold; font-size: 14px;">' .. message .. '</span>'
domoticz.devices('Netto energie verbruik').updateText(style)
For more than one space see this page:
https://www.domoticz.com/forum/viewtopi ... 09#p314709
SolarEdge ModbusTCP - Open Weather Map - Kaku - Synology NAS - Watermeter - ESPEasy - DS18b20
Work in progress = Life in general..
pgas37
Posts: 99 Joined: Wednesday 06 December 2017 19:44
Target OS: -
Domoticz version:
Contact:
Post
by pgas37 » Sunday 05 May 2024 11:38
thanks,
but your solution is only a amendment in style.
i replaced the dots by " " which resulted in
Schermafbeelding 2024-05-05 113451.png (35.06 KiB) Viewed 244 times
.
The adjusted code:
Code: Select all
T1 = ('+ Bruto levering zonnepanelen = '..SolarVandaag.. '<br>')
T2 = ('- Device60: Netto levering net = '..LeveringNetVandaag..'<br>')
T3 = ('= Netto intern verbruikt = '..nettoInternverbruik..'<br><br><br>')
T4 = (' Device60: Verbruik uit net = '..VerbruikNetVandaag.. '<br>')
T5 = ('- Device60: Netto levering net = '..LeveringNetVandaag..'<br>')
T6 = ('= Netto verbruik/levering = '..nettoverbruik_levering.. '<br><br>')
local message = T1 .. T2 .. T3 .. T4 .. T5 .. T6
local style = '<span style="font-family: Consolas; font-weight: bold; font-size: 14px;">' .. message .. '</span>'
domoticz.devices('Netto energie verbruik #update 2min').updateText(style)
Users browsing this forum: No registered users and 1 guest