AndroidTV Binding [3.2.0;4.2.0)

What does your thing and item configuration look like?

The thing:

UID: androidtv:googletv:TV
label: 65OLED707
thingTypeUID: androidtv:googletv
configuration:
ipAddress: 192.168.178.44

The item:

I think I see it. Put REQUEST in quotes when doing it on the command line. I just ran a test on my side to make sure Google didn’t update anything and it worked cleanly. If you put the binding logging into debug you should see something along the lines of:

openhab> openhab:send ShieldTV_THEATER_PINCODE "REQUEST"
Command has been sent successfully.
openhab> openhab:send ShieldTV_THEATER_PINCODE "D0F06D"
Command has been sent successfully.

2023-05-24 13:35:28.733 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - Opening GoogleTV SSL connection to 10.0.0.1:6466
2023-05-24 13:35:28.765 [DEBUG] [l.googletv.GoogleTVConnectionManager] - Assuming server certificate is valid
2023-05-24 13:35:28.766 [DEBUG] [l.googletv.GoogleTVConnectionManager] - Returning empty certificate for getAcceptedIssuers
2023-05-24 13:35:28.771 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - Message reader thread started 6466
2023-05-24 13:35:28.771 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - Command sender thread started 6466
2023-05-24 13:35:28.811 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - GoogleTV PIN Process Incomplete
2023-05-24 13:35:28.811 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - startChildConnectionManager parent config: 6466 NORMAL false
2023-05-24 13:35:28.811 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - startChildConnectionManager child config: 6467 PIN false
2023-05-24 13:35:28.815 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - Opening GoogleTV SSL connection to 10.0.0.1:6467
2023-05-24 13:35:28.815 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - Message reader thread exiting 6466
2023-05-24 13:35:28.853 [DEBUG] [l.googletv.GoogleTVConnectionManager] - Assuming server certificate is valid
2023-05-24 13:35:28.853 [DEBUG] [l.googletv.GoogleTVConnectionManager] - Returning empty certificate for getAcceptedIssuers
2023-05-24 13:35:28.858 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - Message reader thread started 6467
2023-05-24 13:35:28.858 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - Command sender thread started 6467

2023-05-24 13:37:55.943 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - Command received: pincode
2023-05-24 13:37:55.943 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - Command received: pincode
2023-05-24 13:37:55.960 [DEBUG] [tocol.googletv.GoogleTVMessageParser] - theater - PIN Process Successful!
2023-05-24 13:37:55.960 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - Disconnecting GoogleTV
2023-05-24 13:37:55.960 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - Command sender thread exiting 6467
2023-05-24 13:37:55.961 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - Disconnecting GoogleTV
2023-05-24 13:37:55.961 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - Attempting to reconnect to the GoogleTV
2023-05-24 13:37:55.961 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - Disconnecting GoogleTV
2023-05-24 13:37:55.961 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - Opening GoogleTV SSL connection to 10.0.0.1:6466
2023-05-24 13:37:55.961 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - Command sender thread exiting 6466

2023-05-24 13:37:56.001 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - Message reader thread started 6466
2023-05-24 13:37:56.001 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - Command sender thread started 6466
2023-05-24 13:37:56.052 [DEBUG] [tocol.googletv.GoogleTVMessageParser] - theater - 0a5b08ff041256 "SHIELD Android TV" "NVIDIA" 11 com.google.android.tv.remote.service 5.2.473254133
2023-05-24 13:37:56.053 [INFO ] [tocol.googletv.GoogleTVMessageParser] - theater - Login Successful
2023-05-24 13:37:56.057 [DEBUG] [l.googletv.GoogleTVConnectionManager] - theater - Setting power to true
2023-05-24 13:37:56.066 [DEBUG] [tocol.googletv.GoogleTVMessageParser] - theater - Device Update: 920319084a1009 "SHIELD Android TV" 01
2023-05-24 13:37:56.335 [DEBUG] [tocol.googletv.GoogleTVMessageParser] - theater - Current App: a201210a1f com.google.android.tvlauncher

Thanks! I tried this before in the console but somehow it was doing strange things when I started using quotes. How did you manage to type this?

When I type the following…

openhab:send PIN "

… then my console automatically autocompletes this to…

openhab:send PIN " "

… and I cannot seem to get rid of the whitespace in the quotes, ending up with:

openhab:send PIN "REQUEST "

Not sure something is set incorrectly with my environment. It’s really odd.

Thats the auto complete. For lack of a better way of putting it, that last quote isn’t actually there. Just type the actual last quote and it will disappear.

Oh wow, that is really counter-intuitive. But thank you, that indeed made it work! Great!

Okay I have another minor question now. I am using a String item to detect whenever a key was pressed on the remote control:

String TVKeyPress “KeyPress” { channel = “androidtv:googletv:tv:keypress” }

The item is also “Online”, however, even though I press keys on the remote, the String value remains NULL. Should it not be updated to the respective key code?

Sorry, that channel is write only. We don’t get any information about what the device remote sends to the AndroidTV itself. Different parts of the OS that don’t talk. All that this channel does is send the keypress to the device.

