Multiple Harmony Hubs in HA?

Does the Harmony Hub integration allow for multiple hubs? I want to have one in one room to handle things in a cabinet, and another in other room that uses infrared. So when I turn something on with HA it turns on one element in the cabinet and the other elements in the family room with the other one. Can this be done? Note I am not using discovery.

Thanks

JR

yes, have you checked out the docs? just add 2 platforms to remote.

Thanks, yeah I saw that but one of the youtubers who posts a lot of HA videos felt it didn’t work with multiple hubs.

Thanks.

JR

Don’t watch youtubers for installing components. That changes so much that information is wrong and outdated everywhere. Always consult the docs for the correct answer.

EDIT: an example

remote:
  - platform: harmony
    name: Bedroom
    host: 10.168.1.13
  - platform: harmony
    name: Living Room
    host: 10.168.1.14

Just make sure to name them

Note taken.

By the way, if I have devices like an XBox 360 that does not have any known way to manage it thru the network, if someone turns off the XBox manually I assume the hub nor HA will know that? If not, what if I got a compatible remote to the harmony hub and turned it off with that. Can’t assume everyone will want to manage the TV and accessories with HA. That will probably just be me.

Thanks.

JR

yes, that’s a good assumption.

I hid all the remotes accept the one that connects to the hub. I also went and found stickers with a X over a hand and placed them on all the remotes. As ridiculous as it sounds, it worked. They only use the harmony remote.

Cool, so will guess from your response that HA will be aware of the XBox 360 being turned off by the remote? That said, does the remote for the harmony hub support two hubs or would I assume it would work with the one in the closet and it would handle the infrared work of enabling things in the family room?

Thanks.

JR

If you add an RF device to a harmony activity, harmony will attempt to store the state in that activity. There is a chance to get out of sync. You can use the phone app to restore the state. It’s only happened a few times in the past few years. Typically when switching activities and the xbox doesn’t shut off. Surprisingly, the xbox one does not have automation built into it, so it’s treated the same way as the 360. You’ll need to get IR blasters for your hub for this to work btw. The harmony elite comes with that, not sure about the hub stand alone.

Thanks I currently have a Harmony 900 with a remote RF hub of sorts and blasters that come out of it. Unfortunately not network manageable but familiar with the blasters.

Also it would be kind of cool if Harmony had a remote blaster that would connect to the hub thru RF so I didn’t need a second hub in the other room. I could run blasters from the other room into the family room but like things that are clean and not have infrared blasters taped to the TV and be visible.

Thanks

JR

No, but the mobile app allows you to switch between hubs. It’s a bit slow though. Controlling both through HA is definitely the quickest way.

And if you use Alexa, support is very kludgy with two hubs. You need to install another skill to control the second hub, and you need to say a very intuitive (sarcasm), “Alexa, tell harmony to turn on -whatever-”… :roll_eyes:

Interesting. i probably do not understand how Alexa works with HA but I was hoping with haaska that I’m using, Alexa would see it as a smarthome skill and just tell HA to run the skill. But thinking maybe Alexa doesn’t see things like automations and sensors, just devices. I know I made a sensor for my garage door so I could show the state of it on the screen, but couldn’t expand that to Alexa so i could ask her the state of the garage door and have her tell me.

Thanks.

JR

I haven’t heard of haaska before. Looks interesting. It looks like it can interface with automations and input booleans/sliders. If that’s the case, then you should be able to control your hubs through haaska.

You can. You can connect both hubs to HA through template switches. Then expose the switches to alexa via Alexa Smart Home Skill, or the deprecated hasska. Both are one in the same, hasska is no longer maintained because Alexa Smart Home Skill replaced it. It can control everything home assistant cloud can, it’s pretty much the free version of Nabu Casa. It’s just a challenge to setup. Once setup, you can use normal phrases to command the hubs as long as you name your activities with unique names.

Here’s a guide for the template switches & harmony control. Alexa Smart Home Skill is the final piece of the puzzle.

