Skip to content

Commit

Permalink
Add Open garage unique_id (home-assistant#36074)
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielhiversen authored May 24, 2020
1 parent fe45935 commit ed7ac3c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions homeassistant/components/opengarage/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
)
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.device_registry import format_mac

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -72,23 +73,28 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
device_config[CONF_VERIFY_SSL],
async_get_clientsession(hass),
)

covers.append(OpenGarageCover(device_config.get(CONF_NAME), open_garage))
status = await open_garage.update_state()
covers.append(
OpenGarageCover(
device_config.get(CONF_NAME), open_garage, format_mac(status["mac"])
)
)

async_add_entities(covers, True)


class OpenGarageCover(CoverEntity):
"""Representation of a OpenGarage cover."""

def __init__(self, name, open_garage):
def __init__(self, name, open_garage, device_id):
"""Initialize the cover."""
self._name = name
self._open_garage = open_garage
self._state = None
self._state_before_move = None
self._device_state_attributes = {}
self._available = True
self._device_id = device_id

@property
def name(self):
Expand Down Expand Up @@ -181,3 +187,8 @@ def device_class(self):
def supported_features(self):
"""Flag supported features."""
return SUPPORT_OPEN | SUPPORT_CLOSE

@property
def unique_id(self):
"""Return a unique ID."""
return self._device_id

0 comments on commit ed7ac3c

Please sign in to comment.