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

Re-org emulated_hue and fix google home #4708

Merged
merged 1 commit into from Dec 4, 2016
Merged

Conversation

balloob
Copy link
Member

@balloob balloob commented Dec 4, 2016

Description:
This will fix emulated_hue so that it works with Google Home.

In the original Hue api, /lights returns an object of lights. Each key is a stringified number starting at 1 that represents the hub light id. In our emulated_hue we used the entity_id for this. This is something that Alexa supports and will remember between restarts of HASS.

Google Home will try to parse the string key to a number. If it can't parse it it will default to 0. Since we use entity_id it will process all lights as key 0 and thus only remember the last one, which then is unreachable as we don't know that id.

So this PR introduces a new type config parameter for emulated_hue. When set to google_home, it will convert all entity ids to numbers starting at 1. Google Home requests the state of the lights every 10 seconds so when the mapping of id to entity id changes after a restart, Home Assistant will know quick enough.

Note: you will need to set your listening port for the emulated Hue API to port 80 or else Google Home will not work.

This PR also introduces a significant re-org of the code to make it more organized and maintainable.

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>

Example entry for configuration.yaml (if applicable):

emulated_hue:
  type: google_home
  listen_port: 80

# Defaults to Alexa and port 8300
emulated_hue:

Checklist:

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

@mention-bot
Copy link

@balloob, thanks for your PR! By analyzing the history of the files in this pull request, we identified @fabaff, @bah2830 and @vkorn to be potential reviewers.

@balloob
Copy link
Member Author

balloob commented Dec 4, 2016

In the future we could probably work with id persistence so that we no longer have to differentiate between Alexa / Google Home but for now this will already get people going.

@arsaboo
Copy link
Contributor

arsaboo commented Dec 4, 2016

Super!! Does that mean, if we want to use both Alexa and Google Home, the config will have two emulated_hue entries like you have in the first post?

@balloob
Copy link
Member Author

balloob commented Dec 4, 2016 via email

@arsaboo
Copy link
Contributor

arsaboo commented Dec 4, 2016

Got it.
Purely from the user perspective, wondering if it may be easier to just have an option in the emulated_hue entry to enable google_home (defaults to off):

emulated_hue:
   google_home: True

If google_home is true, then create entities for both Alexa and Google Home.

@balloob
Copy link
Member Author

balloob commented Dec 4, 2016

Nah, we can't have both entities be available. It is either one or the other.

@balloob balloob added this to the 0.34.1 milestone Dec 4, 2016
@balloob balloob merged commit a9be6c3 into dev Dec 4, 2016
@balloob balloob deleted the emulated-hue-google-home branch December 4, 2016 18:57
balloob added a commit that referenced this pull request Dec 4, 2016
@claudioita
Copy link

SO for the moment is either Alexa OR Google Home, together both it will not work, correct?

@ronvl
Copy link

ronvl commented Dec 5, 2016

@balloob how did you get it working on port 80 as on a PI we can't unless HASS runs as root....
See #4737

@ronvl
Copy link

ronvl commented Dec 6, 2016

Cool got it working with :
sudo setcap 'cap_net_bind_service=+ep' /usr/bin/python3.4

@colinodell
Copy link
Contributor

No, that won't work as upnp will conflict. We need to get to a better
solution with persistent ids for entities.

I already validated that they accept entity numbers that are not sequential
so now I just need to persist them.

Is this being tracked somewhere? (I'd like to subscribe to updates if possible)

@claudioita
Copy link

what would be the command for a HASSBIAN installation?

@home-assistant home-assistant locked and limited conversation to collaborators Apr 23, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants