I’ve never used this, but I took a quick look at the code. I’m not quite sure why irCodeChangeEvent calls postCommand when every other change event calls updateChannel.
@digitaldan By any chance, do you remember why irCodeChangeEvent is handled differently than the other change events?
Strange, I have no idea why its like that, but it does not look right. Also irCodeChangeEvent is a good candidate for a trigger channel since I don’t think is makes sense to store state here or tie it to a item. I think the idea is that you trigger a rule when a new ir code event comes in. . So we would change the thing channel definition to
<channel-type id="ircode" advanced="true">
<kind>trigger</kind>
<label>IR Code</label>
<description>Trigger channel for the last IR code sent (string)</description>
<event></event>
</channel-type>
The code would change to:
if (isMe(mac)) {
triggerChannel(CHANNEL_IRCODE, ircode);
}
and then rules would look like
rule "IR Code"
when
Channel "squeezebox:squeezeboxplayer:D841762A-D007-4609-988D-EC0A58A82A56:DEADBEEEF:ircode" triggered
then
logInfo("TEST","IR Code Received " + receivedEvent.event);
end
Thank you for your reply - do I understand correctly; the example given does not work yet with the current 2.1.0 binding (@ least it did not work for me).
I could use this to update the item … but using the known pattern of just having an item bound to the channel would be prefered - but that would work as well:
val fileName = "IR.rules"
rule "IR Code Küche"
when
Channel "squeezebox:squeezeboxplayer:D841762A-D007-4609-988D-EC0A58A82A56:DEADBEEF:ircode" triggered
then
logInfo(fileName,"IR: " + receivedEvent.event)
ItemRadioIRCodeKueche.postUpdate(receivedEvent.event)
end