# Squeezebox IR

**URL:** <https://community.openhab.org/t/squeezebox-ir/32878>\
**Category:** Bindings\
**Tags:** squeezebox, infrared\
**Created:** [August 6, 2017, 9:28pm UTC](https://community.openhab.org/t/squeezebox-ir/32878 "2017-08-06T21:28:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrik\_gfeller](https://community.openhab.org/user_avatar/community.openhab.org/patrik_gfeller/32/118631_2.png) [@patrik\_gfeller](https://community.openhab.org/u/patrik_gfeller)\
**Post date:** [August 6, 2017, 9:28pm UTC](https://community.openhab.org/t/squeezebox-ir/32878/1 "2017-08-06T21:28:40Z")

</div>

Hi all,

I try to get the last IR code from my Squeezeboxes using OH 2.1 & the respective binding:

```csv
String ItemRadioIRCodeKueche "IR Code (Küche) [%s]" <remote> (GroupRadioIRCode) {
  channel="squeezebox:squeezeboxplayer:D841762A-D007-4609-988D-EC0A58A82A56:DEADBEEEF:ircode"
}

```

Other squeezebox channels work ok; anybody managed to get this working?  
with kind regards,  
Patrik

---

<div class="post-metadata">

**Author:** ![mhilbush](https://community.openhab.org/user_avatar/community.openhab.org/mhilbush/32/56108_2.png) [@mhilbush](https://community.openhab.org/u/mhilbush)\
**Post date:** [August 6, 2017, 10:54pm UTC](https://community.openhab.org/t/squeezebox-ir/32878/2 "2017-08-06T22:54:37Z")

</div>

> [@patrik\_gfeller](#):
>
> anybody managed to get this working?

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?

> <https://github.com/openhab/openhab2-addons/blob/09fa631c43bb6907b96baa8aac8a95aa2a750251/addons/binding/org.openhab.binding.squeezebox/src/main/java/org/openhab/binding/squeezebox/handler/SqueezeBoxPlayerHandler.java#L391>

---

<div class="post-metadata">

**Author:** ![digitaldan](https://community.openhab.org/user_avatar/community.openhab.org/digitaldan/32/114476_2.png) [@digitaldan](https://community.openhab.org/u/digitaldan)\
**Post date:** [August 6, 2017, 11:32pm UTC](https://community.openhab.org/t/squeezebox-ir/32878/3 "2017-08-06T23:32:10Z")

</div>

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

```xml
<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:

```java
 if (isMe(mac)) {
  triggerChannel(CHANNEL_IRCODE, ircode);
}

```

and then rules would look like

```java
rule "IR Code"
    when
        Channel "squeezebox:squeezeboxplayer:D841762A-D007-4609-988D-EC0A58A82A56:DEADBEEEF:ircode" triggered
    then
        logInfo("TEST","IR Code Received " + receivedEvent.event);
end

```

wdyt?

---

<div class="post-metadata">

**Author:** ![mhilbush](https://community.openhab.org/user_avatar/community.openhab.org/mhilbush/32/56108_2.png) [@mhilbush](https://community.openhab.org/u/mhilbush)\
**Post date:** [August 7, 2017, 11:00am UTC](https://community.openhab.org/t/squeezebox-ir/32878/4 "2017-08-07T11:00:27Z")

</div>

I hadn’t thought about setting it up as a trigger event, but that makes really good sense.

@patrik_gfeller Does that make sense for the use case you were trying to accomplish?

---

<div class="post-metadata">

**Author:** ![patrik\_gfeller](https://community.openhab.org/user_avatar/community.openhab.org/patrik_gfeller/32/118631_2.png) [@patrik\_gfeller](https://community.openhab.org/u/patrik_gfeller)\
**Post date:** [August 8, 2017, 5:35pm UTC](https://community.openhab.org/t/squeezebox-ir/32878/5 "2017-08-08T17:35:11Z")

</div>

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:

```php
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

```

with kind regards,  
Patrik

---

<div class="post-metadata">

**Author:** ![mhilbush](https://community.openhab.org/user_avatar/community.openhab.org/mhilbush/32/56108_2.png) [@mhilbush](https://community.openhab.org/u/mhilbush)\
**Post date:** [August 8, 2017, 8:57pm UTC](https://community.openhab.org/t/squeezebox-ir/32878/6 "2017-08-08T20:57:44Z")

</div>

> [@patrik\_gfeller](#):
>
> do I understand correctly; the example given does not work yet with the current 2.1.0 binding

Correct. The functionality described above doesn’t exist yet.

---

<div class="post-metadata">

**Author:** ![patrik\_gfeller](https://community.openhab.org/user_avatar/community.openhab.org/patrik_gfeller/32/118631_2.png) [@patrik\_gfeller](https://community.openhab.org/u/patrik_gfeller)\
**Post date:** [August 15, 2017, 3:21am UTC](https://community.openhab.org/t/squeezebox-ir/32878/7 "2017-08-15T03:21:53Z")

</div>

Shall I create an Issue for this? If so, can you please point me to the correct location?

thanks & kind regards,  
Patrik
