I’m trying to create a volume sensor that will convert the volume_level on a media player to the volume shown on the front of my receiver. Receiver is in db, volume slider seems to be a float between 0-1. After I do this, i’m going to create an alexa voice command to set the volume to a specific decibel. My problem is, I’m having trouble trying to create this sensor. I understand the sensor is unnecessary in the long run, but i’d like to map the min max and increment before i create the alexa Intents.
Here is the code I’ve tried when creating a template sensor:
Not having a yamaha with WIFI, I can only test your template with what I have and your second example template works in the template tester for everything I have THAT’S ON. The media players registered, but off give no values.
When you look at the media player’s detail in the dev states panel, is the attribute for volume level there and named the same?
Yes. Whats odd is that I can control everything I want to do. I’ve already begun making my alexa skills. I’d still like to have a sensor that has the actual decibel level though. Anyways, here is what is listed for the media_player.
That’s a nice solution! Also, this prevents getting the dreaded “Attribute None” errors when the template sensor gets rendered before the sensor you’re pulling the attribute from initializes. Something I could see happening in this case.
This worked for me. It’s odd how I was getting key errors on the dictionary because the device has been on the whole time. Maybe for a split second during start up the state of the object is off and it causes the error.
hey @petro thanks heaps for this chunk of code. I’ve just discovered home assistant and am trying to setup a bunch of stuff for google assistant.
I’ve got the correct volume appearing in the overview (thanks again) but how are you getting the volume set to a specific dB level via alexa? Do you have config in home assistant to convert the dB number back to a yamaha friendly number or is it all happening on the alexa side?