Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with new binary sensor for recodings in philips_js integration #104610

Closed
ReneNulschDE opened this issue Nov 27, 2023 · 6 comments · Fixed by #104665
Closed

Error with new binary sensor for recodings in philips_js integration #104610

ReneNulschDE opened this issue Nov 27, 2023 · 6 comments · Fixed by #104665

Comments

@ReneNulschDE
Copy link
Contributor

ReneNulschDE commented Nov 27, 2023

The problem

Running on Dev latest, the philips_js integration shows the following error on startup.

...
  File "/home/rene/repo/core/homeassistant/components/philips_js/binary_sensor.py", line 62, in <genexpr>
    PhilipsTVBinarySensorEntityRecordingType(coordinator, description)
  File "/home/rene/repo/core/homeassistant/components/philips_js/binary_sensor.py", line 89, in __init__
    self._attr_is_on = _check_for_recording_entry(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rene/repo/core/homeassistant/components/philips_js/binary_sensor.py", line 69, in _check_for_recording_entry
    for rec in api.recordings_list["recordings"]:
               ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

What version of Home Assistant Core has the issue?

System Information

version | core-2023.12.0.dev0 -- | -- installation_type | Home Assistant Core dev | true hassio | false docker | false virtualenv | true python_version | 3.11.4 os_name | Linux os_version | 6.2.0-37-generic arch |

What was the last working version of Home Assistant Core?

core-2023.11.0.dev0

What type of installation are you running?

Home Assistant Core

Integration causing the issue

philips_js

Link to integration documentation on our website

https://www.home-assistant.io/integrations/philips_js/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

Pull request that integrated the change
#94691
Adding @Floyer007: Looks like you created this PR

@home-assistant
Copy link

Hey there @elupus, mind taking a look at this issue as it has been labeled with an integration (philips_js) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of philips_js can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign philips_js Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


philips_js documentation
philips_js source
(message by IssueLinks)

@Floyer007
Copy link
Contributor

Hi,
could you please provide the diagnosis information about the device?

Does it have Android as operating system?

Mainly I'm interested into the entry information like shown here from my device:

"data": {
        "host": "192.168.1.105",
        "api_version": 6,
        "system": {
          "notifyChange": "http",
          "menulanguage": "German",
          "name": "55OLED706/12",
          "country": "Germany",
          "serialnumber": "**REDACTED**",
          "softwareversion": "TPM211EA_R.101.001.004.113",
          "model": "55OLED706/12",
          "deviceid": "**REDACTED**",
          "nettvversion": "10.0.0",
          "epgsource": "no_epg",
          "api_version": {
            "Major": 6,
            "Minor": 1,
            "Patch": 0
          },
          "featuring": {
            "jsonfeatures": {
              "editfavorites": [
                "TVChannels",
                "SatChannels"
              ],
              "recordings": [
                "List",
                "Schedule",
                "Manage"
              ],
              "ambilight": [
                "LoungeLight",
                "Hue",
                "Ambilight",
                "HueStreaming"
              ],
              "menuitems": [
                "Setup_Menu"
              ],
              "textentry": [
                "not_available"
              ],
              "applications": [
                "TV_Apps",
                "TV_Games",
                "TV_Settings"
              ],
              "pointer": [
                "not_available"
              ],
              "inputkey": [
                "key"
              ],
              "activities": [
                "intent"
              ],
              "channels": [
                "preset_string"
              ],
              "mappings": [
                "server_mapping"
              ]
            },
            "systemfeatures": {
              "tvtype": "consumer",
              "content": [
                "dmr",
                "pvr"
              ],
              "tvsearch": "intent",
              "pairing_type": "digest_auth_pairing",
              "secured_transport": "true",
              "companion_screen": "true"
            }
          },
          "os_type": "MSAF_2019_P"
        },
        "username": "**REDACTED**",
        "password": "**REDACTED**"
      },

Alternatively you can get the information directly from your device by opening it's website.
For my Andorid TV it's this one. Replace the IP obviously according to your device.
https://IP-ADDRESS:1926/system

@Floyer007
Copy link
Contributor

I think I found the issue, but feel free to share the information anyway to see more information from different systems.

The recordings_list is actually not subscribable if the TV is off. I assume this is the case for your setup.
Could you please verify by turning the TV on and restarting HA?

I'll work on a fix. I missed this scenario within the tests, so it slipped through...

@ReneNulschDE
Copy link
Contributor Author

Hi, Yes it is an android device and it was on standby. However same error when the device is on.

I have two entries for the same device in the diagnostic output.?.

Here the relevant HA diagnostic output on "TV-standby" restart:

"data": {
    "entry": {
      "entry_id": "1b250d8ebf7c45a7c6a9af55fb1798a3",
      "version": 1,
      "domain": "philips_js",
      "title": "**REDACTED**",
      "data": {
        "host": "192.168.178.39",
        "api_version": 6,
        "system": {
          "notifyChange": "http",
          "menulanguage": "German",
          "name": "75PUS7101/12",
          "country": "Germany",
          "serialnumber": "**REDACTED**",
          "softwareversion": "AND1E.0.0.0.1",
          "model": "75PUS7101/12",
          "deviceid": "**REDACTED**",
          "nettvversion": "8.1.3",
          "epgsource": "one",
          "api_version": {
            "Major": 6,
            "Minor": 2,
            "Patch": 0
          },
          "featuring": {
            "jsonfeatures": {
              "editfavorites": [
                "TVChannels",
                "SatChannels"
              ],
              "recordings": [
                "List",
                "Schedule",
                "Manage"
              ],
              "ambilight": [
                "LoungeLight",
                "Hue",
                "Ambilight"
              ],
              "menuitems": [
                "Setup_Menu"
              ],
              "textentry": [
                "context_based",
                "initial_string_available",
                "editor_info_available"
              ],
              "applications": [
                "TV_Apps",
                "TV_Games",
                "TV_Settings"
              ],
              "pointer": [
                "not_available"
              ],
              "inputkey": [
                "key"
              ],
              "activities": [
                "intent"
              ],
              "channels": [
                "preset_string"
              ],
              "mappings": [
                "server_mapping"
              ]
            },
            "systemfeatures": {
              "tvtype": "consumer",
              "content": [
                "dmr",
                "dms_tad"
              ],
              "tvsearch": "intent",
              "pairing_type": "digest_auth_pairing",
              "secured_transport": "true"
            }
          }
        },
        "username": "**REDACTED**",
        "password": "**REDACTED**"
      },
      "options": {
        "allow_notify": false
      },
      "pref_disable_new_entities": false,
      "pref_disable_polling": false,
      "source": "user",
      "unique_id": "**REDACTED**",
      "disabled_by": null
    },
    "data": {
      "system": {
        "notifyChange": "http",
        "menulanguage": "German",
        "name": "75PUS7101/12",
        "country": "Germany",
        "serialnumber": "**REDACTED**",
        "softwareversion": "AND1E.0.0.0.1",
        "model": "75PUS7101/12",
        "deviceid": "**REDACTED**",
        "nettvversion": "8.1.3",
        "epgsource": "one",
        "api_version": {
          "Major": 6,
          "Minor": 2,
          "Patch": 0
        },
        "featuring": {
          "jsonfeatures": {
            "editfavorites": [
              "TVChannels",
              "SatChannels"
            ],
            "recordings": [
              "List",
              "Schedule",
              "Manage"
            ],
            "ambilight": [
              "LoungeLight",
              "Hue",
              "Ambilight"
            ],
            "menuitems": [
              "Setup_Menu"
            ],
            "textentry": [
              "context_based",
              "initial_string_available",
              "editor_info_available"
            ],
            "applications": [
              "TV_Apps",
              "TV_Games",
              "TV_Settings"
            ],
            "pointer": [
              "not_available"
            ],
            "inputkey": [
              "key"
            ],
            "activities": [
              "intent"
            ],
            "channels": [
              "preset_string"
            ],
            "mappings": [
              "server_mapping"
            ]
          },
          "systemfeatures": {
            "tvtype": "consumer",
            "content": [
              "dmr",
              "dms_tad"
            ],
            "tvsearch": "intent",
            "pairing_type": "digest_auth_pairing",
            "secured_transport": "true"
          }
        }
      },
      "powerstate": null,
      "context": null,
      "application": null,
      "applications": {},
      "source_id": null,
      "sources": {},
      "ambilight_styles": {},
      "ambilight_topology": null,
      "ambilight_current_configuration": null,
      "ambilight_mode_raw": null,
      "ambilight_modes": [
        "internal",
        "manual",
        "expert",
        "lounge"
      ],
      "ambilight_power_raw": null,
      "ambilight_power": null,
      "ambilight_cached": null,
      "ambilight_measured": null,
      "ambilight_processed": null,
      "screenstate": null,
      "on": false,
      "channel": null,
      "channels": {},
      "channel_lists": {},
      "favorite_lists": {}
    }
  }

@Floyer007
Copy link
Contributor

There are two entries for me as well. If I see it right, one is from the HA entity and one from the TV "system" json directly.

At least I prevent the NoneType error within a new branch now. A PR will follow if we know more.
( Branch: https://github.com/Floyer007/core/tree/philips_js-no_list-bugfix )
I noticed that my TV sometimes wakes up, while it's in Stand-By and the entities can be updated. So it's save to skip entity updates if the recordings_list is not available.

Your TV has API 6.2 and "jsonfeatures" states it supports "recordings" as well. So API is higher than mine (6.1).
I have the strange feeling, that this might have an influence.

Could you share the json for the recording list please?
It should look like this: https://github.com/home-assistant/core/blob/dev/tests/components/philips_js/__init__.py#L77

You can get it by visiting in your case:
https://192.168.178.39:1926/6/recordings/list

The TV will ask for a basic-auth.
You'll get the login data by following "Pairing with TV" here: https://github.com/danielperna84/ha-philipsjs
Hint: Just save username and password for the future, it will stay the same.

@ReneNulschDE
Copy link
Contributor Author

ReneNulschDE commented Nov 28, 2023

Thanks for your comments and yes your code change helps...

First, I have to restate the scenario: The exception occurs when the network connection to TV is not available on HA startup. Its not a TV standby problem.

I pulled your code change and tested it with and without network connection. Looks good. Now no exception is shown on startup. Good to prepare a PR.

Thx for your support

@github-actions github-actions bot locked and limited conversation to collaborators Dec 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants