And in my change above, if you add an extra app name into this line, it's child apps will also show up. E.g.,
var apps = ['Rule Machine Legacy', 'Rule Machine', 'Event Engine'];
(albeit that the grouping into "Rooms" by the first word of the rule name isn't quite right, since it depends upon the sorting of the individual list of child apps)
Both of those warnings are outside my changes. And you can safely ignore them anyway; eslint is a static checker, and doesn't understand loaded code. E.g., moment and Highcharts come from the @require blocks at the top of the file.
So can confirm it works on "Violent Monkey" as well!! Very cool - graphs look great.
I have multiple hubs and have a simple VM script to change the body background depending on my hub. Helps distinguish which hub I'm on. This would be a nice add on I think..
Question, could the Hub name be added somewhere that is always visible (unlike the spot HE decided to put it. ). My thoughts were lower right hand corner, where the 'Terms of service, Documentation, ext' is located.
I actually liked the Rules portion so much, I created an Event Engine version. Those that use EE can find the link in the 1st post of the EE thread.
Well, it's positioned in the lower left corner, so you just want to move it right? Should be easy to do..
I'm glad people find this script useful There can be plenty of edits done, but I was kinda hoping Hubitat staff will implement it directly in HE, when it's clear how easy those changes are, and hom much value/usability it adds.
For rules from different apps - I could imagine having the Rules menu added, and apps could then expose boolean property whether or not to include their child apps in Rules menu. User could toggle this boolean on every app screen.. Also, every standalone-app and child-app could have a possibility to assign a room to it. Most apps/child apps sort out things for room anyway, so this would just add clarity and filtering possibility. For integration apps, users would just leave the field "room" as "not assigned". But that would have to be done in HE, not just javascript.
eslint is just being extra pedantic. That's not an error, but a style warning. You can safely ignore them.
The problem it's trying to prevent is when you have code like this (line 18):
if (!document.title.includes('Hubitat'))
document.title = `Hubitat - ${document.title}`;
and you need to add an extra line into the statement protected by the if clause. If you just blindly add the line, then it's a bug. It looks right because of the indentation, but it's not.
if (!document.title.includes('Hubitat'))
document.title = `Hubitat - ${document.title}`;
document.foobar = `Haha`; // BUG this line will always be executed
You avoid the bug by adding braces when you add a line:
By suggesting (forcing) you to always use braces { } to bracket the statement after the if clause, you can't accidentally introduce this bug. So if you start with this:
if (!document.title.includes('Hubitat')) {
document.title = `Hubitat - ${document.title}`;
}
Then it is easy to add a line, without needing to inspect the surrounding code.
What does the table section with Rule Machine in the Apps page look like? This code just reformats that, using the rule name up to the first space (or dash) as the "Room" grouping.
Full-bracing is a common style convention in many languages derived from C (C++, C#, Perl, Java, etc). Avoiding this sort of bug is the basis for Python, which does away with braces completely and uses the indentation to decide code flow.