Seriously Petro?!?!? :slight_smile: I must have missed this as setting up haaska was equally no joke. Brief look seems basically the same. So assuming I should build the Smart Home Skill and remove the haaska one? Then I assume before enabling the Smart Home Skill should get rid of everything Alexa found with haaska?

Once that’s all done do you know if I say “Watch a movie” that it would use the automation to turn on the TV with one Hub and turn on the XBox and Receiver with the other? Or would I have to ask it to do each one at a time?

Thanks.

JR

this completely depends on how you set it up.

I have a switch that turns on the tv, reciever, and xbox. Then I say ‘alexa turn on xbox’.

I can’t say ‘watch a movie’ because it’s not connected that way, it’s connected as a switch. I’m sure if you got inventive within the confines of HA, you could manage that as a saying. But you’d probably need to make it a routine that turns on a switch.

Also, you should know that you can still use haaska if you want. Does the same thing as Smart Home Skill. Or you can replace haaska’s lambda with alexa smart home’s lambda. I don’t see haaska ever changing. Only thing that would break them is HA changing or adding something. But if you use ASMS’s lambda instead of haaska’s, you shouldn’t have a problem.

So that was a bummer. Seems the instructions were a bit different between haaska and this with Amazon so not sure if that’s the reason but I got everything setup and it passed the test and showed devices from HA. However when I tried to enable it thru the mobile app or thru the website said We were unable to link HomeAssistant at this time. No idea why.

Specifically showed " For instructions and assistance with configuring your skill for account linking with OAuth, please see this guide." but not sure if that’s relevant. I know haaska said to use basic authentication where this said that’s not supported and wanted to use credentials in request body. And for most of the URL’s it used Amazon specific URL’s for most of it where the guide here showed pointing to my server. And the referrrer URL’s it did stuff with but this guide didn’t. So not sure where it went wrong especially since the test worked.

I’m guessing your lambda account isn’t linked to your aws skill. Go through the process start to finish and perform all necessary actions. If you are in the EU, i’ve seen people complaining that EU servers don’t show the appropriate skill, so set it up for NA, Virginia.

Thanks I’ll try again. One question. So am I supposed to create and add the long access token from HA or not? That part was confusing to me.

EDIT: No joy. May have to go back to haaska. This keeps hanging on the linking in the mobile app. I know I followed the directions even though they seems a tiny bit dated. Like when you are supposed to be in the Designer screen and select Alexa Smart Home, it’s not there. You have to click on Triggers and then search for it so not sure if everything there is accurate to the current layout of Alexa.

Thanks.

JR

Note this is probably a lot, but below is what I did no joy. Hiding a couple things:

Login to Developer Console: https://developer.amazon.com/alexa/console/ask?
Click Create Skill
Name: HomeAssistant
Select Smart home
Verify Provision your own is selected
Click Create Skill
Verify v3 selected on page
Copy your Skill ID: ###########################################
Open a new tab and login to AWS Console https://console.aws.amazon.com/
Click Services > IAM > Roles > Create role
Select AWS Service
Select Lambda
Click Next: Permissions
Search for AWSLambdaBasicExecutionRole and select it.
Click Next: Tags
Click Next: Review
Enter Role Name of AWSLambdaBasicExecutionRole-SmartHome and click Create role
Click Service > Lambda
Verified N. Virginia selected
Click Create Function
Set Author from scratch
Function Name: HomeAssistant
Runtime: Python 3.7
Expand Choose execution role
Select Use an existing role
Select AWSLambdaBasicExecutionRole-SmartHome
Click Create function
Expand Designer
Click Add Trigger
Select Alexa Smart Home
Application ID paste in your Skill ID from before
Click Add
Click on HomeAssistant
Clear the contents of lambda_function.py and paste in