Oh I see, thanks. I thought in the documentation it said RW. Never mind then.

Trying to add my Philips TV.
It is discovered, but after adding it, the log is swamped with:

2023-05-28 23:03:52.982 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'androidtv:googletv:A067208E81C7' to inbox.
2023-05-28 23:04:02.803 [WARN ] [tocol.googletv.GoogleTVMessageParser] - A067208E81C7 - GoogleTV Error Message: 1a47080312430a41087e123d0a08534d2d4739393855120773616d73756e671801220231332a19636f6d2e676f6f676c652e616e64726f69642e766964656f733207342e33382e3138
2023-05-28 23:04:02.883 [WARN ] [tocol.googletv.GoogleTVMessageParser] - A067208E81C7 - GoogleTV Error Message: 1a47080312430a41087e123d0a08534d2d4739393855120773616d73756e671801220231332a19636f6d2e676f6f676c652e616e64726f69642e766964656f733207342e33382e3138
2023-05-28 23:04:02.993 [WARN ] [tocol.googletv.GoogleTVMessageParser] - A067208E81C7 - GoogleTV Error Message: 1a47080312430a41087e123d0a08534d2d4739393855120773616d73756e671801220231332a19636f6d2e676f6f676c652e616e64726f69642e766964656f733207342e33382e3138
2023-05-28 23:04:03.107 [WARN ] [tocol.googletv.GoogleTVMessageParser] - A067208E81C7 - GoogleTV Error Message: 1a47080312430a41087e123d0a08534d2d4739393855120773616d73756e671801220231332a19636f6d2e676f6f676c652e616e64726f69642e766964656f733207342e33382e3138
2023-05-28 23:04:03.183 [WARN ] [tocol.googletv.GoogleTVMessageParser] - A067208E81C7 - GoogleTV Error Message: 1a47080312430a41087e123d0a08534d2d4739393855120773616d73756e671801220231332a19636f6d2e676f6f676c652e616e64726f69642e766964656f733207342e33382e3138
2023-05-28 23:04:03.258 [WARN ] [tocol.googletv.GoogleTVMessageParser] - A067208E81C7 - GoogleTV Error Message: 1a47080312430a41087e123d0a08534d2d4739393855120773616d7

It only stops after uninstalling the bundle.
Sending REQUEST to PinCode works, but after sending the 6 digit pincode, the log swamping continue and the OH UI becomes unresponsive.

{
  "systemInfo": {
    "configFolder": "/etc/openhab",
    "userdataFolder": "/var/lib/openhab",
    "logFolder": "/var/log/openhab",
    "javaVersion": "11.0.15",
    "javaVendor": "Azul Systems, Inc.",
    "javaVendorVersion": "Zulu11.56+19-CA",
    "osName": "Linux",
    "osVersion": "5.15.43-v8+",
    "osArchitecture": "aarch64",
    "availableProcessors": 4,
    "freeMemory": 70148144,
    "totalMemory": 191889408,
    "startLevel": 100
  }
}

image

This error is definitely getting frustrating. I think you’re the third or fourth to report it now. I can’t recreate it on my side at all. Can you please put the binding into trace logging and DM me the entire thing. I need to compare the protocol exchange between the known good.

It looks like Google pushed a code update a few days ago from 4.38 to 4.39. I’m wondering if they changed something in the protocol exchange. For anyone who is having the error, can you confirm which version of googletv is installed on the device? In wondering if this was some kind of staged rollout hence why it’s been cropping up randomly.

For anyone having the current issue, can you plesse confirm version numbers on your device for the following… (this is what my Shield currently has)

Sorry for the spam. There IS a breaking update for 4.39 which will require a change on our side. Please avoid updating your devices beyond 4.38 until I can make changes, test, and publish an update.

1 Like

I’ve uploaded a new version (8b79ccc) that may fix the issue with the upgraded GoogleTV code. I have no way to test here as I’m still on the older code. I can say that I’m having issues with my shield and the PIN process not connecting properly. It finally worked after a few power cycles. If someone who has the error message can try to upgrade their binding and test the new login that would be appreciated.

I uploaded one small update this morning (7d7ce37) to add some additional logging with the PIN process. I had several issues with my shield last night (which turned out to be entirely the shield, not the binding). This logging will help debugging PIN issues in the future. If you aren’t having PIN issues, you can skip this update, it doesn’t do anything that the update from last night did in respect to actual interaction with the device.

That all said, if you are having PIN issues, my suggestion is to try the following:

  1. uninstall the binding
  2. find your userdata folder (/var/lib/openhab or /userdata if on docker normally), find the androidtv folder in it, and delete all of the .keystore files
  3. reinstall the binding
  4. rerun the PIN process

It’s unclear to me, because of the issues I had, if PIN needs to be rerun now that we’ve adapted for GoogleTV 4.39.

Hi everyone.

If interested, I would like to give you this widget to request and send the PIN to connect the TV easily.

uid: androidtv_pairingtool
tags:
  - androidtv
  - pairing tool
