Ehlo,
I have an issue with my configuration of universal media player. I can’t get the volume to work. My setup is as follow :
A samsung smart TV that is obsolete and that I control via IR
A HDMI selector device controlled via IR
A LG HTS system controlled via IR and via SOAP querries
Since the REST sensor/switches cannot do SOAP, I was forced to try otherwise. First I tried to adapt a custom Samsung SOAP component to connect with the LG but Python sockets just plain didn’t worked.
Now I am forced to poll on the volume level and mute state with a curl command at unreasonable frequency.
I figured out most things but the Universal media player won’t display a volume slider no matter what I do.
Here is my configuration :
I cannot get the volume right. I found out that the volume must be formated as a float between 0 and 1 and did the value template in the sensor and it works great. I also tested manually volume_set and it works as well.
Is this behavior normal or should I open a github issue ?
Thanks in advance for the brave soul that will try to help.
Media players wont show volume if the device is off. Is the device on when you try to change the volume?
The volume slider does not appear in the user interface, it will only appear in the expanded media_player. To expand it, click on the media player in the interface while the device is on. A new panel will appear with your volume slider.
Interesting project, is it possible to share the various scripts you use to control the TV? I have an old Samsung TV and i would like to control just like you do…
If yes, thanks since now…
That’s odd. When you check the media player in the states page, does volume_level have a value associated with it? If yes, the universal control may not actually allow a slider.
I use a broadlink RM Mini for IR control and this custom component to transform it into a media_player.
If your TV is a smart TV this custom component might do the trick too.
If you are interested here is the SOAP command I use for volume (LG HTS device) :
So it must probably be SUPPORT_VOLUME_SET that makes the slider appear. However here is the code for the universal media_player :
if any([cmd in self._cmds for cmd in [SERVICE_VOLUME_UP,
SERVICE_VOLUME_DOWN]]):
flags |= SUPPORT_VOLUME_STEP
flags &= ~SUPPORT_VOLUME_SET
elif SERVICE_VOLUME_SET in self._cmds:
flags |= SUPPORT_VOLUME_SET
So it can’t have both the step mode and the slider as I understand it. I’m going to try to break it to see if both works but otherwise I will just remove the step part. That’s very confusing because the documentation clearly declares both in the example…
Edit : it works ! just do the following replacement in the file components/media_player/universal.py in the python install folder of HA :
Wherever you wish, you only need to provide the path of it relative to the root folder of your configuration.
For the SOAP : it’s a protocol based on HTTP POST requests with an XML payload that can command some parts of most “smart” media appliances. It can set and get the volume level and the mute state if used correctly.
Well that isn’t that easy. First you’ll need to make your own ini file by following the example. You get the codes by learning them using the service switch.broadlink_learn_command_ip_of_rm_mini and pushing each button on the remote (quite tedious and long to do). Normally the Samsung ini file should work.
If your devices are compatible, I would suggest using HDMI-CEC (plug the onkyo with an HDMI cable to your TV and search the menus for Anynet+). This will allow commands issued on the TV to be replicated on your reciever (and have sound level consistant).
For the android TV box you’ll need either an app on it that can interface with a protocol supported by HA or you can try your luck meddling with UPnP and SOAP like I did by using this app.
All of that will require a ton of work to make everything seamless but I always find it worth it. Good luck !
I am having problems with turning on and off the samsung tv. I already had two switches created with broadlink mini rm3 to turning on and off the tv and i am noticing the codes are different from the ones into the samsung.ini file. Which one to use?
I have my codes with me, i have already created ini file,
but what should be done for volume,
do i need to get codes like
Volume 0 = ?
Volume 1 = ?
Volume 2 = ?
like vice
which will never be same.
No, as far as I know the broadlink component doesn’t work this way. I use a Universal media player that is like a template media player. You’ll need a sensor for the volume or a way to retrieve it. That is the very hard part.
The thing is that you’ll need to do some retro engineering. If your TV is connected either try with this component (and hope everything works out of the box) or with the android App to scan the network. Once you found your TV (it’s better to set it’s IP static in the DHCP settings of your router to avoid future problems), look for the controls in it. It should be like “GetVolume”. Then invoke the service and go into the logs. There you will need to find the line of the action you just did (clear and try again if necessary). That will give you all the informations to tweak the command line sensor I posted earlier.
The last resort is to try to either guess the volume and use a variable in HA to keep track (which will stop working if anything changes the volume externally) or if you have a display of the volume to find a way to capture it and use OCR on it (using a camera and the 7 segment component of HA).
That is quite advanced endeavour but you’ll probably learn a lot doing it.