Looking for ideas on the best way to build the ESPHome software to make an ESP-controlled amplifier look like a media_player to HA (with just 3 controls: on/off/volume).
(note: This is NOT about ESP handling the media stream, just controlling the amp the way it can control shutters, lamps, garage doors, etc. The ESP will control the amp via an I2C bus).
I’ve built custom components before, so would not be uncomfortable with that here, but am unclear how to cause it to present itself to HA as a “media_player / Speakers” (there’s even a device_class for that).
The closest existing component is “DFPlayer” which is an actual media player daughter card.
I suppose I could customise that and strip out every function except on/off/volume.
Or, perhaps make it as a custom dimmable monochromatic light. (i.e. it would present almost the same controls: on/off/brightness) but I’d prefer to do this in a way that HA perceives as a Media Player, not a light.
Could it be as simple as a lambda in the Monochromatic Light component that changes the reported device_class?
Wifi is probably not a good solution for this purpose.
It will use a lot of power so it needs to wired, or wireless and needs to wake up before you can use it.
I would suggest get a zigbee dimmer and just create automations based on the movements/clicks.
Like the IKEA Symfonisk volume control.
The amp will have its own power supply, speakers, and a line-level audio feed.
All I’m looking to do is have the ESP control the amp.
The amp is a class-D amp with an I2C-controlled volume. A piece of cake for an ESP to vary the volume on it. Just send it the proper I2C commands. That part is easy for me.
I just want to know how to make the ESP appear as the proper kind of device to HomeAssistant, so HA ‘sees’ it as being some kind of uber-simplistic media_player.
Thanks. That seems like it would be handy for defining a new player in Home Assistant.
I was really hoping this could all be done in ESPHome, though.
e.g. by having it report itself to HA as an object HA already understands, similar to the way nn ESPHome monochromatic light component does.
There’s just no ESPHome component for media_player. (maybe there should be?)
I may just use the class(es) underlying the existing DFPlayer component in a Custom Component of my own.
The only part(s) I need are the ones that tell HA that it’s a media player or speaker, which is a device_class HA already understands.
Ah, you are correct. I inferred that it would from its description. But it doesn’t.
I guess I shall trod some fresh ground here, and have to somehow figure out how to make it do so.
(or, I’ll just give up and pretend it’s a monochromatic dimmable light)
Thanks, but no, I don’t want the ESP to be handling the media at all. It should treat the amplifier more like a cover or a servo. Just a thing to be reduced or intensified opened/closed, widened/narrowed, etc.
I just want the ESP to expose the ability to effect on/off/volume controls to HA. The media are generated elsewhere and supplied to the amplifier via analog copper signals as line level (0-1v) analog signals.
define it all as a monochromatic light, and use custom outputs to have “dimming” control the volume, and on/off do the obvious things. That way, it’ll at least be physically tested, and hopefully usable. Only the UI semantics will be weird. (“Hey Google, dim the backyard speakers”)
In parallel with those controls, I’ll experiment with added code that exposes the same controls in ways that will [attempt to] emulate a media_player (like an imaginary ESP-based Chromecast) so that ‘Volume’ is portrayed as such in HA.
That way, I’ll be able to use it, and figure out how to make it semantically prettier at the same time.
I have not, mainly due to believing that it wouldn’t be the right place to ask (this not being a bug-like thing). But I’ll go check it out. Perhaps I’ll figure out how to simplify the question for brevity first.
Thanks for the idea.
I think it at least qualifies as a feature request, doesn’t it? I mean we have all kinds of devices in ESPHome, from sensors to climate controls to a sous-vide stick for cooking. Taking a “media_player” into this portfolio would make sense, IMHO.
You’d get my vote for sure!
EDIT: once again, to late to the feature request party