There are no questions or comments on the RPI deployment and configuration other than mine, and I feel it is quite an important topic given that a RPI is involved in the solution.
I managed to deploy the CXA custom component manually and I see it is able to send commands out. Not sure if those are landing with my raspberry. I will continue investigating during the next few weeks. There are 2 syntax corrections that need to be made, or home assistant will refuse to load the component. Check the pending pull request and you will see my proposed changes.
Hi all CXN/homeassistant integrators.
I made some changes into original github code by @liveencohe
What was done:
some refactoring
selected source now shown on HA mediaplayer card
device class defined
pre_amp_mode check added which solves volume level and mute state errors. Depending if preamp mode turned on or off different set of controls shown on media_player card UI.
shuffle and repeat mode set/read added
media album name and duration added
Please give a try and report issues if any.
Thanks.
Great work! I have been using your version of the component for the last few days without issues. Can you send a pull request, so I can merge your changes to my repo?
Iām currently reworking this cambridge_cxa component. It is now making use of MQTT/Node Red.
Basically, what happens, is that the Home Assistant Component uses MQTT to publish and read messages from certain MQTT Topics.
On the Raspberry Pi that connected over Serial-to-USB to the Cambridge CXA, I have Node Red running. The Node Red flow is also subscribed to the MQTT topics, and translates them to the relevant serial commands the CXA can understand.
Would such a solution make sense?
Iām only using MQTT/Node Red currently, because I canāt figure out a reliable way to address the serial connection directly (or indirectly using ser2net) from the Home Assistant component. If anyone could guide me here, this would be much appreciated, and the setup could be a lot less complex than it is currently.
I donāt think thereās docs available on the CXN endpoints. I reverse engineered the URLās that are called by proxying the commands while using the StreamMagic iOS app on my phone.
So, not sure why the skip_track seems not to be available on your unit. What are you playing when you get this error? This only works when a playlist is playing. I get an error while playing an internet radio stream too, which is normal.
What firmware is your device on? You can check it by opening a browser and entering the IP address of your CNX. The firmware version will be at the bottom of the page.
it is just awesome that you are working on this! In the past I had this all-in-one system from Maranta (Marantz Melody X) and I got used to doing everything off my iPhone. Then I couldnāt refrain myself and decided to sell it and go with discrete components, like a dedicated DAC, a dedicated streamer, a dedicated Ampā¦ When I made the move, I certainly did not imagine how easy and intuitive things were with my all-in-one!!!
Iām afraid I canāt help much as my coding skills are poor. I tried to drive my CXA using the RS232 port from the CLI, and I did not succeed; maybe my Serial port on the CXA is deadā¦ who knows!
Never heard of ser2net but I can give it a try. Iāll try to play around a bit with it and report back. Do you know what I discovered? it turns out you canāt control the CXA volume through the serial interfaceā¦ would you believe it???
I have been doing some more work on this, and have now succeed in getting this to work with ser2net. I canāt test a direct serial connection as my NUC running Home Assistant is too far from my CXA amplifierā¦
Anyway, if you have a device like a Raspberry Pi lying around, you can use it to connect the USB to Serial to the CXA. Install ser2net on the Raspberry Pi, and configure it so the serial connection can be used over the network.
Hi there! It is awesome that you manage to go ahead and work on this. Iāve had a raspberry sitting by the amp for weeks, ever since I discovered this threadā¦ I will give this a shot during the weekend and update this thread. I guess I rather use GitHub for issue tracking.
Did you by any chance found a way to control volume on the unit using the serial connection? it looks like Cambridge did not allow (for unit integrity protection maybe?) that through their serial protocol implementation or they just did not publish how to do it.
@lievencoghe all deployed. RPI set up. ssh key from HA already copied into RPI. I see a āconnection refusedā error on HA. Any suggestion on where to start?
[140259982100608] [Errno 111] Connection refused
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 200, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1744, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1781, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 208, in handle_service
await service.entity_service_call(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 678, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 943, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 715, in _handle_entity_call
await result
File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 705, in async_turn_on
await self.hass.async_add_executor_job(self.turn_on)
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/cambridge_cxa/media_player.py", line 283, in turn_on
self._command(AMP_CMD_SET_PWR_ON)
File "/config/custom_components/cambridge_cxa/media_player.py", line 198, in _command
s.connect((self._host, self._port))
ConnectionRefusedError: [Errno 111] Connection refused
I ssh into the RPI just fine from within HA cli. I need to figure out whether the request actually hits the RPI, when triggered from HA interface.
One question: you did remove username from this new version right?
It looks like you still need to install ser2net on your RPi, and make sure it is running. Have you done so? (At least the web socket errors you receive seem to indicate this)
FYI, the component does not use SSH sessions anymore. Itās using ser2net which makes a serial port available over the network. So indeed, there is no use for a username anymore in the configuration of the component.
Thanks! I had read the documentation on your GitHub page, but yes, I had not fully digested what ser2net meant. I would say that earlier today I managed to turn my Cambridge CXA61 on remotely using your component, but right after that every remote command that I send from HA is not reaching the amp correctly, or the amp is not accepting it, or maybe it is ser2net that is failing. For example, I just now powered on the amp, clicked on the on/off button on HA frontend, and this is what I see.
Is there anyway I can test the multiple pieces independently? Iām thinking of ssh-ing into the new RPI, and theyāre issuing local remote commands. Once, say, I verify on/off, mute, etc., locally on the new RPI, and then my next step that I would like to try would be from HA command line.
I donāt think this output is a good sign, is it?
root@raspberrypi:/home/marc# /etc/init.d/ser2net status
ā ser2net.service - Serial port to network proxy
Loaded: loaded (/lib/systemd/system/ser2net.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2022-11-13 08:11:13 GMT; 12h ago
Docs: man:ser2net(8)
Main PID: 1075 (ser2net)
Tasks: 1 (limit: 779)
CPU: 18.997s
CGroup: /system.slice/ser2net.service
āā1075 /usr/sbin/ser2net -n -c /etc/ser2net.yaml -P /run/ser2net.pid
Nov 13 16:04:21 raspberrypi ser2net[1075]: The dev write(2) for port cambridge had error: Internal I/O error
Nov 13 16:04:21 raspberrypi ser2net[1075]: The dev write(3) for port cambridge had error: Object was not ready for operation
Nov 13 16:55:11 raspberrypi ser2net[1075]: dev read error for device on port cambridge: Remote end closed connection
Nov 13 17:37:02 raspberrypi ser2net[1075]: The dev write(2) for port cambridge had error: Internal I/O error
Nov 13 17:37:02 raspberrypi ser2net[1075]: The dev write(3) for port cambridge had error: Object was not ready for operation
Nov 13 18:20:32 raspberrypi ser2net[1075]: dev read error for device on port cambridge: Remote end closed connection
Nov 13 20:49:23 raspberrypi ser2net[1075]: The dev write(2) for port cambridge had error: Internal I/O error
Nov 13 20:49:23 raspberrypi ser2net[1075]: The dev write(3) for port cambridge had error: Object was not ready for operation
Nov 13 20:53:53 raspberrypi ser2net[1075]: The dev write(2) for port cambridge had error: Internal I/O error
Nov 13 20:53:53 raspberrypi ser2net[1075]: The dev write(3) for port cambridge had error: Object was not ready for operation
root@raspberrypi:/home/marc#
Could you share a few tests that I could ran? Happy to move these posts to a Github issue.
Iāve managed to switch on my CXA61 from within HA. However, when I do so, HA interface wonāt transition from an idle player to an active one. So from then on, I canāt further interact with my CXA as I guess HA wonāt be sending other type of commands as it still believes the amp is still off
At this point I think Iāve made significant progress because that means that ser2net is accepting incoming messages, and this also proves that my CXA serial port is healthy (which could have not been the case as it is a refurbished product).
Could you continue to support me please? Many many thanks in advance. Iām very thankful for the work youāve done!!
Hi @lievencoghe !
Thanks for Your work.
I successfully connect my cxa61. HA (docker on RPI) detects it by serial2net on 127.0.0.1 but after few commands stops to sending new commands randomly. If I turn off an on cxa61 HA detects correctly is changing os state and starts to sending a few commands correctly then stops again. If I restart HA the issues is present again with the same issues.
Have You an idea to solve my issue?
Thanks
Thanks for all the work everyone has put into this.
I am struggling to get it working though.
I am trying to use the CXN integration, I have a CXA amp and probably dont need to change anything on the amp via HA, so happy with just CXN on its own. It looks like this should be possible but I am getting an error.
I have tried using @lievencogheās integration as well as the various forks in this thread.
I have copied the files into the custom_componants folder as described on github, added the supplied lines to the configuration.yaml and I have changed the IP address on the second line to that of my device.
I now get the following error in HA;
Platform error media_player.cambridge_cxn - Integration ācambridge_cxnā not found.
On github somebody suggests adding āversionā to the manifest.json file but it already appears to have one.
I also donāt seem to be able to find the integration on HACS either.