I have successfully installed the helper libraries and I am now porting my DSL rules.
I have one issue with org.joda.time. It is mentioned here:
Use org.joda.time.DateTime from org.joda.time import DateTime start = DateTime.now()
When I try to use it, I am getting the error:
Error during evaluation of script ‘file:/etc/openhab/automation/jsr223/python/personal/Squeeze.py’: ImportError: No module named joda in /etc/openhab/automation/jsr223/python/personal/Squeeze.py at line number 3
@schup011 the issue you are having is actually because you have moved to OH3, not directly to do with the libraries. You are correct in using ZonedDateTime like you show in your last post, I recommend using that everywhere for consistency.
The documentation you have linked is actually from the original repo not mine, but you would find the same on mine at this time. I have not had time to update any of the documentation to also include examples for OH3.
Ok, thanks a lot, Ivan, for clarifying, that’s fine.
I was just wondering whether my installation was somehow wrong or broken.
I can live with that without a problem, knowing now how to correct the code.
For anyone who needs to adapt his rules: I was using DateTime.now()
before. ZonedDateTime.now()
did not work either, because one has to provide the zone. So, one needs to use from java.time import ZonedDateTime from java.time import ZoneId
and then use ZonedDateTime.now(ZoneId.systemDefault())
Anyone else getting these problems with newest snapshot? Some rules don’t load anymore…
File "/etc/openhab/automation/lib/python/core/triggers.py", line 353, in when
elif target_type == "Item" and trigger_target not in ["added", "removed", "updated"] and old_state is not None and trigger_type == "changed" and TypeParser.parseState(itemRegistry.getItem(trigger_target).acceptedDataTypes, old_state) is None:
ClassCastException: java.lang.ClassCastException: class org.openhab.core.library.types.OnOffType cannot be cast to class org.openhab.core.types.State (org.openhab.core.library.types.OnOffType is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @6052c10b; org.openhab.core.types.State is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @64c724e2)
Edit: Ok just downgraded to 3.4-M4 but the problems still there. Maybe it is not related to M6.
But still anyone else having these issues?
I had the same error after upgrading to M6. The mentioned line was 357 instead of 353, so I may have a different version of the helper libraries.
I did another restart of OH and than the error was gone. Btw. after a previous update I had the same error which was also gone “automagically”.
yesterday i updated to m6 and then i saw the same errors as you and @usambara reported in my log:
File "/etc/openhab/automation/lib/python/core/triggers.py", line 357, in when
elif target_type == "Item" and trigger_target not in ["added", "removed", "updated"] and new_state is not None and trigger_type == "received command" and TypeParser.parseCommand(itemRegistry.getItem(trigger_target).acceptedCommandTypes, new_state) is None:
ClassCastException: java.lang.ClassCastException: class org.openhab.core.library.types.DecimalType cannot be cast to class org.openhab.core.types.Command (org.openhab.core.library.types.DecimalType is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @4f4b1a; org.openhab.core.types.Command is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @46630b)
File "/etc/openhab/automation/lib/python/core/triggers.py", line 353, in when
elif target_type == "Item" and trigger_target not in ["added", "removed", "updated"] and old_state is not None and trigger_type == "changed" and TypeParser.parseState(itemRegistry.getItem(trigger_target).acceptedDataTypes, old_state) is None:
ClassCastException: java.lang.ClassCastException: class org.openhab.core.library.types.StringType cannot be cast to class org.openhab.core.types.State (org.openhab.core.library.types.StringType is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @4f4b1a; org.openhab.core.types.State is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @46630b)
File "/etc/openhab/automation/lib/python/core/triggers.py", line 355, in when
elif target_type == "Item" and trigger_target not in ["added", "removed", "updated"] and new_state is not None and (trigger_type == "changed" or trigger_type == "received update") and TypeParser.parseState(itemRegistry.getItem(trigger_target).acceptedDataTypes, new_state) is None:
ClassCastException: java.lang.ClassCastException: class org.openhab.core.library.types.OnOffType cannot be cast to class org.openhab.core.types.State (org.openhab.core.library.types.OnOffType is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @4f4b1a; org.openhab.core.types.State is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @46630b)
``
but i can confirm what usambara wrote: after another reboot of my rpi the errors dont appear again.