Skip to content

Commit

Permalink
Set name to hyperion assets (home-assistant#1822)
Browse files Browse the repository at this point in the history
* set name to hyperion assets

by specifying the name in the configuration:

light kodi_xxx:
  name: "Kodi XXX"
  platform: hyperion
  host: 192.168.1.222
  port: 19444

* Update hyperion.py

fix extra space
  • Loading branch information
sch3m4 authored and balloob committed Apr 19, 2016
1 parent c1ca13d commit b9fd491
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions homeassistant/components/light/hyperion.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Setup a Hyperion server remote."""
host = config.get(CONF_HOST, None)
port = config.get("port", 19444)
device = Hyperion(host, port)
device = Hyperion(config.get('name', host), host, port)
if device.setup():
add_devices_callback([device])
return True
Expand All @@ -30,11 +30,11 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
class Hyperion(Light):
"""Representation of a Hyperion remote."""

def __init__(self, host, port):
def __init__(self, name, host, port):
"""Initialize the light."""
self._host = host
self._port = port
self._name = host
self._name = name
self._is_available = True
self._rgb_color = [255, 255, 255]

Expand Down Expand Up @@ -75,7 +75,8 @@ def setup(self):
"""Get the hostname of the remote."""
response = self.json_request({"command": "serverinfo"})
if response:
self._name = response["info"]["hostname"]
if self._name == self._host:
self._name = response["info"]["hostname"]
return True

return False
Expand Down

0 comments on commit b9fd491

Please sign in to comment.