zarpli / Logitech-Z906

Logitech Z906 Control Library
MIT License
98 stars 14 forks source link

Integrate into ESPHome #5

Closed Algram closed 2 years ago

Algram commented 2 years ago

Hi, thanks for this awesome lib!

It would be great if this could be integrated into ESPHome. That way the Z906 sound system would seamlessly integrate into my home automation settup. Currently I am using an ESP with an IR Blaster for that.

It should be fairly straightforward by using the UART module: https://esphome.io/components/uart.html

There is even a way to add a custom uart device here: https://esphome.io/custom/uart.html

EpicLPer commented 1 year ago

Have there been any implementations into ESPHome due to the issue being closed?

paco3346 commented 1 year ago

@EpicLPer @Algram I'm assuming it was closed due to no action.

I've been working on this the last few weeks and last night got finally got things working. I'll be creating a PR for HA & esphome this weekend (hopefully) and will link it here.

lbckmnn commented 1 year ago

@paco3346 Any updates on this?

I am willing to help / give this a try myself :) Do you have a branch somewhere?

BreadJS commented 1 year ago

I did create an integration with MQTT brokers. Still adding some features like effect select and others. Also some bug fixing but it will be up on my Github profile between now and a week. I'm aiming for an ESP32 based system because of the fact that it has 2 ADC pins which allows for playback from bluetooth or from home assistant. This WOULD work with an ESP8266 too but that will be something I will work on later

EpicLPer commented 1 year ago

I did create an integration with MQTT brokers. Still adding some features like effect select and others. Also some bug fixing but it will be up on my Github profile between now and a week. I'm aiming for an ESP32 based system because of the fact that it has 2 ADC pins which allows for playback from bluetooth or from home assistant. This WOULD work with an ESP8266 too but that will be something I will work on later

I would really not use a ESP32 directly on your Z906 as a playback device without any external DAC, the internal one on the ESP32's are rather crappy and can only do about 6 kHz :)
I'm using HiFiBerry connected to the Z906 via a USB audio card (config editing) and it works way great, so in my use case I'd only ever need it to actually control the system itself.

BreadJS commented 1 year ago

I did create an integration with MQTT brokers. Still adding some features like effect select and others. Also some bug fixing but it will be up on my Github profile between now and a week. I'm aiming for an ESP32 based system because of the fact that it has 2 ADC pins which allows for playback from bluetooth or from home assistant. This WOULD work with an ESP8266 too but that will be something I will work on later

I would really not use a ESP32 directly on your Z906 as a playback device without any external DAC, the internal one on the ESP32's are rather crappy and can only do about 6 kHz :) I'm using HiFiBerry connected to the Z906 via a USB audio card (config editing) and it works way great, so in my use case I'd only ever need it to actually control the system itself.

That is also an options for sure! I had no issues with quality on my ESP32 tbh. I will be using an external DAC in the future tough. I currently released my integration on https://github.com/BreadJS/Z906-Home-Assistant It's a very rough sketch for now but will be improve it a lot soon. Also I will be making it compatible with ESP8266 in the future.

paco3346 commented 1 year ago

@paco3346 Any updates on this?

I am willing to help / give this a try myself :) Do you have a branch somewhere?

Sorry, life gets busy. I've been using my code for ~2 months now and have had 0 issues so I feel confident about the stability. The main issue now is that 1) ESPHome moves fast and I have to rebase often to keep up and 2) I'm sure I'll have many iterations after I create the PR to get the code up to standards.

That being said- I'll see if I can rebase today and at least get the PR started.

BreadJS commented 1 year ago

@paco3346 Awesome! I just did it without ESPHome as I'm not that familiar with the code base yet. I still have to do some commits on my repo, but lots of things have changed. It is still a bit buggy but I'm not sure if this because of my network or the code itself. But so far when it it works, it works amazing! I will update you when I commited the new changes

templehasfallen commented 1 year ago

@paco3346 Any updates on this? I am willing to help / give this a try myself :) Do you have a branch somewhere?

Sorry, life gets busy. I've been using my code for ~2 months now and have had 0 issues so I feel confident about the stability. The main issue now is that 1) ESPHome moves fast and I have to rebase often to keep up and 2) I'm sure I'll have many iterations after I create the PR to get the code up to standards.

That being said- I'll see if I can rebase today and at least get the PR started.

Hi! Fiddling with this on my own and wondering if you could share/upload the code you are using

Algram commented 1 year ago

@paco3346 Any chance you can release your current iteration somewhere? I would be interested in trying it out myself :)

paco3346 commented 1 year ago

https://github.com/paco3346/aioesphomeapi/tree/media-player-feature-parity https://github.com/paco3346/esphome/tree/logitech-z906

Please note that I just rebased this on the latest upstream but haven't actually tested (I'm still running a version of Home Assistant that's a few months old because I keep having to redo this code).

You'll need to pull the branch and override the home assistant esphome component: image

And override the api and media_player esphome components: image

I'd love to get this actually merged into Home Assistant but that's proved challenging over the past few months with how busy I am.

Edit: I've started a discussion in the esphome discord to see about getting assistance getting this merged. There are some pretty major changes (and minor breaking ones) so I don't expect this to be easy to get merged.

EpicLPer commented 1 year ago

@paco3346 Thanks already for sharing :) I'm not sure how to properly use this so I can't test it yet, a custom component to import into ESPHome might be easier for testing but probably requires a lot of changes.

BreadJS commented 1 year ago

I recently finished my MQTT integration. Currently they're working on my bathroom so working on my pc is a nightmare. Also I have to catch up stuff with work after that (I'm a web developer). When I caught up, I will update my repo!