[RELEASE] Hub Information Driver v3

I know how to add the % symbol.
I'm talking about display the number as "15" % instead of "0.15"

Use a rule to
Set hubVariable to cpuLoad *100
Then display the variable on a tile.

3 Likes

Any chance this can be added as an option within the device, like with the memory?

It could be done, but load isn't a percentage, and you'd need to divide it by 4 (# of cores in the CPU) and then multiply it by 100 to make it approximate a true value (i.e. cpuPct).

2 Likes

Not sure if I’m missing something regarding @vadimchp ’s question but I of course defer to @thebearmay . Here is my Hub Status dashboard:

Again, not sure what the continued confusion is about (I’m probably just missing the point @vadimchp is trying to make)?

2 Likes

Seems to me that he just doesn’t want the intermediary step of a rule creating the integer percentage, but just wants to directly display a number in a tile on the dashboard. Such a rule would have to run periodically (or trigger on changed) to keep the percentage updated for the tile.

Yes, that’s my point (and my point of confusion) as the percentage value is taken directly from the cpuPct attribute by @thebearmay ’s excellent Hub Information app and is already expressed in % value. Anyway, @thebearmay can better explain this. I have been using @thebearmay ’s device app since it came out for the last several years to keep track of my Hub status (per my dashboard screen shot). Anyway, was just trying to understand what @vadimchp was trying to do for my own understanding and learning.

I actually think I understand what @vadimchp need is about - I myself use @garyjmilne Tile Builder to concate the % symbol in my tile on HD+.
image
I get that the value is numeric - the symbol is extraneous to the attribute - as my mother would say 'it's decorative, desired by unnecessary'. so I see both viewpoints.
Can't this be solved with css? just add a ' %' somehow ... my crappy css:

<input type="text" class="percent">

.percent::after {
    content: ' %';
}

Would that solve the issue?

My objection to the request is that displaying the raw load value as a percentage is completely inaccurate, i.e. a load value of 4.0 is roughly saying that that hub has enough threads waiting or running such that it should be considered 100% busy, this request would make that value seem to be 400% busy.

5 Likes

I see—so it is % per core. I guess I'll just run a rule for this. I am trying to display this for a broader audience, who need a simplified figure.

1 Like

Compare what you get to the cpuPct value in the driver...

1 Like

The cpuPct IS the simpler figure. Not sure why you refuse to just use that? The percent here is just approximated from the load, the hub does not report an actual percent only the load value. CPU load is not a percent and it can be greater than 1.0 per core as explained in this article below.

2 Likes

So the “Cpu 5 min” is the load not percentage? And the “CPU Pct” is the actual percentage (over 100)?
Eg:

CPU 5 Min is the average load over a 5 min time span, the CPU Pct is that number coverted to an approximate percentage of CPU usage using the formula:
CPU5Min / NumberOfCores * 100
where NumberOfCores = 4

3 Likes

I installed this package, created the virtual device (I called it "Hub Information Driver"), and set up polling. Now I'm trying to use one of its attributes in a Log Action in Rule Machine, but I can't figure out how to access it. Is what I'm trying to do even possible? My action is "Log: 'Mode is now %Hub Information Driver currentMode%'", but this currentMode stays "null", even though it is shown as "Evening" in the Events section of the virtual device.

Remove "Hub Information Driver". It should just be "%currentMode%".

Edit: I just realized I have something similar and that variable will not work in a basic log rule. Setup something like the screenshot. If you us the variable %text%, that is acutally all you need as it will read "Home in now in Away mode"

3 Likes

Thanks for helping, @CAZ! Indeed I had already tried the plain "%currentMode%". I'm now trying to create the special local variables you show, but when I am asked for "Variable Type", the dropdown shows only Number, Decimal, String, Boolean, and DateTime. How are you creating those special local variables?

Thank you for the reference, @UserSeventeen. Based on the web page you pointed to, I was able to test the built-in local variables, which appeared in the list of local variables once I added a trigger for my test rule, and used the trigger instead of just "run actions" to cause the rule to fire. The result (of my log action) is:

app:134 2025-01-08 12:58:02.770 info Log test of currentMode: (null); device: (Sunroom east light button); value: (1); text: (Button 1 (On) was pushed); date: (2025-01-08); time: (12:58); now: (12:58)

Note that the %text% variable refers to the trigger, not to the previous action in the rule's action list (which was to set Mode to Day). I'm learning something, and I'm pleased about that, but it doesn't address my original problem, which was to access the information set up by the Hub Information Driver. When I look at that virtual device, under Events and under Current States I see all the right stuff, including currentMode, but I have no idea how to pull that information into a Log action in another rule.

In a rule machine trigger you can also trigger on any attribite changing without variables. Use custom attribute trigger. Ie

1 Like

Ah, I think I get it now! In a rule, I can do "percent-style" references only to local variables (including the "special" ones mentioned in the documentation for rule 5.1, that is, %text%, %value%, and friends), so if I want to refer to a device attribute, I have to first pull that into a local variable. That works! Thanks, @UserSeventeen.

And thank you also, @kahn-hubitat, for reminding me that I could just trigger on the attribute change (in Hub Information Driver) directly. That's not what I'm looking for in this case, but it will be useful for other cases.

1 Like