Skip to main content
Contributor I
January 11, 2022

Sonos-HDMI by Retired Guy isn't outputting graphics...

  • January 11, 2022
  • 31 replies
  • 696 views

@Chicks, thank you for the port of your touchscreen controller to a view only HDMI code.  

I’ve got your code installed on my Pi Zero W, auto login to shell, the Sonos.py script auto-running and edited to my named speaker group, and it connected to the HDMI on the big-screen.  Unfortunately, the Pi isn’t showing the artwork/music on screen, just the bash prompt after the linux boot menu.

Can you direct me to what I am missing from the auto-run or the python or the output variable for the screen? Is there one more utility to be the front end?  Maybe my systmctrl of the Sonos app isn’t running?

I needed to chmod your utility to executable, so that should be OK now…. Thoughts?

    This topic has been closed for further comments. You can use the search bar to find a similar topic, or create a new one by clicking Create Topic at the top of the page.

    31 replies

    Lyricist III
    January 19, 2022

     

    This stuff assumes some Linux and Python experience, not a cakewalk for noobs.

    Yes, I’m clearly struggling.


    I started from the beginning and made sure I had the Hyperpixel 4 working. Screen was working well. I began following the HDMI directions for installing packages (even though I will be using your remote master.zip). I also installed pigpio and and evdev.

    I moved the SD card back to my linux laptop and edited rc.local just above exit 0 as you recommended.

    I have both /dev/fb0 and /dev/fb1 and my guess is the Hyperpixel is fb1. I tried googling but don’t see a clear way to change that.

    When I rebooted after making the changes you suggested to rc.local I no longer have any screen output.

    Right now when I run sonos.py I get the following error (I haven’t figured out how to make this a service yet, just trying to make it work first).

     


    pi@raspberrypi:~/sonos $ python3 sonos.py
    screen brightness set
    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 169, in _new_conn
        conn = connection.create_connection(
      File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 96, in create_connection
        raise err
      File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 86, in create_connection
        sock.connect(sa)
    socket.timeout: timed out

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
        httplib_response = self._make_request(
      File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 394, in _make_request
        conn.request(method, url, **httplib_request_kw)
      File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 234, in request
        super(HTTPConnection, self).request(method, url, body=body, headers=headers)
      File "/usr/lib/python3.9/http/client.py", line 1255, in request
        self._send_request(method, url, body, headers, encode_chunked)
      File "/usr/lib/python3.9/http/client.py", line 1301, in _send_request
        self.endheaders(body, encode_chunked=encode_chunked)
      File "/usr/lib/python3.9/http/client.py", line 1250, in endheaders
        self._send_output(message_body, encode_chunked=encode_chunked)
      File "/usr/lib/python3.9/http/client.py", line 1010, in _send_output
        self.send(msg)
      File "/usr/lib/python3.9/http/client.py", line 950, in send
        self.connect()
      File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 200, in connect
        conn = self._new_conn()
      File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 174, in _new_conn
        raise ConnectTimeoutError(
    urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPConnection object at 0xb4c8ffa0>, 'Connection to 192.168.68.128 timed out. (connect timeout=3)')

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
        resp = conn.urlopen(
      File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 755, in urlopen
        retries = retries.increment(
      File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 574, in increment
        raise MaxRetryError(_pool, url, error or ResponseError(cause))
    urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.68.128', port=1400): Max retries exceeded with url: /MediaRenderer/AVTransport/Event (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0xb4c8ffa0>, 'Connection to 192.168.68.128 timed out. (connect timeout=3)'))

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/pi/sonos/sonos.py", line 290, in <module>
        info = zone.avTransport.subscribe(
      File "/home/pi/.local/lib/python3.9/site-packages/soco/services.py", line 609, in subscribe
        return subscription.subscribe(
      File "/home/pi/.local/lib/python3.9/site-packages/soco/events.py", line 294, in subscribe
        return self._wrap(subscribe, strict, requested_timeout, auto_renew)
      File "/home/pi/.local/lib/python3.9/site-packages/soco/events.py", line 440, in _wrap
        method(*args, **kwargs)
      File "/home/pi/.local/lib/python3.9/site-packages/soco/events_base.py", line 468, in subscribe
        return self._request(
      File "/home/pi/.local/lib/python3.9/site-packages/soco/events.py", line 392, in _request
        response = requests.request(method, url, headers=headers, timeout=3)
      File "/usr/lib/python3/dist-packages/requests/api.py", line 61, in request
        return session.request(method=method, url=url, **kwargs)
      File "/usr/lib/python3/dist-packages/requests/sessions.py", line 542, in request
        resp = self.send(prep, **send_kwargs)
      File "/usr/lib/python3/dist-packages/requests/sessions.py", line 655, in send
        r = adapter.send(request, **kwargs)
      File "/usr/lib/python3/dist-packages/requests/adapters.py", line 504, in send
        raise ConnectTimeout(e, request=request)
    requests.exceptions.ConnectTimeout: HTTPConnectionPool(host='192.168.68.128', port=1400): Max retries exceeded with url: /MediaRenderer/AVTransport/Event (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0xb4c8ffa0>, 'Connection to 192.168.68.128 timed out. (connect timeout=3)'))
    pi@raspberrypi:~/sonos $
     

     

    chicks
    January 19, 2022

    Is there a Sonos device at 192.168.68.128?  Doesn’t appear to be, soco is not finding one.  Those errors are way down in soco somewhere.

    Make sure you change this in sonos.py, around line 24 to the IP address of the zone you want to monitor.

    If your Hyperpixel is on fb1, change the Python script to write to /dev/fb1 instead of /dev/fb0.

     

    Lyricist III
    January 19, 2022

    Is there a Sonos device at 192.168.68.128?  Doesn’t appear to be, soco is not finding one.  Those errors are way down in soco somewhere.

    Make sure you change this in sonos.py, around line 24 to the IP address of the zone you want to monitor.

    ########################################## Sonos zone to monitor -CHANGE ME! ##zone = soco.SoCo('192.168.68.128')########################################

    If your Hyperpixel is on fb1, change the Python script to write to /dev/fb1 instead of /dev/fb0.

     

    IP updated!

    May be on fb0, when I tried fb1 it reported the fb.seek no space error.

     

    Getting this error now:

    pi@raspberrypi:~/sonos $ python3 sonos.py
    screen brightness set
    Traceback (most recent call last):
      File "/home/pi/.local/lib/python3.9/site-packages/evdev/device.py", line 126, in __init__
        fd = os.open(dev, os.O_RDWR | os.O_NONBLOCK)
    FileNotFoundError: [Errno 2] No such file or directory: '/dev/input/event1'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/pi/sonos/sonos.py", line 294, in <module>
        dev = InputDevice('/dev/input/event1')
      File "/home/pi/.local/lib/python3.9/site-packages/evdev/device.py", line 128, in __init__
        fd = os.open(dev, os.O_RDONLY | os.O_NONBLOCK)
    FileNotFoundError: [Errno 2] No such file or directory: '/dev/input/event1'
    pi@raspberrypi:~/sonos $

     

     

    Thank you for your help. Gonna give it a bit of a rest. May try to make the HDMI version work on the screen tomorrow.
     

     

     

    chicks
    January 19, 2022

    That’s the input device (touchscreen).  Yours may be 0. 
     

    Change this line, about line 294:

     

    dev = InputDevice('/dev/input/event1')

     

    Change the 1 to 0. 

    Lyricist III
    January 20, 2022

    That’s the input device (touchscreen).  Yours may be 0. 
     

    Change this line, about line 294:

     

    dev = InputDevice('/dev/input/event1')

     

    Change the 1 to 0. 

    Wow thanks! I’m pretty close now. The display worked initially before going through installation steps but it’s remained blank since following reboot. This is the output as I started and stopped music to the sonos device:

     


    pi@raspberrypi:~/sonos $ python3 sonos.py
    screen brightness set
    timeout started!
    timeout cancelled!
    screen brightness set
    timeout started!
    timeout cancelled!
    timeout started!
     

    So seems like things are working I just need to figure out why my display stopped working (light’s up but remains blank). I wonder if it’s pigpio related. I tried undoing these /etc/rc.local settings but the display didn’t turn on. IE I made these changes (and then changed them back when it didn’t solve my problem).

    # Start pigpiod

    # /usr/bin/pigpiod

    # Turn off HDMI
    # /usr/bin/tvservice -o

     

    I also tried turning off the pigpiod service but screen didn’t turn on- I haven’t tried figuring out how to stop the service from running at boot.

     

    Edit: seems like there is an issue starting the service:


    pi@raspberrypi:~ $ systemctl start hyperpixel-init
    ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
    Authentication is required to start 'hyperpixel-init.service'.
    Authenticating as: ,,, (pi)
    Password:
    ==== AUTHENTICATION COMPLETE ===
    Failed to start hyperpixel-init.service: Unit hyperpixel-init.service not found.
    pi@raspberrypi:~ $
     

    I’m going to try and install again via “curl -sSL https://get.pimoroni.com/hyperpixel4 | bash”.

     

    Might be an issue after running sudo apt-get update. I’m going to try to go to an older stable install.

     

    This didn’t work:

    sudo apt-get update; sudo apt-get install --reinstall raspberrypi-bootloader raspberrypi-kernel

     

    I’m going to do give more try at rolling back the kernel and then start from scratch.

    chicks
    January 20, 2022

    I haven’t migrated to bullseye yet, still on buster. Looks like there are issues with the Hyperpixel on bullseye. Haven’t read the entire thread on GitHub, perhaps they’ve resolved it by now?

     

    https://github.com/pimoroni/hyperpixel4/issues/155

     

    Lyricist III
    January 20, 2022

    Screen is now working! I shouldn’t have updated the kernel. Thank you so much for helping me through it!

     

    Lyricist III
    January 20, 2022

    I haven’t migrated to bullseye yet, still on buster. Looks like there are issues with the Hyperpixel on bullseye. Haven’t read the entire thread on GitHub, perhaps they’ve resolved it by now?

     

    https://github.com/pimoroni/hyperpixel4/issues/155

     

    I started from scratch without updating and all is well now. Thank you!

    chicks
    January 20, 2022

    Good show!  
     

    BTW, I’ve moved to the Oswald font for the Squeezelite version of this, as it provides a whole lot more text in the given space. 
     

    https://github.com/retired-guy/Squeezebox-3.5/blob/main/sb.py

     

    Lyricist III
    January 23, 2022

    For anyone that wants to get Sonos-Remote working, a few extra commands in addition to changing code in the files mentioned above:

    curl -sSL https://get.pimoroni.com/hyperpixel4 | bash

    Sudo apt-get install python3-pigpio

    Pip3 install evdev

     

    And for the sonos.service file to make it work at startup:

     

    [Unit]
    Description=Sonos
    After=multi-user.target

    [Service]
    Type=idle
    ExecStart=/usr/bin/python3 /home/pi/sonos/sonos.py
    WorkingDirectory=/home/pi/sonos/
    StandardOutput=inherit
    StandardError=inherit
    Restart=always
    User=pi

    [Install]
    WantedBy=multi-user.target