Hi,
I hae majority of my project, where I need to setup LM before all counter are installed (modbus, powertag....).
And when electrician installe it, I have my total script for category for example that 'got a peak.
So I have this kind of curve. I often export in xml, then re-import in the backup with the trend ID, but it's such a pain.
I was thinking to option:
1- reset the trend file to a blank one by script
2- I would prefer to create a script that monitor all my curve and if value goes above a certain max I setup, it clear it from the rdd file.
I don't know where to start to modifiy a value, is there existing base script I could modify ?
I would definitiv prefer second option.
Regards
-----------
FRANCE SMARTHOME & SMARTBUILDING INTEGRATION
SE ECO EXPERT
22.11.2023, 08:51 (This post was last modified: 22.11.2023, 08:56 by domotiqa.)
(22.11.2023, 08:42)Daniel Wrote: You probably use trend type 'counter' and you have negative delta, Use 'counter with negative delta' to not have such spikes.
I Daniel,
The problem is not that in my caze. I understand what you mean.
I have script that add for example all light counter, all hvac, hall socket.... for the building.
But sometimes, the real counter is not cable.
so it s value is 0. When the electrician fix it,maybe one day or one week later. The Total increase a lot (the counter is not any more 0 but the index value from modbus).
So this point is not an error, however I want to delete it.
So I need to export in xml, find the value in the day and month storeage area, then export in rrd, then import my backup.
I'm looking for a way by script to find value that exeed for example XXXX (setup in the script), then replace it with zero).
This day I have a SE project with 100 counter at least, and for example, the water counter install in modbus are not well connected. The electrician will come next week to fix it (there is more than 10 area in this building). When he will do that I will have an amount collected and a peak on the curve because the index is in reality already in count.
However my HMI is already build with all srcipt to do the TOTAL by category, area, type energy, M3....
Each HMI page have trend id in it and customer already use it. So very hard to generate again everything when all counter will be well wired.
-----------
FRANCE SMARTHOME & SMARTBUILDING INTEGRATION
SE ECO EXPERT
I was thinking:
1- Easiest way is to copy to the trend file in /tmp/trends an empty template
2- the best, a script that look for value above XXX, then replace it by value YYYY (I will calculate average of last day and then add same value)
any help appreciate
-----------
FRANCE SMARTHOME & SMARTBUILDING INTEGRATION
SE ECO EXPERT
22.11.2023, 09:25 (This post was last modified: 22.11.2023, 09:46 by domotiqa.)
(22.11.2023, 09:01)admin Wrote: You can simply delete the trend file then it will be re-created automatically.
Code:
123
id = 99file = '/tmp/trends/t' .. id .. '.trend'os.remove(file)
Making a script that modifies internal trend values is possible but it's a complex task.
thks admin and daniel.
This first solution will be cool.
Can you send some key I will dig in it for the second one ?
For the first solution, this scipt with your help do the job.
I would prefer the second solution where I don't need to put the name... but only a value max
Code:
1234567891011121314151617181920
tabCurveName= {
'ECLAIRAGE-TOTAL-KWH',
'GENERAL_ELEC-TOTAL-KWH'
}
for_, curveNameinipairs(tabCurveName) doid = db:getone('SELECT id FROM trends WHERE name=?', curveName)
ifidthenfile = '/tmp/trends/t' .. id .. '.trend'os.remove(file)
endendscript.disable(_SCRIPTNAME)
-----------
FRANCE SMARTHOME & SMARTBUILDING INTEGRATION
SE ECO EXPERT
For counter type the editing is trickier. The stored value is not the actual counter value but a per-second change rate. This example will log the maximum of all stored values without writing to a different trend log file. You can use this value for replacement in the previous script.
(15.12.2023, 10:47)admin Wrote: This example will change all valid trend values by x2. Recommended way of testing is to create a new trend log with the same parameters as the source.
For counter type the editing is trickier. The stored value is not the actual counter value but a per-second change rate. This example will log the maximum of all stored values without writing to a different trend log file. You can use this value for replacement in the previous script.
Note that when replacing values you should not use direct comparison (==) for floating point values due to possible rounding errors.
Hi,
I've used this scripts to replace erroneus values (due to power losses...) on counter type trends, but I've seen that daily grouped values are still wrong.
Are this values calculated from hourly values? Or are stored? Is there any way to update them?
Hi,
When I use the script to find max value, it's no showing daily max value... I managed to change a wrong value at 23:00 on 30 May but daily values are still wrong...
This will log all daily values with their respective offsets. If the whole list does not fit, you can change line 17 and add an extra offset. Just make sure that this extra offset is divisible by 8.
(31.05.2024, 07:15)admin Wrote: This will log all daily values with their respective offsets. If the whole list does not fit, you can change line 17 and add an extra offset. Just make sure that this extra offset is divisible by 8.
If you need dates then use trends.fetch function. Calculating the date using raw file access is not trivial because the data is written in a circular way.