This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Alarm system sensor list
#1
Hi,
I would like to show with a written list all the sensors with value true.
Is it possible? 
Thanks.
Claudio
Reply
#2
All objects that you want to show must have alarm tag attached. Use label element to display this text, set Additional classes to alarm.
Add to custom JavaScript:
Code:
$(function() {
  if (typeof grp != 'object') {
    return;
  }

  function update() {
    var text = [];

    $.each(grp.tag('alarm'), function(id, object) {
      if (object.value) {
        text.push(object.name + ' is ON');
      }
    });

    $('.alarm').css('white-space', 'pre').text(text.join('\n'));
  }

  grp.taglisten('alarm', update, true);
});
Reply
#3
Thank you Admin.
Is it possible to use this option in Mosaic view?
Thanks.
Reply
#4
You can also store text in a 250-byte object. Use an event script attached to alarm tag, change 32/1/1 as needed:
Code:
res = {}
objs = grp.tag('alarm')
for _, obj in ipairs(objs) do
  if obj.value then
    res[ #res + 1 ] = obj.name .. ' is ON'
  end
end

text = table.concat(res, '\n')
grp.update('32/1/1', text)
Reply
#5
Thank you works great.

Only thing is that even if we use '\n') sensors list is in the same line. Any idea?
Reply
#6
(15.04.2020, 09:27)Domoticatorino Wrote: Thank you works great.

Only thing is that even if we use '\n') sensors list is in the same line. Any idea?
 Ok, it is the instruction table.concat which gives list in the same line. 

I will try with other instruction.
Reply
#7
table.concat is working correctly. You need some extra CSS to show line breaks.
For example, if using Mosaic custom widget with text value display, you can fix text like this:
Code:
.widget-custom div > span { white-space: pre; }
Reply
#8
(15.04.2020, 14:53)admin Wrote: table.concat is working correctly. You need some extra CSS to show line breaks.
For example, if using Mosaic custom widget with text value display, you can fix text like this:
Code:
.widget-custom div > span { white-space: pre; }

Thank you admin for your support.

I think I should insert the css command in the "CUSTOM CSS" field of Styles Mosaic. I have done but nothing change. Probably because I should use the exactly widget- custom id.

I tried to find out it using WEB Developes tools but I cannot find out. Could you suggest please?

Thank you very much.
Reply
#9
Unfortunately there's no unique ID for custom widgets. I'll ask the developers to add this feature.
Reply
#10
Thank you Admin. I appreciate it. Otherwise if we change CSS style, it causes the modify to all single widget in the project with the same format.

In any case, setting the text you suggest in the "CUSTOM CSS" field of Styles Mosaic modify simply the text of the main page. And not the widget of the another page. Are you aware about that?

Thanks.
Reply
#11
Can you provide backup if your Mosaic project?
Reply
#12
(20.04.2020, 09:14)admin Wrote: Can you provide backup if your Mosaic project?

Sent by mail. Thanks.
Reply
#13
Thanks, change CSS to:
Code:
.widget-custom div > span { white-space: pre-line; }
Reply
#14
(20.04.2020, 11:10)admin Wrote: Thanks, change CSS to:
Code:
.widget-custom div > span { white-space: pre-line; }

Nothing change.

In main page is ok but in the page shown enclosed no.

Thanks.

Attached Files Thumbnail(s)
   
Reply
#15
That's because you are using different element style there. Try this:
Code:
.widget-custom h4 { white-space: pre-line; }
Reply
#16
(20.04.2020, 11:29)admin Wrote: That's because you are using different element style there. Try this:
Code:
.widget-custom h4 { white-space: pre-line; }

Thank you Admin. Now it is right.

Last question. Since I would like use HTML PLAIN as widget. In order to change CSS setting, the path is always the same as above?
Reply


Forum Jump: