I’m migrating my jython rules from oh2 to 3 and have a problem with using the items object.
The first three log lines work, but the last line throws an exception: object has no attribute ‘testNum’
OK. Thanks for letting me know. And thanks for the great work.
Another question if I may.
I’ve installed the Typing files from your repo, and also for the helper libraries, so in VSCode, ‘rule’, ‘when’ etc are known, but ‘items’, ‘itemRegistry’, ‘ir’ and others are unknown. Is this expected?
The code works ok, it’s just Pylance that cannot see them.
Read all of the documentation in the stubs repo, I cover how to do all of those things. Let me know if there is anything you don’t understand in there.
I read the documentation (again ). I guess I did not fully appreciate the ‘Usage’ section. It’s sinking in slowly.
I tried the example “In a Script” from that section, but it fails with
Error during evaluation of script 'file:/openhab/conf/automation/jsr223/python/personal/test2.py': ImportError: No module named typing in <script> at line number 1
Do I have to install ‘typing’ in Jython? How do I do that?
Hmm, I guess I need to clarify that then, thank you.
The choice to have typing installed or not applies to your OH installation in automation/lib/pytyon, not the system you are running VSCode on. The system you run VSCode on must have the typing library installed or you wouldn’t be getting any type hints.