NSPanel Lovelace UI Cards (part 3/5, v0.9)

logo

This is part 3 of a 5-part collection of blockLibraries to use the NSPanel with the Lovelace UI. Check out the online documentation about how to use this library.

The required 5 libraries are:

All installed libraries need to have the same version number!

Blocks

For some description of the individual blocks of this library have a look in the online documentation.

Changelog

Version 0.9

  • modified colorwheel. Now returns color instead of position.

Version 0.8

  • fixed various selector issues
  • finally got shutter returnValue right
  • added page reload helper

Version 0.7

  • added option to hide the unit in cardThermo
  • fix for missing timerName, triggered error on direct call of some cards

Version 0.6

  • enhancement: changed returnValue uppercase for cardShutter to be compatible with openHAB shutter item
  • cleanup: moved fullpage Notification to Cards
  • bugfix: context Usage for next Statement was broken in ā€˜ForceContextForScriptā€™
  • enhancement: modified context handling to prevent usage on non-Card statements (stuck on screensaver)
  • enhancement: added helpers to modify all callback settings on-the-fly

Version 0.5

  • fix for broken refresh timers (since 0.4)
  • improved context usage of ā€˜start with forced contextā€™-helper

Version 0.4

  • improved multi-hardware-panel usage (not backwards compatible)
  • added feature to start on same page after leaving screensaver
  • added refresh on hardware button press
  • start screensaver if no startup action is given on callback
  • various bugfixes

Version 0.3

  • improved popupPage handling
  • returnValue of Entitiy Selector modification
  • added support for OpenWeatherMap Icons

Version 0.2

  • added documentation
  • initial realease

Version 0.1

  • pre-release

Resources

nspanel_cards.yaml

3 Likes

Very nice libary! Its really fun and easy to use.
I tried with the newest milestone release (4.2.0.M3).
Everything looks good.

But the ā€œCARD CHARTā€ is not working.
I get this error:

2024-05-26 11:56:44.226 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ā€˜a47f9cdc71ā€™ failed: org.graalvm.polyglot.PolyglotException: TypeError: undefined has no such function ā€œhistoricStateā€

What could be the Problem here?
I think this is the source:

for (i = NumberOfValues - 1; i >= 1; i--) {
              targetValue = parseFloat(items.getItem(item).history.historicState(time.ZonedDateTime.now()['minus'+OffsetUnit](i*Offset))?.state) * scaling;
              if (type == 'cardLChart' && !targetValue)
                continue;
              dataset += '~';
              if (type == 'cardLChart') {
                dataset += String(NumberOfValues - i) + ":";
              }
              if (type == 'cardChart' && targetValue > MAX_VALUE_BY_DESIGN)
                targetValue = MAX_VALUE_BY_DESIGN;
              if (targetValue > maxValue) {
                maxValue = targetValue;
              }
              dataset += String(Math.ceil(targetValue));
              if (type == 'cardChart' && i % Math.floor((NumberOfValues / (NumberOfXLabels - 1))) === 0) {
                dataset += '^-' + String(i*Offset) + OffsetUnit.substring(0,1).toLowerCase();
              }
            }

Hi Tuny,

thanks for pointing to this issue. I donā€™t have 4.2x running, but I can see in the openhab source code changes that historicState method has been removed since 4.2. As far as I can see it, history.historicState must be replaced with persistence.persistedState. Can you edit the file absorb-it:blockly:nspanel_cards in the Blocklibrary admin section (line 1868) and verify that this is working? Canā€™t check this for now.

Best regards, Rene

1 Like

Yes. It is working. Thank you very much.

Hi Tuny,

thanks for the feedback. Pushed some update to github, I will wait for further issues (and more testing time on my side) for some compatibility release.

Best regards, Rene

Same problem here, and your fix really fixed it. But it is line 1930 now. Which raises the question if this change made it into Github. :slight_smile:

Hi @Roi ,

thanks for bringing this up again. Itā€™ had found itā€™s way into github, but I did not released another version yet. Sorry, forgot about that, I will asapā€¦ :slight_smile:

All the best for the new year,
regards, Rene

1 Like

Hi Rene,

thank you very much! :slight_smile:

May I bring up something else? I get three lines of logging in openhab.log every time I refresh the screensaver (which is every 30 seconds here).

2025-01-15 19:26:00.159 [INFO ] [nhab.automation.script.ui.0fc6a95504] - starting script 'absorb_it_nspanel_notify' ...
2025-01-15 19:26:00.206 [INFO ] [nhab.automation.script.ui.0fc6a95504] - starting script 'absorb_it_nspanel_weatherupdate' ...
2025-01-15 19:26:01.208 [INFO ] [nhab.automation.script.ui.0fc6a95504] - starting script 'absorb_it_nspanel_status' ...

Is it possible to make logging optional? :wink:

I commented all console.log("starting script '"ā€¦ statements in the libraries but still see the log entries. :wink: Do I need to restart openHAB for this?

But also I do not altering the code, as my modifications are gone as soon as the libraries get updated.

Regards, and all the best for the new year as well,
Roi

Hi @Roi,

you are right, I just changed the logging level from standard to debug. But the new release needs to be waiting until I can get my hands on some devices again. Stay tuned,

best regards, Rene

PS: the comment should work fine, but it was probably cached somewhere

1 Like

Just wanted to say that I just started giving this a go and it works great, good job! I did notice though that the Thermo card says under the Temperature Change Action ā€œreturnVal=Tempā€ but the actual variable name needs to be returnValue, not returnVal. It should probably be mentioned somewhere that the variable block needs to be manually created as well, unless thereā€™s a way to somehow do that automatically? I did check the github docs and it says the variable name is ā€œreturValueā€ so thereā€™s a typo there too.

Hi @tardismechanic

thanks for pointing to the typos, fixed this (will be part of next release).

I did not found any way to create the variable automatically, except by using the related helper block. What do you think about the description there? Maybe I should link to this helper on every page where ā€˜returnValueā€™ is mentioned? Suggestions are really welcome,

best regards, Rene

The description on that page looks good, I think linking to it on the pages that use it would be a good idea too. I went by what was on the thermo card page which just mentions the variable so I assumed I needed to create it myself. It might be a good idea to put a copy of the block at the top of the library itā€™s used if possible or changing the wording on the blocks that use it to indicate using the helper block for those that didnā€™t necessarily go through all the documentation on github