# HD+ Companion App/Driver

## Description

HD+ Companion App/Driver is a Hubitat Hub app and driver which works with HD+ and allows you to send 'push' notifications from the hub to your phone. With it, you can:

* show system notifications on your phone
* play messages via Text To Speech (TTS)
* run Tasker tasks

![](https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2FcVzvaH3LZaKWctdvhPvY%2Fimage.png?alt=media\&token=d59edbfc-9e4e-4c60-8ee6-8c1274c0d967)

## Alternatives

You can already get push notifications to your phone today using the native [Hubitat app](https://docs2.hubitat.com/en/mobile-app). It will create a new Hubitat device for you and because Hubitat has a cloud server it's already configured to push messages from your Hub to your phone without any additional work needed.

## Google pre-requisite setup

* This is the complicated part. It's required so your Hub can send push messages to your device via Firebase Cloud Messaging (Hub -> Google Servers -> phone)
* Since everyone owns their own 'server' (aka: Hubitat Hub), I can't just create an account myself to do this and use the same API Key on everyone's Hub.
* In effect, you need to obtain 2 API keys.. 1 for the Hub to talk securely to Google and another for the phone to receive push messages from the Hub

1. Navigate to [Firebase Console](https://console.firebase.google.com/) (you'll need to login with a Google account)
2. Click on Create a Project
3. Enter project name. The name isn't important but I used "HD Companion"
4. You'll be asked to enable Google Analytics.. I disabled this (shouldn't matter either way)
5. When done, you'll be at a screen that says "Get started by adding Firebase to your app". Click on the little Android icon

<div><figure><img src="https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2FKkF9aOoohe8MsusjCV7m%2F1%20-%20create%20project.png?alt=media&#x26;token=c43bf115-de01-4abb-a1c8-947aa11e6954" alt=""><figcaption></figcaption></figure> <figure><img src="https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2Fu1a1OKyxEMFhggjwC5j5%2F2%20-%20name.png?alt=media&#x26;token=b79bdbad-97bb-4979-9168-cb466179372f" alt=""><figcaption></figcaption></figure> <figure><img src="https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2FMsV28gwJhnfQT6opowpj%2F3%20-%20analytics.png?alt=media&#x26;token=cf1bbffb-a613-44ce-b2ec-c3aae3fdc974" alt=""><figcaption></figcaption></figure> <figure><img src="https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2F5yZbB2RUm86rF9u2uPHZ%2F4%20-%20android.png?alt=media&#x26;token=f50811b5-4a62-4ed5-8062-35dc76896f41" alt=""><figcaption></figcaption></figure></div>

6. Fill in the following details about the app
   1. "Android package name" -> "com.jpage4500.hubitat"
   2. "App Nickname" -> "HD+" (optional)
   3. "Debug signing certificate SHA-1 (optional)" -> leave this empty
7. Click Register app
8. Click Download `google-services.json`. You'll need this file later!

<div><figure><img src="https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2FAcwEc77Z41jxKrxtA4m8%2F5%20-%20android%20app%20name.png?alt=media&#x26;token=c62d984e-4d56-4fce-bfcc-2241e23669e5" alt=""><figcaption></figcaption></figure> <figure><img src="https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2FTk7GhV3Hy0UgIyqgSNiF%2F6%20-%20google-services.png?alt=media&#x26;token=e36e05c0-791a-4776-a8d9-adfde0e3f699" alt=""><figcaption></figcaption></figure></div>

9. Click Next -> Next -> Continue to Console
10. Click on your new project icon, HD+ and click on the little gear/settings icon
11. You should be on the Project Settings screen. Click on Cloud Messaging and then Manage Service Accounts link
12. This will open a new tab with your project. Click on the little hamburger icon in top-left corner -> API's and Services -> OAuth consent screen
13. Select `External` -> `Create` button
14. Enter app name (HD Companion), support email address (your email address) and developer contact (your email address)
15. Scroll down and click `Save and Continue` button

<div><figure><img src="https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2FYZUeAGAe15tS59DfQd7U%2F7%20-%20continue%20to%20console.png?alt=media&#x26;token=3f42d629-8c6e-45ad-b3ce-8ba7ef061a4c" alt=""><figcaption></figcaption></figure> <figure><img src="https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2FLJUuaKyuISqQ8BMWXMa2%2F8%20-%20hd%20plus%20(b).png?alt=media&#x26;token=b49dfcf3-971b-4925-8e4a-ec4bdfbefdb5" alt=""><figcaption></figcaption></figure> <figure><img src="https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2FGhHQt6curgj3ql1ahdDO%2F9%20-%20project%20settings.png?alt=media&#x26;token=f8a01063-07c8-40ac-9985-d0206e990ebe" alt=""><figcaption></figcaption></figure> <figure><img src="https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2FV4d49zaXxLNC956KRj5Q%2F10%20-%20cloud%20-%20oauth%20consent.png?alt=media&#x26;token=68393f65-4226-45e4-a143-245fa6d143c0" alt=""><figcaption></figcaption></figure> <figure><img src="https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2Fw8VoC6Pz8jgl4EnhJ5WV%2F11%20-%20oauth1.png?alt=media&#x26;token=7b317178-c213-40ae-a1b2-f4d79783af47" alt=""><figcaption></figcaption></figure></div>

<div><figure><img src="https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2FsbH7dOq2OSgDqlS40UhP%2F11%20-%20oauth2.png?alt=media&#x26;token=f16deea5-a081-48ce-a68b-6e455f533f27" alt=""><figcaption></figcaption></figure> <figure><img src="https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2FX3ktlhtDGDE5NNhgjBAv%2F11%20-%20oauth3%20test%20users.png?alt=media&#x26;token=ae7baf56-db37-4601-b810-16e9cfa1a565" alt=""><figcaption></figcaption></figure></div>

16. Hit `Next` button on the Scopes tab
17. On the Test users screen, add your email address. `Save and Continue` again
18. Find and select the `Credentials` link on the left
19. Click on "`+ CREATE CREDENTIALS`" -> OAuth client ID
20. Select `Application type` == `Web application`
21. Enter a name for the client, e.g. `Hubitat Companion`
22. Under `Authorized redirect URIs`, click `+ ADD URI` and enter: `https://cloud.hubitat.com/oauth/stateredirect`
23. Click `CREATE`
24. You will see the new entry under `OAuth 2.0 Client IDs` -- on the far-right, click the download icon and then `DOWNLOAD JSON` button to download OAuth credentials. This file should start with "`client_secret_*.json`" You'll need this file later!

<figure><img src="https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2FuEt6o7Re7A7gg9n1lRkv%2F12%20-%20oauth%20download.png?alt=media&#x26;token=9fde3942-7e9c-41ec-8622-2c18d8b64eda" alt=""><figcaption></figcaption></figure>

25. Before you're done - click on the OAuth consent screen item in left menu and hit PUBLISH APP button. I believe this is necessary to keep the OAuth token active ongoing

<figure><img src="https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2FeFLXyNikEFBx14Z5XWG4%2Fimage.png?alt=media&#x26;token=7e25d69a-c918-4188-bf4a-2ea8135c7789" alt=""><figcaption></figcaption></figure>

## Install HD+ Companion App/Driver

* Install [Hubitat Package Manager](https://hubitatpackagemanager.hubitatcommunity.com/) (HPM) if not already installed
* Use HPM -> Install -> Search for keyword: "HD+ Companion" to install the app and driver
  * NOTE: this replaces an older driver called "HD+ Device". It should update fine but if not please uninstall HD+ Device driver first

## Configure HD+ Companion App

You're going to need to open both the .json files you downloaded earlier. Open them in a text editor.

* Add a new App to the Hub (Add User App -> HD+ Companion)
* Fill in the 5 required fields. The first 2 are needed for the server app and the last 3 are needed for HD+
* From the `client_secret_*.json` file:
  * **Client ID**
    * `"client_id": "123456789-abcd.apps.googleusercontent.com",`
  * **Client Secret**
    * `"client_secret": "VALUE",`
* From the `google_services.json` file
  * **Project ID**
    * `"project_id": "hd-companion-12345",`
  * **API Key**
    * `"current_key": "VALUE"`
  * **App ID**
    * `"mobilesdk_app_id": "1:333482833076:android:XXXX6db1a53e1",`
* After filling in these fields you should see a button show up "Authorize App". Click this and follow the instructions on Google to login and allow access to your Hub to send push messages. When done you should get a link to return back to the Hubitat app

<figure><img src="https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2Fy2HMQlJVpoMNfSBaEBYg%2Fimage.png?alt=media&#x26;token=40058c83-83e5-49fd-a2c7-17550988f964" alt=""><figcaption></figcaption></figure>

## Add newly created HD+ Device to MakerAPI

* The HD Companion app will create a new device called "HD+ Device"
* Open MakerAPI and add this new device so HD+ can access it

## Configure HD+

* In HD+ find this new device, long-press and hit Edit
* Open "Push Notifications"
* Enable "Link Device" to allow this Hubitat device to send push notifications to this phone\
  ![](https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2FHMZSIC1syGgtIHKrB5Ix%2Fimage.png?alt=media\&token=5771bc33-ad8f-4d80-a64c-8e3ed98f3336)<img src="https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2FBfW6bwqNKsKwovNQw7zv%2Fimage.png?alt=media&#x26;token=bd1e913a-f704-4b87-8175-d001baf5aecf" alt="" data-size="original">

## Verify

* Once you link HD+ and the Hubitat device, HD+ will try to get a 'client key' and set it on the device. You can verify this by viewing the device on the hub and look for `clientKey` to be set

<figure><img src="https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2F4iSYxebgxiWwN88lq1Tl%2Fimage.png?alt=media&#x26;token=0cb920f0-5056-41a4-867f-a26c87969c92" alt=""><figcaption></figcaption></figure>

## Button Commands

The HD+ Device driver supports PushableButton, which means you can use it as a virtual button in your Hubitat Hub.

When pushed, an event is sent to the device which you can use to run a Tasker task (today, other actions will be added in the future)

Use the "Button Commands" setting (see above) to set an action for each button press. You will need Tasker installed to use this\
![](https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2FTvuCSRWwAFR4qS74Rl0A%2Fimage.png?alt=media\&token=f5b6076b-3867-46ac-8e36-6279453f8d9a)

## What Next?

* Use this new Hubitat device driver for sending either text or TTS notifications
* The guide below shows how to do both text or TTS notifications

{% embed url="<https://docs2.hubitat.com/apps/notifications>" %}

## And More...

* This device driver also supports presence and can be used with the [Presence Tracking (Geofence)](https://joe-page-software.gitbook.io/hubitat-dashboard/features/presence-tracking-geofence) feature

## Notes

* This device driver / feature currently only works with Google supported devices and not with Amazon Fire devices. This is because Amazon doesn't support Firebase Cloud Messaging (FCM). Once this is all working well I'll try to also support [Amazon](https://developer.amazon.com/docs/adm/overview.html)'s version of pushing messaging as well

## Troubleshooting

If you're having any trouble getting notifications or TTS to work check these things:

1. you're running the latest beta version of HD+ (1.0.2196 or greater)
2. make sure the "HD+ Device" driver is added to MakerAPI
3. find this device in HD+ and check "Support Notifications"
4. look at the HD+ Device driver page and ensure both client key and server key are set (HD+ will do this for you). If either one isn't set - you might need to email me device logs along with what device you're using.

<figure><img src="https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2Fox3j22QqqJm1PIzDuKP8%2Fimage.png?alt=media&#x26;token=29e42330-fa4a-4b15-b175-4cb930424856" alt=""><figcaption></figcaption></figure>

<figure><img src="https://359348802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk-IVGVr8G2SBHju4g7%2Fuploads%2FKi5KNCkConZZuRY0KRjE%2Fimage.png?alt=media&#x26;token=149fc428-da19-4921-893a-6252c3301df1" alt=""><figcaption><p>Seen in HD+ Device Hubitat webpage</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://joe-page-software.gitbook.io/hubitat-dashboard/tiles/hd+-companion-app-driver.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
