UI Enhancements

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)

1 Like

@jlv - trying out your code. Thanks.

NVM - ignore below...seems like those warnings were already there - just hadn't seen them before I was playing w/more of the code.

Getting a warning in the code - ignore it?

Oops, also this:

My line numbers don't match the original code as I added a description and second additional like to include my second hub's address.

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.

1 Like

BINGO!

Works - can see all my rules! :smiley:

Thanks very much!

1 Like

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

Thank you very much @tomas1! Awesome job.

Question, could the Hub name be added somewhere that is always visible (unlike the spot HE decided to put it. :wink:). 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.

1 Like

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 :slight_smile: 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.

7 Likes

Thanks, yes that would be great. Where it is now, when all menus are open, it gets covered up and is useless.

This is super badass! I'm definitely checking this out when I get home.

@gopher.ny

3 Likes

You listening too, @bobbyD - this should result in 48% fewer support calls/contacts!! :slight_smile:

2 Likes

I was watching this and it really blew up quick. Finally installed it on Chrome / TamperMonkey. Very slick.

Had to do the small mod from above to get the graphs to work

Is this anything?

or this

Its just complaining about the code styling, it wants { } around the if statement. But it seems to work anyway.

Ok thanks, i think i put them in anyway.

this is a odd one as well.

some are just not there and i cant work out why some of the (:house:) are not grouping

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:

if (!document.title.includes('Hubitat')) {
    document.title = `Hubitat - ${document.title}`;
    document.foobar = `Haha`;
}

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.

if (!document.title.includes('Hubitat')) {
    document.title = `Hubitat - ${document.title}`;
    document.foobar = `Haha`;
}

This is defensive programming.

6 Likes

I LOVE the sorting of the rules...

2 Likes

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.

Reminds me of a friend who was doing LISP programming years ago...he said LISP stood for "Lots of Idiotic Stupid Parentheses." :slight_smile:

2 Likes

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.

4 Likes