home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.67k stars 30.42k forks source link

Monoprice 6-Zone Amplifier fails after updating to 2023.11.1 #103399

Closed arretx closed 9 months ago

arretx commented 11 months ago

The problem

Home Assistant 2023.10.5 Supervisor 2023.10.1 Operating System 11.1 Frontend 20231005.0 - latest

I'm running this as a VM on Unraid (qcow2, I believe)

The integration failing: Monoprice

What version of Home Assistant Core has the issue?

2023.11.1

What was the last working version of Home Assistant Core?

2023.10.5

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Monoprice

Link to integration documentation on our website

https://www.home-assistant.io/integrations/monoprice/

Diagnostics information

There seems to be no debug link on the integration page. I have already rolled back to the previous HAOS to avoid the problem.

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2023-11-02 08:45:04.448 ERROR (Recorder) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/serial/urlhandler/protocol_socket.py", line 203, in write
    n = self._socket.send(d)
        ^^^^^^^^^^^^^^^^^^^^
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1219, in async_request_call
    return await coro
           ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 715, in async_turn_on
    await self.hass.async_add_executor_job(self.turn_on)
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/monoprice/media_player.py", line 200, in turn_on
    self._monoprice.set_power(self._zone_id, True)
  File "/usr/local/lib/python3.11/site-packages/pymonoprice/__init__.py", line 36, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pymonoprice/__init__.py", line 207, in set_power
    self._process_request(_format_set_power(zone, power))
  File "/usr/local/lib/python3.11/site-packages/pymonoprice/__init__.py", line 153, in _process_request
    self._send_request(request)
  File "/usr/local/lib/python3.11/site-packages/pymonoprice/__init__.py", line 144, in _send_request
    self._port.write(request)
  File "/usr/local/lib/python3.11/site-packages/serial/urlhandler/protocol_socket.py", line 231, in write
    raise SerialException('write failed: {}'.format(e))
serial.serialutil.SerialException: write failed: [Errno 32] Broken pipe

Additional information

Strange behavior. What happens is the devices (6 of which are enabled, the remaining 12 are disabled) fail to respond to any controls issued from the media_player control for each zone, producing the BrokenPipeError: [Errno 32]

If I delete the integration and reconfigure it from scratch, it works for a short period of time, and then fails again.

Since there's an RS232 to Ethernet Adapter between the Monoprice Amp and Home Assistant, I thought perhaps that might be the problem, but it's working as expected. No manner of rebooting those devices changes anything.

I crossed my fingers and rolled back to my most recent version with a full restore and everything was back to normal, except for one big problem that I revealed that's not related. A full restore wiped out my mapped Media folder in the Storage setup which is on my NAS. I'll save that issue for another day.

home-assistant[bot] commented 11 months ago

