Sholofly / lghorizon

Custom integration to control LG Horizon settop boxes for Ziggo(NL), Magenta(AT), UPC(CH), Virgin(GB, IE), Telenet(BE)
GNU General Public License v3.0
58 stars 13 forks source link

Integration stops updating until reload #73

Open Shivy011 opened 10 months ago

Shivy011 commented 10 months ago

Hi ,

I am using Virgin Media (GB). My integration works for a few hours, then the boxes etc stop responding, at which point I have to reload the integration, and it all works fine again. It is really strange issue, but consistently stops working. The integration is loaded etc and running fine, it just seems to lose the link to the Virgin TV boxes

HansOtten commented 10 months ago

Installed two days ago early in the evening.. I am using a Ziggo Next. Worked fine but the integration died in the night, nothing operational on the LG Horizon integration after that.
I am using Home Assistant uptodate version. I have no MQTT and do not need it. Removed the device and deleted the LG Horizon folder to get rid of the errors in the log.

roderik-maker commented 9 months ago

I am also experiencing this issue. My system is currently only locally accessible, could that be related to the connection dropping?

Sholofly commented 9 months ago

It looks like it's encountering an error that it can't recover from. Please enable debug logging for this component and please communicate it to me. Don't forget to obfuscate any sensitive info in your logs.

The support for GB version is minimal, due to the fact that i need a login and a VPN to test and develop new/altered specifications

ptaudio commented 9 months ago

I'm experiencing the same issue from day 1 that i've installed this add-on. the periode of that it's working varies. I also have to do a reload to get it working again. I've have debugging activated but where do i find the reports ?

golles commented 8 months ago

I have this issue as well every now and then, I had debug logs enabled for a while and finally, I had an issue again today. In this case, it seems to be related to a short internet outage. The last part of the log was:

2024-01-02 21:20:33.233 DEBUG (Thread-3 (_thread_main)) [lghorizon.models] Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'redacted'
2024-01-02 21:20:33.247 DEBUG (Thread-3 (_thread_main)) [lghorizon.models] Received CONNACK (0, 5)
2024-01-02 21:20:33.317 DEBUG (Thread-3 (_thread_main)) [lghorizon.models] Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'redacted'
2024-01-02 21:22:33.407 DEBUG (Thread-3 (_thread_main)) [lghorizon.models] Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'redacted'
2024-01-02 21:22:33.423 DEBUG (Thread-3 (_thread_main)) [lghorizon.models] Received CONNACK (0, 5)
2024-01-02 21:22:33.492 DEBUG (Thread-3 (_thread_main)) [lghorizon.models] Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'redacted'
2024-01-02 21:24:33.564 DEBUG (Thread-3 (_thread_main)) [lghorizon.models] Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'redacted'
2024-01-02 21:24:33.574 DEBUG (Thread-3 (_thread_main)) [lghorizon.models] Received CONNACK (0, 5)
2024-01-02 21:24:33.645 DEBUG (Thread-3 (_thread_main)) [lghorizon.models] Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'redacted'

I can email you the full log, it's about 6000 lines (I prefer sending it by mail than sharing it in public)

Sholofly commented 7 months ago

@Shivy011 Since the GB integration stopped working completely, we're not able to reproduce this one. Please, if the Virgin part works again in the future, please feel free to start a new issue.

@golles Please let me know if you experience the same after installing the latest version

Sholofly commented 7 months ago

@HansOtten I re-read your message. Your box is talking MQTT to be controlled. You don't need a mqtt server, but the LGHorizon acts as a MQTT client

steuerzentrale commented 7 months ago

With the update of HA to OS 2024.1.4 the integration with version v0.5.4 it stopped working in CH. Maybe seems like an auth-issue.

Core 2024.1.4 Supervisor 2023.12.1 Operating System 11.4 Frontend 20240104.0

here is what I get from the log in HA:

Logger: lghorizon.lghorizon_api Source: /usr/local/lib/python3.11/site-packages/backoff/_common.py:120 First occurred: 10:12:36 (7 occurrences) Last logged: 10:14:21

Giving up _do_api_call(...) after 3 tries (lghorizon.exceptions.LGHorizonApiConnectionError: Unable to call https://spark-prod-ch.gnp.cloud.sunrisetv.ch/auth-service/v1/mqtt/token. Error:401 Client Error: Unauthorized for url: https://spark-prod-ch.gnp.cloud.sunrisetv.ch/auth-service/v1/mqtt/token)

robertwigley commented 7 months ago

I get this issue with the box becoming unavailable too. Although this doesn't fix the root cause of the problem, you can create an automation to reload the integration when it becomes unavailable, which mostly makes the issue go away. I've pasted my full automation below, which if failing to reload on the first attempt will try to reload every five minutes until it's working again. It includes notifications to my phone when it becomes unavailable and then when it has successfully reloaded. You will need to get the entry_id for your own setup from .storage\core.config_entries.

# Virgin TV 360 integration monitor
- id: C61EBCD1-1C2D-4D78-A6F5-443AD8B9ADAE
  alias: "Audio-Visual: Virgin TV 360 integration monitor"
  variables:
    var_date: "{{ now().strftime('%d/%m/%Y') }}"
    var_time: "{{ now().strftime('%H:%M:%S') }}"
  trigger:
    # Virgin TV 360 becomes unavailable
    - platform: state
      entity_id: media_player.virgin_tv_360
      to: unavailable
  action:
    # Send a notification
    - service: notify.rob_s_phone
      data:
        title: Virgin TV 360 Unavailable
        message: >-
          Virgin TV 360 is {{ states('media_player.virgin_tv_360') }}; attempting to reload the integration.<br>
          {{- var_time }} {{ var_date -}}
        data:
          notification_icon: mdi:set-top-box
          actions:
            - action: URI
              title: View
              uri: /lovelace-home/audio-visual
          clickAction: /lovelace-home/audio-visual
          ttl: 0
          priority: high
          color: '#FFA500' # orange
          sticky: true
          group: Audio-Visual
    # While Virgin TV 360 is unavailable
    - repeat:
        while:
          - condition: state
            entity_id: media_player.virgin_tv_360
            state: unavailable
        sequence:
          # Reload the Virgin TV 360 integration
          - service: homeassistant.reload_config_entry
            data:
              entry_id: 12bcd61c119579af4cd401e40171b6d3 # ID from .storage\core.config_entries
          # Try every 5 minutes
          - delay: 00:05:00
    # Send a notification
    - service: notify.rob_s_phone
      data:
        title: Virgin TV 360 Reloaded
        message: >-
          The Virgin TV 360 integration has been reloaded.<br>
          {{- var_time }} {{ var_date -}}
        data:
          notification_icon: mdi:set-top-box
          actions:
            - action: URI
              title: View
              uri: /lovelace-home/audio-visual
          clickAction: /lovelace-home/audio-visual
          ttl: 0
          priority: high
          color: green
          sticky: true
          group: Audio-Visual
Sholofly commented 7 months ago

@robertwigley @Shivy011 Please let me know if you can retrieve the cause of the unavailabillity. I've tried to make the api as self-healing as i could. I personally don't experience it anymore but if there still situation where the integration can't recover from, let me know. I'll try to fix that.

Shivy011 commented 7 months ago

@robertwigley @Shivy011 Please let me know if you can retrieve the cause of the unavailabillity. I've tried to make the api as self-healing as i could. I personally don't experience it anymore but if there still situation where the integration can't recover from, let me know. I'll try to fix that.

I am out of action at the moment as GB based :(

Sholofly commented 7 months ago

Ah thats a pity....we're on it...