mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
Moved siren to Wink from switch (#9879)
This commit is contained in:
parent
d16c5f9046
commit
41c2bdb4fb
@ -223,7 +223,7 @@ omit =
|
|||||||
homeassistant/components/wemo.py
|
homeassistant/components/wemo.py
|
||||||
homeassistant/components/*/wemo.py
|
homeassistant/components/*/wemo.py
|
||||||
|
|
||||||
homeassistant/components/wink.py
|
homeassistant/components/wink/*
|
||||||
homeassistant/components/*/wink.py
|
homeassistant/components/*/wink.py
|
||||||
|
|
||||||
homeassistant/components/xiaomi_aqara.py
|
homeassistant/components/xiaomi_aqara.py
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
foursquare:
|
foursquare:
|
||||||
checkin:
|
checkin:
|
||||||
description: Check a user into a Foursquare venue
|
description: Check a user into a Foursquare venue
|
||||||
@ -542,45 +543,6 @@ input_boolean:
|
|||||||
description: Entity id of the input boolean to turn on
|
description: Entity id of the input boolean to turn on
|
||||||
example: 'input_boolean.notify_alerts'
|
example: 'input_boolean.notify_alerts'
|
||||||
|
|
||||||
wink:
|
|
||||||
pair_new_device:
|
|
||||||
description: Pair a new device to a Wink Hub.
|
|
||||||
|
|
||||||
fields:
|
|
||||||
hub_name:
|
|
||||||
description: The name of the hub to pair a new device to.
|
|
||||||
example: 'My hub'
|
|
||||||
pairing_mode:
|
|
||||||
description: One of ["zigbee", "zwave", "zwave_exclusion", "zwave_network_rediscovery", "lutron", "bluetooth", "kidde"]
|
|
||||||
example: 'zigbee'
|
|
||||||
kidde_radio_code:
|
|
||||||
description: A string of 8 1s and 0s one for each dip switch on the kidde device left --> right = 1 --> 8
|
|
||||||
example: '10101010'
|
|
||||||
|
|
||||||
rename_wink_device:
|
|
||||||
description: Rename the provided device.
|
|
||||||
|
|
||||||
fields:
|
|
||||||
entity_id:
|
|
||||||
description: The entity_id of the device to rename.
|
|
||||||
example: binary_sensor.front_door_opened
|
|
||||||
name:
|
|
||||||
description: The name to change it to.
|
|
||||||
example: back_door
|
|
||||||
|
|
||||||
delete_wink_device:
|
|
||||||
description: Remove/unpair device from Wink.
|
|
||||||
|
|
||||||
fields:
|
|
||||||
entity_id:
|
|
||||||
description: The entity_id of the device to delete.
|
|
||||||
|
|
||||||
pull_newly_added_devices_from_wink:
|
|
||||||
description: Pull newly pair devices from Wink.
|
|
||||||
|
|
||||||
refresh_state_from_wink:
|
|
||||||
description: Pull the latest states for every device.
|
|
||||||
|
|
||||||
homeassistant:
|
homeassistant:
|
||||||
check_config:
|
check_config:
|
||||||
description: Check the Home Assistant configuration files for errors. Errors will be displayed in the Home Assistant log.
|
description: Check the Home Assistant configuration files for errors. Errors will be displayed in the Home Assistant log.
|
||||||
|
@ -35,79 +35,3 @@ mysensors_send_ir_code:
|
|||||||
V_IR_SEND:
|
V_IR_SEND:
|
||||||
description: IR code to send
|
description: IR code to send
|
||||||
example: '0xC284'
|
example: '0xC284'
|
||||||
|
|
||||||
wink_set_chime_volume:
|
|
||||||
description: Set the volume of the chime for a Dome siren/chime.
|
|
||||||
|
|
||||||
fields:
|
|
||||||
entity_id:
|
|
||||||
description: Name(s) of the entities to set
|
|
||||||
example: 'switch.dome_siren'
|
|
||||||
volume:
|
|
||||||
description: Volume level. One of ["low", "medium", "high"]
|
|
||||||
example: "low"
|
|
||||||
|
|
||||||
|
|
||||||
wink_set_siren_volume:
|
|
||||||
description: Set the volume of the siren for a Dome siren/chime.
|
|
||||||
|
|
||||||
fields:
|
|
||||||
entity_id:
|
|
||||||
description: Name(s) of the entities to set
|
|
||||||
example: 'switch.dome_siren'
|
|
||||||
volume:
|
|
||||||
description: Volume level. One of ["low", "medium", "high"]
|
|
||||||
example: "high"
|
|
||||||
|
|
||||||
wink_enable_chime:
|
|
||||||
description: Enable the chime of a Dome siren with the provided sound.
|
|
||||||
|
|
||||||
fields:
|
|
||||||
entity_id:
|
|
||||||
description: Name(s) of the entities to set
|
|
||||||
example: 'switch.dome_siren'
|
|
||||||
tone:
|
|
||||||
description: The tone to use for the chime. One of ["doorbell", "fur_elise", "doorbell_extended", "alert", "william_tell", "rondo_alla_turca", "police_siren", "evacuation", "beep_beep", "beep", "inactive"]
|
|
||||||
example: "doorbell"
|
|
||||||
|
|
||||||
wink_set_siren_tone:
|
|
||||||
description: Set the sound to use when the siren is enabled. (This doesn't enable the siren)
|
|
||||||
|
|
||||||
fields:
|
|
||||||
entity_id:
|
|
||||||
description: Name(s) of the entities to set
|
|
||||||
example: 'switch.dome_siren'
|
|
||||||
tone:
|
|
||||||
description: The tone to use for the chime. One of ["doorbell", "fur_elise", "doorbell_extended", "alert", "william_tell", "rondo_alla_turca", "police_siren", "evacuation", "beep_beep", "beep", "inactive"]
|
|
||||||
example: "alert"
|
|
||||||
|
|
||||||
wink_siren_set_auto_shutoff:
|
|
||||||
description: How long to sound the siren before turning off.
|
|
||||||
|
|
||||||
fields:
|
|
||||||
entity_id:
|
|
||||||
description: Name(s) of the entities to set
|
|
||||||
example: 'switch.dome_siren'
|
|
||||||
auto_shutoff:
|
|
||||||
description: The time in seconds to sound the siren. One of [None, -1, 30, 60, 120] (None and -1 are forever. Use None for gocontrol, and -1 for Dome)
|
|
||||||
example: 60
|
|
||||||
|
|
||||||
wink_set_siren_strobe_enabled:
|
|
||||||
description: Enable or disable the strobe light when the siren is sounding.
|
|
||||||
|
|
||||||
fields:
|
|
||||||
entity_id:
|
|
||||||
description: Name(s) of the entities to set
|
|
||||||
example: 'switch.dome_siren'
|
|
||||||
enabled:
|
|
||||||
description: "True or False"
|
|
||||||
|
|
||||||
wink_set_chime_strobe_enabled:
|
|
||||||
description: Enable or disable the strobe light when the chime is sounding.
|
|
||||||
|
|
||||||
fields:
|
|
||||||
entity_id:
|
|
||||||
description: Name(s) of the entities to set
|
|
||||||
example: 'switch.dome_siren'
|
|
||||||
enabled:
|
|
||||||
description: "True or False"
|
|
||||||
|
@ -6,109 +6,19 @@ https://home-assistant.io/components/switch.wink/
|
|||||||
"""
|
"""
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from os import path
|
|
||||||
|
|
||||||
import voluptuous as vol
|
|
||||||
|
|
||||||
from homeassistant.components.wink import WinkDevice, DOMAIN
|
from homeassistant.components.wink import WinkDevice, DOMAIN
|
||||||
from homeassistant.helpers.entity import ToggleEntity
|
from homeassistant.helpers.entity import ToggleEntity
|
||||||
import homeassistant.helpers.config_validation as cv
|
|
||||||
from homeassistant.const import ATTR_ENTITY_ID
|
|
||||||
from homeassistant.config import load_yaml_config_file
|
|
||||||
|
|
||||||
DEPENDENCIES = ['wink']
|
DEPENDENCIES = ['wink']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
SERVICE_SET_CHIME_VOLUME = "wink_set_chime_volume"
|
|
||||||
SERVICE_SET_SIREN_VOLUME = "wink_set_siren_volume"
|
|
||||||
SERVICE_ENABLE_CHIME = "wink_enable_chime"
|
|
||||||
SERVICE_SET_SIREN_TONE = "wink_set_siren_tone"
|
|
||||||
SERVICE_SET_SIREN_AUTO_SHUTOFF = "wink_siren_set_auto_shutoff"
|
|
||||||
SERVICE_SET_SIREN_STROBE_ENABLED = "wink_set_siren_strobe_enabled"
|
|
||||||
SERVICE_SET_CHIME_STROBE_ENABLED = "wink_set_chime_strobe_enabled"
|
|
||||||
|
|
||||||
ATTR_VOLUME = "volume"
|
|
||||||
ATTR_TONE = "tone"
|
|
||||||
ATTR_ENABLED = "enabled"
|
|
||||||
ATTR_AUTO_SHUTOFF = "auto_shutoff"
|
|
||||||
|
|
||||||
VOLUMES = ["low", "medium", "high"]
|
|
||||||
TONES = ["doorbell", "fur_elise", "doorbell_extended", "alert",
|
|
||||||
"william_tell", "rondo_alla_turca", "police_siren",
|
|
||||||
"evacuation", "beep_beep", "beep"]
|
|
||||||
CHIME_TONES = TONES + ["inactive"]
|
|
||||||
AUTO_SHUTOFF_TIMES = [None, -1, 30, 60, 120]
|
|
||||||
|
|
||||||
|
|
||||||
SET_VOLUME_SCHEMA = vol.Schema({
|
|
||||||
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
|
||||||
vol.Required(ATTR_VOLUME): vol.In(VOLUMES)
|
|
||||||
})
|
|
||||||
|
|
||||||
SET_SIREN_TONE_SCHEMA = vol.Schema({
|
|
||||||
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
|
||||||
vol.Required(ATTR_TONE): vol.In(TONES)
|
|
||||||
})
|
|
||||||
|
|
||||||
SET_CHIME_MODE_SCHEMA = vol.Schema({
|
|
||||||
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
|
||||||
vol.Required(ATTR_TONE): vol.In(CHIME_TONES)
|
|
||||||
})
|
|
||||||
|
|
||||||
SET_AUTO_SHUTOFF_SCHEMA = vol.Schema({
|
|
||||||
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
|
||||||
vol.Required(ATTR_AUTO_SHUTOFF): vol.In(AUTO_SHUTOFF_TIMES)
|
|
||||||
})
|
|
||||||
|
|
||||||
SET_STROBE_ENABLED_SCHEMA = vol.Schema({
|
|
||||||
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
|
||||||
vol.Required(ATTR_ENABLED): cv.boolean
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Set up the Wink platform."""
|
"""Set up the Wink platform."""
|
||||||
import pywink
|
import pywink
|
||||||
|
|
||||||
def service_handle(service):
|
|
||||||
"""Handler for services."""
|
|
||||||
entity_ids = service.data.get('entity_id')
|
|
||||||
all_sirens = []
|
|
||||||
for switch in hass.data[DOMAIN]['entities']['switch']:
|
|
||||||
if isinstance(switch, WinkSirenDevice):
|
|
||||||
all_sirens.append(switch)
|
|
||||||
sirens_to_set = []
|
|
||||||
if entity_ids is None:
|
|
||||||
sirens_to_set = all_sirens
|
|
||||||
else:
|
|
||||||
for siren in all_sirens:
|
|
||||||
if siren.entity_id in entity_ids:
|
|
||||||
sirens_to_set.append(siren)
|
|
||||||
|
|
||||||
for siren in sirens_to_set:
|
|
||||||
if service.service != SERVICE_SET_SIREN_AUTO_SHUTOFF:
|
|
||||||
if siren.wink.device_manufacturer() != 'dome':
|
|
||||||
_LOGGER.error("Service only valid for Dome sirens.")
|
|
||||||
return
|
|
||||||
if service.service == SERVICE_SET_CHIME_VOLUME:
|
|
||||||
siren.wink.set_chime_volume(service.data.get(ATTR_VOLUME))
|
|
||||||
elif service.service == SERVICE_SET_SIREN_VOLUME:
|
|
||||||
siren.wink.set_siren_volume(service.data.get(ATTR_VOLUME))
|
|
||||||
elif service.service == SERVICE_SET_SIREN_TONE:
|
|
||||||
siren.wink.set_siren_sound(service.data.get(ATTR_TONE))
|
|
||||||
elif service.service == SERVICE_ENABLE_CHIME:
|
|
||||||
siren.wink.set_chime(service.data.get(ATTR_TONE))
|
|
||||||
elif service.service == SERVICE_SET_SIREN_STROBE_ENABLED:
|
|
||||||
siren.wink.set_siren_strobe_enabled(
|
|
||||||
service.data.get(ATTR_ENABLED))
|
|
||||||
elif service.service == SERVICE_SET_CHIME_STROBE_ENABLED:
|
|
||||||
siren.wink.set_chime_strobe_enabled(
|
|
||||||
service.data.get(ATTR_ENABLED))
|
|
||||||
else:
|
|
||||||
siren.wink.set_auto_shutoff(
|
|
||||||
service.data.get(ATTR_AUTO_SHUTOFF))
|
|
||||||
|
|
||||||
for switch in pywink.get_switches():
|
for switch in pywink.get_switches():
|
||||||
_id = switch.object_id() + switch.name()
|
_id = switch.object_id() + switch.name()
|
||||||
if _id not in hass.data[DOMAIN]['unique_ids']:
|
if _id not in hass.data[DOMAIN]['unique_ids']:
|
||||||
@ -117,10 +27,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
_id = switch.object_id() + switch.name()
|
_id = switch.object_id() + switch.name()
|
||||||
if _id not in hass.data[DOMAIN]['unique_ids']:
|
if _id not in hass.data[DOMAIN]['unique_ids']:
|
||||||
add_devices([WinkToggleDevice(switch, hass)])
|
add_devices([WinkToggleDevice(switch, hass)])
|
||||||
for siren in pywink.get_sirens():
|
|
||||||
_id = siren.object_id() + siren.name()
|
|
||||||
if _id not in hass.data[DOMAIN]['unique_ids']:
|
|
||||||
add_devices([WinkSirenDevice(siren, hass)])
|
|
||||||
for sprinkler in pywink.get_sprinklers():
|
for sprinkler in pywink.get_sprinklers():
|
||||||
_id = sprinkler.object_id() + sprinkler.name()
|
_id = sprinkler.object_id() + sprinkler.name()
|
||||||
if _id not in hass.data[DOMAIN]['unique_ids']:
|
if _id not in hass.data[DOMAIN]['unique_ids']:
|
||||||
@ -130,44 +36,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
if _id not in hass.data[DOMAIN]['unique_ids']:
|
if _id not in hass.data[DOMAIN]['unique_ids']:
|
||||||
add_devices([WinkToggleDevice(switch, hass)])
|
add_devices([WinkToggleDevice(switch, hass)])
|
||||||
|
|
||||||
descriptions = load_yaml_config_file(
|
|
||||||
path.join(path.dirname(__file__), 'services.yaml'))
|
|
||||||
|
|
||||||
hass.services.register(DOMAIN, SERVICE_SET_SIREN_TONE,
|
|
||||||
service_handle,
|
|
||||||
descriptions.get(SERVICE_SET_SIREN_TONE),
|
|
||||||
schema=SET_SIREN_TONE_SCHEMA)
|
|
||||||
|
|
||||||
hass.services.register(DOMAIN, SERVICE_ENABLE_CHIME,
|
|
||||||
service_handle,
|
|
||||||
descriptions.get(SERVICE_ENABLE_CHIME),
|
|
||||||
schema=SET_CHIME_MODE_SCHEMA)
|
|
||||||
|
|
||||||
hass.services.register(DOMAIN, SERVICE_SET_SIREN_VOLUME,
|
|
||||||
service_handle,
|
|
||||||
descriptions.get(SERVICE_SET_SIREN_VOLUME),
|
|
||||||
schema=SET_VOLUME_SCHEMA)
|
|
||||||
|
|
||||||
hass.services.register(DOMAIN, SERVICE_SET_CHIME_VOLUME,
|
|
||||||
service_handle,
|
|
||||||
descriptions.get(SERVICE_SET_CHIME_VOLUME),
|
|
||||||
schema=SET_VOLUME_SCHEMA)
|
|
||||||
|
|
||||||
hass.services.register(DOMAIN, SERVICE_SET_SIREN_STROBE_ENABLED,
|
|
||||||
service_handle,
|
|
||||||
descriptions.get(SERVICE_SET_SIREN_STROBE_ENABLED),
|
|
||||||
schema=SET_STROBE_ENABLED_SCHEMA)
|
|
||||||
|
|
||||||
hass.services.register(DOMAIN, SERVICE_SET_CHIME_STROBE_ENABLED,
|
|
||||||
service_handle,
|
|
||||||
descriptions.get(SERVICE_SET_CHIME_STROBE_ENABLED),
|
|
||||||
schema=SET_STROBE_ENABLED_SCHEMA)
|
|
||||||
|
|
||||||
hass.services.register(DOMAIN, SERVICE_SET_SIREN_AUTO_SHUTOFF,
|
|
||||||
service_handle,
|
|
||||||
descriptions.get(SERVICE_SET_SIREN_AUTO_SHUTOFF),
|
|
||||||
schema=SET_AUTO_SHUTOFF_SCHEMA)
|
|
||||||
|
|
||||||
|
|
||||||
class WinkToggleDevice(WinkDevice, ToggleEntity):
|
class WinkToggleDevice(WinkDevice, ToggleEntity):
|
||||||
"""Representation of a Wink toggle device."""
|
"""Representation of a Wink toggle device."""
|
||||||
@ -201,60 +69,3 @@ class WinkToggleDevice(WinkDevice, ToggleEntity):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
return attributes
|
return attributes
|
||||||
|
|
||||||
|
|
||||||
class WinkSirenDevice(WinkDevice, ToggleEntity):
|
|
||||||
"""Representation of a Wink siren device."""
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
|
||||||
def async_added_to_hass(self):
|
|
||||||
"""Callback when entity is added to hass."""
|
|
||||||
self.hass.data[DOMAIN]['entities']['switch'].append(self)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_on(self):
|
|
||||||
"""Return true if device is on."""
|
|
||||||
return self.wink.state()
|
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
|
||||||
"""Turn the device on."""
|
|
||||||
self.wink.set_state(True)
|
|
||||||
|
|
||||||
def turn_off(self):
|
|
||||||
"""Turn the device off."""
|
|
||||||
self.wink.set_state(False)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def device_state_attributes(self):
|
|
||||||
"""Return the state attributes."""
|
|
||||||
attributes = super(WinkSirenDevice, self).device_state_attributes
|
|
||||||
|
|
||||||
auto_shutoff = self.wink.auto_shutoff()
|
|
||||||
if auto_shutoff is not None:
|
|
||||||
attributes["auto_shutoff"] = auto_shutoff
|
|
||||||
|
|
||||||
siren_volume = self.wink.siren_volume()
|
|
||||||
if siren_volume is not None:
|
|
||||||
attributes["siren_volume"] = siren_volume
|
|
||||||
|
|
||||||
chime_volume = self.wink.chime_volume()
|
|
||||||
if chime_volume is not None:
|
|
||||||
attributes["chime_volume"] = chime_volume
|
|
||||||
|
|
||||||
strobe_enabled = self.wink.strobe_enabled()
|
|
||||||
if strobe_enabled is not None:
|
|
||||||
attributes["siren_strobe_enabled"] = strobe_enabled
|
|
||||||
|
|
||||||
chime_strobe_enabled = self.wink.chime_strobe_enabled()
|
|
||||||
if chime_strobe_enabled is not None:
|
|
||||||
attributes["chime_strobe_enabled"] = chime_strobe_enabled
|
|
||||||
|
|
||||||
siren_sound = self.wink.siren_sound()
|
|
||||||
if siren_sound is not None:
|
|
||||||
attributes["siren_sound"] = siren_sound
|
|
||||||
|
|
||||||
chime_mode = self.wink.chime_mode()
|
|
||||||
if chime_mode is not None:
|
|
||||||
attributes["chime_mode"] = chime_mode
|
|
||||||
|
|
||||||
return attributes
|
|
||||||
|
@ -4,6 +4,7 @@ Support for Wink hubs.
|
|||||||
For more details about this component, please refer to the documentation at
|
For more details about this component, please refer to the documentation at
|
||||||
https://home-assistant.io/components/wink/
|
https://home-assistant.io/components/wink/
|
||||||
"""
|
"""
|
||||||
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
@ -20,8 +21,10 @@ from homeassistant.helpers.event import track_time_interval
|
|||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_BATTERY_LEVEL, CONF_EMAIL, CONF_PASSWORD,
|
ATTR_BATTERY_LEVEL, CONF_EMAIL, CONF_PASSWORD,
|
||||||
EVENT_HOMEASSISTANT_START,
|
EVENT_HOMEASSISTANT_START,
|
||||||
EVENT_HOMEASSISTANT_STOP, __version__, ATTR_ENTITY_ID)
|
EVENT_HOMEASSISTANT_STOP, __version__, ATTR_ENTITY_ID,
|
||||||
|
STATE_ON, STATE_OFF)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.config import load_yaml_config_file
|
from homeassistant.config import load_yaml_config_file
|
||||||
|
|
||||||
@ -66,7 +69,26 @@ SERVICE_REFRESH_STATES = 'refresh_state_from_wink'
|
|||||||
SERVICE_RENAME_DEVICE = 'rename_wink_device'
|
SERVICE_RENAME_DEVICE = 'rename_wink_device'
|
||||||
SERVICE_DELETE_DEVICE = 'delete_wink_device'
|
SERVICE_DELETE_DEVICE = 'delete_wink_device'
|
||||||
SERVICE_SET_PAIRING_MODE = 'pair_new_device'
|
SERVICE_SET_PAIRING_MODE = 'pair_new_device'
|
||||||
|
SERVICE_SET_CHIME_VOLUME = "set_chime_volume"
|
||||||
|
SERVICE_SET_SIREN_VOLUME = "set_siren_volume"
|
||||||
|
SERVICE_ENABLE_CHIME = "enable_chime"
|
||||||
|
SERVICE_SET_SIREN_TONE = "set_siren_tone"
|
||||||
|
SERVICE_SET_AUTO_SHUTOFF = "siren_set_auto_shutoff"
|
||||||
|
SERVICE_SIREN_STROBE_ENABLED = "set_siren_strobe_enabled"
|
||||||
|
SERVICE_CHIME_STROBE_ENABLED = "set_chime_strobe_enabled"
|
||||||
|
SERVICE_ENABLE_SIREN = "enable_siren"
|
||||||
|
|
||||||
|
ATTR_VOLUME = "volume"
|
||||||
|
ATTR_TONE = "tone"
|
||||||
|
ATTR_ENABLED = "enabled"
|
||||||
|
ATTR_AUTO_SHUTOFF = "auto_shutoff"
|
||||||
|
|
||||||
|
VOLUMES = ["low", "medium", "high"]
|
||||||
|
TONES = ["doorbell", "fur_elise", "doorbell_extended", "alert",
|
||||||
|
"william_tell", "rondo_alla_turca", "police_siren",
|
||||||
|
"evacuation", "beep_beep", "beep"]
|
||||||
|
CHIME_TONES = TONES + ["inactive"]
|
||||||
|
AUTO_SHUTOFF_TIMES = [None, -1, 30, 60, 120]
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema({
|
CONFIG_SCHEMA = vol.Schema({
|
||||||
DOMAIN: vol.Schema({
|
DOMAIN: vol.Schema({
|
||||||
@ -82,7 +104,6 @@ CONFIG_SCHEMA = vol.Schema({
|
|||||||
})
|
})
|
||||||
}, extra=vol.ALLOW_EXTRA)
|
}, extra=vol.ALLOW_EXTRA)
|
||||||
|
|
||||||
|
|
||||||
RENAME_DEVICE_SCHEMA = vol.Schema({
|
RENAME_DEVICE_SCHEMA = vol.Schema({
|
||||||
vol.Required(ATTR_ENTITY_ID): cv.entity_ids,
|
vol.Required(ATTR_ENTITY_ID): cv.entity_ids,
|
||||||
vol.Required(ATTR_NAME): cv.string
|
vol.Required(ATTR_NAME): cv.string
|
||||||
@ -98,6 +119,36 @@ SET_PAIRING_MODE_SCHEMA = vol.Schema({
|
|||||||
vol.Optional(ATTR_KIDDE_RADIO_CODE): cv.string
|
vol.Optional(ATTR_KIDDE_RADIO_CODE): cv.string
|
||||||
}, extra=vol.ALLOW_EXTRA)
|
}, extra=vol.ALLOW_EXTRA)
|
||||||
|
|
||||||
|
SET_VOLUME_SCHEMA = vol.Schema({
|
||||||
|
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
||||||
|
vol.Required(ATTR_VOLUME): vol.In(VOLUMES)
|
||||||
|
})
|
||||||
|
|
||||||
|
SET_SIREN_TONE_SCHEMA = vol.Schema({
|
||||||
|
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
||||||
|
vol.Required(ATTR_TONE): vol.In(TONES)
|
||||||
|
})
|
||||||
|
|
||||||
|
SET_CHIME_MODE_SCHEMA = vol.Schema({
|
||||||
|
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
||||||
|
vol.Required(ATTR_TONE): vol.In(CHIME_TONES)
|
||||||
|
})
|
||||||
|
|
||||||
|
SET_AUTO_SHUTOFF_SCHEMA = vol.Schema({
|
||||||
|
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
||||||
|
vol.Required(ATTR_AUTO_SHUTOFF): vol.In(AUTO_SHUTOFF_TIMES)
|
||||||
|
})
|
||||||
|
|
||||||
|
SET_STROBE_ENABLED_SCHEMA = vol.Schema({
|
||||||
|
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
||||||
|
vol.Required(ATTR_ENABLED): cv.boolean
|
||||||
|
})
|
||||||
|
|
||||||
|
ENABLED_SIREN_SCHEMA = vol.Schema({
|
||||||
|
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
|
||||||
|
vol.Required(ATTR_ENABLED): cv.boolean
|
||||||
|
})
|
||||||
|
|
||||||
WINK_COMPONENTS = [
|
WINK_COMPONENTS = [
|
||||||
'binary_sensor', 'sensor', 'light', 'switch', 'lock', 'cover', 'climate',
|
'binary_sensor', 'sensor', 'light', 'switch', 'lock', 'cover', 'climate',
|
||||||
'fan', 'alarm_control_panel', 'scene'
|
'fan', 'alarm_control_panel', 'scene'
|
||||||
@ -204,7 +255,7 @@ def setup(hass, config):
|
|||||||
from pubnubsubhandler import PubNubSubscriptionHandler
|
from pubnubsubhandler import PubNubSubscriptionHandler
|
||||||
|
|
||||||
descriptions = load_yaml_config_file(
|
descriptions = load_yaml_config_file(
|
||||||
os.path.join(os.path.dirname(__file__), 'services.yaml')).get(DOMAIN)
|
os.path.join(os.path.dirname(__file__), 'services.yaml'))
|
||||||
|
|
||||||
if hass.data.get(DOMAIN) is None:
|
if hass.data.get(DOMAIN) is None:
|
||||||
hass.data[DOMAIN] = {
|
hass.data[DOMAIN] = {
|
||||||
@ -434,11 +485,110 @@ def setup(hass, config):
|
|||||||
descriptions.get(SERVICE_SET_PAIRING_MODE),
|
descriptions.get(SERVICE_SET_PAIRING_MODE),
|
||||||
schema=SET_PAIRING_MODE_SCHEMA)
|
schema=SET_PAIRING_MODE_SCHEMA)
|
||||||
|
|
||||||
|
def service_handle(service):
|
||||||
|
"""Handler for services."""
|
||||||
|
entity_ids = service.data.get('entity_id')
|
||||||
|
all_sirens = []
|
||||||
|
for switch in hass.data[DOMAIN]['entities']['switch']:
|
||||||
|
if isinstance(switch, WinkSirenDevice):
|
||||||
|
all_sirens.append(switch)
|
||||||
|
sirens_to_set = []
|
||||||
|
if entity_ids is None:
|
||||||
|
sirens_to_set = all_sirens
|
||||||
|
else:
|
||||||
|
for siren in all_sirens:
|
||||||
|
if siren.entity_id in entity_ids:
|
||||||
|
sirens_to_set.append(siren)
|
||||||
|
|
||||||
|
for siren in sirens_to_set:
|
||||||
|
if (service.service != SERVICE_SET_AUTO_SHUTOFF and
|
||||||
|
service.service != SERVICE_ENABLE_SIREN and
|
||||||
|
siren.wink.device_manufacturer() != 'dome'):
|
||||||
|
_LOGGER.error("Service only valid for Dome sirens.")
|
||||||
|
return
|
||||||
|
|
||||||
|
if service.service == SERVICE_ENABLE_SIREN:
|
||||||
|
siren.wink.set_state(service.data.get(ATTR_ENABLED))
|
||||||
|
elif service.service == SERVICE_SET_AUTO_SHUTOFF:
|
||||||
|
siren.wink.set_auto_shutoff(
|
||||||
|
service.data.get(ATTR_AUTO_SHUTOFF))
|
||||||
|
elif service.service == SERVICE_SET_CHIME_VOLUME:
|
||||||
|
siren.wink.set_chime_volume(service.data.get(ATTR_VOLUME))
|
||||||
|
elif service.service == SERVICE_SET_SIREN_VOLUME:
|
||||||
|
siren.wink.set_siren_volume(service.data.get(ATTR_VOLUME))
|
||||||
|
elif service.service == SERVICE_SET_SIREN_TONE:
|
||||||
|
siren.wink.set_siren_sound(service.data.get(ATTR_TONE))
|
||||||
|
elif service.service == SERVICE_ENABLE_CHIME:
|
||||||
|
siren.wink.set_chime(service.data.get(ATTR_TONE))
|
||||||
|
elif service.service == SERVICE_SIREN_STROBE_ENABLED:
|
||||||
|
siren.wink.set_siren_strobe_enabled(
|
||||||
|
service.data.get(ATTR_ENABLED))
|
||||||
|
elif service.service == SERVICE_CHIME_STROBE_ENABLED:
|
||||||
|
siren.wink.set_chime_strobe_enabled(
|
||||||
|
service.data.get(ATTR_ENABLED))
|
||||||
|
|
||||||
# Load components for the devices in Wink that we support
|
# Load components for the devices in Wink that we support
|
||||||
for wink_component in WINK_COMPONENTS:
|
for wink_component in WINK_COMPONENTS:
|
||||||
hass.data[DOMAIN]['entities'][wink_component] = []
|
hass.data[DOMAIN]['entities'][wink_component] = []
|
||||||
discovery.load_platform(hass, wink_component, DOMAIN, {}, config)
|
discovery.load_platform(hass, wink_component, DOMAIN, {}, config)
|
||||||
|
|
||||||
|
component = EntityComponent(_LOGGER, DOMAIN, hass)
|
||||||
|
|
||||||
|
sirens = []
|
||||||
|
has_dome_siren = False
|
||||||
|
for siren in pywink.get_sirens():
|
||||||
|
if siren.device_manufacturer() == "dome":
|
||||||
|
has_dome_siren = True
|
||||||
|
_id = siren.object_id() + siren.name()
|
||||||
|
if _id not in hass.data[DOMAIN]['unique_ids']:
|
||||||
|
sirens.append(WinkSirenDevice(siren, hass))
|
||||||
|
|
||||||
|
if sirens:
|
||||||
|
|
||||||
|
hass.services.register(DOMAIN, SERVICE_SET_AUTO_SHUTOFF,
|
||||||
|
service_handle,
|
||||||
|
descriptions.get(SERVICE_SET_AUTO_SHUTOFF),
|
||||||
|
schema=SET_AUTO_SHUTOFF_SCHEMA)
|
||||||
|
|
||||||
|
hass.services.register(DOMAIN, SERVICE_ENABLE_SIREN,
|
||||||
|
service_handle,
|
||||||
|
descriptions.get(SERVICE_ENABLE_SIREN),
|
||||||
|
schema=ENABLED_SIREN_SCHEMA)
|
||||||
|
|
||||||
|
if has_dome_siren:
|
||||||
|
|
||||||
|
hass.services.register(DOMAIN, SERVICE_SET_SIREN_TONE,
|
||||||
|
service_handle,
|
||||||
|
descriptions.get(SERVICE_SET_SIREN_TONE),
|
||||||
|
schema=SET_SIREN_TONE_SCHEMA)
|
||||||
|
|
||||||
|
hass.services.register(DOMAIN, SERVICE_ENABLE_CHIME,
|
||||||
|
service_handle,
|
||||||
|
descriptions.get(SERVICE_ENABLE_CHIME),
|
||||||
|
schema=SET_CHIME_MODE_SCHEMA)
|
||||||
|
|
||||||
|
hass.services.register(DOMAIN, SERVICE_SET_SIREN_VOLUME,
|
||||||
|
service_handle,
|
||||||
|
descriptions.get(SERVICE_SET_SIREN_VOLUME),
|
||||||
|
schema=SET_VOLUME_SCHEMA)
|
||||||
|
|
||||||
|
hass.services.register(DOMAIN, SERVICE_SET_CHIME_VOLUME,
|
||||||
|
service_handle,
|
||||||
|
descriptions.get(SERVICE_SET_CHIME_VOLUME),
|
||||||
|
schema=SET_VOLUME_SCHEMA)
|
||||||
|
|
||||||
|
hass.services.register(DOMAIN, SERVICE_SIREN_STROBE_ENABLED,
|
||||||
|
service_handle,
|
||||||
|
descriptions.get(SERVICE_SIREN_STROBE_ENABLED),
|
||||||
|
schema=SET_STROBE_ENABLED_SCHEMA)
|
||||||
|
|
||||||
|
hass.services.register(DOMAIN, SERVICE_CHIME_STROBE_ENABLED,
|
||||||
|
service_handle,
|
||||||
|
descriptions.get(SERVICE_CHIME_STROBE_ENABLED),
|
||||||
|
schema=SET_STROBE_ENABLED_SCHEMA)
|
||||||
|
|
||||||
|
component.add_entities(sirens)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@ -594,3 +744,59 @@ class WinkDevice(Entity):
|
|||||||
if hasattr(self.wink, 'tamper_detected'):
|
if hasattr(self.wink, 'tamper_detected'):
|
||||||
return self.wink.tamper_detected()
|
return self.wink.tamper_detected()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class WinkSirenDevice(WinkDevice):
|
||||||
|
"""Representation of a Wink siren device."""
|
||||||
|
|
||||||
|
@asyncio.coroutine
|
||||||
|
def async_added_to_hass(self):
|
||||||
|
"""Callback when entity is added to hass."""
|
||||||
|
self.hass.data[DOMAIN]['entities']['switch'].append(self)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def state(self):
|
||||||
|
"""Return sirens state."""
|
||||||
|
if self.wink.state():
|
||||||
|
return STATE_ON
|
||||||
|
return STATE_OFF
|
||||||
|
|
||||||
|
@property
|
||||||
|
def icon(self):
|
||||||
|
"""Return the icon to use in the frontend, if any."""
|
||||||
|
return "mdi:bell-ring"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_state_attributes(self):
|
||||||
|
"""Return the state attributes."""
|
||||||
|
attributes = super(WinkSirenDevice, self).device_state_attributes
|
||||||
|
|
||||||
|
auto_shutoff = self.wink.auto_shutoff()
|
||||||
|
if auto_shutoff is not None:
|
||||||
|
attributes["auto_shutoff"] = auto_shutoff
|
||||||
|
|
||||||
|
siren_volume = self.wink.siren_volume()
|
||||||
|
if siren_volume is not None:
|
||||||
|
attributes["siren_volume"] = siren_volume
|
||||||
|
|
||||||
|
chime_volume = self.wink.chime_volume()
|
||||||
|
if chime_volume is not None:
|
||||||
|
attributes["chime_volume"] = chime_volume
|
||||||
|
|
||||||
|
strobe_enabled = self.wink.strobe_enabled()
|
||||||
|
if strobe_enabled is not None:
|
||||||
|
attributes["siren_strobe_enabled"] = strobe_enabled
|
||||||
|
|
||||||
|
chime_strobe_enabled = self.wink.chime_strobe_enabled()
|
||||||
|
if chime_strobe_enabled is not None:
|
||||||
|
attributes["chime_strobe_enabled"] = chime_strobe_enabled
|
||||||
|
|
||||||
|
siren_sound = self.wink.siren_sound()
|
||||||
|
if siren_sound is not None:
|
||||||
|
attributes["siren_sound"] = siren_sound
|
||||||
|
|
||||||
|
chime_mode = self.wink.chime_mode()
|
||||||
|
if chime_mode is not None:
|
||||||
|
attributes["chime_mode"] = chime_mode
|
||||||
|
|
||||||
|
return attributes
|
122
homeassistant/components/wink/services.yaml
Normal file
122
homeassistant/components/wink/services.yaml
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
pair_new_device:
|
||||||
|
description: Pair a new device to a Wink Hub.
|
||||||
|
|
||||||
|
fields:
|
||||||
|
hub_name:
|
||||||
|
description: The name of the hub to pair a new device to.
|
||||||
|
example: 'My hub'
|
||||||
|
pairing_mode:
|
||||||
|
description: One of ["zigbee", "zwave", "zwave_exclusion", "zwave_network_rediscovery", "lutron", "bluetooth", "kidde"]
|
||||||
|
example: 'zigbee'
|
||||||
|
kidde_radio_code:
|
||||||
|
description: 'A string of 8 1s and 0s one for each dip switch on the kidde device left --> right = 1 --> 8'
|
||||||
|
example: '10101010'
|
||||||
|
|
||||||
|
rename_wink_device:
|
||||||
|
description: Rename the provided device.
|
||||||
|
|
||||||
|
fields:
|
||||||
|
entity_id:
|
||||||
|
description: The entity_id of the device to rename.
|
||||||
|
example: binary_sensor.front_door_opened
|
||||||
|
name:
|
||||||
|
description: The name to change it to.
|
||||||
|
example: back_door
|
||||||
|
|
||||||
|
delete_wink_device:
|
||||||
|
description: Remove/unpair device from Wink.
|
||||||
|
|
||||||
|
fields:
|
||||||
|
entity_id:
|
||||||
|
description: The entity_id of the device to delete.
|
||||||
|
|
||||||
|
pull_newly_added_devices_from_wink:
|
||||||
|
description: Pull newly pair devices from Wink.
|
||||||
|
|
||||||
|
refresh_state_from_wink:
|
||||||
|
description: Pull the latest states for every device.
|
||||||
|
|
||||||
|
set_siren_volume:
|
||||||
|
description: Set the volume of the siren for a Dome siren/chime.
|
||||||
|
|
||||||
|
fields:
|
||||||
|
entity_id:
|
||||||
|
description: Name(s) of the entities to set
|
||||||
|
example: 'switch.dome_siren'
|
||||||
|
volume:
|
||||||
|
description: Volume level. One of ["low", "medium", "high"]
|
||||||
|
example: "high"
|
||||||
|
|
||||||
|
enable_chime:
|
||||||
|
description: Enable the chime of a Dome siren with the provided sound.
|
||||||
|
|
||||||
|
fields:
|
||||||
|
entity_id:
|
||||||
|
description: Name(s) of the entities to set
|
||||||
|
example: 'switch.dome_siren'
|
||||||
|
tone:
|
||||||
|
description: The tone to use for the chime. One of ["doorbell", "fur_elise", "doorbell_extended", "alert", "william_tell", "rondo_alla_turca", "police_siren", "evacuation", "beep_beep", "beep", "inactive"]
|
||||||
|
example: "doorbell"
|
||||||
|
|
||||||
|
set_siren_tone:
|
||||||
|
description: Set the sound to use when the siren is enabled. (This doesn't enable the siren)
|
||||||
|
|
||||||
|
fields:
|
||||||
|
entity_id:
|
||||||
|
description: Name(s) of the entities to set
|
||||||
|
example: 'switch.dome_siren'
|
||||||
|
tone:
|
||||||
|
description: The tone to use for the chime. One of ["doorbell", "fur_elise", "doorbell_extended", "alert", "william_tell", "rondo_alla_turca", "police_siren", "evacuation", "beep_beep", "beep", "inactive"]
|
||||||
|
example: "alert"
|
||||||
|
|
||||||
|
siren_set_auto_shutoff:
|
||||||
|
description: How long to sound the siren before turning off.
|
||||||
|
|
||||||
|
fields:
|
||||||
|
entity_id:
|
||||||
|
description: Name(s) of the entities to set
|
||||||
|
example: 'switch.dome_siren'
|
||||||
|
auto_shutoff:
|
||||||
|
description: The time in seconds to sound the siren. One of [None, -1, 30, 60, 120] (None and -1 are forever. Use None for gocontrol, and -1 for Dome)
|
||||||
|
example: 60
|
||||||
|
|
||||||
|
set_siren_strobe_enabled:
|
||||||
|
description: Enable or disable the strobe light when the siren is sounding.
|
||||||
|
|
||||||
|
fields:
|
||||||
|
entity_id:
|
||||||
|
description: Name(s) of the entities to set
|
||||||
|
example: 'switch.dome_siren'
|
||||||
|
enabled:
|
||||||
|
description: "True or False"
|
||||||
|
|
||||||
|
set_chime_strobe_enabled:
|
||||||
|
description: Enable or disable the strobe light when the chime is sounding.
|
||||||
|
|
||||||
|
fields:
|
||||||
|
entity_id:
|
||||||
|
description: Name(s) of the entities to set
|
||||||
|
example: 'switch.dome_siren'
|
||||||
|
enabled:
|
||||||
|
description: "True or False"
|
||||||
|
|
||||||
|
enable_siren:
|
||||||
|
description: Enable/disable the siren.
|
||||||
|
|
||||||
|
fields:
|
||||||
|
entity_id:
|
||||||
|
description: Name(s) of the entities to set
|
||||||
|
example: 'switch.dome_siren'
|
||||||
|
enabled:
|
||||||
|
description: "True or False"
|
||||||
|
|
||||||
|
set_chime_volume:
|
||||||
|
description: Set the volume of the chime for a Dome siren/chime.
|
||||||
|
|
||||||
|
fields:
|
||||||
|
entity_id:
|
||||||
|
description: Name(s) of the entities to set
|
||||||
|
example: 'switch.dome_siren'
|
||||||
|
volume:
|
||||||
|
description: Volume level. One of ["low", "medium", "high"]
|
||||||
|
example: "low"
|
Loading…
x
Reference in New Issue
Block a user