mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Fix Gogogate2 'available' attribute (#13728)
* Fixed bug - unable to set base readaonly property * PR fixes * Added line
This commit is contained in:
parent
286476f0d6
commit
58f3690ef6
@ -11,7 +11,7 @@ import voluptuous as vol
|
|||||||
from homeassistant.components.cover import (
|
from homeassistant.components.cover import (
|
||||||
CoverDevice, SUPPORT_OPEN, SUPPORT_CLOSE)
|
CoverDevice, SUPPORT_OPEN, SUPPORT_CLOSE)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_USERNAME, CONF_PASSWORD, STATE_CLOSED, STATE_UNKNOWN,
|
CONF_USERNAME, CONF_PASSWORD, STATE_CLOSED,
|
||||||
CONF_IP_ADDRESS, CONF_NAME)
|
CONF_IP_ADDRESS, CONF_NAME)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
@ -50,7 +50,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
|
|
||||||
add_devices(MyGogogate2Device(
|
add_devices(MyGogogate2Device(
|
||||||
mygogogate2, door, name) for door in devices)
|
mygogogate2, door, name) for door in devices)
|
||||||
return
|
|
||||||
|
|
||||||
except (TypeError, KeyError, NameError, ValueError) as ex:
|
except (TypeError, KeyError, NameError, ValueError) as ex:
|
||||||
_LOGGER.error("%s", ex)
|
_LOGGER.error("%s", ex)
|
||||||
@ -60,7 +59,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
''.format(ex),
|
''.format(ex),
|
||||||
title=NOTIFICATION_TITLE,
|
title=NOTIFICATION_TITLE,
|
||||||
notification_id=NOTIFICATION_ID)
|
notification_id=NOTIFICATION_ID)
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
class MyGogogate2Device(CoverDevice):
|
class MyGogogate2Device(CoverDevice):
|
||||||
@ -72,7 +70,7 @@ class MyGogogate2Device(CoverDevice):
|
|||||||
self.device_id = device['door']
|
self.device_id = device['door']
|
||||||
self._name = name or device['name']
|
self._name = name or device['name']
|
||||||
self._status = device['status']
|
self._status = device['status']
|
||||||
self.available = None
|
self._available = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -97,24 +95,22 @@ class MyGogogate2Device(CoverDevice):
|
|||||||
@property
|
@property
|
||||||
def available(self):
|
def available(self):
|
||||||
"""Could the device be accessed during the last update call."""
|
"""Could the device be accessed during the last update call."""
|
||||||
return self.available
|
return self._available
|
||||||
|
|
||||||
def close_cover(self, **kwargs):
|
def close_cover(self, **kwargs):
|
||||||
"""Issue close command to cover."""
|
"""Issue close command to cover."""
|
||||||
self.mygogogate2.close_device(self.device_id)
|
self.mygogogate2.close_device(self.device_id)
|
||||||
self.schedule_update_ha_state(True)
|
|
||||||
|
|
||||||
def open_cover(self, **kwargs):
|
def open_cover(self, **kwargs):
|
||||||
"""Issue open command to cover."""
|
"""Issue open command to cover."""
|
||||||
self.mygogogate2.open_device(self.device_id)
|
self.mygogogate2.open_device(self.device_id)
|
||||||
self.schedule_update_ha_state(True)
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update status of cover."""
|
"""Update status of cover."""
|
||||||
try:
|
try:
|
||||||
self._status = self.mygogogate2.get_status(self.device_id)
|
self._status = self.mygogogate2.get_status(self.device_id)
|
||||||
self.available = True
|
self._available = True
|
||||||
except (TypeError, KeyError, NameError, ValueError) as ex:
|
except (TypeError, KeyError, NameError, ValueError) as ex:
|
||||||
_LOGGER.error("%s", ex)
|
_LOGGER.error("%s", ex)
|
||||||
self._status = STATE_UNKNOWN
|
self._status = None
|
||||||
self.available = False
|
self._available = False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user