Hey there @etsinko, @onfreund, mind taking a look at this issue as it has been labeled with an integration (monoprice) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `monoprice` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign monoprice` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


monoprice documentation monoprice source (message by IssueLinks)

OnFreund commented 11 months ago

That's strange. There hasn't been any change to the integration in this release (and for quite a while now), and I also made sure the pyserial dependency has stayed in the same version. A couple of questions:

  1. Are you using the same Python version in the last working HA version?
  2. The adapter is just to extend serial over a cat cable, right? You're not running it over IP
  3. Any other change in your environment?
arretx commented 11 months ago

I'll back everything up again and migrate to the newest core to see if the problem comes back. No other changes, correct. I don't know about Python or its version. I just go with the latest core releases to HA. The adapter for the amp is a simple ethernet to rs232 converter. The amp doesn't support direct ethernet, unfortunately. ;). After I upgrade again, I'll see if I can't increase the logging level and grab some log information.

OnFreund commented 11 months ago

The amp doesn't support direct ethernet, unfortunately. ;)

I know, but you can have a computer connected to it and run serial over ip. Not relevant in this case though.

Please update after the upgrade.

OnFreund commented 11 months ago

Any news? Did you try 2023.11.2?

pookieman commented 11 months ago

Hello in a similar situation .. suddenly this integration stopped working with latest upgrade currently on 2023.11.2

The one thing I noticed though was this error

Logger: homeassistant.components.monoprice
Source: components/monoprice/__init__.py:32
Integration: Monoprice 6-Zone Amplifier (documentation, issues)
First occurred: 4:22:00 PM (19 occurrences)
Last logged: 4:42:08 PM

Error connecting to Monoprice controller at /dev/ttyUSB0

when i login and check the /dev dir I see ttyUSB1

So it seems like the port has changed.. I was trying to check how to update my configuration so it looks at ttyUSB1 instead. The only place I can see this setting is in the UI under

Edit the name of this config entry

but I changed that value and restarted the host .. didn't help. I guess I could remove/readded the whole integration again but was hoping to avoid all that drama.

pookieman commented 11 months ago

I did some more poking. I removed all the monoprice integrations/readded and pointed to USB1. Then I restarted and see this

image

it's just repeating over and over

pookieman commented 11 months ago

OK last post :)

I did a hard reboot of the host for HASS. Then I noticed the USB0 had returned .. I removed the monoprice integration and readded it .. presto it works .. no idea what happened it's all working now on version

image

Note .. I have automated nightly backups .. if I run into any surprising issue after an upgrade it's always nice to have a backup I can restore the system to!

pookieman commented 11 months ago

I lied .. was working then randomly stopped .. I see this error now .. after switching back to USB0

image
OnFreund commented 11 months ago

@pookieman seems like you're seeing different errors. Are you seeing the broken pipe error that the OP is?

OnFreund commented 11 months ago

Also, @pookieman which hardware are you running on?

pookieman commented 11 months ago

@pookieman seems like you're seeing different errors. Are you seeing the broken pipe error that the OP is?

@OnFreund I'm not .. I just stumbled across this when I ran into issue's y'day

pookieman commented 11 months ago

Also, @pookieman which hardware are you running on?

@OnFreund so I'm running HA OS version on a Proxmox VM

After I sent that last post last night I restarted the whole VM .. it's been almost a day and the error hasn't re-occurred - if it does I'll collect more info and post.

arretx commented 11 months ago

And I haven't had a chance to test upgrade again, but I'll do it as soon as I can.

TopoTop1 commented 9 months ago

I too am having this issue. It works fine for a day or so but then breaks and I have to restart the integration.

pookieman commented 9 months ago

It's not actually reoccurred for me (yet)

arretx commented 9 months ago

Is it coincidence? Today at 12:00 noon, the last automation that uses the amplifier was triggered. At about the same time, Core update 2024.1.0 was released.

This isn't the only integration I've experienced this with, but this one definitely quit responding exactly around the same time the new core version was released.

I have not yet upgraded. What would cause integrations to quit working simply because there's a pending update?

OnFreund commented 9 months ago

I don't think it's directly related, but it could be that your hardware is reaching some capacity. Maybe try a powered USB hub for your adapter?

arretx commented 9 months ago

It must be directly related as upgrading to 24.1.0 fixed it. I don’t use a USB adapter. I have an Ethernet to Serial adapter with its own power source.

[image: photo] Jon Griffith REALTOR®, HomeSmart

480-463-4062| @.***

http://realtor.jongriffith.com 10601 N. Hayden Road, Suite I-100 | @RealScottsdale http://facebook.com/realscottsdaleliving http://twitter.com/realscottsdale http://www.youtube.com/realscottsdaleliving https://www.linkedin.com/in/jonathangriffith Create your own email signature https://www.wisestamp.com/create-own-email-signature/?utm_source=promotion&utm_medium=signature&utm_campaign=create_your_own&srcid=

On Thu, Jan 4, 2024 at 12:12 AM On Freund @.***> wrote:

I don't think it's directly related, but it could be that your hardware is reaching some capacity. Maybe try a powered USB hub for your adapter?

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/103399#issuecomment-1876562228, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHURKUROK2P75TQVJJFCDETYMZI6XAVCNFSM6AAAAAA65YDYY6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZWGU3DEMRSHA . You are receiving this because you authored the thread.Message ID: @.***>

OnFreund commented 9 months ago

It must be directly related as upgrading to 24.1.0 fixed it.

Most likely coincidental - there have been no recent changes to the integration (the last major one was 2 years ago). The only other explanation I can think of is that 23.10 and 23.11 were somehow using your system resources heavily causing the serial stack to fail.

I don’t use a USB adapter. I have an Ethernet to Serial adapter with its own power source.

What does it connect to on your machine? A NIC? What's your connection string?

arretx commented 9 months ago

This problem originally started back at the end of October, perhaps even on November 1. My last post on it was November 16th, and I decided to take a risk by upgrading to the previous version which was 2023.11 As I think back to it, the original problem began around that same time and I chose not to upgrade to 2023.11 until after the 16th of November. When I brought the system up to 2023.11.3, it started working again, so I thought nothing of it.

It's currently working, as I've upgraded to 24.1.0.

The strange thing about it is that any time there is a pending update that I haven't applied (core updates, not anything else) certain integrations of HA stop working until I update. This one is now behaving the same way.

So, what I'll do is watch the behavior when the next update is released and see if the problem happens again.

Like you suggest, it could be resource related, but I'm not sure how as I've allocated plenty of resources to the VM running HA. My unraid box has 32GB ram and 42.3 billion cores (exxageration, obviously). I'll keep a lookout and follow up if it happens again at that time. Otherwise, it's a gremlin.

OnFreund commented 9 months ago

ok, based on that description, my hypothesis is some resource leak. The availability of an update is probably correlated with a long uptime, and the upgrade causes a restart which releases the resources and makes everything work again. I doubt it's related specifically to the Monoprice integration though.

arretx commented 9 months ago

I agree. Sounds likely. In every case it has resolved itself with an upgrade, but it certainly does color the stability experience. Thanks for the quick response.