edberoi / python-airmusicapi

Python based API to control Airmusic based Internet Radios.
Apache License 2.0
4 stars 3 forks source link

Integration with Home Assistant #1

Open DominikWrobel opened 2 years ago

DominikWrobel commented 2 years ago

Hi, your api for airmusic is great, I have it tested with my two internet radios:

Device Name: Radio Å�azienka { “SW_Ver”: “AT9THFCR-i724h-i713**ad-i725a-(DB:20211111)”, “wifi_info”: { “status”: “connected”, “MAC”: “0C8C243E5CE0”, “SSID”: “DOM3”, “Signal”: “76”, “Encryption”: “WPA2/AES”, “IP”: “192.168.0.141”, “Subnet”: “255.255.255.0”, “Gateway”: “192.168.0.1”, “DNS1”: “192.168.0.91”, “DNS2”: null } } Current volume = 3 Current mute = False Hotkeylist: 5 out of 5: 75_256, Muzo.fm, file 75_770, Antyradio 94 FM Warszawa, file 75_4, Rock Radio, file 75_0, Double Q 101 WWQQ FM 101.3, file 75_0, Radio TOK FM, file Verify navigation through menus to reach a station to play. List: 10 out of 10: 87 Local Radio → content 51 my mediaU → content 52 Internet Radio → content 2 Media Center → content 5 FM → content 91 DAB/DAB+ → content 3 Information Center → content 47 AUX → content 104 Bluetooth → content 6 Configuration → content List: 6 out of 6: 75 My Favorite → content 71 Radio Station/Music → content 87 Local Radio → content 154 Sleep Radio → content 59 History → content 4 Service → content List: 8 out of 8: 75_0 Muzo.fm → file 75_1 Antyradio 94 FM Warszawa → file 75_2 Rock Radio → file 75_3 Double Q 101 WWQQ FM 101.3 → file 75_4 Radio TOK FM → file 75_5 Radio Nowy Å�wiat → file 75_6 Rádio Anténa Rock → file 75_7 Empty → emptyfile Press CTRL-C to interrupt. Vol sid Status 3 1 Connecting … 3 1 Connecting … 3 1 Connecting … 3 1 Connecting … 3 1 Connecting … 3 1 Connecting … 3 1 Connecting … 3 1 Connecting … 3 1 Connecting … 3 1 Connecting … ^CGoing to play the radio station at hotkey 1. Press CTRL-C to interrupt. Vol sid Status 3 1 Connecting … 3 1 Connecting … 3 1 Connecting … 3 2 Buffering 25% 3 6 Playing 3 6 Playing 3 6 Playing

Second one:

created 8d last reply 4d 1 reply 53 views 1 user 2 links

DominikW Dominik Wrobel 4d

I’ve installed on my raspberry pi 4 (not running HA - I run HA on a Lenovo M72e) the tests.py from https://github.com/edberoi/python-airmusicapi

And after running it on my two internet radios I get this info:

Device Name: Radio �azienka
{
“SW_Ver”: “AT9THFCR-i724h-i713**ad-i725a-(DB:20211111)”,
“wifi_info”: {
“status”: “connected”,
“MAC”: “0C8C243E5CE0”,
“SSID”: “DOM3”,
“Signal”: “76”,
“Encryption”: “WPA2/AES”,
“IP”: “192.168.0.141”,
“Subnet”: “255.255.255.0”,
“Gateway”: “192.168.0.1”,
“DNS1”: “192.168.0.91”,
“DNS2”: null
}
}
Current volume = 3
Current mute = False
Hotkeylist: 5 out of 5:
75_256, Muzo.fm, file
75_770, Antyradio 94 FM Warszawa, file
75_4, Rock Radio, file
75_0, Double Q 101 WWQQ FM 101.3, file
75_0, Radio TOK FM, file
Verify navigation through menus to reach a station to play.
List: 10 out of 10:
87 Local Radio → content
51 my mediaU → content
52 Internet Radio → content
2 Media Center → content
5 FM → content
91 DAB/DAB+ → content
3 Information Center → content
47 AUX → content
104 Bluetooth → content
6 Configuration → content
List: 6 out of 6:
75 