"""
Copyright 2019 Jason Hu <awaregit at gmail.com>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import os
import json
import logging
import urllib3

_debug = bool(os.environ.get('DEBUG'))

_logger = logging.getLogger('HomeAssistant-SmartHome')
_logger.setLevel(logging.DEBUG if _debug else logging.INFO)


def lambda_handler(event, context):
    """Handle incoming Alexa directive."""
    
    _logger.debug('Event: %s', event)

    base_url = os.environ.get('BASE_URL')
    assert base_url is not None, 'Please set BASE_URL environment variable'

    directive = event.get('directive')
    assert directive is not None, 'Malformatted request - missing directive'
    assert directive.get('header', {}).get('payloadVersion') == '3', \
        'Only support payloadVersion == 3'
    
    scope = directive.get('endpoint', {}).get('scope')
    if scope is None:
        # token is in grantee for Linking directive 
        scope = directive.get('payload', {}).get('grantee')
    if scope is None:
        # token is in payload for Discovery directive 
        scope = directive.get('payload', {}).get('scope')
    assert scope is not None, 'Malformatted request - missing endpoint.scope'
    assert scope.get('type') == 'BearerToken', 'Only support BearerToken'

    token = scope.get('token')
    if token is None and _debug:
        token = os.environ.get('LONG_LIVED_ACCESS_TOKEN')  # only for debug purpose
    
    verify_ssl = not bool(os.environ.get('NOT_VERIFY_SSL'))
    
    http = urllib3.PoolManager(
        cert_reqs='CERT_REQUIRED' if verify_ssl else 'CERT_NONE',
        timeout=urllib3.Timeout(connect=2.0, read=10.0)
    )
    
    response = http.request(
        'POST', 
        '{}/api/alexa/smart_home'.format(base_url),
        headers={
            'Authorization': 'Bearer {}'.format(token),
            'Content-Type': 'application/json',
        },
        body=json.dumps(event).encode('utf-8'),
    )
    if response.status >= 400:
        return {
            'event': {
                'payload': {
                    'type': 'INVALID_AUTHORIZATION_CREDENTIAL' 
                            if response.status in (401, 403) else 'INTERNAL_ERROR',
                    'message': response.data.decode("utf-8"),
                }
            }
        }
    return json.loads(response.data.decode('utf-8'))

Under Environment variables add:
BASE_URL: https://<public_url>:8123
DEBUG: True
Click Save
Copy ARN at top: ###############################################
Make sure you have the following in your configuration.yaml and reboot:

alexa:
  smart_home:

In AWS Console click Test
Event Name: Discovery
Clear the body and put in:

{
  "directive": {
    "header": {
      "namespace": "Alexa.Discovery",
      "name": "Discover",
      "payloadVersion": "3",
      "messageId": "1bd5d003-31b9-476f-ad03-71d471922820"
    },
    "payload": {
      "scope": {
        "type": "BearerToken"
      }
    }
  }
}

Click Create

Go to Home Assistant and create a Long-Lived Access Token
##########################################################################################################################

Go back to AWS console and add LONG_LIVED_ACCESS_TOKEN Environment Variables
Click Save
Test should pass

Go back to the developer console tab still open and paste in the ARN value for Default endpoint and click Save
Click Setup Account Linking
Authorization URI: https://<public_url>:8123/auth/authorize
Access Token URI: https://<public_url>:8123/auth/token
Your Client ID: https://pitangui.amazon.com/
Client Secret: HiThere
Authorization Scheme: Credentials in request body
Scope click + and put in smart_home
Click Save
Open the mobile app go to Skills & Games > Your Skills Dev
Click on HomeAssistant
Click ENABLE TO USE

We were unable to link HomeAssistant at this time

Think this is related but in the log:

2019-11-17 12:09:44 ERROR (MainThread) [homeassistant.components.http.data_validator] Data does not match schema: required key not provided @ data[‘redirect_uri’]
2019-11-17 12:35:01 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from 3.230.166.109

EDIT: See a lot of people with this problem. Some say it’s a HA issue with oauth 2.0 authentication and how HA handles it but no clue.