Intro
I have recently been having some success in controlling music systems in the house. I use web pages which allow me to tailor the choice of music and the way it is played. Although android/iOS apps are available they require some faffing around to achieve resukts and each of them is different. A web page has just the options I want to use and it is easy to select albums or stream music from my home server. Previously I have set up the ability to control Denon amplifier, Sonos speakers and Pure Jongo devices.
The last remaining music device which would benefit from home control is a Roberts Radio 94i. It is a portable radio with wifi interface for music streaming. My Home Assistant system recognises the radio but doesnt allow me to do much more than turn it on or off.
PoC
Until recently I thought that there wasn't an app to provide remote control, then I came across UNDOK, which is recommended by Roberts and allows you to do all the necessary functions from an iPad.
Roberts don't provide documentation on commands to program the radio. Functionality is provided a by Frontier Silicon chip and although there isn't a specification, some people have managed to reverse engineer their software api so that FS devices can be controlled.I have had a lot of success recently using a TP-link monitor port and an iPad ethernet cable which allow me to monitor network traffic from the iPad using wireshark. I started monitoring UNDOK traffic between the iPad (192.168.0.200) and Roberts Radio (192.168.0.54) and found that communication uses HTTP GET commands with XML responses.
HTTP GET commands are easy to use, you can enter them directly into a browser and see the response, for example the power off command puts Roberts into standby and gives an "FS_OK" response:
I was hoping to use Javascript for programming but I soon fell foul of CORS (Cross-Origin Resource Sharing) as the Roberts Radio (RR) doesn't permit it (perfectly normal) and I quickly decided to use a python back-end which generally works well for me.
After a little experimentation I found that the fsapi-tools python library "fsapi.net" establsihes communication easily with RR:
Programming
Using the fsapi.net api programming for power (and volume) is very simple:
To view / change the preset we use a HTTP GET request:
Now we can set up a web page to control Roberts:In Javascript we can invoke the python commands using websockets. For example four commands are issued to update the power/volume/muted/preset current status:
Python responses are received back via the web socket and processed in Javascript to update the web page:
No comments:
Post a Comment