Device Name: Oakcastle IR100 { “SW_Ver”: “5SADNB33-jb21h-jb21*a-jb21a-(DB:20220114)”, “wifi_info”: { “status”: “connected”, “MAC”: “74EE2A365265”, “SSID”: “DOM3”, “Signal”: “82”, “Encryption”: “WPA2/AES”, “IP”: “192.168.0.142”, “Subnet”: “255.255.255.0”, “Gateway”: “192.168.0.1”, “DNS1”: “192.168.0.91”, “DNS2”: null } } Current volume = 10 Current mute = False Hotkeylist: 5 out of 5: 75_0, Muzo.fm, file 75_1, Antyradio FM, file 75_2, Rock Radio, file 75_3, EskaROCK, file 75_4, Radio Nowy Swiat, file Verify navigation through menus to reach a station to play. List: 7 out of 7: 87 Local Radio → content 52 Internet Radio → content 2 Media Center → content 136 Spotify Connect → content 3 Information Center → content 104 Bluetooth → content 6 Configuration → content List: 5 out of 5: 75 My Favorite → content 71 Radio Station/Music → content 154 Sleep Radio → content 59 History → content 4 Service → content List: 10 out of 10: 75_0 Muzo.fm → file 75_1 Antyradio FM → file 75_2 Rock Radio → file 75_3 EskaROCK → file 75_4 Radio Nowy Swiat → file 75_5 ANTENA ROCK → file 75_6 Zlote → file 75_7 MELO- → file 75_8 TOK FM → file 75_9 Empty → emptyfile Press CTRL-C to interrupt. Vol sid Status 10 1 Connecting … 10 2 Buffering 25% 10 6 Playing 10 6 Playing 10 6 Playing 10 6 Playing 10 6 Playing ^CGoing to play the radio station at hotkey 1. Press CTRL-C to interrupt. Vol sid Status 10 6 Playing 10 1 Connecting … 10 3 Buffering 50% 10 6 Playing 10 6 Playing

Everything works fine, my issue is that I would like to integrate this api with home assistant so I can use the media player to control these radios - but I have no idea how to do that.

edberoi commented 2 years ago

Hi Dominik, it is nice to read the API is helpful for you. The API was written to enable others to kick-start development of higher applications, or for those like you owning different devices and potentially able to extend the API even with features not available in the device I own. Home Assistant was not the first thing I had in mind, but I am sure it should be possible to integrate this API in HA.

I am not a user of HA, but I think you can integrate with HA in two ways:

  1. For specific tasks / services a Python script is created, where the script imports the airmusic API. (See: https://www.home-assistant.io/integrations/python_script/)
  2. Add the API to HA, but that might need some tailoring and probably you will need to publish on PyPi as well. (See: https://developers.home-assistant.io/docs/api_lib_index)

Not sure what is easier / faster / better in your case.

If you have suggestions to improve the API code to enable integration with HA, just let me know.

Cheers, Eric.

DominikWrobel commented 2 years ago

Thank you for your answer. I just started with Home Assistant and I have no programming knowlage, I just want to kontrol my kitchen radio via HA, because the airmusic app is crappy and I have everything alse controlled via HA (like lights, vacuum, cameras etc.)

I probablly could set up scripts with commands to the airmusic api - but 1. I have no idea how to install it on my Home Assistant machine (running bare metal install) - I have the API set up for testing on my raspberry pi but I have no idea how to send commands from HA to Pi4. Any help would be great.

edberoi commented 2 years ago

As I have no experience in Home Assistant it is difficult to give advice. My suggestion is to lookup assistance from the Home Assistant community. It must be possible to add this Airmusic API / library to Home Assistant at its configuration. From that point on it is possible to configure the actions, like on / off / mute/ etc., as well, using the API directly. No need to have the Home Assistant host to communicate with the RPi.

Cheers, Eric.