Logic Machine Forum
Alarm system sensor list - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Visualization (https://forum.logicmachine.net/forumdisplay.php?fid=9)
+--- Thread: Alarm system sensor list (/showthread.php?tid=2574)



Alarm system sensor list - Domoticatorino - 12.04.2020

Hi,
I would like to show with a written list all the sensors with value true.
Is it possible? 
Thanks.
Claudio


RE: Alarm system sensor list - admin - 14.04.2020

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);
});



RE: Alarm system sensor list - Domoticatorino - 14.04.2020

Thank you Admin.
Is it possible to use this option in Mosaic view?
Thanks.


RE: Alarm system sensor list - admin - 15.04.2020

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)



RE: Alarm system sensor list - Domoticatorino - 15.04.2020

Thank you works great.

Only thing is that even if we use '\n') sensors list is in the same line. Any idea?


RE: Alarm system sensor list - Domoticatorino - 15.04.2020

(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.


RE: Alarm system sensor list - admin - 15.04.2020

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; }



RE: Alarm system sensor list - Domoticatorino - 20.04.2020

(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.


RE: Alarm system sensor list - admin - 20.04.2020

Unfortunately there's no unique ID for custom widgets. I'll ask the developers to add this feature.


RE: Alarm system sensor list - Domoticatorino - 20.04.2020

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.


RE: Alarm system sensor list - admin - 20.04.2020

Can you provide backup if your Mosaic project?


RE: Alarm system sensor list - Domoticatorino - 20.04.2020

(20.04.2020, 09:14)admin Wrote: Can you provide backup if your Mosaic project?

Sent by mail. Thanks.


RE: Alarm system sensor list - admin - 20.04.2020

Thanks, change CSS to:
Code:
.widget-custom div > span { white-space: pre-line; }



RE: Alarm system sensor list - Domoticatorino - 20.04.2020

(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.


RE: Alarm system sensor list - admin - 20.04.2020

That's because you are using different element style there. Try this:
Code:
.widget-custom h4 { white-space: pre-line; }



RE: Alarm system sensor list - Domoticatorino - 20.04.2020

(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?