Executing Onkyo actions from Jython

The Onkyo binding allows to send raw eISCP commands (https://community.openhab.org/t/onkyo-testers-for-thing-action-to-send-raw-eiscp-commands/68446)

This works in DSL as such (entire rule is slightly edited):

rule "Onkyo change radio frequency"
	when
		Item Onkyo_Radio_Frequency received command
	then
		val onkyoActions = getActions("onkyo","onkyo:TX-NR555:av1")
		val radioFrequency = Onkyo_Radio_Frequency.state.toString
		var transformedFrequency = radioFrequency.replace('.', '')
		onkyoActions.sendRawCommand("TUN", transformedFrequency)

After reading:
https://crazyivan359.github.io/openhab-helper-libraries/Guides/Actions.html

and a few other posts in the forum I tried to replicate the above rule in jython but cannot seem to do so successfully. This is what I have:

@rule ("Onkyo change radio frequency")
@when ("Item Onkyo_Radio_Frequency received command")
def onkyoChangeRadioFrequency(event):
	onkyoActions = actions.get("onkyo","onkyo:TX-NR555:av1")
	radioFrequency = ir.getItem("Onkyo_Radio_Frequency").state.toString()
	transformedFrequency = radioFrequency.replace('.', '')
	onkyoActions.sendRawCommand("TUN", transformedFrequency)

but I get an error: Undefined variable 'actions' for this line:
onkyoActions = actions.get("onkyo","onkyo:TX-NR555:av1")

Also same error with: actions.get("onkyo","onkyo:TX-NR555:av1").sendRawCommand("TUN", transformedFrequency)

I also tried to import Onkyo: from core.actions import Onkyo however:

20:13:38.677 [ERROR] [ript.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab/automation/jsr223/python/personal/onkyo_avr.py': ImportError: cannot import name Onkyo in /etc/openhab/automation/jsr223/python/personal/onkyo_avr.py at line number 6

Just hoping there’s someone out there with some experience with this. I wonder whether I’m doing something wrong? Any suggestions gratefully received.

Running openHAB 3.2.0 Release Build.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.