Custom component AIMP Media Player

hi,

I’m trying create AIMP integration with this:

using modified code from mphc and volumio component, but the code dont work

can someone point where i miss something,

    def send_aimp_msg(self, method, params=None):
        """Send message."""
        try:
            data = {"version": "1.1", "method": method, "id": "1", "params": params}
            requests.post(f"http://{self._url}/RPC_JSON", data=data, timeout=3)
        except requests.exceptions.RequestException:
            _LOGGER.error(
                "Could not send command %s to AIMP at: %s", method, self._url
            )

    def update(self):
        """Update state."""
        try:
            playinfo = self.send_aimp_msg("GetPlaylistEntryInfo", params="{playlist_id: -1, track_id: -1}")
            self._playinfo = playinfo.copy()

            control = self.send_aimp_msg("SubscribeOnAIMPStateUpdateEvent", params="{event: \"control_panel_state_change\"}")
            self._control = control.copy()

            coverurl = self.send_aimp_msg("GetCover", params="{playlist_id: -1, track_id: -1, cover_width: 512, cover_height: 512}")
            self._coverurl = coverurl.copy()

and here is the log

aimp: Error on device update!
Traceback (most recent call last):

  File "/config/custom_components/aimp/media_player.py", line 109, in update
    self._playinfo = playinfo.copy()
AttributeError: 'NoneType' object has no attribute 'copy'

[UPDATE]
You can download AIMP custom component for Home Assistant on link below:
AIMP custom component

[CASE CLOSED]

apparently my code didn’t work because no response from AIMP.

after add firewall exception and got response from AIMP,
few trial and error, my code works now… yay

only select source/playlist haven’t work yet, but other function works well

Could you please share your code template. I want to create same player.

1 Like

im sorry for late answer

you can check yaml config and AIMP custom component on my github

i just updated the custom component today, it broken on latest HA but it works now after fix breaking changes

feel free to ask again if there are something not clear