props:
  parameters:
    - description: Title of the card
      label: Title
      name: set_card_title
      required: false
      type: TEXT
      groupName: grp_card_parameters
      advanced: false
    - default: "true"
      description: Show/Hide icon for the widget card
      label: Widget icon
      name: set_card_icon_show
      required: false
      type: BOOLEAN
      groupName: grp_card_parameters
      advanced: true
    - default: "true"
      description: Show border of the widget card
      label: Widget border
      name: set_card_border_show
      required: false
      type: BOOLEAN
      groupName: grp_card_parameters
      advanced: true
    - context: item
      description: Item to manage pairing using a PIN code. Plase select tv PIN CODE item!
      label: Item
      name: set_tv_pin_item
      required: true
      type: TEXT
      groupName: grp_item_parameters
      advanced: false
  parameterGroups:
    - name: grp_card_parameters
      label: Card parameters
    - name: grp_item_parameters
      label: Android TV items parameters
timestamp: May 28, 2023, 7:10:05 PM
component: f7-card
config:
  style:
    border-radius: 5px
    box-shadow: "=props.set_card_border_show ? 1px 1px 1px 1px rgba(0,0,0,0.1) : 0px 0px 0px 0px rgba(0,0,0,0.0)"
    noShadow: =props.set_card_border_show
    padding: false
    position: relative
slots:
  default:
    - component: f7-card-header
      config:
        visible: "=props.set_card_icon_show ? true : props.set_card_title ? true : false"
      slots:
        default:
          - component: oh-icon
            config:
              height: 19px
              icon: lock
              visible: =props.set_card_icon_show
          - component: Label
            config:
              style:
                color: "=themeOptions.dark === 'dark' ? set_color_dark_theme : set_color_light_theme"
                margin-left: "=props.set_card_icon_show ? '30px' : '0px'"
                position: absolute
              text: =props.set_card_title
    - component: f7-block
      config:
        class:
          - padding
        style:
          --f7-button-bg-color: var(--f7-card-bg-color)
          --f7-button-text-color: var(--f7-text-color)
          --f7-theme-color-rgb: var(--f7-color-blue-rgb)
      slots:
        default:
          - component: oh-label-card
            config:
              class:
                - margin-bottom
              label: =vars.pincode
              outline: true
          - component: f7-row
            config:
              class:
                - margin
            slots:
              default:
                - component: oh-repeater
                  config:
                    for: digit
                    fragment: true
                    in:
                      - "1"
                      - "2"
                      - "3"
                      - "4"
                      - "5"
                      - "6"
                      - "7"
                      - "8"
                      - "9"
                      - "0"
                      - A
                      - B
                      - C
                      - D
                      - E
                      - F
                  slots:
                    default:
                      - component: f7-col
                        config:
                          class:
                            - margin-vertical-half
                          width: "25"
                        slots:
                          default:
                            - component: oh-button
                              config:
                                action: variable
                                actionVariable: pincode
                                actionVariableValue: "=(vars.pincode) ? vars.pincode + loop.digit : loop.digit"
                                large: true
                                raised: true
                                text: =loop.digit
          - component: f7-row
            config:
              class:
                - margin
              style:
                --f7-button-bg-color: transparent
            slots:
              default:
                - component: f7-col
                  slots:
                    default:
                      - component: oh-button
                        config:
                          action: command
                          actionCommand: REQUEST
                          actionItem: =props.set_tv_pin_item
                          class: []
                          disabled: =!props.set_tv_pin_item
                          fill: true
                          large: true
                          style:
                            --f7-button-hover-bg-color: var(--f7-color-blue-tint)
                            --f7-button-pressed-bg-color: var(--f7-color-blue-tint)
                            --f7-theme-color: var(--f7-color-blue)
                          text: Request
                - component: f7-col
                  slots:
                    default:
                      - component: oh-button
                        config:
                          action: variable
                          actionVariable: pincode
                          actionVariableValue: ""
                          disabled: =!vars.pincode
                          large: true
                          text: Clear
                - component: f7-col
                  slots:
                    default:
                      - component: oh-button
                        config:
                          action: command
                          actionCommand: =vars.pincode
                          actionItem: =props.set_tv_pin_item
                          class: []
                          clearVariable: pincode
                          disabled: =!vars.pincode || !props.set_tv_pin_item
                          fill: true
                          large: true
                          style:
                            --f7-button-hover-bg-color: var(--f7-color-green-tint)
                            --f7-button-pressed-bg-color: var(--f7-color-green-tint)
                            --f7-theme-color: var(--f7-color-green)
                          text: Send

In the Set Props section, simply select the PINCODE item.

2 Likes

Thanks for creating the AndroidTV binding!
It works as a charm on my Philips 43PUS8545/12.
It has Android version 9 and I am running openHAB 3.4.4.
I am using it together with the Philips TV (2016+) Binding to control the Ambilight as well.
Keep up the excellent work! :smiley:

1 Like

Someone has a working sitemap example ?
Thank you

Sitemaps are really “depending on use case” for this, which is why I didn’t include one. There are probably a few like power that would be a no brainer, but when you start to use keycodes it becimes far more complicated to have a set example.