openHAB 4.2 Milestone discussion

Hello seeing this warning now during startup

[aml.internal.YamlModelRepositoryImpl] - Version is missing or not a number in model automation/js/node_modules/@jamescoyle/vue-icon/pnpm-lock. Ignoring it.

Problem with tado binding in M3 is normally fixed by

4.2 code changes only

I Upgraded from 4.2M2 to 4.2M3

a) you have analyzed your issue

I noticed that the calculation was not correct since the update from 4.2m2 to 4.2M3. so I tried to solve it by writing it in a line of logs so that I can understand and filter the problem. But when I noticed that 2 values ​​were not added correctly, I don’t have the skills to look in the ā€˜source code’. That’s why I listen here if something has changed so that it can be adjusted again. In the meantime I had to do a downgrade.

b) your issue is reasonably likely to be caused by recent code changes in latest milestone

I upgradet from 4.2m2 to 4.2M3 so I think the problem is in M3 and if i go back the problem is gone. I can be wrong an if I am please let me know!

I looked at the changed code again, and nothing jumps out to me that could cause a difference, except that StateSince now returns a State (with unit) instead of a DecimalType. I may be wrong, but I suspect your item or persistence definitions have an error in unit definitions, which didn’t cause an issue before because it was not returning a unit.
To further analyse more logging would be required. It is best to break this into a separate topic.

I have another issue:

I have an inline blockly script. In this script there is a block looking like that:

grafik

The generate code looks like that:

var newRainValue;


newRainValue = event.oldItemState !== undefined ? Quantity(event.oldItemState.toString() : undefined);

I think the closing bracket is on the wrong location so it generates an error:

 <eval>:34:0 Expected eof but found }                                                                                                                                             
 }                                                                                                                                                                                
 ^                                                                                                                                                                                
                                                                                                                                                                                  
         at org.graalvm.polyglot.Context.eval(Context.java:399)                                                                                                                   
         at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:458)                                                                             
         at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:426)                                                                             
         at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:262)                                                                                  
         at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutocloseable 
         ... 20 more                                                                                                                                                              
 14:12:47.089 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID '871ce9c1b4' failed: org.graalvm.polyglot.PolyglotException: SyntaxError: <eval> 
   newRainValue = event.itemState !== undefined ? Quantity(event.itemState.toString() : undefined);                                                                               
                                                                                      ^                                                                                           
 <eval>:11:91 Expected , but found :                                                                                                                                              
   oldRainValue = event.oldItemState !== undefined ? Quantity(event.oldItemState.toString() : undefined);                                                                         
                                                                                            ^                                                                                     
 <eval>:34:0 Expected eof but found }                                                                                                                                             
 } 

I can try to remove unit definition the if you won’t?

I am pretty sure that it is nothing to do with the change from DecimalType to UoM. I did that myself in a prior PR and am essentially testing that 7/24 on my current operative system on M2.

I am pretty sure that the issue is indeed due to the auto generated code produced from the YAML file by Swagger CodeGen. When you say you ā€œlooked at the changed codeā€ were you just looking in src/main/java or did you look in target/generated-sources/swagger/src/main/java too?

Yes, that’s definitely a regression. File an issue on openhab-webui.

1 Like

I created an issue:

1 Like

The line of thinking is that there is an issue with Return units in persistence extension commands and support future persisted states by mherwege Ā· Pull Request #3736 Ā· openhab/openhab-core Ā· GitHub. There is no specific code generated in that, and I don’t find a fault at this time with it. I don’t see the relation to Swagger CodeGen. Without further detailed logging, I don’t knwo what it is.

Obviously, the above PR changes the return types of some of the persistence actions to State, which includes a unit when it is a QuantityType. Before these actions just returned a DecimalType without unit, effectively losing the quantity and forcing guessing of the unit (although most of the time you would know and could assume or hard code).
What strikes me is that the issues I see so far are all with rules DSL. Also, specifically here Unknown variable or command ā€˜-’ In Rule - #5 by norbert_jordan. In all cases it is trying to use plain Number items on channels that return QuantityTypes and then do calculations with it in DSL. I believe the persistence actions return the correct value, but it is the calculation that goes wrong. It should be possible to solve this in the DSL rule by forcing the correct type, but I still do not understand why that happens.

@TomV

Could you try with (using DecimalType instead of Number):

val Number export_uur_dag = (Dagtarief_export.deltaSince(now.minusHours(1)) as DecimalType)
val Number export_uur_nacht = (Nachttarief_export.deltaSince(now.minusHours(1)) as DecimalType)

val Number import_uur_dag = (Dagtarrief.deltaSince(now.minusHours(1)) as DecimalType)
val Number import_uur_nacht = (Nachttarief.deltaSince(now.minusHours(1)) as DecimalType)

//prijs berekening
val Number injectie_net = ((export_uur_nacht + export_uur_dag) * (ELE_prijs_actiefkWh_inj.state as DecimalType))
val Number verbruik_net = ((import_uur_dag + import_uur_nacht) * (ELE_prijs_actiefkWh.state as DecimalType))

I thought you were responding to the post related to the Tado binding, where in M2 there was indeed a PR to schange from a DecimalType to a UoM, but the OP saw the problem in M3 (and M2 worked just fine). However I think you were talking about something else, so please ignore my comment.

