Until I found your component, I was using my own simple HA custom_component to control volume on my DigiHome (Vestel) TV. But your vestel component and HA integration is a complete package, so I've made use of it with a couple of modifications to better control volume on my TV. Specifically when using a volume slider in HA to set volume level.
Thought I'd share :)
Instead of using sendkey (increase / decrease volume) in volume_set, I use a TCP command to set specific volume level based on the HA volume slider.
TCP commands;
"GETVOLUME" returns current volume level.
"VOLUME 15" will set the volume to 15.
This is the spaghetti code changes/additions in pyvesteltv.py;
async def set_volume(self, volume):
"""Simulates setting volume by calling volume steps multiple times."""
### MY HACK ###
await asyncio.wait_for(self._write_data(volume*100), 5)
### MY HACK ###
### MY HACK ###
async def _write_data(self,value):
"""Private method for reading data."""
if not self.get_websocket_state():
_LOGGER.info("Trying to connect WS...")
await self._ws_connect()
_LOGGER.info("WS connect successful!")
else:
pong_waiter = await self.websocket.ping()
await pong_waiter
try:
if not self.writer:
_LOGGER.debug("Trying to connect TCP...")
await self._tcp_connect()
_LOGGER.debug("TCP connect successful!")
### MY HACK ###
volumestring = "VOLUME "+str(value)+"\r\n"
self.volume = await self._read_tcp_data(volumestring, int)
### MY HACK ###
_LOGGER.debug("TCP read ready!")
except Exception as exp:
await self._tcp_close()
_LOGGER.warning("TCP connect/read error:", exc_info=True)
### MY HACK ###
async def _read_data(self):
"""Private method for reading data."""
........
### MY HACK ###
self.volume = await self._read_tcp_data("GETVOLUME \r\n", int)
### MY HACK ###
........
Hi @T3m3z,
Great component!
Until I found your component, I was using my own simple HA custom_component to control volume on my DigiHome (Vestel) TV. But your vestel component and HA integration is a complete package, so I've made use of it with a couple of modifications to better control volume on my TV. Specifically when using a volume slider in HA to set volume level.
Thought I'd share :)
Instead of using sendkey (increase / decrease volume) in volume_set, I use a TCP command to set specific volume level based on the HA volume slider. TCP commands; "GETVOLUME" returns current volume level. "VOLUME 15" will set the volume to 15.
This is the spaghetti code changes/additions in pyvesteltv.py;