mirror of
https://github.com/home-assistant/core.git
synced 2025-08-07 22:55:10 +02:00
Black
This commit is contained in:
@@ -95,7 +95,11 @@ SUBTYPE_ZONE_CYCLING = "ZONE_CYCLING"
|
|||||||
SUBTYPE_ZONE_CYCLING_COMPLETED = "ZONE_CYCLING_COMPLETED"
|
SUBTYPE_ZONE_CYCLING_COMPLETED = "ZONE_CYCLING_COMPLETED"
|
||||||
|
|
||||||
# Webhook callbacks
|
# Webhook callbacks
|
||||||
LISTEN_EVENT_TYPES = ["DEVICE_STATUS_EVENT", "ZONE_STATUS_EVENT", "SCHEDULE_STATUS_EVENT"]
|
LISTEN_EVENT_TYPES = [
|
||||||
|
"DEVICE_STATUS_EVENT",
|
||||||
|
"ZONE_STATUS_EVENT",
|
||||||
|
"SCHEDULE_STATUS_EVENT",
|
||||||
|
]
|
||||||
WEBHOOK_CONST_ID = "homeassistant.rachio:"
|
WEBHOOK_CONST_ID = "homeassistant.rachio:"
|
||||||
WEBHOOK_PATH = URL_API + DOMAIN
|
WEBHOOK_PATH = URL_API + DOMAIN
|
||||||
SIGNAL_RACHIO_UPDATE = DOMAIN + "_update"
|
SIGNAL_RACHIO_UPDATE = DOMAIN + "_update"
|
||||||
@@ -298,7 +302,6 @@ class RachioIro:
|
|||||||
if event_type[KEY_NAME] in LISTEN_EVENT_TYPES:
|
if event_type[KEY_NAME] in LISTEN_EVENT_TYPES:
|
||||||
event_types.append({"id": event_type[KEY_ID]})
|
event_types.append({"id": event_type[KEY_ID]})
|
||||||
|
|
||||||
|
|
||||||
# Register to listen to these events from the device
|
# Register to listen to these events from the device
|
||||||
url = self.rachio.webhook_url
|
url = self.rachio.webhook_url
|
||||||
auth = WEBHOOK_CONST_ID + self.rachio.webhook_auth
|
auth = WEBHOOK_CONST_ID + self.rachio.webhook_auth
|
||||||
|
@@ -278,6 +278,7 @@ class RachioZone(RachioSwitch):
|
|||||||
self.hass, SIGNAL_RACHIO_ZONE_UPDATE, self._handle_update
|
self.hass, SIGNAL_RACHIO_ZONE_UPDATE, self._handle_update
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class RachioSchedule(RachioSwitch):
|
class RachioSchedule(RachioSwitch):
|
||||||
"""Representation of one fixed schedule on the Rachio Iro."""
|
"""Representation of one fixed schedule on the Rachio Iro."""
|
||||||
|
|
||||||
@@ -319,8 +320,11 @@ class RachioSchedule(RachioSwitch):
|
|||||||
@property
|
@property
|
||||||
def state_attributes(self) -> dict:
|
def state_attributes(self) -> dict:
|
||||||
"""Return the optional state attributes."""
|
"""Return the optional state attributes."""
|
||||||
return {ATTR_SCHEDULE_SUMMARY: self._summary, ATTR_SCHEDULE_ENABLED: self.schedule_is_enabled,
|
return {
|
||||||
ATTR_SCHEDULE_DURATION: self._duration /60}
|
ATTR_SCHEDULE_SUMMARY: self._summary,
|
||||||
|
ATTR_SCHEDULE_ENABLED: self.schedule_is_enabled,
|
||||||
|
ATTR_SCHEDULE_DURATION: self._duration / 60,
|
||||||
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def schedule_is_enabled(self) -> bool:
|
def schedule_is_enabled(self) -> bool:
|
||||||
@@ -332,9 +336,7 @@ class RachioSchedule(RachioSwitch):
|
|||||||
|
|
||||||
self._controller.rachio.schedulerule.start(self.schedule_id)
|
self._controller.rachio.schedulerule.start(self.schedule_id)
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Schedule %s started on %s",
|
"Schedule %s started on %s", self.name, self._controller.name,
|
||||||
self.name,
|
|
||||||
self._controller.name,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def turn_off(self, **kwargs) -> None:
|
def turn_off(self, **kwargs) -> None:
|
||||||
@@ -348,12 +350,15 @@ class RachioSchedule(RachioSwitch):
|
|||||||
|
|
||||||
def _handle_update(self, *args, **kwargs) -> None:
|
def _handle_update(self, *args, **kwargs) -> None:
|
||||||
"""Handle incoming webhook schedule data."""
|
"""Handle incoming webhook schedule data."""
|
||||||
#Schedule ID not passed when running indvidual zones, so we catch that error
|
# Schedule ID not passed when running indvidual zones, so we catch that error
|
||||||
try:
|
try:
|
||||||
if args[0][KEY_SCHEDULE_ID] == self.schedule_id:
|
if args[0][KEY_SCHEDULE_ID] == self.schedule_id:
|
||||||
if args[0][KEY_SUBTYPE] in [SUBTYPE_SCHEDULE_STARTED]:
|
if args[0][KEY_SUBTYPE] in [SUBTYPE_SCHEDULE_STARTED]:
|
||||||
self._state = True
|
self._state = True
|
||||||
elif args[0][KEY_SUBTYPE] in [SUBTYPE_SCHEDULE_STOPPED, SUBTYPE_SCHEDULE_COMPLETED]:
|
elif args[0][KEY_SUBTYPE] in [
|
||||||
|
SUBTYPE_SCHEDULE_STOPPED,
|
||||||
|
SUBTYPE_SCHEDULE_COMPLETED,
|
||||||
|
]:
|
||||||
self._state = False
|
self._state = False
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
@@ -365,4 +370,3 @@ class RachioSchedule(RachioSwitch):
|
|||||||
async_dispatcher_connect(
|
async_dispatcher_connect(
|
||||||
self.hass, SIGNAL_RACHIO_SCHEDULE_UPDATE, self._handle_update
|
self.hass, SIGNAL_RACHIO_SCHEDULE_UPDATE, self._handle_update
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user