I updated from M2 to M3
Also if there are no updates for shelly binding now i cannot add from .things file shelly gen1. (gen 2 works fine)
Gen1 from .things file say: ā€œUnable to connect to device - ConnectException: Connection refusedā€

Thing shelly:shelly25-roller:RS_BAGNO 		"Tapparella Bagno  172.24.74.75" @ "Bagno" 	[deviceIp="172.24.74.75", userId="", password=""]
Thing shelly:shellyplus1pm:SC_BAGNO 		"Scaldabagno" @ "Bagno"	 					[deviceIp="172.24.74.76", userId="", password=""]

First doesn’t work (and was working fine) 2nd still works.
Commenting the shelly25 and adding the shelly 2.5 from inbox with the same id everything works fine.
Any idea?

Ok will try that! Thx for the help and I let you kown if it worked or not!
I will test it tomorrow because there is a malfunction of the internet so I can’t upgrade…

Sorry for the late answer! Was a busy week!

I have tested your proposal but I get an error message.

2024-06-01 13:37:06.096 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'Test-1' failed: Could not cast 0 kWh to org.openhab.core.library.types.DecimalType; line 27, column 30, length 55 in Test

If i test the old code

//Totaal net verbruik
val Number import_uur_dag = (Dagtarrief.deltaSince(now.minusHours(1)) as Number)
val Number import_uur_nacht = (Nachttarief.deltaSince(now.minusHours(1)) as Number)



// Totaal injectie net
val Number export_uur_dag = (Dagtarief_export.deltaSince(now.minusHours(1)) as Number)
val Number export_uur_nacht = (Nachttarief_export.deltaSince(now.minusHours(1)) as Number)


//prijs berekening
val Number injectie_net = ((export_uur_nacht + export_uur_dag) * (ELE_prijs_actiefkWh_inj.state as Number))
val Number verbruik_net = ((import_uur_dag + import_uur_nacht) * (ELE_prijs_actiefkWh.state as Number))


	postUpdate(DeltaWattDagAVG, DeltawattDag_1.averageSince(now.minusYears(1)))
	logInfo("testing", "export_uur_dag = {}", export_uur_dag)   
	logInfo("testing", "export_uur_nacht = {}", export_uur_nacht)   
	logInfo("testing", "import_uur_dag = {}", import_uur_dag)   
	logInfo("testing", "import_uur_nacht = {}", import_uur_nacht) 
	logInfo("testing", "tussen_resultaat1 = {}",(export_uur_nacht + export_uur_dag))  
	logInfo("testing", "tussen_resultaat2 = {}",(import_uur_dag + import_uur_nacht))
	logInfo("testing", "import_price = {}", ELE_prijs_actiefkWh.state as Number) 
	logInfo("testing", "export_price = {}", ELE_prijs_actiefkWh_inj.state as Number) 
	logInfo("testing", "injectie_net = {}", injectie_net)
	logInfo("testing", "verbruik_net = {}", (verbruik_net))	

the result is

2024-06-01 13:40:32.611 [INFO ] [rg.openhab.core.model.script.testing] - export_uur_dag = 0 kWh
2024-06-01 13:40:32.612 [INFO ] [rg.openhab.core.model.script.testing] - export_uur_nacht = 0.010 kWh
2024-06-01 13:40:32.612 [INFO ] [rg.openhab.core.model.script.testing] - import_uur_dag = 0 kWh
2024-06-01 13:40:32.612 [INFO ] [rg.openhab.core.model.script.testing] - import_uur_nacht = 0.005 kWh

2024-06-01 13:40:32.614 [INFO ] [rg.openhab.core.model.script.testing] - tussen_resultaat1 = 36000
2024-06-01 13:40:32.615 [INFO ] [rg.openhab.core.model.script.testing] - tussen_resultaat2 = 18000
2024-06-01 13:40:32.616 [INFO ] [rg.openhab.core.model.script.testing] - import_price = 10.04047
2024-06-01 13:40:32.616 [INFO ] [rg.openhab.core.model.script.testing] - export_price = 0.518
2024-06-01 13:40:32.617 [INFO ] [rg.openhab.core.model.script.testing] - injectie_net = 18648.000
2024-06-01 13:40:32.617 [INFO ] [rg.openhab.core.model.script.testing] - verbruik_net = 180728.46000

If I can test something else let me know i go back to m2. But i can stil test it.

@TomV

In some of my own testing, what worked was something like:
(EVMeterstand.state as QuantityType).toBigDecimal

Rules DSL is picky about these types and sometimes makes bad conversions. I normally don’t use Rules DSL, but the above worked for me.

So if I’m correct it has to look like this?

val Number export_uur_dag = (Dagtarief_export.deltaSince(now.minusHours(1)) as QuantityType).toBigDecimal

Yes

That worked for me also!
the only thing i had to do was add a parameter.

for example

val Number import_uur_dag = (Dagtarrief.deltaSince(now.minusHours(1)) as QuantityType<Energy>).toBigDecimal

thx for the help!!

Can somebody confirm that this error still exists in M3?
I am getting the following error message when calling isBankHoliday:

java.lang.Exception: java.lang.NoClassDefFoundError: Could not initialize class de.focus_shift.jollyday.core.HolidayManager