How to integrate Busch und Jäger inet Radio in openHAB

Dear community,

I want to share my solution for integrating the Busch und Jäger inet Radio in openHAB.

As starting position I assume that:

  • the inet radio is already connected to your wifi
  • you are able to administrate the inet radio via webinterface
  • you have already created some radio stations

Sadly the only possibility how to communicate with the radio is via http. After getting the response we have to do some REGEX magic.

reqiurements:

I created two number items (station and volume) that get updated via http binding:

// Kuechenradio
Number UG_Kueche_Radiosender "Radiosender" <radio> (MM_Radios)  { http="<[http://kuechenradio/de/index.shtml:5000:REGEX(.*Station (.):.*)] >[0:GET:http://kuechenradio/de/general.cgi?es=1&ss=01] >[*:GET:http://kuechenradio/de/index.cgi?p%2$s]" }
Number UG_Kueche_Radiolaut "Lautstärke" <speaker> (MM_Radios) { http="<[http://kuechenradio/de/index.shtml:5000:REGEX(.*size=5 maxlength=5 value=\"(.*?)\".*)] >[*:GET:http://kuechenradio/de/index.cgi?vo=%2$s] "}

As the radio can also be switched on/off by hand I update the station item via http binding.

I have two different html codes to find the information I want:

  1. if the radio was switched off:
<legend>Zur Zeit l&auml;uft</legend>
				<p>
					:
					<p>
					<input type="text" name="--" readonly size=70 maxlength=64 value="" />
					</p>
  1. if the radio is currently playing e.g. Station 2:
<legend>Zur Zeit l&auml;uft</legend>
				<p>
					Station 2:
					<p>
					<input type="text" name="--" readonly size=70 maxlength=64 value="Berliner Rundfunk" />
					</p>

For getting the actual station I use the following regular expression:

.*Station (.):.*

This changed the item status to “2” if station 2 is playing. Currently I am dealing with the problem that the regex pattern giving me “null” when the radio is switched off. I am working on that! :sunglasses:

In the sitemap file I created a selection:

Selection item=UG_Kueche_Radiosender label="Sender:" mappings=[0="RADIO AUS", 1="Energy", 2="Berliner Rundfunk", 3="Fritz", 4="BB Radio", 5="Antenne Brandenburg", 6="MDR Jump"]

For the sake of completeness:
When choosing a radio station via openHAB the item gets updated via selection in the sitemap. For switching the radio off (“RADIO AUS”) the item status changes to “0” and as per item definiton the following url gets called:

// we are unable to switch the radio off directly but we have to activate a sleep timer
// so the radio gets switched off after 1 minute
http://kuechenradio/de/general.cgi?es=1&ss=01

Furthermore I am able to get the current volume level by http as this can also be changed by hand.
The html code relevant is:

http://kuechenradio/de/general.cgi?es=1&ss=01

I update my item by regular expression:

.*size=5 maxlength=5 value=\"(.*?)\".*)

In my sitemap file I created the following setpoint:

Setpoint item=UG_Kueche_Radiolaut label="Lautstärke:" minValue=2 maxValue=30 step=2

After adjusting the volume in openHAB the following url gets called:

// giving the item status to the url by %2$s
http://kuechenradio/de/index.cgi?vo=%2$s

I will update this as soon as I find any solutions for my problem.

Todos / ideas:

  • if possible: dynamically create the sitemap file depending on the radio - all possible radio stations are available via http-request
  • deal somehow with the “null” response if the radio was manually switched off.

Greetings,
Michael

1 Like