I am making some progress on an Oppo Bluray Player binding over RS-232.
I have two threads (CommandSender and CommandReceiver), which handle the input and output from the RS-232 port. This is because if the player is set in "Verbose Mode", it will send events at anytime. These events correspond to state changes in the device. For example transitioned from playing to paused. Ultimately I want to fade lights up and down when these events occur.
Messages from OpenHAB are placed onto an internal event queue, which are then picked up by the Sender thread.
The Receiver thread listens for SerialEvent messages from the device and puts them onto its own internal event queue, which is then read and sent to the OpenHAB EventBus. I'm doing this to decouple the OpenHAB bus from the Serial port.
So far it's working with the two threads being completely asynchronous. Commands are sent to the player (eg, #PON to power the player on) and the corresponding response (@OK ON) is returned.
I then send this to the OpenHAB event bus, but receive a message from the bus indicating that is can't update a non-existing item.
I am unsure what to send as the itemName. The Javadoc just says...
/**
* Initiate asynchronous sending of a status update.
* This method returns immediately to the caller.
*
* @param itemName name of the item to send the update for
* @param newState the new state to send
*/
public abstract void postUpdate(String itemName, State newState);
My home.items looks like this...
Switch Oppo_Living_Power { oppoblurayplayer="hometheatre:Power:60000" }
Is the itemName "hometheatre" or "Oppo_Living_Power" or "Power"? Or something else?
Here is a debug log of the transaction.
23:39:22.227 DEBUG o.o.b.o.i.OppoBlurayPlayerBinding[:204]- Sending command POWER_ON to 'hometheatre'
23:39:22.227 DEBUG o.o.b.o.i.OppoBlurayPlayerDevice[:58]- Command: '#PON'
23:39:22.227 DEBUG o.o.b.o.i.c.OppoBlurayPlayerCommandSender[:79]- Sending command POWER_ON. Will attempt to add it to the event queue.
23:39:22.228 DEBUG o.o.b.o.i.c.OppoBlurayPlayerCommandSender[:57]- Sending command #PON
23:39:22.248 DEBUG o.o.b.o.c.OppoBlurayPlayerSerialConnector[:156]- SerialPortEvent received. /dev/ttyUSB12: 1
23:39:22.299 DEBUG o.o.b.o.c.OppoBlurayPlayerSerialConnector[:173]- SerialPortEvent line received. @OK ON
23:39:22.300 DEBUG o.o.b.o.i.c.OppoBlurayPlayerCommandReceiver[:120]- Received command @OK ON. Will attempt to add it to the event queue.
23:39:22.300 DEBUG o.o.b.o.i.c.OppoBlurayPlayerCommandReceiver[:66]- Received command @OK ON. Will attempt to send it to eventbus
23:39:22.301 DEBUG o.o.c.i.items.ItemUpdater[:76]- Received update for non-existing item: Item 'hometheatre' could not be found in the item registry
Should I be looking up the itemName somehow? Bearing in mind that the update comes in out of context. I don't know what command solicited it, if any.
I am running OpenHAB 1.5.1 on Ubuntu.
Thanks, Net Wolf.