bendavid / aiopylgtv

Library to control webOS based LG Tv devices
MIT License
143 stars 47 forks source link

Fix the loss of the channel callback #23

Closed HerrHofrat closed 3 years ago

HerrHofrat commented 3 years ago

I stumbled upon an issue where the current channel subscription is lost and self._current_channel is never updated again. Steps to reproduce:

  1. start on the Live TV app
  2. switch input to HDMI
  3. go back to Live TV

In that case self._current_channel would stay on the channel that has been set during step 1. Seems like the ep.GET_CURRENT_CHANNEL subscription is lost when the TV switches from Live TV to an HDMI input. With this pull request the current channel subscription is restored when the TV is switched back to Live TV. The time.sleep seems to be necessary because an immediate setting of the current channel subscription as soon as set_current_app_state is called does not work (I suspect an race condition somewhere?). Let me know in case there is a better way!