# Executing Onkyo actions from Jython

**URL:** <https://community.openhab.org/t/executing-onkyo-actions-from-jython/132069>\
**Category:** Bindings\
**Tags:** jsr223, jython\
**Created:** [January 19, 2022, 9:34am UTC](https://community.openhab.org/t/executing-onkyo-actions-from-jython/132069 "2022-01-19T09:34:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lukie](https://community.openhab.org/letter_avatar_proxy/v4/letter/l/3e96dc/32.png) [@Lukie](https://community.openhab.org/u/Lukie)\
**Post date:** [January 19, 2022, 9:34am UTC](https://community.openhab.org/t/executing-onkyo-actions-from-jython/132069/1 "2022-01-19T09:34:50Z")

</div>

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](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):

```auto
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](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:

```auto
@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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![system](https://community-openhab-org.s3-eu-central-1.amazonaws.com/original/2X/6/6a52f2ac5d00e4c7b50471a354b3a9221188be90.png) [@system](https://community.openhab.org/u/system)\
**Post date:** [March 2, 2022, 1:35am UTC](https://community.openhab.org/t/executing-onkyo-actions-from-jython/132069/2 "2022-03-02T01:35:03Z")

</div>

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