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.
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();
}
}
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.
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.
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ā¦
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
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.
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,
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