Ok so I have room of lights. These objects ( group addresses ) which are either switch ( boolean ) or value based ( scale ) they are tagged as "Liivng". I want to show the average value of these lights. All of the status objects have been tagged with the tag called "Living Feedback". An event based script is placed on the "Living Feedback" tag. I created a two virtual objects. The first allows me to set the value of tag objects. The second represents the feedback, the average value of the objects. The problem is that there is always a varying number of lights and it can that only one light is changed or all of them are changed. The feedback value can jump up and down whilst every light returns its status. I have tried to overcome this by not recalculating the every time by checking when the average value status object has just been updated. Which can lead to the value not always being correct. Is there a better way to do this?
You cannot do a SQL query on object values as only raw value is stored. The best approach would be to monitor the bus and calculate the average once there's no status telegram for several seconds. This example can be used a starting point:
That's my question. How can we determine when to make the avg calculation? Given effectively the avg status should only update once all the lights have given their feedback. Because in a group of the tagged objects, all could change or just one. The group can consist of 5 objects or it could be 100 objects. Selecting a fixed amount of time doesn't work all the time.
Each group consists of tagged objects so count does not matter, you have to monitor all objects anyhow. The idea is to have a timer for each group, where each status update resets/reloads this timer. Only once all status updates are received you can calculate and send the average. I'll try to prepare an example next week.
14.06.2016, 08:09 (This post was last modified: 14.06.2016, 08:31 by buuuudzik.)
Perfect solution admin
Do I must use 1 script for 1 central status e.g. Room and another script for another status? Or I can add in this script a few groups of statuses e.g. Room1, Room2, Room3, Floor1 etc...
I tried to add:
Code:
123456789
groups = {
{ tag = 'my_group_and', output = '4/0/0', mode = 'and' },
{ tag = 'my_group_or', output = '4/0/1', mode = 'or' },
{ tag = 'my_group_avg', output = '4/0/2', mode = 'avg' },
{ tag = 'new_group_and', output = '4/0/20', mode = 'and' },
{ tag = 'new_group_or', output = '4/0/21', mode = 'or' },
{ tag = 'new_group_avg', output = '4/0/22', mode = 'avg' },
}
You should do full script reload after adding new group via disable / enable. You should also use only one script for all groups, otherwise there's unnecessary resource usage increase.
(14.06.2016, 08:49)admin Wrote: You should do full script reload after adding new group via disable / enable. You should also use only one script for all groups, otherwise there's unnecessary resource usage increase.
I've tried this script also for obtaining an average value of some temperature values obtained from a temperature sensor that send values at 5-10 second.
The script should work at each 10 min(scheduled script), and calculate the average value for the elapsed time from the last run
Maybe something I make wrong, or I just miss something.
13/2/9 - is the GA where the sensor sends the values
13/2/11 - should be the average value of received value.