Closed jowi24 closed 3 years ago
I'm not familiar with this action, but the actions don't really need much help from the libraries. I'm going to guess it's an openHAB Core action so we'd need to add it in actions.py
as you suggest.
Looks like it's a service, not an action, that makes it a little harder. There is already a service getter in the OSGi module of the libraries, a new semantics.py
file could be created and a wrapper added to acquire and interface to this service.
Thank you for commenting my question. I realized that the Semantics action I tried to import is not yet avaible in https://github.com/openhab/openhab-core/tree/3.0.x but only in OH master branch... Thats why I failed :-(
If you can find the action code itself and give me a link I can check if you will be able to use it without modifying the libraries.
I just upgraded to OpenHAB 3.1.0M2 milestone release and could succesfully use the following code without need to modify your library :-)
from org.openhab.core.model.script.actions import Semantics
locationItem = Semantics.getLocation(pointItem)
Thanks for your help!
I will add this to the core/actions.py
module so that it can be use as simply from core.actions import Semantics
I will add this to the
core/actions.py
module so that it can be use as simplyfrom core.actions import Semantics
This works for me already. I have cloned the current branch.
@janwo are you using from actions import semantics
or from core.actions import semantics
?
from core.actions import semantics
Is your feature request related to a problem? Please describe. OH3 exposes a new action called "Semantics" to access attributes of the new OH3 semantic model, e.g. locations, equipments, points... I tried to use that action in Jython but it failed out of the box (see below).
Describe the solution you'd like It would be great to use Sematics action like other actions:
from core.actions import Semantics
...
locationItem = Semantics.getLocation(pointItem)
Describe alternatives you've considered I tried to import the action directly, but failed:
from org.openhab.core.model.script.actions import Semantics
Error during evaluation of script 'file:/etc/openhab/automation/jsr223/python/personal/tests.py': ImportError: cannot import name Semantics
Additional context Do you know what steps are required to use that new action? Is it required to extend
automation/lib/python/core/actions.py
?