RobertMe / cec2mqtt

CEC to MQTT bridge
3 stars 0 forks source link

Raspberry Pi 4 Support #1

Open jWXZSCsqrpZRSVwauBjn opened 2 years ago

jWXZSCsqrpZRSVwauBjn commented 2 years ago

Hey there,

I'm trying to use this image with my raspberry pi 4 and I'm getting stuck at this:

time="2022-05-13T17:52:01Z" level=info msg="Starting Cec2Mqtt" version=0.0.1
time="2022-05-13T17:52:01Z" level=info msg="Reading configuration" config_file=/data/cec2mqtt/config.yaml
time="2022-05-13T17:52:01Z" level=info msg="Reading devices from config file" config_file=/data/cec2mqtt/devices.yaml
time="2022-05-13T17:52:01Z" level=info msg="Devices configuration file does not exist yet" config_file=/data/cec2mqtt/devices.yaml
time="2022-05-13T17:52:01Z" level=info msg="Connected to MQTT"
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
main.InitialiseCec(0x40000d04c0, {0x0, 0x0})
        /go/src/cec2mqtt/cec.go:53 +0x500
main.main()
        /go/src/cec2mqtt/main.go:107 +0xa58

My docker-compose.yml:

  cec2mqtt:
    container_name: cec2mqtt
    image: ghcr.io/robertme/cec2mqtt:edge
    volumes:
      - ./config/cec2mqtt:/data/cec2mqtt
    devices:
      - /dev/vchiq
    restart: unless-stopped

My config.yaml:

mqtt:      
  host: 192.168.188.82:1883
  username: rpi_cec
  password: *****
  state_topic: cec2mqtt/state
  birth_message: online
  will_message: offline
  base_topic: cec2mqtt
home_assistant:
  enable: true
  discovery_prefix: homeassistant

I assume it's because the Raspi 4 uses /dev/vchiq instead of /dev/cecX

Let me know if it's something else or if you can fix it :)

BenJamesAndo commented 4 months ago

I was able to get this working on a Raspberry Pi 4 running Raspberry Pi OS 64-bit Bookworm. I simply left the devices as the default of /dev/cec0 Not sure why it didn't work for you. Interestingly if I did use /dev/vchiq then it also worked. Perhaps run sudo cec-client -l and see what you get. This is what I got.

device:              1
com port:            /dev/cec0
vendor id:           0000
product id:          0000
firmware version:    0
type:                Linux

device:              2
com port:            /dev/cec1
vendor id:           0000
product id:          0000
firmware version:    0
type:                Linux

This is the devices.yaml file it generated

00412314-93ad-4f02-86c6-4773a8ebf6ea:
    id: 00412314-93ad-4f02-86c6-4773a8ebf6ea
    physical_address: 0.0.0.0
    vendor_id: 5067851
    osd: TV
    mqtt_topic: TV
    ignore: false
bfbe6768-fc30-4189-879e-d98e661bf652:
    id: bfbe6768-fc30-4189-879e-d98e661bf652
    physical_address: 0.0.0.0
    vendor_id: 7173227
    osd: TV
    mqtt_topic: TV
    ignore: false