mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Add service to set netatmo home heating schedule (#29244)
* Add service to set netatmo home heating schedule. * handle NoDevice exeption; add service argument constant
This commit is contained in:
parent
48aba426a9
commit
b8434fdcfd
@ -30,6 +30,7 @@ CONF_WEBHOOKS = "webhooks"
|
|||||||
|
|
||||||
SERVICE_ADDWEBHOOK = "addwebhook"
|
SERVICE_ADDWEBHOOK = "addwebhook"
|
||||||
SERVICE_DROPWEBHOOK = "dropwebhook"
|
SERVICE_DROPWEBHOOK = "dropwebhook"
|
||||||
|
SERVICE_SETSCHEDULE = "set_schedule"
|
||||||
|
|
||||||
NETATMO_AUTH = None
|
NETATMO_AUTH = None
|
||||||
NETATMO_WEBHOOK_URL = None
|
NETATMO_WEBHOOK_URL = None
|
||||||
@ -63,6 +64,7 @@ ATTR_IS_KNOWN = "is_known"
|
|||||||
ATTR_FACE_URL = "face_url"
|
ATTR_FACE_URL = "face_url"
|
||||||
ATTR_SNAPSHOT_URL = "snapshot_url"
|
ATTR_SNAPSHOT_URL = "snapshot_url"
|
||||||
ATTR_VIGNETTE_URL = "vignette_url"
|
ATTR_VIGNETTE_URL = "vignette_url"
|
||||||
|
ATTR_SCHEDULE = "schedule"
|
||||||
|
|
||||||
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=5)
|
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=5)
|
||||||
MIN_TIME_BETWEEN_EVENT_UPDATES = timedelta(seconds=5)
|
MIN_TIME_BETWEEN_EVENT_UPDATES = timedelta(seconds=5)
|
||||||
@ -87,6 +89,8 @@ SCHEMA_SERVICE_ADDWEBHOOK = vol.Schema({vol.Optional(CONF_URL): cv.string})
|
|||||||
|
|
||||||
SCHEMA_SERVICE_DROPWEBHOOK = vol.Schema({})
|
SCHEMA_SERVICE_DROPWEBHOOK = vol.Schema({})
|
||||||
|
|
||||||
|
SCHEMA_SERVICE_SETSCHEDULE = vol.Schema({vol.Required(ATTR_SCHEDULE): cv.string})
|
||||||
|
|
||||||
|
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
"""Set up the Netatmo devices."""
|
"""Set up the Netatmo devices."""
|
||||||
@ -106,6 +110,12 @@ def setup(hass, config):
|
|||||||
_LOGGER.error("Unable to connect to Netatmo API")
|
_LOGGER.error("Unable to connect to Netatmo API")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
try:
|
||||||
|
home_data = pyatmo.HomeData(auth)
|
||||||
|
except pyatmo.NoDevice:
|
||||||
|
home_data = None
|
||||||
|
_LOGGER.debug("No climate device. Disable %s service", SERVICE_SETSCHEDULE)
|
||||||
|
|
||||||
# Store config to be used during entry setup
|
# Store config to be used during entry setup
|
||||||
hass.data[DATA_NETATMO_AUTH] = auth
|
hass.data[DATA_NETATMO_AUTH] = auth
|
||||||
|
|
||||||
@ -151,6 +161,20 @@ def setup(hass, config):
|
|||||||
schema=SCHEMA_SERVICE_DROPWEBHOOK,
|
schema=SCHEMA_SERVICE_DROPWEBHOOK,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _service_setschedule(service):
|
||||||
|
"""Service to change current home schedule."""
|
||||||
|
schedule_name = service.data.get(ATTR_SCHEDULE)
|
||||||
|
home_data.switchHomeSchedule(schedule=schedule_name)
|
||||||
|
_LOGGER.info("Set home schedule to %s", schedule_name)
|
||||||
|
|
||||||
|
if home_data is not None:
|
||||||
|
hass.services.register(
|
||||||
|
DOMAIN,
|
||||||
|
SERVICE_SETSCHEDULE,
|
||||||
|
_service_setschedule,
|
||||||
|
schema=SCHEMA_SERVICE_SETSCHEDULE,
|
||||||
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,3 +28,10 @@ set_light_off:
|
|||||||
entity_id:
|
entity_id:
|
||||||
description: Entity id.
|
description: Entity id.
|
||||||
example: 'camera.living_room'
|
example: 'camera.living_room'
|
||||||
|
|
||||||
|
set_schedule:
|
||||||
|
description: Set the home heating schedule
|
||||||
|
fields:
|
||||||
|
schedule:
|
||||||
|
description: Schedule name
|
||||||
|
example: Standard
|
Loading…
x
Reference in New Issue
Block a user