Pulled from dev to get up-to-date
This commit is contained in:
commit
cceb79a378
34 files changed
+1194
-176
No files matched your search
@@ -39,7 +39,9 @@ omit =
|
||||
homeassistant/components/device_tracker/aruba.py
|
||||
homeassistant/components/device_tracker/asuswrt.py
|
||||
homeassistant/components/device_tracker/ddwrt.py
|
||||
homeassistant/components/device_tracker/fritz.py
|
||||
homeassistant/components/device_tracker/geofancy.py
|
||||
homeassistant/components/device_tracker/icloud.py
|
||||
homeassistant/components/device_tracker/luci.py
|
||||
homeassistant/components/device_tracker/ubus.py
|
||||
homeassistant/components/device_tracker/netgear.py
|
||||
@@ -84,6 +86,7 @@ omit =
|
||||
homeassistant/components/sensor/command_sensor.py
|
||||
homeassistant/components/sensor/cpuspeed.py
|
||||
homeassistant/components/sensor/dht.py
|
||||
homeassistant/components/sensor/dweet.py
|
||||
homeassistant/components/sensor/efergy.py
|
||||
homeassistant/components/sensor/forecast.py
|
||||
homeassistant/components/sensor/glances.py
|
||||
@@ -97,6 +100,7 @@ omit =
|
||||
homeassistant/components/sensor/temper.py
|
||||
homeassistant/components/sensor/time_date.py
|
||||
homeassistant/components/sensor/transmission.py
|
||||
homeassistant/components/sensor/twitch.py
|
||||
homeassistant/components/sensor/worldclock.py
|
||||
homeassistant/components/switch/arest.py
|
||||
homeassistant/components/switch/command_switch.py
|
||||
|
||||
+1
-2
@@ -17,8 +17,7 @@ For help on building your component, please see the [developer documentation](ht
|
||||
|
||||
After you finish adding support for your device:
|
||||
|
||||
- Add a link to the website of your device/service/component in the "examples" listing of the `README.md` file.
|
||||
- Add any new dependencies to `requirements_all.txt` if needed. There is no ordering right now, so just add it to the end of the file.
|
||||
- Add any new dependencies to `requirements_all.txt` if needed. Use `script/gen_requirements_all.py`.
|
||||
- Update the `.coveragerc` file to exclude your platform if there are no tests available.
|
||||
- Provide some documentation for [home-assistant.io](https://home-assistant.io/). It's OK to just add a docstring with configuration details (sample entry for `configuration.yaml` file and alike) to the file header as a start. Visit the [website documentation](https://home-assistant.io/developers/website/) for further information on contributing to [home-assistant.io](https://github.com/balloob/home-assistant.io).
|
||||
- Make sure all your code passes ``pylint`` and ``flake8`` (PEP8 and some more) validation. To check your repository, run `./script/lint`.
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
"""
|
||||
components.alexa
|
||||
~~~~~~~~~~~~~~~~
|
||||
Component to offer a service end point for an Alexa skill.
|
||||
|
||||
For more details about this component, please refer to the documentation at
|
||||
https://home-assistant.io/components/alexa/
|
||||
"""
|
||||
import enum
|
||||
import logging
|
||||
|
||||
from homeassistant.const import HTTP_OK, HTTP_UNPROCESSABLE_ENTITY
|
||||
from homeassistant.util import template
|
||||
|
||||
DOMAIN = 'alexa'
|
||||
DEPENDENCIES = ['http']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
_CONFIG = {}
|
||||
|
||||
API_ENDPOINT = '/api/alexa'
|
||||
|
||||
CONF_INTENTS = 'intents'
|
||||
CONF_CARD = 'card'
|
||||
CONF_SPEECH = 'speech'
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
""" Activate Alexa component. """
|
||||
_CONFIG.update(config[DOMAIN].get(CONF_INTENTS, {}))
|
||||
|
||||
hass.http.register_path('POST', API_ENDPOINT, _handle_alexa, True)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def _handle_alexa(handler, path_match, data):
|
||||
""" Handle Alexa. """
|
||||
_LOGGER.debug('Received Alexa request: %s', data)
|
||||
|
||||
req = data.get('request')
|
||||
|
||||
if req is None:
|
||||
_LOGGER.error('Received invalid data from Alexa: %s', data)
|
||||
handler.write_json_message(
|
||||
"Invalid value received for port", HTTP_UNPROCESSABLE_ENTITY)
|
||||
return
|
||||
|
||||
req_type = req['type']
|
||||
|
||||
if req_type == 'SessionEndedRequest':
|
||||
handler.send_response(HTTP_OK)
|
||||
handler.end_headers()
|
||||
return
|
||||
|
||||
intent = req.get('intent')
|
||||
response = AlexaResponse(handler.server.hass, intent)
|
||||
|
||||
if req_type == 'LaunchRequest':
|
||||
response.add_speech(
|
||||
SpeechType.plaintext,
|
||||
"Hello, and welcome to the future. How may I help?")
|
||||
handler.write_json(response.as_dict())
|
||||
return
|
||||
|
||||
if req_type != 'IntentRequest':
|
||||
_LOGGER.warning('Received unsupported request: %s', req_type)
|
||||
return
|
||||
|
||||
intent_name = intent['name']
|
||||
config = _CONFIG.get(intent_name)
|
||||
|
||||
if config is None:
|
||||
_LOGGER.warning('Received unknown intent %s', intent_name)
|
||||
response.add_speech(
|
||||
SpeechType.plaintext,
|
||||
"This intent is not yet configured within Home Assistant.")
|
||||
handler.write_json(response.as_dict())
|
||||
return
|
||||
|
||||
speech = config.get(CONF_SPEECH)
|
||||
card = config.get(CONF_CARD)
|
||||
|
||||
# pylint: disable=unsubscriptable-object
|
||||
if speech is not None:
|
||||
response.add_speech(SpeechType[speech['type']], speech['text'])
|
||||
|
||||
if card is not None:
|
||||
response.add_card(CardType[card['type']], card['title'],
|
||||
card['content'])
|
||||
|
||||
handler.write_json(response.as_dict())
|
||||
|
||||
|
||||
class SpeechType(enum.Enum):
|
||||
""" Alexa speech types. """
|
||||
plaintext = "PlainText"
|
||||
ssml = "SSML"
|
||||
|
||||
|
||||
class CardType(enum.Enum):
|
||||
""" Alexa card types. """
|
||||
simple = "Simple"
|
||||
link_account = "LinkAccount"
|
||||
|
||||
|
||||
class AlexaResponse(object):
|
||||
""" Helps generating the response for Alexa. """
|
||||
|
||||
def __init__(self, hass, intent=None):
|
||||
self.hass = hass
|
||||
self.speech = None
|
||||
self.card = None
|
||||
self.reprompt = None
|
||||
self.session_attributes = {}
|
||||
self.should_end_session = True
|
||||
if intent is not None and 'slots' in intent:
|
||||
self.variables = {key: value['value'] for key, value
|
||||
in intent['slots'].items()}
|
||||
else:
|
||||
self.variables = {}
|
||||
|
||||
def add_card(self, card_type, title, content):
|
||||
""" Add a card to the response. """
|
||||
assert self.card is None
|
||||
|
||||
card = {
|
||||
"type": card_type.value
|
||||
}
|
||||
|
||||
if card_type == CardType.link_account:
|
||||
self.card = card
|
||||
return
|
||||
|
||||
card["title"] = self._render(title),
|
||||
card["content"] = self._render(content)
|
||||
self.card = card
|
||||
|
||||
def add_speech(self, speech_type, text):
|
||||
""" Add speech to the response. """
|
||||
assert self.speech is None
|
||||
|
||||
key = 'ssml' if speech_type == SpeechType.ssml else 'text'
|
||||
|
||||
self.speech = {
|
||||
'type': speech_type.value,
|
||||
key: self._render(text)
|
||||
}
|
||||
|
||||
def add_reprompt(self, speech_type, text):
|
||||
""" Add repromopt if user does not answer. """
|
||||
assert self.reprompt is None
|
||||
|
||||
key = 'ssml' if speech_type == SpeechType.ssml else 'text'
|
||||
|
||||
self.reprompt = {
|
||||
'type': speech_type.value,
|
||||
key: self._render(text)
|
||||
}
|
||||
|
||||
def as_dict(self):
|
||||
""" Returns response in an Alexa valid dict. """
|
||||
response = {
|
||||
'shouldEndSession': self.should_end_session
|
||||
}
|
||||
|
||||
if self.card is not None:
|
||||
response['card'] = self.card
|
||||
|
||||
if self.speech is not None:
|
||||
response['outputSpeech'] = self.speech
|
||||
|
||||
if self.reprompt is not None:
|
||||
response['reprompt'] = {
|
||||
'outputSpeech': self.reprompt
|
||||
}
|
||||
|
||||
return {
|
||||
'version': '1.0',
|
||||
'sessionAttributes': self.session_attributes,
|
||||
'response': response,
|
||||
}
|
||||
|
||||
def _render(self, template_string):
|
||||
""" Render a response, adding data from intent if available. """
|
||||
return template.render(self.hass, template_string, self.variables)
|
||||
@@ -125,22 +125,23 @@ def _handle_get_api_stream(handler, path_match, data):
|
||||
try:
|
||||
wfile.write(msg.encode("UTF-8"))
|
||||
wfile.flush()
|
||||
handler.server.sessions.extend_validation(session_id)
|
||||
except IOError:
|
||||
except (IOError, ValueError):
|
||||
# IOError: socket errors
|
||||
# ValueError: raised when 'I/O operation on closed file'
|
||||
block.set()
|
||||
|
||||
def forward_events(event):
|
||||
""" Forwards events to the open request. """
|
||||
nonlocal gracefully_closed
|
||||
|
||||
if block.is_set() or event.event_type == EVENT_TIME_CHANGED or \
|
||||
restrict and event.event_type not in restrict:
|
||||
if block.is_set() or event.event_type == EVENT_TIME_CHANGED:
|
||||
return
|
||||
elif event.event_type == EVENT_HOMEASSISTANT_STOP:
|
||||
gracefully_closed = True
|
||||
block.set()
|
||||
return
|
||||
|
||||
handler.server.sessions.extend_validation(session_id)
|
||||
write_message(json.dumps(event, cls=rem.JSONEncoder))
|
||||
|
||||
handler.send_response(HTTP_OK)
|
||||
@@ -148,7 +149,11 @@ def _handle_get_api_stream(handler, path_match, data):
|
||||
session_id = handler.set_session_cookie_header()
|
||||
handler.end_headers()
|
||||
|
||||
hass.bus.listen(MATCH_ALL, forward_events)
|
||||
if restrict:
|
||||
for event in restrict:
|
||||
hass.bus.listen(event, forward_events)
|
||||
else:
|
||||
hass.bus.listen(MATCH_ALL, forward_events)
|
||||
|
||||
while True:
|
||||
write_message(STREAM_PING_PAYLOAD)
|
||||
@@ -162,7 +167,11 @@ def _handle_get_api_stream(handler, path_match, data):
|
||||
_LOGGER.info("Found broken event stream to %s, cleaning up",
|
||||
handler.client_address[0])
|
||||
|
||||
hass.bus.remove_listener(MATCH_ALL, forward_events)
|
||||
if restrict:
|
||||
for event in restrict:
|
||||
hass.bus.remove_listener(event, forward_events)
|
||||
else:
|
||||
hass.bus.remove_listener(MATCH_ALL, forward_events)
|
||||
|
||||
|
||||
def _handle_get_api_config(handler, path_match, data):
|
||||
|
||||
@@ -8,13 +8,14 @@ at https://home-assistant.io/components/automation/#numeric-state-trigger
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.const import CONF_VALUE_TEMPLATE
|
||||
from homeassistant.helpers.event import track_state_change
|
||||
from homeassistant.util import template
|
||||
|
||||
|
||||
CONF_ENTITY_ID = "entity_id"
|
||||
CONF_BELOW = "below"
|
||||
CONF_ABOVE = "above"
|
||||
CONF_ATTRIBUTE = "attribute"
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -29,7 +30,7 @@ def trigger(hass, config, action):
|
||||
|
||||
below = config.get(CONF_BELOW)
|
||||
above = config.get(CONF_ABOVE)
|
||||
attribute = config.get(CONF_ATTRIBUTE)
|
||||
value_template = config.get(CONF_VALUE_TEMPLATE)
|
||||
|
||||
if below is None and above is None:
|
||||
_LOGGER.error("Missing configuration key."
|
||||
@@ -37,13 +38,20 @@ def trigger(hass, config, action):
|
||||
CONF_BELOW, CONF_ABOVE)
|
||||
return False
|
||||
|
||||
if value_template is not None:
|
||||
renderer = lambda value: template.render(hass,
|
||||
value_template,
|
||||
{'state': value})
|
||||
else:
|
||||
renderer = lambda value: value.state
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def state_automation_listener(entity, from_s, to_s):
|
||||
""" Listens for state changes and calls action. """
|
||||
|
||||
# Fire action if we go from outside range into range
|
||||
if _in_range(to_s, above, below, attribute) and \
|
||||
(from_s is None or not _in_range(from_s, above, below, attribute)):
|
||||
if _in_range(above, below, renderer(to_s)) and \
|
||||
(from_s is None or not _in_range(above, below, renderer(from_s))):
|
||||
action()
|
||||
|
||||
track_state_change(
|
||||
@@ -63,7 +71,7 @@ def if_action(hass, config):
|
||||
|
||||
below = config.get(CONF_BELOW)
|
||||
above = config.get(CONF_ABOVE)
|
||||
attribute = config.get(CONF_ATTRIBUTE)
|
||||
value_template = config.get(CONF_VALUE_TEMPLATE)
|
||||
|
||||
if below is None and above is None:
|
||||
_LOGGER.error("Missing configuration key."
|
||||
@@ -71,18 +79,23 @@ def if_action(hass, config):
|
||||
CONF_BELOW, CONF_ABOVE)
|
||||
return None
|
||||
|
||||
if value_template is not None:
|
||||
renderer = lambda value: template.render(hass,
|
||||
value_template,
|
||||
{'state': value})
|
||||
else:
|
||||
renderer = lambda value: value.state
|
||||
|
||||
def if_numeric_state():
|
||||
""" Test numeric state condition. """
|
||||
state = hass.states.get(entity_id)
|
||||
return state is not None and _in_range(state, above, below, attribute)
|
||||
return state is not None and _in_range(above, below, renderer(state))
|
||||
|
||||
return if_numeric_state
|
||||
|
||||
|
||||
def _in_range(state, range_start, range_end, attribute):
|
||||
def _in_range(range_start, range_end, value):
|
||||
""" Checks if value is inside the range """
|
||||
value = (state.state if attribute is None
|
||||
else state.attributes.get(attribute))
|
||||
try:
|
||||
value = float(value)
|
||||
except ValueError:
|
||||
|
||||
@@ -7,7 +7,10 @@ For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/binary_sensor.mqtt/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.const import CONF_VALUE_TEMPLATE
|
||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||
from homeassistant.util import template
|
||||
import homeassistant.components.mqtt as mqtt
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@@ -34,13 +37,15 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
config.get('state_topic', None),
|
||||
config.get('qos', DEFAULT_QOS),
|
||||
config.get('payload_on', DEFAULT_PAYLOAD_ON),
|
||||
config.get('payload_off', DEFAULT_PAYLOAD_OFF))])
|
||||
config.get('payload_off', DEFAULT_PAYLOAD_OFF),
|
||||
config.get(CONF_VALUE_TEMPLATE))])
|
||||
|
||||
|
||||
# pylint: disable=too-many-arguments, too-many-instance-attributes
|
||||
class MqttBinarySensor(BinarySensorDevice):
|
||||
""" Represents a binary sensor that is updated by MQTT. """
|
||||
def __init__(self, hass, name, state_topic, qos, payload_on, payload_off):
|
||||
def __init__(self, hass, name, state_topic, qos, payload_on, payload_off,
|
||||
value_template):
|
||||
self._hass = hass
|
||||
self._name = name
|
||||
self._state = False
|
||||
@@ -51,6 +56,9 @@ class MqttBinarySensor(BinarySensorDevice):
|
||||
|
||||
def message_received(topic, payload, qos):
|
||||
""" A new MQTT message has been received. """
|
||||
if value_template is not None:
|
||||
payload = template.render_with_possible_json_value(
|
||||
hass, value_template, payload)
|
||||
if payload == self._payload_on:
|
||||
self._state = True
|
||||
self.update_ha_state()
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
"""
|
||||
homeassistant.components.device_tracker.fritz
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Device tracker platform that supports scanning a FRITZ!Box router for device
|
||||
presence.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/device_tracker.fritz/
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
|
||||
from homeassistant.const import CONF_HOST, CONF_USERNAME, CONF_PASSWORD
|
||||
from homeassistant.helpers import validate_config
|
||||
from homeassistant.util import Throttle
|
||||
from homeassistant.components.device_tracker import DOMAIN
|
||||
|
||||
# Return cached results if last scan was less then this time ago
|
||||
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=5)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# noinspection PyUnusedLocal
|
||||
def get_scanner(hass, config):
|
||||
""" Validates config and returns FritzBoxScanner. """
|
||||
if not validate_config(config,
|
||||
{DOMAIN: []},
|
||||
_LOGGER):
|
||||
return None
|
||||
|
||||
scanner = FritzBoxScanner(config[DOMAIN])
|
||||
return scanner if scanner.success_init else None
|
||||
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
class FritzBoxScanner(object):
|
||||
"""
|
||||
This class queries a FRITZ!Box router. It is using the
|
||||
fritzconnection library for communication with the router.
|
||||
|
||||
The API description can be found under:
|
||||
https://pypi.python.org/pypi/fritzconnection/0.4.6
|
||||
|
||||
This scanner retrieves the list of known hosts and checks their
|
||||
corresponding states (on, or off).
|
||||
|
||||
Due to a bug of the fritzbox api (router side) it is not possible
|
||||
to track more than 16 hosts.
|
||||
"""
|
||||
def __init__(self, config):
|
||||
self.last_results = []
|
||||
self.host = '169.254.1.1' # This IP is valid for all fritzboxes
|
||||
self.username = 'admin'
|
||||
self.password = ''
|
||||
self.success_init = True
|
||||
|
||||
# Try to import the fritzconnection library
|
||||
try:
|
||||
# noinspection PyPackageRequirements,PyUnresolvedReferences
|
||||
import fritzconnection as fc
|
||||
except ImportError:
|
||||
_LOGGER.exception("""Failed to import Python library
|
||||
fritzconnection. Please run
|
||||
<home-assistant>/setup to install it.""")
|
||||
self.success_init = False
|
||||
return
|
||||
|
||||
# Check for user specific configuration
|
||||
if CONF_HOST in config.keys():
|
||||
self.host = config[CONF_HOST]
|
||||
if CONF_USERNAME in config.keys():
|
||||
self.username = config[CONF_USERNAME]
|
||||
if CONF_PASSWORD in config.keys():
|
||||
self.password = config[CONF_PASSWORD]
|
||||
|
||||
# Establish a connection to the FRITZ!Box
|
||||
try:
|
||||
self.fritz_box = fc.FritzHosts(address=self.host,
|
||||
user=self.username,
|
||||
password=self.password)
|
||||
except (ValueError, TypeError):
|
||||
self.fritz_box = None
|
||||
|
||||
# At this point it is difficult to tell if a connection is established.
|
||||
# So just check for null objects ...
|
||||
if self.fritz_box is None or not self.fritz_box.modelname:
|
||||
self.success_init = False
|
||||
|
||||
if self.success_init:
|
||||
_LOGGER.info("Successfully connected to %s",
|
||||
self.fritz_box.modelname)
|
||||
self._update_info()
|
||||
else:
|
||||
_LOGGER.error("Failed to establish connection to FRITZ!Box "
|
||||
"with IP: %s", self.host)
|
||||
|
||||
def scan_devices(self):
|
||||
""" Scan for new devices and return a list of found device ids. """
|
||||
self._update_info()
|
||||
active_hosts = []
|
||||
for known_host in self.last_results:
|
||||
if known_host["status"] == "1":
|
||||
active_hosts.append(known_host["mac"])
|
||||
return active_hosts
|
||||
|
||||
def get_device_name(self, mac):
|
||||
""" Returns the name of the given device or None if is not known. """
|
||||
ret = self.fritz_box.get_specific_host_entry(mac)["NewHostName"]
|
||||
if ret == {}:
|
||||
return None
|
||||
return ret
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
||||
def _update_info(self):
|
||||
""" Retrieves latest information from the FRITZ!Box. """
|
||||
if not self.success_init:
|
||||
return False
|
||||
|
||||
_LOGGER.info("Scanning")
|
||||
self.last_results = self.fritz_box.get_hosts_info()
|
||||
return True
|
||||
@@ -0,0 +1,85 @@
|
||||
"""
|
||||
homeassistant.components.device_tracker.icloud
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Device tracker platform that supports scanning iCloud devices.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/device_tracker.icloud/
|
||||
"""
|
||||
import logging
|
||||
|
||||
import re
|
||||
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD
|
||||
from homeassistant.helpers.event import track_utc_time_change
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
REQUIREMENTS = ['pyicloud==0.7.2']
|
||||
|
||||
CONF_INTERVAL = 'interval'
|
||||
DEFAULT_INTERVAL = 8
|
||||
|
||||
|
||||
def setup_scanner(hass, config, see):
|
||||
""" Set up the iCloud Scanner. """
|
||||
from pyicloud import PyiCloudService
|
||||
from pyicloud.exceptions import PyiCloudFailedLoginException
|
||||
from pyicloud.exceptions import PyiCloudNoDevicesException
|
||||
|
||||
# Get the username and password from the configuration
|
||||
username = config.get(CONF_USERNAME)
|
||||
password = config.get(CONF_PASSWORD)
|
||||
|
||||
if username is None or password is None:
|
||||
_LOGGER.error('Must specify a username and password')
|
||||
return
|
||||
|
||||
try:
|
||||
_LOGGER.info('Logging into iCloud Account')
|
||||
# Attempt the login to iCloud
|
||||
api = PyiCloudService(username,
|
||||
password,
|
||||
verify=True)
|
||||
except PyiCloudFailedLoginException as error:
|
||||
_LOGGER.exception('Error logging into iCloud Service: %s', error)
|
||||
return
|
||||
|
||||
def keep_alive(now):
|
||||
""" Keeps authenticating iCloud connection. """
|
||||
api.authenticate()
|
||||
_LOGGER.info("Authenticate against iCloud")
|
||||
|
||||
track_utc_time_change(hass, keep_alive, second=0)
|
||||
|
||||
def update_icloud(now):
|
||||
""" Authenticate against iCloud and scan for devices. """
|
||||
try:
|
||||
# The session timeouts if we are not using it so we
|
||||
# have to re-authenticate. This will send an email.
|
||||
api.authenticate()
|
||||
# Loop through every device registered with the iCloud account
|
||||
for device in api.devices:
|
||||
status = device.status()
|
||||
location = device.location()
|
||||
# If the device has a location add it. If not do nothing
|
||||
if location:
|
||||
see(
|
||||
dev_id=re.sub(r"(\s|\W|')",
|
||||
'',
|
||||
status['name']),
|
||||
host_name=status['name'],
|
||||
gps=(location['latitude'], location['longitude']),
|
||||
battery=status['batteryLevel']*100,
|
||||
gps_accuracy=location['horizontalAccuracy']
|
||||
)
|
||||
else:
|
||||
# No location found for the device so continue
|
||||
continue
|
||||
except PyiCloudNoDevicesException:
|
||||
_LOGGER.info('No iCloud Devices found!')
|
||||
|
||||
track_utc_time_change(
|
||||
hass, update_icloud,
|
||||
minute=range(0, 60, config.get(CONF_INTERVAL, DEFAULT_INTERVAL)),
|
||||
second=0
|
||||
)
|
||||
@@ -11,7 +11,6 @@ import logging
|
||||
from . import version, mdi_version
|
||||
import homeassistant.util as util
|
||||
from homeassistant.const import URL_ROOT, HTTP_OK
|
||||
from homeassistant.config import get_default_config_dir
|
||||
|
||||
DOMAIN = 'frontend'
|
||||
DEPENDENCIES = ['api']
|
||||
@@ -109,8 +108,6 @@ def _handle_get_local(handler, path_match, data):
|
||||
"""
|
||||
req_file = util.sanitize_path(path_match.group('file'))
|
||||
|
||||
path = os.path.join(get_default_config_dir(), 'www', req_file)
|
||||
if not os.path.isfile(path):
|
||||
return False
|
||||
path = handler.server.hass.config.path('www', req_file)
|
||||
|
||||
handler.write_file(path)
|
||||
@@ -1,2 +1,2 @@
|
||||
""" DO NOT MODIFY. Auto-generated by build_frontend script """
|
||||
VERSION = "aac488c33cd4291cd0924e60a55bd309"
|
||||
VERSION = "0d8516cd9a13ee2ae3f27c702777e028"
|
||||
@@ -3775,6 +3775,7 @@ case"touchend":return this.addPointerListenerEnd(t,e,i,n);case"touchmove":return
|
||||
|
||||
.column {
|
||||
max-width: 500px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.zone-card {
|
||||
@@ -3790,6 +3791,12 @@ case"touchend":return this.addPointerListenerEnd(t,e,i,n);case"touchmove":return
|
||||
.zone-card {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 599px) {
|
||||
.column {
|
||||
max-width: 600px;
|
||||
}
|
||||
}</style><template><div class="main"><template is="dom-if" if="[[cards._badges.length]]"><div class="badges"><template is="dom-if" if="[[cards._demo]]"><ha-demo-badge></ha-demo-badge></template><ha-badges-card states="[[cards._badges]]"></ha-badges-card></div></template><template is="dom-if" if="[[!cards._badges.length]]"><div class="no-badges"></div></template><div class="horizontal layout"><template is="dom-repeat" items="[[cards._columns]]" as="column"><template is="dom-if" if="[[computeShouldRenderColumn(index, column)]]"><div class="column flex-1"><template is="dom-if" if="[[computeShowIntroduction(index, showIntroduction, cards)]]"><div class="zone-card"><ha-introduction-card show-hide-instruction="[[computeShowHideInstruction(states, cards)]]"></ha-introduction-card></div></template><template is="dom-repeat" items="[[column]]" as="domain"><div class="zone-card"><ha-domain-card domain="[[domain]]" states="[[computeStatesOfCard(cards, domain)]]" group-entity="[[computeGroupEntityOfCard(cards, domain)]]"></ha-domain-card></div></template></div></template></template></div></div></template></dom-module><dom-module id="partial-zone" assetpath="layouts/"><style>:host {
|
||||
display: block;
|
||||
background-color: #E5E5E5;
|
||||
@@ -6080,12 +6087,11 @@ case"touchend":return this.addPointerListenerEnd(t,e,i,n);case"touchmove":return
|
||||
font-weight: 300;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
text-rendering: optimizeLegibility;
|
||||
}</style><template><template is="dom-if" if="[[!loaded]]"><login-form force-show-loading="[[computeForceShowLoading(dataLoaded, iconsLoaded)]]"></login-form></template><template is="dom-if" if="[[loaded]]"><home-assistant-main></home-assistant-main></template></template></dom-module><script>!function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),o=r(i),u=n(2),a=n(4),s=r(a),c=n(42),l=r(c);n(97),n(96),e["default"]=new o["default"]({is:"home-assistant",hostAttributes:{auth:null,icons:null},behaviors:[s["default"]],properties:{auth:{type:String},icons:{type:String},dataLoaded:{type:Boolean,bindNuclear:u.syncGetters.isDataLoaded},iconsLoaded:{type:Boolean,value:!1},loaded:{type:Boolean,computed:"computeLoaded(dataLoaded, iconsLoaded)"}},computeLoaded:function(t,e){return t&&e},computeForceShowLoading:function(t,e){return t&&!e},loadIcons:function(){var t=this,e=function(){return t.iconsLoaded=!0};this.importHref("/static/mdi-"+this.icons+".html",e,function(){return t.importHref("/static/mdi.html",e,e)})},created:function(){this.registerServiceWorker()},attached:function(){var t=document.getElementById("init");t.parentElement.removeChild(t)},ready:function(){var t=this;u.reactor.batch(function(){t.auth?(0,l["default"])(t.auth,!1):u.localStoragePreferences.authToken&&(0,l["default"])(u.localStoragePreferences.authToken,!0),u.navigationActions.showSidebar(u.localStoragePreferences.showSidebar)}),(0,u.startLocalStoragePreferencesSync)(),this.loadIcons()},registerServiceWorker:function(){"serviceWorker"in navigator&&navigator.serviceWorker.register("./service_worker.js").then(function(t){console.log("Service Worker registration succeeded.")})["catch"](function(t){console.log("Service Worker registration failed: "+t)})}}),t.exports=e["default"]},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=window.Polymer,t.exports=e["default"]},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(64),o=r(i);e["default"]=new o["default"],t.exports=e["default"]},function(t,e,n){"use strict";!function(e,n){t.exports=n()}(void 0,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0}),n(1);var i=n(2),o=r(i),u=n(6),a=r(u),s=n(3),c=r(s),l=n(5),f=n(11),d=n(10),p=n(7),h=r(p);e["default"]={Reactor:a["default"],Store:o["default"],Immutable:c["default"],isKeyPath:f.isKeyPath,isGetter:d.isGetter,toJS:l.toJS,toImmutable:l.toImmutable,isImmutable:l.isImmutable,createReactMixin:h["default"]},t.exports=e["default"]},function(t,e){try{window.console&&console.log||(console={log:function(){},debug:function(){},info:function(){},warn:function(){},error:function(){}})}catch(n){}},function(t,e,n){function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t){return t instanceof c}Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();e.isStore=i;var u=n(3),a=n(4),s=n(5),c=function(){function t(e){r(this,t),this.__handlers=(0,u.Map)({}),e&&(0,a.extend)(this,e),this.initialize()}return o(t,[{key:"initialize",value:function(){}},{key:"getInitialState",value:function(){return(0,u.Map)()}},{key:"handle",value:function(t,e,n){var r=this.__handlers.get(e);return"function"==typeof r?r.call(this,t,n,e):t}},{key:"handleReset",value:function(t){return this.getInitialState()}},{key:"on",value:function(t,e){this.__handlers=this.__handlers.set(t,e)}},{key:"serialize",value:function(t){return(0,s.toJS)(t)}},{key:"deserialize",value:function(t){return(0,s.toImmutable)(t)}}]),t}();e["default"]=(0,a.toFactory)(c)},function(t,e,n){!function(e,n){t.exports=n()}(this,function(){function t(t,e){e&&(t.prototype=Object.create(e.prototype)),t.prototype.constructor=t}function e(t){return t.value=!1,t}function n(t){t&&(t.value=!0)}function r(){}function i(t,e){e=e||0;for(var n=Math.max(0,t.length-e),r=new Array(n),i=0;n>i;i++)r[i]=t[i+e];return r}function o(t){return void 0===t.size&&(t.size=t.__iterate(a)),t.size}function u(t,e){if("number"!=typeof e){var n=+e;if(""+n!==e)return NaN;e=n}return 0>e?o(t)+e:e}function a(){return!0}function s(t,e,n){return(0===t||void 0!==n&&-n>=t)&&(void 0===e||void 0!==n&&e>=n)}funcLine truncated
|
||||
var xn=16,Ln=255,Nn=0,Rn={};t(st,D),st.prototype.get=function(t,e){return this._iter.get(t,e)},st.prototype.has=function(t){return this._iter.has(t)},st.prototype.valueSeq=function(){return this._iter.valueSeq()},st.prototype.reverse=function(){var t=this,e=ht(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},st.prototype.map=function(t,e){var n=this,r=pt(this,t,e);return this._useKeys||(r.valueSeq=function(){return n._iter.toSeq().map(t,e)}),r},st.prototype.__iterate=function(t,e){var n,r=this;return this._iter.__iterate(this._useKeys?function(e,n){return t(e,n,r)}:(n=e?Ct(this):0,function(i){return t(i,e?--n:n++,r)}),e)},st.prototype.__iterator=function(t,e){if(this._useKeys)return this._iter.__iterator(t,e);var n=this._iter.__iterator(bn,e),r=e?Ct(this):0;return new O(function(){var i=n.next();return i.done?i:S(t,e?--r:r++,i.value,i)})},st.prototype[mn]=!0,t(ct,C),ct.prototype.includes=function(t){return this._iter.includes(t)},ct.prototype.__iterate=function(t,e){var n=this,r=0;return this._iter.__iterate(function(e){return t(e,r++,n)},e)},ct.prototype.__iterator=function(t,e){var n=this._iter.__iterator(bn,e),r=0;return new O(function(){var e=n.next();return e.done?e:S(t,r++,e.value,e)})},t(lt,A),lt.prototype.has=function(t){return this._iter.includes(t)},lt.prototype.__iterate=function(t,e){var n=this;return this._iter.__iterate(function(e){return t(e,e,n)},e)},lt.prototype.__iterator=function(t,e){var n=this._iter.__iterator(bn,e);return new O(function(){var e=n.next();return e.done?e:S(t,e.value,e.value,e)})},t(ft,D),ft.prototype.entrySeq=function(){return this._iter.toSeq()},ft.prototype.__iterate=function(t,e){var n=this;return this._iter.__iterate(function(e){if(e){Dt(e);var r=_(e);return t(r?e.get(1):e[1],r?e.get(0):e[0],n)}},e)},ft.prototype.__iterator=function(t,e){var n=this._iter.__iterator(bn,e);return new O(function(){for(;;){var e=n.next();if(e.done)return e;var r=e.value;if(r){Dt(r);var i=_(r);return S(t,i?r.get(0):r[0],i?r.get(1):r[1],e)}}})},ct.prototype.cacheResult=st.prototype.cacheResult=lt.prototype.cacheResult=ft.prototype.cacheResult=xt,t(Rt,q),Rt.prototype.toString=function(){return this.__toString("Map {","}")},Rt.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},Rt.prototype.set=function(t,e){return Jt(this,t,e)},Rt.prototype.setIn=function(t,e){return this.updateIn(t,dn,function(){return e})},Rt.prototype.remove=function(t){return Jt(this,t,dn)},Rt.prototype.deleteIn=function(t){return this.updateIn(t,function(){return dn})},Rt.prototype.update=function(t,e,n){return 1===arguments.length?t(this):this.updateIn([t],e,n)},Rt.prototype.updateIn=function(t,e,n){n||(n=e,e=void 0);var r=oe(this,Nt(t),e,n);return r===dn?void 0:r},Rt.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Kt()},Rt.prototype.merge=function(){return ne(this,void 0,arguments)},Rt.prototype.mergeWith=function(t){var e=an.call(arguments,1);return ne(this,t,e)},Rt.prototype.mergeIn=function(t){var e=an.call(arguments,1);return this.updateIn(t,Kt(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},Rt.prototype.mergeDeep=function(){return ne(this,re(void 0),arguments)},Rt.prototype.mergeDeepWith=function(t){var e=an.call(arguments,1);return ne(this,re(t),e)},Rt.prototype.mergeDeepIn=function(t){var e=an.call(arguments,1);return this.updateIn(t,Kt(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},Rt.prototype.sort=function(t){return we(Tt(this,t))},Rt.prototype.sortBy=function(t,e){return we(Tt(this,e,t))},Rt.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},Rt.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new r)},Rt.prototype.asImmutable=function(){return this.__ensureOwner()},Rt.prototype.wasAltered=function(){return this.__altered},Rt.prototype.__iterator=function(t,e){return new Bt(this,t,e)},Rt.prototype.__iterate=function(t,e){var n=this,r=0;return this._root&&this._root.iterate(function(e){return r++,t(e[1],e[0],n)},e),r},Rt.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Wt(this.size,this._root,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},Rt.isMap=zt;var zn="@@__IMMUTABLE_MAP__@@",Hn=Rt.prototype;Hn[zn]=!0,Hn[sn]=Hn.remove,Hn.removeIn=Hn.deleteIn,Ht.prototype.get=function(t,e,n,r){for(var i=this.entries,o=0,u=i.length;u>o;o++)if(J(n,i[o][0]))return i[o][1];return r},Ht.prototype.update=function(t,e,r,o,u,a,s){for(var c=u===dn,l=this.entries,f=0,d=l.length;d>f&&!J(o,l[f][0]);f++);var p=d>f;if(p?l[f][1]===u:c)return this;if(n(s),(c||!p)&&n(a),!c||1!==l.length){if(!p&&!c&&l.length>=Gn)return Qt(t,l,o,u);var h=t&&t===this.ownerID,v=h?l:i(l);return p?c?f===d-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),h?(this.entries=v,this):new Ht(t,v)}},Yt.prLine truncated
|
||||
}},{key:"dispatch",value:function(t,e){if(0===this.__batchDepth){if(this.__isDispatching)throw this.__isDispatching=!1,new Error("Dispatch may not be called while a dispatch is in progress");this.__isDispatching=!0}try{this.reactorState=d["default"].dispatch(this.reactorState,t,e)}catch(n){throw this.__isDispatching=!1,n}try{this.__notify()}finally{this.__isDispatching=!1}}},{key:"batch",value:function(t){this.batchStart(),t(),this.batchEnd()}},{key:"registerStore",value:function(t,e){console.warn("Deprecation warning: `registerStore` will no longer be supported in 1.1, use `registerStores` instead"),this.registerStores(i({},t,e))}},{key:"registerStores",value:function(t){this.reactorState=d["default"].registerStores(this.reactorState,t),this.__notify()}},{key:"serialize",value:function(){return d["default"].serialize(this.reactorState)}},{key:"loadState",value:function(t){this.reactorState=d["default"].loadState(this.reactorState,t),this.__notify()}},{key:"reset",value:function(){var t=d["default"].reset(this.reactorState);this.reactorState=t,this.prevReactorState=t,this.observerState=new y.ObserverState}},{key:"__notify",value:function(){var t=this;if(!(this.__batchDepth>0)){var e=this.reactorState.get("dirtyStores");if(0!==e.size){var n=s["default"].Set().withMutations(function(n){n.union(t.observerState.get("any")),e.forEach(function(e){var r=t.observerState.getIn(["stores",e]);r&&n.union(r)})});n.forEach(function(e){var n=t.observerState.getIn(["observersMap",e]);if(n){var r=n.get("getter"),i=n.get("handler"),o=d["default"].evaluate(t.prevReactorState,r),u=d["default"].evaluate(t.reactorState,r);t.prevReactorState=o.reactorState,t.reactorState=u.reactorState;var a=o.result,c=u.result;s["default"].is(a,c)||i.call(null,c)}});var r=d["default"].resetDirtyStores(this.reactorState);this.prevReactorState=r,this.reactorState=r}}}},{key:"batchStart",value:function(){this.__batchDepth++}},{key:"batchEnd",value:function(){if(this.__batchDepth--,this.__batchDepth<=0){this.__isDispatching=!0;try{this.__notify()}catch(t){throw this.__isDispatching=!1,t}this.__isDispatching=!1}}}]),t}();e["default"]=(0,_.toFactory)(m),t.exports=e["default"]},function(t,e,n){function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i(t,e){var n={};return(0,o.each)(e,function(e,r){n[r]=t.evaluate(e)}),n}Object.defineProperty(e,"__esModule",{value:!0});var o=n(4);e["default"]=function(t){return{getInitialState:function(){return i(t,this.getDataBindings())},componentDidMount:function(){var e=this;this.__unwatchFns=[],(0,o.each)(this.getDataBindings(),function(n,i){var o=t.observe(n,function(t){e.setState(r({},i,t))});e.__unwatchFns.push(o)})},componentWillUnmount:function(){for(;this.__unwatchFns.length;)this.__unwatchFns.shift()()}}},t.exports=e["default"]},function(t,e,n){function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){return new b({result:t,reactorState:e})}function o(t){return t}function u(t,e){var n=o(e);return t.getIn(["cache",n])}function a(t,e){var n=u(t,e);if(!n)return!1;var r=n.get("storeStates");return 0===r.size?!1:r.every(function(e,n){return t.getIn(["storeStates",n])===e})}function s(t,e,n){var r=o(e),i=t.get("dispatchId"),u=(0,y.getStoreDeps)(e),a=(0,_.toImmutable)({}).withMutations(function(e){u.forEach(function(n){var r=t.getIn(["storeStates",n]);e.set(n,r)})});return t.setIn(["cache",r],p["default"].Map({value:n,storeStates:a,dispatchId:i}))}function c(t,e){var n=o(e);return t.getIn(["cache",n,"value"])}function l(t){return t.update("dispatchId",function(t){return t+1})}function f(t,e){return t.withMutations(function(t){e.forEach(function(e){var n=t.has(e)?t.get(e)+1:1;t.set(e,n)})})}var d=n(3),p=r(d),h=n(9),v=r(h),_=n(5),y=n(10),m=n(11),g=n(4),b=p["default"].Record({result:null,reactorState:null});e.registerStores=function(t,e){var n=t.get("debug");return t.withMutations(function(t){(0,g.each)(e,function(e,r){t.getIn(["stores",r])&&console.warn("Store already defined for id = "+r);var i=e.getInitialState();if(n&&!(0,_.isImmutableValue)(i))throw new Error("Store getInitialState() must return an immutable value, did you forget to call toImmutable");t.update("stores",function(t){return t.set(r,e)}).update("state",function(t){return t.set(r,i)}).update("dirtyStores",function(t){return t.add(r)}).update("storeStates",function(t){return f(t,[r])})}),l(t)})},e.dispatch=function(t,e,n){var r=t.get("state"),i=t.get("debug"),o=t.get("dirtyStores"),u=r.withMutations(function(r){i&&v["default"].dispatchStart(e,n),t.get("stores").forEach(function(t,u){var a=r.get(u),s=void 0;try{s=t.handle(a,e,n)}catch(c){throw v["default"].dispatchError(c.message),c}if(i&&void 0===s){var l="Store handler must return a value, did you forget a return statement";throw v["default"].dispatchError(l),new Error(l)}r.set(u,s),a!==s&&(o=o.add(u)),i&&v["default"].storeHandled(u,a,s)}),i&&v["default"].dispatchEnd(r)}),a=t.set("state",u).set("dirtyStores",o).update(Line truncated
|
||||
return 1970>t&&e.setUTCFullYear(t),e}function at(t){return st(t)?366:365}function st(t){return t%4===0&&t%100!==0||t%400===0}function ct(){return st(this.year())}function lt(t,e,n){var r,i=n-e,o=n-t.day();return o>i&&(o-=7),i-7>o&&(o+=7),r=Dt(t).add(o,"d"),{week:Math.ceil(r.dayOfYear()/7),year:r.year()}}function ft(t){return lt(t,this._week.dow,this._week.doy).week}function dt(){return this._week.dow}function pt(){return this._week.doy}function ht(t){var e=this.localeData().week(this);return null==t?e:this.add(7*(t-e),"d")}function vt(t){var e=lt(this,1,4).week;return null==t?e:this.add(7*(t-e),"d")}function _t(t,e,n,r,i){var o,u=6+i-r,a=ut(t,0,1+u),s=a.getUTCDay();return i>s&&(s+=7),n=null!=n?1*n:i,o=1+u+7*(e-1)-s+n,{year:o>0?t:t-1,dayOfYear:o>0?o:at(t-1)+o}}function yt(t){var e=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return null==t?e:this.add(t-e,"d")}function mt(t,e,n){return null!=t?t:null!=e?e:n}function gt(t){var e=new Date;return t._useUTC?[e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()]:[e.getFullYear(),e.getMonth(),e.getDate()]}function bt(t){var e,n,r,i,o=[];if(!t._d){for(r=gt(t),t._w&&null==t._a[cr]&&null==t._a[sr]&&Ot(t),t._dayOfYear&&(i=mt(t._a[ar],r[ar]),t._dayOfYear>at(i)&&(l(t)._overflowDayOfYear=!0),n=ut(i,0,t._dayOfYear),t._a[sr]=n.getUTCMonth(),t._a[cr]=n.getUTCDate()),e=0;3>e&&null==t._a[e];++e)t._a[e]=o[e]=r[e];for(;7>e;e++)t._a[e]=o[e]=null==t._a[e]?2===e?1:0:t._a[e];24===t._a[lr]&&0===t._a[fr]&&0===t._a[dr]&&0===t._a[pr]&&(t._nextDay=!0,t._a[lr]=0),t._d=(t._useUTC?ut:ot).apply(null,o),null!=t._tzm&&t._d.setUTCMinutes(t._d.getUTCMinutes()-t._tzm),t._nextDay&&(t._a[lr]=24)}}function Ot(t){var e,n,r,i,o,u,a;e=t._w,null!=e.GG||null!=e.W||null!=e.E?(o=1,u=4,n=mt(e.GG,t._a[ar],lt(Dt(),1,4).year),r=mt(e.W,1),i=mt(e.E,1)):(o=t._locale._week.dow,u=t._locale._week.doy,n=mt(e.gg,t._a[ar],lt(Dt(),o,u).year),r=mt(e.w,1),null!=e.d?(i=e.d,o>i&&++r):i=null!=e.e?e.e+o:o),a=_t(n,r,i,u,o),t._a[ar]=a.year,t._dayOfYear=a.dayOfYear}function St(t){if(t._f===e.ISO_8601)return void rt(t);t._a=[],l(t).empty=!0;var n,r,i,o,u,a=""+t._i,s=a.length,c=0;for(i=z(t._f,t._locale).match(Gn)||[],n=0;n<i.length;n++)o=i[n],r=(a.match(G(o,t))||[])[0],r&&(u=a.substr(0,a.indexOf(r)),u.length>0&&l(t).unusedInput.push(u),a=a.slice(a.indexOf(r)+r.length),c+=r.length),Bn[o]?(r?l(t).empty=!1:l(t).unusedTokens.push(o),V(o,r,t)):t._strict&&!r&&l(t).unusedTokens.push(o);l(t).charsLeftOver=s-c,a.length>0&&l(t).unusedInput.push(a),l(t).bigHour===!0&&t._a[lr]<=12&&t._a[lr]>0&&(l(t).bigHour=void 0),t._a[lr]=wt(t._locale,t._a[lr],t._meridiem),bt(t),Q(t)}function wt(t,e,n){var r;return null==n?e:null!=t.meridiemHour?t.meridiemHour(e,n):null!=t.isPM?(r=t.isPM(n),r&&12>e&&(e+=12),r||12!==e||(e=0),e):e}function Mt(t){var e,n,r,i,o;if(0===t._f.length)return l(t).invalidFormat=!0,void(t._d=new Date(NaN));for(i=0;i<t._f.length;i++)o=0,e=p({},t),null!=t._useUTC&&(e._useUTC=t._useUTC),e._f=t._f[i],St(e),f(e)&&(o+=l(e).charsLeftOver,o+=10*l(e).unusedTokens.length,l(e).score=o,(null==r||r>o)&&(r=o,n=e));a(t,n||e)}function Tt(t){if(!t._d){var e=j(t._i);t._a=[e.year,e.month,e.day||e.date,e.hour,e.minute,e.second,e.millisecond],bt(t)}}function Et(t){var e=new h(Q(It(t)));return e._nextDay&&(e.add(1,"d"),e._nextDay=void 0),e}function It(t){var e=t._i,n=t._f;return t._locale=t._locale||T(t._l),null===e||void 0===n&&""===e?d({nullInput:!0}):("string"==typeof e&&(t._i=e=t._locale.preparse(e)),v(e)?new h(Q(e)):(r(n)?Mt(t):n?St(t):i(e)?t._d=e:jt(t),t))}function jt(t){var n=t._i;void 0===n?t._d=new Date:i(n)?t._d=new Date(+n):"string"==typeof n?it(t):r(n)?(t._a=o(n.slice(0),function(t){return parseInt(t,10)}),bt(t)):"object"==typeof n?Tt(t):"number"==typeof n?t._d=new Date(n):e.createFromInputFallback(t)}function Pt(t,e,n,r,i){var o={};return"boolean"==typeof n&&(r=n,n=void 0),o._isAMomentObject=!0,o._useUTC=o._isUTC=i,o._l=n,o._i=t,o._f=e,o._strict=r,Et(o)}function Dt(t,e,n,r){return Pt(t,e,n,r,!1)}function Ct(t,e){var n,i;if(1===e.length&&r(e[0])&&(e=e[0]),!e.length)return Dt();for(n=e[0],i=1;i<e.length;++i)(!e[i].isValid()||e[i][t](n))&&(n=e[i]);return n}function At(){var t=[].slice.call(arguments,0);return Ct("isBefore",t)}function kt(){var t=[].slice.call(arguments,0);return Ct("isAfter",t)}function xt(t){var e=j(t),n=e.year||0,r=e.quarter||0,i=e.month||0,o=e.week||0,u=e.day||0,a=e.hour||0,s=e.minute||0,c=e.second||0,l=e.millisecond||0;this._milliseconds=+l+1e3*c+6e4*s+36e5*a,this._days=+u+7*o,this._months=+i+3*r+12*n,this._data={},this._locale=T(),this._bubble()}function Lt(t){return t instanceof xt}function Nt(t,e){x(t,0,0,function(){var t=this.utcOffset(),n="+";return 0>t&&(t=-t,n="-"),n+k(~~(t/60),2)+e+k(~~t%60,2)})}function Rt(t){var e=(t||"").match(nr)||[],n=e[e.length-1]||[],r=(n+"").match(Tr)||["-",0,0],i=+(60*r[1])+y(r[2]);return"+"===r[0]?i:-i}function zt(t,n){var r,o;return n._isUTC?(r=n.clone(),o=(v(t)||i(t)?+t:+Dt(t))-+r,r._d.setTime(+r._d+o),e.updateOffset(r,!1),r):Dt(t).local()}function Ht(t){retLine truncated
|
||||
n(7),e["default"]=new o["default"]({is:"state-card-display",properties:{stateObj:{type:Object}}}),t.exports=e["default"]},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e["default"]="bookmark",t.exports=e["default"]},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t){return(0,u["default"])(t).format("LT")}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=i;var o=n(33),u=r(o);t.exports=e["default"]},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(2);e["default"]=function(t,e){r.authActions.validate(t,{rememberAuth:e,useStreaming:r.localStoragePreferences.useStreaming})},t.exports=e["default"]},function(t,e,n){"use strict";function r(t,e,n){function r(){y&&clearTimeout(y),p&&clearTimeout(p),g=0,p=y=m=void 0}function s(e,n){n&&clearTimeout(n),p=y=m=void 0,e&&(g=o(),h=t.apply(_,d),y||p||(d=_=void 0))}function c(){var t=e-(o()-v);0>=t||t>e?s(m,p):y=setTimeout(c,t)}function l(){s(O,y)}function f(){if(d=arguments,v=o(),_=this,m=O&&(y||!S),b===!1)var n=S&&!y;else{p||S||(g=v);var r=b-(v-g),i=0>=r||r>b;i?(p&&(p=clearTimeout(p)),g=v,h=t.apply(_,d)):p||(p=setTimeout(l,r))}return i&&y?y=clearTimeout(y):y||e===b||(y=setTimeout(c,e)),n&&(i=!0,h=t.apply(_,d)),!i||y||p||(d=_=void 0),h}var d,p,h,v,_,y,m,g=0,b=!1,O=!0;if("function"!=typeof t)throw new TypeError(u);if(e=0>e?0:+e||0,n===!0){var S=!0;O=!1}else i(n)&&(S=!!n.leading,b="maxWait"in n&&a(+n.maxWait||0,e),O="trailing"in n?!!n.trailing:O);return f.cancel=r,f}var i=n(47),o=n(130),u="Expected a function",a=Math.max;t.exports=r},function(t,e,n){"use strict";function r(t,e){var n=null==t?void 0:t[e];return i(n)?n:void 0}var i=n(133);t.exports=r},function(t,e){"use strict";function n(t){return!!t&&"object"==typeof t}t.exports=n},function(t,e,n){"use strict";function r(t){return i(t)&&a.call(t)==o}var i=n(47),o="[object Function]",u=Object.prototype,a=u.toString;t.exports=r},function(t,e){"use strict";function n(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}t.exports=n},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(3),i=["isLoadingEntityHistory"];e.isLoadingEntityHistory=i;var o=["currentEntityHistoryDate"];e.currentDate=o;var u=["entityHistory"];e.entityHistoryMap=u;var a=[o,u,function(t,e){return e.get(t)||(0,r.toImmutable)({})}];e.entityHistoryForCurrentDate=a;var s=[o,u,function(t,e){return!!e.get(t)}];e.hasDataForCurrentDate=s;var c=["recentEntityHistory"];e.recentEntityHistoryMap=c;var l=["recentEntityHistory"];e.recentEntityHistoryUpdatedMap=l},function(t,e,n){"use strict";function r(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e["default"]=t,e}function i(t){return t&&t.__esModule?t:{"default":t}}function o(t){t.registerStores({currentEntityHistoryDate:a["default"],entityHistory:c["default"],isLoadingEntityHistory:f["default"],recentEntityHistory:p["default"],recentEntityHistoryUpdated:v["default"]})}Object.defineProperty(e,"__esModule",{value:!0}),e.register=o;var u=n(145),a=i(u),s=n(146),c=i(s),l=n(147),f=i(l),d=n(148),p=i(d),h=n(149),v=i(h),_=n(144),y=r(_),m=n(48),g=r(m),b=y;e.actions=b;var O=g;e.getters=O},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),u=function(t,e,n){for(var r=!0;r;){var i=t,o=e,u=n;r=!1,null===i&&(i=Function.prototype);var a=Object.getOwnPropertyDescriptor(i,o);if(void 0!==a){if("value"in a)return a.value;var s=a.get;if(void 0===s)return;return s.call(u)}var c=Object.getPrototypeOf(i);if(null===c)return;t=c,e=o,n=u,r=!0,a=c=void 0}},a=n(3),s=n(6),c="event",l=new a.Immutable.Record({event:null,listenerCount:0},"Event"),f=function(t){function e(t){var n=arguments.length<=1||void 0===arguments[1]?0:arguments[1];r(this,e),u(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,{event:t,listenerCount:n})}return i(e,t),o(e,null,[{key:"entity",value:c,enumerable:!0}]),o(e,[{key:"id",get:function(){return this.event}}],[{key:"fetchAll",value:function(t){return(0,s.callApi)(t,"GET","events")}},{key:"fromJSON",value:function(t){var n=t.event,r=t.listener_count;return new e(n,r)}}]),e}(l);e["default"]=f,t.exports=e["default"]},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}ObjecLine truncated
|
||||
type:Boolean,value:!1,observer:"dialogOpenChanged"},finalTranscript:{type:String,bindNuclear:i.voiceGetters.finalTranscript},interimTranscript:{type:String,bindNuclear:i.voiceGetters.extraInterimTranscript},isTransmitting:{type:Boolean,bindNuclear:i.voiceGetters.isTransmitting},isListening:{type:Boolean,bindNuclear:i.voiceGetters.isListening},showListenInterface:{type:Boolean,computed:"computeShowListenInterface(isListening, isTransmitting)",observer:"showListenInterfaceChanged"},_boundOnBackdropTap:{type:Function,value:function(){return this._onBackdropTap.bind(this)}}},computeShowListenInterface:function(t,e){return t||e},dialogOpenChanged:function(t){t?this.$.dialog.backdropElement.addEventListener("click",this._boundOnBackdropTap):!t&&this.isListening&&i.voiceActions.stop()},showListenInterfaceChanged:function(t){!t&&this.dialogOpen?this.dialogOpen=!1:t&&(this.dialogOpen=!0)},_onBackdropTap:function(){this.$.dialog.backdropElement.removeEventListener("click",this._boundOnBackdropTap),this.isListening&&i.voiceActions.stop()}}),t.exports=e["default"]},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(2),o=n(1),u=r(o),a=n(4),s=r(a);n(19),n(38),n(110);var c=["camera","configurator","scene"];e["default"]=new u["default"]({is:"more-info-dialog",behaviors:[s["default"]],properties:{stateObj:{type:Object,bindNuclear:i.moreInfoGetters.currentEntity,observer:"stateObjChanged"},stateHistory:{type:Object,bindNuclear:[i.moreInfoGetters.currentEntityHistory,function(t){return t?[t]:!1}]},isLoadingHistoryData:{type:Boolean,computed:"computeIsLoadingHistoryData(_delayedDialogOpen, _isLoadingHistoryData)"},_isLoadingHistoryData:{type:Boolean,bindNuclear:i.entityHistoryGetters.isLoadingEntityHistory},hasHistoryComponent:{type:Boolean,bindNuclear:i.configGetters.isComponentLoaded("history"),observer:"fetchHistoryData"},shouldFetchHistory:{type:Boolean,bindNuclear:i.moreInfoGetters.isCurrentEntityHistoryStale,observer:"fetchHistoryData"},showHistoryComponent:{type:Boolean,value:!1},dialogOpen:{type:Boolean,value:!1,observer:"dialogOpenChanged"},_delayedDialogOpen:{type:Boolean,value:!1}},computeIsLoadingHistoryData:function(t,e){return!t||e},fetchHistoryData:function(){this.stateObj&&this.hasHistoryComponent&&this.shouldFetchHistory&&i.entityHistoryActions.fetchRecent(this.stateObj.entityId)},stateObjChanged:function(t){var e=this;return t?(this.showHistoryComponent=this.hasHistoryComponent&&-1===c.indexOf(this.stateObj.domain),void this.async(function(){e.fetchHistoryData(),e.dialogOpen=!0},10)):void(this.dialogOpen=!1)},dialogOpenChanged:function(t){var e=this;t?this.async(function(){return e._delayedDialogOpen=!0},10):!t&&this.stateObj&&(i.moreInfoActions.deselectEntity(),this._delayedDialogOpen=!1)}}),t.exports=e["default"]},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),o=r(i),u=n(2),a=n(4),s=r(a);n(87),n(105),n(103),n(102),n(104),n(98),n(99),n(101),n(100),n(106),n(95),n(94),e["default"]=new o["default"]({is:"home-assistant-main",behaviors:[s["default"]],properties:{narrow:{type:Boolean,value:!1},activePane:{type:String,bindNuclear:u.navigationGetters.activePane,observer:"activePaneChanged"},isSelectedStates:{type:Boolean,bindNuclear:u.navigationGetters.isActivePane("states")},isSelectedHistory:{type:Boolean,bindNuclear:u.navigationGetters.isActivePane("history")},isSelectedMap:{type:Boolean,bindNuclear:u.navigationGetters.isActivePane("map")},isSelectedLogbook:{type:Boolean,bindNuclear:u.navigationGetters.isActivePane("logbook")},isSelectedDevEvent:{type:Boolean,bindNuclear:u.navigationGetters.isActivePane("devEvent")},isSelectedDevState:{type:Boolean,bindNuclear:u.navigationGetters.isActivePane("devState")},isSelectedDevService:{type:Boolean,bindNuclear:u.navigationGetters.isActivePane("devService")},isSelectedDevInfo:{type:Boolean,bindNuclear:u.navigationGetters.isActivePane("devInfo")},showSidebar:{type:Boolean,bindNuclear:u.navigationGetters.showSidebar}},listeners:{"open-menu":"openMenu","close-menu":"closeMenu"},openMenu:function(){this.narrow?this.$.drawer.openDrawer():u.navigationActions.showSidebar(!0)},closeMenu:function(){this.$.drawer.closeDrawer(),this.showSidebar&&u.navigationActions.showSidebar(!1)},activePaneChanged:function(){this.narrow&&this.$.drawer.closeDrawer()},attached:function(){(0,u.startUrlSync)()},computeForceNarrow:function(t,e){return t||!e},detached:function(){(0,u.stopUrlSync)()}}),t.exports=e["default"]},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),o=r(i),u=n(2),a=n(4),s=r(a),c=n(42),l=r(c);e["default"]=new o["default"]({is:"login-form",behaviors:[s["default"]],properties:{errorMessage:{type:String,bindNuclear:u.authGetters.attemptErrorMessage},isInvalid:{type:Boolean,bindNuclear:u.authGetters.isInvalidAttemLine truncated
|
||||
Z=t}function f(){return function(){t.nextTick(_)}}function d(){return function(){q(_)}}function p(){var t=0,e=new tt(_),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function h(){var t=new MessageChannel;return t.port1.onmessage=_,function(){t.port2.postMessage(0)}}function v(){return function(){setTimeout(_,1)}}function _(){for(var t=0;$>t;t+=2){var e=rt[t],n=rt[t+1];e(n),rt[t]=void 0,rt[t+1]=void 0}$=0}function y(){try{var t=n(202);return q=t.runOnLoop||t.runOnContext,d()}catch(e){return v()}}function m(){}function g(){return new TypeError("You cannot resolve a promise with itself")}function b(){return new TypeError("A promises callback cannot return that same promise.")}function O(t){try{return t.then}catch(e){return at.error=e,at}}function S(t,e,n,r){try{t.call(e,n,r)}catch(i){return i}}function w(t,e,n){Z(function(t){var r=!1,i=S(n,e,function(n){r||(r=!0,e!==n?E(t,n):j(t,n))},function(e){r||(r=!0,P(t,e))},"Settle: "+(t._label||" unknown promise"));!r&&i&&(r=!0,P(t,i))},t)}function M(t,e){e._state===ot?j(t,e._result):e._state===ut?P(t,e._result):D(e,void 0,function(e){E(t,e)},function(e){P(t,e)})}function T(t,e){if(e.constructor===t.constructor)M(t,e);else{var n=O(e);n===at?P(t,at.error):void 0===n?j(t,e):a(n)?w(t,e,n):j(t,e)}}function E(t,e){t===e?P(t,g()):u(e)?T(t,e):j(t,e)}function I(t){t._onerror&&t._onerror(t._result),C(t)}function j(t,e){t._state===it&&(t._result=e,t._state=ot,0!==t._subscribers.length&&Z(C,t))}function P(t,e){t._state===it&&(t._state=ut,t._result=e,Z(I,t))}function D(t,e,n,r){var i=t._subscribers,o=i.length;t._onerror=null,i[o]=e,i[o+ot]=n,i[o+ut]=r,0===o&&t._state&&Z(C,t)}function C(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r,i,o=t._result,u=0;u<e.length;u+=3)r=e[u],i=e[u+n],r?x(n,r,i,o):i(o);t._subscribers.length=0}}function A(){this.error=null}function k(t,e){try{return t(e)}catch(n){return st.error=n,st}}function x(t,e,n,r){var i,o,u,s,c=a(n);if(c){if(i=k(n,r),i===st?(s=!0,o=i.error,i=null):u=!0,e===i)return void P(e,b())}else i=r,u=!0;e._state!==it||(c&&u?E(e,i):s?P(e,o):t===ot?j(e,i):t===ut&&P(e,i))}function L(t,e){try{e(function(e){E(t,e)},function(e){P(t,e)})}catch(n){P(t,n)}}function N(t,e){var n=this;n._instanceConstructor=t,n.promise=new t(m),n._validateInput(e)?(n._input=e,n.length=e.length,n._remaining=e.length,n._init(),0===n.length?j(n.promise,n._result):(n.length=n.length||0,n._enumerate(),0===n._remaining&&j(n.promise,n._result))):P(n.promise,n._validationError())}function R(t){return new ct(this,t).promise}function z(t){function e(t){E(i,t)}function n(t){P(i,t)}var r=this,i=new r(m);if(!J(t))return P(i,new TypeError("You must pass an array to race.")),i;for(var o=t.length,u=0;i._state===it&&o>u;u++)D(r.resolve(t[u]),void 0,e,n);return i}function H(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var n=new e(m);return E(n,t),n}function Y(t){var e=this,n=new e(m);return P(n,t),n}function G(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function F(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function U(t){this._id=ht++,this._state=void 0,this._result=void 0,this._subscribers=[],m!==t&&(a(t)||G(),this instanceof U||F(),L(this,t))}function B(){var t;if("undefined"!=typeof i)t=i;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var n=t.Promise;(!n||"[object Promise]"!==Object.prototype.toString.call(n.resolve())||n.cast)&&(t.Promise=vt)}var V;V=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var q,W,K,J=V,$=0,Z=({}.toString,function(t,e){rt[$]=t,rt[$+1]=e,$+=2,2===$&&(W?W(_):K())}),X="undefined"!=typeof window?window:void 0,Q=X||{},tt=Q.MutationObserver||Q.WebKitMutationObserver,et="undefined"!=typeof t&&"[object process]"==={}.toString.call(t),nt="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,rt=new Array(1e3);K=et?f():tt?p():nt?h():void 0===X?y():v();var it=void 0,ot=1,ut=2,at=new A,st=new A;N.prototype._validateInput=function(t){return J(t)},N.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},N.prototype._init=function(){this._result=new Array(this.length)};var ct=N;N.prototype._enumerate=function(){for(var t=this,e=t.length,n=t.promise,r=t._input,i=0;n._state===it&&e>i;i++)t._eachEntry(r[i],i)},N.prototype._eachEntry=function(t,e){var n=this,r=n._instanceConstructor;s(t)?t.constructor===r&&t._state!==it?(t._onerror=null,n._settledAt(t._state,e,t._result)):n._willSettleAt(r.resolve(t),e):(n._remaining--,n._result[e]=t)},N.prototype._settledAt=function(t,e,n){var r=this,i=r.promise;i._state===it&&(r._remaining--,t===ut?P(i,n):r._result[e]=Line truncated
|
||||
value:!0}),e.register=o;var u=n(160),a=i(u),s=n(161),c=i(s),l=n(162),f=i(l),d=n(163),p=i(d),h=n(156),v=r(h),_=n(157),y=r(_),m=v;e.actions=m;var g=y;e.getters=g},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var u=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),a=function(t,e,n){for(var r=!0;r;){var i=t,o=e,u=n;r=!1,null===i&&(i=Function.prototype);var a=Object.getOwnPropertyDescriptor(i,o);if(void 0!==a){if("value"in a)return a.value;var s=a.get;if(void 0===s)return;return s.call(u)}var c=Object.getPrototypeOf(i);if(null===c)return;t=c,e=o,n=u,r=!0,a=c=void 0}},s=n(3),c=n(32),l=r(c),f=new s.Immutable.Record({when:null,name:null,message:null,domain:null,entityId:null},"LogbookEntry"),d=function(t){function e(t,n,r,o,u){i(this,e),a(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,{when:t,name:n,message:r,domain:o,entityId:u})}return o(e,t),u(e,null,[{key:"fromJSON",value:function(t){var n=t.when,r=t.name,i=t.message,o=t.domain,u=t.entity_id;return new e((0,l["default"])(n),r,i,o,u)}}]),e}(f);e["default"]=d,t.exports=e["default"]},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function u(t,e){var n=e.date;return(0,d["default"])(n)}function a(){return _.getInitialState()}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),c=function(t,e,n){for(var r=!0;r;){var i=t,o=e,u=n;r=!1,null===i&&(i=Function.prototype);var a=Object.getOwnPropertyDescriptor(i,o);if(void 0!==a){if("value"in a)return a.value;var s=a.get;if(void 0===s)return;return s.call(u)}var c=Object.getPrototypeOf(i);if(null===c)return;t=c,e=o,n=u,r=!0,a=c=void 0}},l=n(3),f=n(31),d=r(f),p=n(12),h=r(p),v=function(t){function e(){i(this,e),c(Object.getPrototypeOf(e.prototype),"constructor",this).apply(this,arguments)}return o(e,t),s(e,[{key:"getInitialState",value:function(){return(0,d["default"])(new Date)}},{key:"initialize",value:function(){this.on(h["default"].LOGBOOK_DATE_SELECTED,u),this.on(h["default"].LOG_OUT,a)}}]),e}(l.Store),_=new v;e["default"]=_,t.exports=e["default"]},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var u=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),a=function(t,e,n){for(var r=!0;r;){var i=t,o=e,u=n;r=!1,null===i&&(i=Function.prototype);var a=Object.getOwnPropertyDescriptor(i,o);if(void 0!==a){if("value"in a)return a.value;var s=a.get;if(void 0===s)return;return s.call(u)}var c=Object.getPrototypeOf(i);if(null===c)return;t=c,e=o,n=u,r=!0,a=c=void 0}},s=n(3),c=n(12),l=r(c),f=function(t){function e(){i(this,e),a(Object.getPrototypeOf(e.prototype),"constructor",this).apply(this,arguments)}return o(e,t),u(e,[{key:"getInitialState",value:function(){return!1}},{key:"initialize",value:function(){this.on(l["default"].LOGBOOK_ENTRIES_FETCH_START,function(){return!0}),this.on(l["default"].LOGBOOK_ENTRIES_FETCH_SUCCESS,function(){return!1}),this.on(l["default"].LOGBOOK_ENTRIES_FETCH_ERROR,function(){return!1}),this.on(l["default"].LOG_OUT,function(){return!1})}}]),e}(s.Store),d=new f;e["defaLine truncated
|
||||
for(var r=!0;r;){var i=t,o=e,u=n;r=!1,null===i&&(i=Function.prototype);var a=Object.getOwnPropertyDescriptor(i,o);if(void 0!==a){if("value"in a)return a.value;var s=a.get;if(void 0===s)return;return s.call(u)}var c=Object.getPrototypeOf(i);if(null===c)return;t=c,e=o,n=u,r=!0,a=c=void 0}},s=n(3),c=n(29),l=r(c),f=function(t){function e(){i(this,e),a(Object.getPrototypeOf(e.prototype),"constructor",this).apply(this,arguments)}return o(e,t),u(e,[{key:"getInitialState",value:function(){return!1}},{key:"initialize",value:function(){this.on(l["default"].SYNC_SCHEDULED,function(){return!0}),this.on(l["default"].SYNC_SCHEDULE_CANCELLED,function(){return!1}),this.on(l["default"].LOG_OUT,function(){return!1})}}]),e}(s.Store),d=new f;e["default"]=d,t.exports=e["default"]},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t){return d[t.hassId]}function o(t){var e=i(t);if(e){var n=e.finalTranscript||e.interimTranscript;t.dispatch(f["default"].VOICE_TRANSMITTING,{finalTranscript:n}),c.actions.callService(t,"conversation","process",{text:n}).then(function(){t.dispatch(f["default"].VOICE_DONE)},function(){t.dispatch(f["default"].VOICE_ERROR)})}}function u(t){var e=i(t);e&&(e.recognition.stop(),d[t.hassId]=!1)}function a(t){o(t),u(t)}function s(t){var e=a.bind(null,t);e();var n=new webkitSpeechRecognition;d[t.hassId]={recognition:n,interimTranscript:"",finalTranscript:""},n.interimResults=!0,n.onstart=function(){return t.dispatch(f["default"].VOICE_START)},n.onerror=function(){return t.dispatch(f["default"].VOICE_ERROR)},n.onend=e,n.onresult=function(e){var n=i(t);if(n){for(var r="",o="",u=e.resultIndex;u<e.results.length;u++)e.results[u].isFinal?r+=e.results[u][0].transcript:o+=e.results[u][0].transcript;n.interimTranscript=o,n.finalTranscript+=r,t.dispatch(f["default"].VOICE_RESULT,{interimTranscript:o,finalTranscript:n.finalTranscript})}},n.start()}Object.defineProperty(e,"__esModule",{value:!0}),e.stop=u,e.finish=a,e.listen=s;var c=n(13),l=n(62),f=r(l),d={}},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=["isVoiceSupported"];e.isVoiceSupported=n;var r=["currentVoiceCommand","isListening"];e.isListening=r;var i=["currentVoiceCommand","isTransmitting"];e.isTransmitting=i;var o=["currentVoiceCommand","interimTranscript"];e.interimTranscript=o;var u=["currentVoiceCommand","finalTranscript"];e.finalTranscript=u;var a=[o,u,function(t,e){return t.slice(e.length)}];e.extraInterimTranscript=a},function(t,e,n){"use strict";function r(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e["default"]=t,e}function i(t){return t&&t.__esModule?t:{"default":t}}function o(t){t.registerStores({currentVoiceCommand:c["default"],isVoiceSupported:a["default"]})}Object.defineProperty(e,"__esModule",{value:!0}),e.register=o;var u=n(192),a=i(u),s=n(191),c=i(s),l=n(188),f=r(l),d=n(189),p=r(d),h=f;e.actions=h;var v=p;e.getters=v},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function u(t){return t.set("isListening",!0)}function a(t,e){var n=e.interimTranscript,r=e.finalTranscript;return t.withMutations(function(t){return t.set("isListening",!0).set("isTransmitting",!1).set("interimTranscript",n).set("finalTranscript",r)})}function s(t,e){var n=e.finalTranscript;return t.withMutations(function(t){return t.set("isListening",!1).set("isTransmitting",!0).set("interimTranscript","").set("finalTranscript",n)})}function c(){return m.getInitialState()}function l(){return m.getInitialState()}function f(){return m.getInitialState()}Object.defineProperty(e,"__esModule",{value:!0});var d=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),p=function(t,e,n){for(var r=!0;r;){var i=t,o=e,u=n;r=!1,null===i&&(i=Function.prototype);var a=Object.getOwnPropertyDescriptor(i,o);if(void 0!==a){if("value"in a)return a.value;var s=a.get;if(void 0===s)return;return s.call(u)}var c=Object.getPrototypeOf(i);if(null===c)return;t=c,e=o,n=u,r=!0,a=c=void 0}},h=n(3),v=n(62),_=r(v),y=function(t){function e(){i(this,e),p(Object.getPrototypeOf(e.prototype),"constructor",this).apply(this,arguments)}return o(e,t),d(e,[{key:"getInitialState",value:function(){return(0,h.toImmutable)({isListening:!1,isTransmitting:!1,interimTranscript:"",finalTranscript:""})}},{key:"initialize",value:function(){this.on(_["defaulLine truncated
|
||||
}</style><template><template is="dom-if" if="[[!loaded]]"><login-form force-show-loading="[[computeForceShowLoading(dataLoaded, iconsLoaded)]]"></login-form></template><template is="dom-if" if="[[loaded]]"><home-assistant-main></home-assistant-main></template></template></dom-module><script>!function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),o=r(i),a=n(2),u=r(a),s=n(4),c=r(s),l=n(41),f=r(l);n(89),n(88);var d=u["default"].localStoragePreferences,h=u["default"].navigationActions,p=u["default"].reactor,_=u["default"].startLocalStoragePreferencesSync,v=u["default"].syncGetters;e["default"]=new o["default"]({is:"home-assistant",hostAttributes:{auth:null,icons:null},behaviors:[c["default"]],properties:{auth:{type:String},icons:{type:String},dataLoaded:{type:Boolean,bindNuclear:v.isDataLoaded},iconsLoaded:{type:Boolean,value:!1},loaded:{type:Boolean,computed:"computeLoaded(dataLoaded, iconsLoaded)"}},computeLoaded:function(t,e){return t&&e},computeForceShowLoading:function(t,e){return t&&!e},loadIcons:function(){var t=this,e=function(){return t.iconsLoaded=!0};this.importHref("/static/mdi-"+this.icons+".html",e,function(){return t.importHref("/static/mdi.html",e,e)})},created:function(){this.registerServiceWorker()},attached:function(){var t=document.getElementById("init");t.parentElement.removeChild(t)},ready:function(){var t=this;p.batch(function(){t.auth?(0,f["default"])(t.auth,!1):d.authToken&&(0,f["default"])(d.authToken,!0),h.showSidebar(d.showSidebar)}),_(),this.loadIcons()},registerServiceWorker:function(){"serviceWorker"in navigator&&navigator.serviceWorker.register("./service_worker.js")}})},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=window.Polymer},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(65),o=r(i);e["default"]=new o["default"]},function(t,e,n){!function(e,n){t.exports=n()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0}),n(1);var i=n(2),o=r(i),a=n(6),u=r(a),s=n(3),c=r(s),l=n(5),f=n(11),d=n(10),h=n(7),p=r(h);e["default"]={Reactor:u["default"],Store:o["default"],Immutable:c["default"],isKeyPath:f.isKeyPath,isGetter:d.isGetter,toJS:l.toJS,toImmutable:l.toImmutable,isImmutable:l.isImmutable,createReactMixin:p["default"]},t.exports=e["default"]},function(t,e){"use strict";try{window.console&&console.log||(console={log:function(){},debug:function(){},info:function(){},warn:function(){},error:function(){}})}catch(n){}},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t){return t instanceof c}Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();e.isStore=i;var a=n(3),u=n(4),s=n(5),c=function(){function t(e){r(this,t),this.__handlers=(0,a.Map)({}),e&&(0,u.extend)(this,e),this.initialize()}return o(t,[{key:"initialize",value:function(){}},{key:"getInitialState",value:function(){return(0,a.Map)()}},{key:"handle",value:function(t,e,n){var r=this.__handlers.get(e);return"function"==typeof r?r.call(this,t,n,e):t}},{key:"handleReset",value:function(t){return this.getInitialState()}},{key:"on",value:function(t,e){this.__handlers=this.__handlers.set(t,e)}},{key:"serialize",value:function(t){return(0,s.toJS)(t)}},{key:"deserialize",value:function(t){return(0,s.toImmutable)(t)}}]),t}();e["default"]=(0,u.toFactory)(c)},function(t,e,n){!function(e,n){t.exports=n()}(this,function(){"use strict";function t(t,e){e&&(t.prototype=Object.create(e.prototype)),t.prototype.constructor=t}function e(t){return t.value=!1,t}function n(t){t&&(t.value=!0)}function r(){}function i(t,e){e=e||0;for(var n=Math.max(0,t.length-e),r=new Array(n),i=0;n>i;i++)r[i]=t[i+e];return r}function o(t){return void 0===t.size&&(t.size=t.__iterate(u)),t.size}function a(t,e){if("number"!=typeof e){var n=+e;if(""+n!==e)return NaN;e=n}return 0>e?o(t)+e:e}function u(){return!0}function s(t,e,n){return(0===t||void 0!==n&&-n>=t)&&(void 0===e||void 0!==n&&e>=n)}function c(t,e){return f(t,e,0)}function l(t,e){return f(t,e,e)}function f(t,e,n){return void 0===t?n:0>t?Math.max(0,e+t):void 0===e?t:Math.min(e,t)}funLine truncated
|
||||
},st.prototype.reverse=function(){var t=this,e=pt(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},st.prototype.map=function(t,e){var n=this,r=ht(this,t,e);return this._useKeys||(r.valueSeq=function(){return n._iter.toSeq().map(t,e)}),r},st.prototype.__iterate=function(t,e){var n,r=this;return this._iter.__iterate(this._useKeys?function(e,n){return t(e,n,r)}:(n=e?At(this):0,function(i){return t(i,e?--n:n++,r)}),e)},st.prototype.__iterator=function(t,e){if(this._useKeys)return this._iter.__iterator(t,e);var n=this._iter.__iterator(bn,e),r=e?At(this):0;return new S(function(){var i=n.next();return i.done?i:w(t,e?--r:r++,i.value,i)})},st.prototype[mn]=!0,t(ct,A),ct.prototype.includes=function(t){return this._iter.includes(t)},ct.prototype.__iterate=function(t,e){var n=this,r=0;return this._iter.__iterate(function(e){return t(e,r++,n)},e)},ct.prototype.__iterator=function(t,e){var n=this._iter.__iterator(bn,e),r=0;return new S(function(){var e=n.next();return e.done?e:w(t,r++,e.value,e)})},t(lt,P),lt.prototype.has=function(t){return this._iter.includes(t)},lt.prototype.__iterate=function(t,e){var n=this;return this._iter.__iterate(function(e){return t(e,e,n)},e)},lt.prototype.__iterator=function(t,e){var n=this._iter.__iterator(bn,e);return new S(function(){var e=n.next();return e.done?e:w(t,e.value,e.value,e)})},t(ft,j),ft.prototype.entrySeq=function(){return this._iter.toSeq()},ft.prototype.__iterate=function(t,e){var n=this;return this._iter.__iterate(function(e){if(e){jt(e);var r=v(e);return t(r?e.get(1):e[1],r?e.get(0):e[0],n)}},e)},ft.prototype.__iterator=function(t,e){var n=this._iter.__iterator(bn,e);return new S(function(){for(;;){var e=n.next();if(e.done)return e;var r=e.value;if(r){jt(r);var i=v(r);return w(t,i?r.get(0):r[0],i?r.get(1):r[1],e)}}})},ct.prototype.cacheResult=st.prototype.cacheResult=lt.prototype.cacheResult=ft.prototype.cacheResult=Lt,t(zt,q),zt.prototype.toString=function(){return this.__toString("Map {","}")},zt.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},zt.prototype.set=function(t,e){return Jt(this,t,e)},zt.prototype.setIn=function(t,e){return this.updateIn(t,dn,function(){return e})},zt.prototype.remove=function(t){return Jt(this,t,dn)},zt.prototype.deleteIn=function(t){return this.updateIn(t,function(){return dn})},zt.prototype.update=function(t,e,n){return 1===arguments.length?t(this):this.updateIn([t],e,n)},zt.prototype.updateIn=function(t,e,n){n||(n=e,e=void 0);var r=oe(this,Rt(t),e,n);return r===dn?void 0:r},zt.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Kt()},zt.prototype.merge=function(){return ne(this,void 0,arguments)},zt.prototype.mergeWith=function(t){var e=un.call(arguments,1);return ne(this,t,e)},zt.prototype.mergeIn=function(t){var e=un.call(arguments,1);return this.updateIn(t,Kt(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},zt.prototype.mergeDeep=function(){return ne(this,re(void 0),arguments)},zt.prototype.mergeDeepWith=function(t){var e=un.call(arguments,1);return ne(this,re(t),e)},zt.prototype.mergeDeepIn=function(t){var e=un.call(arguments,1);return this.updateIn(t,Kt(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},zt.prototype.sort=function(t){return Oe(Et(this,t))},zt.prototype.sortBy=function(t,e){return Oe(Et(this,e,t))},zt.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},zt.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new r)},zt.prototype.asImmutable=function(){return this.__ensureOwner()},zt.prototype.wasAltered=function(){return this.__altered},zt.prototype.__iterator=function(t,e){return new Bt(this,t,e)},zt.prototype.__iterate=function(t,e){var n=this,r=0;return this._root&&this._root.iterate(function(e){return r++,t(e[1],e[0],n)},e),r},zt.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Wt(this.size,this._root,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},zt.isMap=xt;var xn="@@__IMMUTABLE_MAP__@@",Hn=zt.prototype;Hn[xn]=!0,Hn[sn]=Hn.remove,Hn.removeIn=Hn.deleteIn,Ht.prototype.get=function(t,e,n,r){for(var i=this.entries,o=0,a=i.length;a>o;o++)if(J(n,i[o][0]))return i[o][1];return r},Ht.prototype.update=function(t,e,r,o,a,u,s){for(var c=a===dn,l=this.entries,f=0,d=l.length;d>f&&!J(o,l[f][0]);f++);var h=d>f;if(h?l[f][1]===a:c)return this;if(n(s),(c||!h)&&n(u),!c||1!==l.length){if(!h&&!c&&l.length>=Un)return Qt(t,l,o,a);var p=t&&t===this.ownerID,_=p?l:i(l);return h?c?f===d-1?_.pop():_[f]=_.pop():_[f]=[o,a]:_.push([o,a]),p?(this.entries=_,this):new Ht(t,_)}},Yt.prototype.get=function(t,e,n,r){void 0===e&&(e=et(n));var i=1<<((0===t?e:e>>>t)&fn),o=this.bitmap;return 0===(o&i)?r:this.nodes[ae(o&i-1)].get(t+cn,e,n,r)},Yt.prototype.update=function(t,e,n,r,i,o,a){void 0===n&&(Line truncated
|
||||
this.__isDispatching=!0}try{this.reactorState=d["default"].dispatch(this.reactorState,t,e)}catch(n){throw this.__isDispatching=!1,n}try{this.__notify()}finally{this.__isDispatching=!1}}},{key:"batch",value:function(t){this.batchStart(),t(),this.batchEnd()}},{key:"registerStore",value:function(t,e){console.warn("Deprecation warning: `registerStore` will no longer be supported in 1.1, use `registerStores` instead"),this.registerStores(i({},t,e))}},{key:"registerStores",value:function(t){this.reactorState=d["default"].registerStores(this.reactorState,t),this.__notify()}},{key:"serialize",value:function(){return d["default"].serialize(this.reactorState)}},{key:"loadState",value:function(t){this.reactorState=d["default"].loadState(this.reactorState,t),this.__notify()}},{key:"reset",value:function(){var t=d["default"].reset(this.reactorState);this.reactorState=t,this.prevReactorState=t,this.observerState=new y.ObserverState}},{key:"__notify",value:function(){var t=this;if(!(this.__batchDepth>0)){var e=this.reactorState.get("dirtyStores");if(0!==e.size){var n=s["default"].Set().withMutations(function(n){n.union(t.observerState.get("any")),e.forEach(function(e){var r=t.observerState.getIn(["stores",e]);r&&n.union(r)})});n.forEach(function(e){var n=t.observerState.getIn(["observersMap",e]);if(n){var r=n.get("getter"),i=n.get("handler"),o=d["default"].evaluate(t.prevReactorState,r),a=d["default"].evaluate(t.reactorState,r);t.prevReactorState=o.reactorState,t.reactorState=a.reactorState;var u=o.result,c=a.result;s["default"].is(u,c)||i.call(null,c)}});var r=d["default"].resetDirtyStores(this.reactorState);this.prevReactorState=r,this.reactorState=r}}}},{key:"batchStart",value:function(){this.__batchDepth++}},{key:"batchEnd",value:function(){if(this.__batchDepth--,this.__batchDepth<=0){this.__isDispatching=!0;try{this.__notify()}catch(t){throw this.__isDispatching=!1,t}this.__isDispatching=!1}}}]),t}();e["default"]=(0,v.toFactory)(m),t.exports=e["default"]},function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i(t,e){var n={};return(0,o.each)(e,function(e,r){n[r]=t.evaluate(e)}),n}Object.defineProperty(e,"__esModule",{value:!0});var o=n(4);e["default"]=function(t){return{getInitialState:function(){return i(t,this.getDataBindings())},componentDidMount:function(){var e=this;this.__unwatchFns=[],(0,o.each)(this.getDataBindings(),function(n,i){var o=t.observe(n,function(t){e.setState(r({},i,t))});e.__unwatchFns.push(o)})},componentWillUnmount:function(){for(;this.__unwatchFns.length;)this.__unwatchFns.shift()()}}},t.exports=e["default"]},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){return new b({result:t,reactorState:e})}function o(t){return t}function a(t,e){var n=o(e);return t.getIn(["cache",n])}function u(t,e){var n=a(t,e);if(!n)return!1;var r=n.get("storeStates");return 0===r.size?!1:r.every(function(e,n){return t.getIn(["storeStates",n])===e})}function s(t,e,n){var r=o(e),i=t.get("dispatchId"),a=(0,y.getStoreDeps)(e),u=(0,v.toImmutable)({}).withMutations(function(e){a.forEach(function(n){var r=t.getIn(["storeStates",n]);e.set(n,r)})});return t.setIn(["cache",r],h["default"].Map({value:n,storeStates:u,dispatchId:i}))}function c(t,e){var n=o(e);return t.getIn(["cache",n,"value"])}function l(t){return t.update("dispatchId",function(t){return t+1})}function f(t,e){return t.withMutations(function(t){e.forEach(function(e){var n=t.has(e)?t.get(e)+1:1;t.set(e,n)})})}var d=n(3),h=r(d),p=n(9),_=r(p),v=n(5),y=n(10),m=n(11),g=n(4),b=h["default"].Record({result:null,reactorState:null});e.registerStores=function(t,e){var n=t.get("debug");return t.withMutations(function(t){(0,g.each)(e,function(e,r){t.getIn(["stores",r])&&console.warn("Store already defined for id = "+r);var i=e.getInitialState();if(n&&!(0,v.isImmutableValue)(i))throw new Error("Store getInitialState() must return an immutable value, did you forget to call toImmutable");t.update("stores",function(t){return t.set(r,e)}).update("state",function(t){return t.set(r,i)}).update("dirtyStores",function(t){return t.add(r)}).update("storeStates",function(t){return f(t,[r])})}),l(t)})},e.dispatch=function(t,e,n){var r=t.get("state"),i=t.get("debug"),o=t.get("dirtyStores"),a=r.withMutations(function(r){i&&_["default"].dispatchStart(e,n),t.get("stores").forEach(function(t,a){var u=r.get(a),s=void 0;try{s=t.handle(u,e,n)}catch(c){throw _["default"].dispatchError(c.message),c}if(i&&void 0===s){var l="Store handler must return a value, did you forget a return statement";throw _["default"].dispatchError(l),new Error(l)}r.set(a,s),u!==s&&(o=o.add(a)),i&&_["default"].storeHandled(a,u,s)}),i&&_["default"].dispatchEnd(r)}),u=t.set("state",a).set("dirtyStores",o).update("storeStates",function(t){return f(t,o)});return l(u)},e.loadState=function(t,e){var n=[],r=(0,v.toImmutable)({}).withMutations(function(r){(0,g.each)(e,function(e,iLine truncated
|
||||
var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e["default"]=t,e}function i(t){return t&&t.__esModule?t:{"default":t}}function o(t){t.registerStores({moreInfoEntityId:u["default"]})}Object.defineProperty(e,"__esModule",{value:!0}),e.getters=e.actions=void 0,e.register=o;var a=n(153),u=i(a),s=n(151),c=r(s),l=n(152),f=r(l);e.actions=c,e.getters=f},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){t.dispatch(u["default"].SHOW_SIDEBAR,{show:e})}function o(t,e){t.dispatch(u["default"].NAVIGATE,{pane:e})}Object.defineProperty(e,"__esModule",{value:!0}),e.showSidebar=i,e.navigate=o;var a=n(26),u=r(a)},function(t,e){"use strict";function n(t){return[r,function(e){return e===t}]}Object.defineProperty(e,"__esModule",{value:!0}),e.isActivePane=n;var r=e.activePane=["selectedNavigationPanel"];e.showSidebar=["showSidebar"]},function(t,e,n){"use strict";function r(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e["default"]=t,e}function i(t){return t&&t.__esModule?t:{"default":t}}function o(t){t.registerStores({selectedNavigationPanel:u["default"],showSidebar:c["default"]})}Object.defineProperty(e,"__esModule",{value:!0}),e.urlSync=e.getters=e.actions=void 0,e.register=o;var a=n(154),u=i(a),s=n(155),c=i(s),l=n(47),f=r(l),d=n(48),h=r(d),p=n(156),_=r(p);e.actions=f,e.getters=h,e.urlSync=_},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(6),o=r(i);e["default"]=(0,o["default"])({NOTIFICATION_CREATED:null})},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(6),o=r(i);e["default"]=(0,o["default"])({API_FETCH_SUCCESS:null,API_FETCH_START:null,API_FETCH_FAIL:null,API_SAVE_SUCCESS:null,API_SAVE_START:null,API_SAVE_FAIL:null,API_DELETE_SUCCESS:null,API_DELETE_START:null,API_DELETE_FAIL:null,LOG_OUT:null})},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){return[h(t),function(t){return!!t&&t.services.has(e)}]}function o(t){return[u.getters.byId(t),d,f["default"]]}Object.defineProperty(e,"__esModule",{value:!0}),e.byDomain=e.entityMap=e.hasData=void 0,e.hasService=i,e.canToggleEntity=o;var a=n(10),u=n(9),s=n(53),c=r(s),l=n(166),f=r(l),d=(e.hasData=(0,a.createHasDataGetter)(c["default"]),e.entityMap=(0,a.createEntityMapGetter)(c["default"])),h=e.byDomain=(0,a.createByIdGetter)(c["default"])},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();Object.defineProperty(e,"__esModule",{value:!0});var u=n(3),s=n(5),c="service",l=new u.Immutable.Record({domain:null,services:[]},"ServiceDomain"),f=function(t){function e(t,n){return r(this,e),i(this,Object.getPrototypeOf(e).call(this,{domain:t,services:n}))}return o(e,t),a(e,[{key:"id",get:function(){return this.domain}}],[{key:"fetchAll",value:function(){return(0,s.callApi)("GET","services")}},{key:"fromJSON",value:function(t){var n=t.domain,r=t.services;return new e(n,(0,u.toImmutable)(r))}}]),e}(l);f.entity=c,e["default"]=f},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(6),o=r(i);e["default"]=(0,o["default"])({STREAM_START:null,STREAM_STOP:null,STREAM_ERROR:null})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isSyncScheduled=e.isFetching=e.isDataLoaded=void 0;var r=n(9),i=n(25),o=n(13);e.isDataLoaded=[r.getters.hasData,i.getters.hasData,o.getters.hasData,function(t,e,n){return t&&e&&n}],e.isFetching=["isFetchingData"],e.isSyncScheduled=["isSyncScheduled"]},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(6),o=r(i);e["default"]=(0,o["default"])({VOICE_START:null,VOICE_RESULT:null,VOICE_TRANSMITTING:null,VOICE_DONE:null,VOICE_ERROR:null})},function(t,e){"use strict";function n(t){return!t||(new Date).getTime()-t>6e4}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=n},function(t,e,n){fLine truncated
|
||||
e.createFromInputFallback=et("moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.",function(t){t._d=new Date(t._i+(t._useUTC?" UTC":""))}),L(0,["YY",2],0,function(){return this.year()%100}),L(0,["YYYY",4],0,"year"),L(0,["YYYYY",5],0,"year"),L(0,["YYYYYY",6,!0],0,"year"),I("year","y"),Y("Y",er),Y("YY",$n,qn),Y("YYYY",Xn,Kn),Y("YYYYY",Qn,Jn),Y("YYYYYY",Qn,Jn),F(["YYYYY","YYYYYY"],ur),F("YYYY",function(t,n){n[ur]=2===t.length?e.parseTwoDigitYear(t):y(t)}),F("YY",function(t,n){n[ur]=e.parseTwoDigitYear(t)}),e.parseTwoDigitYear=function(t){return y(t)+(y(t)>68?1900:2e3)};var Sr=C("FullYear",!1);L("w",["ww",2],"wo","week"),L("W",["WW",2],"Wo","isoWeek"),I("week","w"),I("isoWeek","W"),Y("w",$n),Y("ww",$n,qn),Y("W",$n),Y("WW",$n,qn),B(["w","ww","W","WW"],function(t,e,n,r){e[r.substr(0,1)]=y(t)});var wr={dow:0,doy:6};L("DDD",["DDDD",3],"DDDo","dayOfYear"),I("dayOfYear","DDD"),Y("DDD",Zn),Y("DDDD",Wn),F(["DDD","DDDD"],function(t,e,n){n._dayOfYear=y(t)}),e.ISO_8601=function(){};var Or=et("moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548",function(){var t=jt.apply(null,arguments);return this>t?this:t}),Mr=et("moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548",function(){var t=jt.apply(null,arguments);return t>this?this:t});Rt("Z",":"),Rt("ZZ",""),Y("Z",nr),Y("ZZ",nr),F(["Z","ZZ"],function(t,e,n){n._useUTC=!0,n._tzm=zt(t)});var Er=/([\+\-]|\d\d)/gi;e.updateOffset=function(){};var Ir=/(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,Tr=/^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/;Zt.fn=Lt.prototype;var Dr=ee(1,"add"),Cr=ee(-1,"subtract");e.defaultFormat="YYYY-MM-DDTHH:mm:ssZ";var jr=et("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(t){return void 0===t?this.localeData():this.locale(t)});L(0,["gg",2],0,function(){return this.weekYear()%100}),L(0,["GG",2],0,function(){return this.isoWeekYear()%100}),je("gggg","weekYear"),je("ggggg","weekYear"),je("GGGG","isoWeekYear"),je("GGGGG","isoWeekYear"),I("weekYear","gg"),I("isoWeekYear","GG"),Y("G",er),Y("g",er),Y("GG",$n,qn),Y("gg",$n,qn),Y("GGGG",Xn,Kn),Y("gggg",Xn,Kn),Y("GGGGG",Qn,Jn),Y("ggggg",Qn,Jn),B(["gggg","ggggg","GGGG","GGGGG"],function(t,e,n,r){e[r.substr(0,2)]=y(t)}),B(["gg","GG"],function(t,n,r,i){n[i]=e.parseTwoDigitYear(t)}),L("Q",0,0,"quarter"),I("quarter","Q"),Y("Q",Vn),F("Q",function(t,e){e[sr]=3*(y(t)-1)}),L("D",["DD",2],"Do","date"),I("date","D"),Y("D",$n),Y("DD",$n,qn),Y("Do",function(t,e){return t?e._ordinalParse:e._ordinalParseLenient}),F(["D","DD"],cr),F("Do",function(t,e){e[cr]=y(t.match($n)[0],10)});var Ar=C("Date",!0);L("d",0,"do","day"),L("dd",0,0,function(t){return this.localeData().weekdaysMin(this,t)}),L("ddd",0,0,function(t){return this.localeData().weekdaysShort(this,t)}),L("dddd",0,0,function(t){return this.localeData().weekdays(this,t)}),L("e",0,0,"weekday"),L("E",0,0,"isoWeekday"),I("day","d"),I("weekday","e"),I("isoWeekday","E"),Y("d",$n),Y("e",$n),Y("E",$n),Y("dd",ir),Y("ddd",ir),Y("dddd",ir),B(["dd","ddd","dddd"],function(t,e,n){var r=n._locale.weekdaysParse(t);null!=r?e.d=r:l(n).invalidWeekday=t}),B(["d","e","E"],function(t,e,n,r){e[r]=y(t)});var Pr="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),kr="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),Lr="Su_Mo_Tu_We_Th_Fr_Sa".split("_");L("H",["HH",2],0,"hour"),L("h",["hh",2],0,function(){return this.hours()%12||12}),Ve("a",!0),Ve("A",!1),I("hour","h"),Y("a",qe),Y("A",qe),Y("H",$n),Y("h",$n),Y("HH",$n,qn),Y("hh",$n,qn),F(["H","HH"],lr),F(["a","A"],function(t,e,n){n._isPm=n._locale.isPM(t),n._meridiem=t}),F(["h","hh"],function(t,e,n){e[lr]=y(t),l(n).bigHour=!0});var Nr=/[ap]\.?m?\.?/i,Rr=C("Hours",!0);L("m",["mm",2],0,"minute"),I("minute","m"),Y("m",$n),Y("mm",$n,qn),F(["m","mm"],fr);var zr=C("Minutes",!1);L("s",["ss",2],0,"second"),I("second","s"),Y("s",$n),Y("ss",$n,qn),F(["s","ss"],dr);var xr=C("Seconds",!1);L("S",0,0,function(){return~~(this.millisecond()/100)}),L(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),L(0,["SSS",3],0,"millisecond"),L(0,["SSSS",4],0,function(){return 10*this.millisecond()}),L(0,["SSSSS",5],0,function(){return 100*this.millisecond()}),L(0,["SSSSSS",6],0,function(){return 1e3*this.millisecond()}),L(0,["SSSSSSS",7],0,function(){return 1e4*this.millisecond()}),L(0,["SSSSSSSS",8],0,function(){return 1e5*this.millisecond()}),L(0,["SSSSSSSSS",9],0,function(){return 1e6*this.millisecond()}),I("millisecond","ms"),Y("S",Zn,Vn),Y("SS",Zn,qn),Y("SSS",Zn,Wn);var Hr;for(Hr="SSSS";Hr.length<=9;Hr+="S")Y(Hr,tr);for(Hr="S";Hr.length<=9;Hr+="S")F(Hr,Je);var Yr=C("Milliseconds",!1);L("z",0,0,"zoneAbbr"),L("zz",0,0,"zoneName");var Ur=p.prototypeLine truncated
|
||||
return e._delayedDialogOpen=!0},10):!t&&this.stateObj&&(p.deselectEntity(),this._delayedDialogOpen=!1)}})},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),o=r(i),a=n(2),u=r(a),s=n(4),c=r(s);n(79),n(97),n(95),n(94),n(96),n(90),n(91),n(93),n(92),n(98),n(87),n(86);var l=u["default"].navigationActions,f=u["default"].navigationGetters,d=u["default"].startUrlSync,h=u["default"].stopUrlSync;e["default"]=new o["default"]({is:"home-assistant-main",behaviors:[c["default"]],properties:{narrow:{type:Boolean,value:!1},activePane:{type:String,bindNuclear:f.activePane,observer:"activePaneChanged"},isSelectedStates:{type:Boolean,bindNuclear:f.isActivePane("states")},isSelectedHistory:{type:Boolean,bindNuclear:f.isActivePane("history")},isSelectedMap:{type:Boolean,bindNuclear:f.isActivePane("map")},isSelectedLogbook:{type:Boolean,bindNuclear:f.isActivePane("logbook")},isSelectedDevEvent:{type:Boolean,bindNuclear:f.isActivePane("devEvent")},isSelectedDevState:{type:Boolean,bindNuclear:f.isActivePane("devState")},isSelectedDevService:{type:Boolean,bindNuclear:f.isActivePane("devService")},isSelectedDevInfo:{type:Boolean,bindNuclear:f.isActivePane("devInfo")},showSidebar:{type:Boolean,bindNuclear:f.showSidebar}},listeners:{"open-menu":"openMenu","close-menu":"closeMenu"},openMenu:function(){this.narrow?this.$.drawer.openDrawer():l.showSidebar(!0)},closeMenu:function(){this.$.drawer.closeDrawer(),this.showSidebar&&l.showSidebar(!1)},activePaneChanged:function(){this.narrow&&this.$.drawer.closeDrawer()},attached:function(){d()},computeForceNarrow:function(t,e){return t||!e},detached:function(){h()}})},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),o=r(i),a=n(2),u=r(a),s=n(4),c=r(s),l=n(41),f=r(l),d=u["default"].authGetters;e["default"]=new o["default"]({is:"login-form",behaviors:[c["default"]],properties:{errorMessage:{type:String,bindNuclear:d.attemptErrorMessage},isInvalid:{type:Boolean,bindNuclear:d.isInvalidAttempt},isValidating:{type:Boolean,observer:"isValidatingChanged",bindNuclear:d.isValidating},loadingResources:{type:Boolean,value:!1},forceShowLoading:{type:Boolean,value:!1},showLoading:{type:Boolean,computed:"computeShowSpinner(forceShowLoading, isValidating)"}},listeners:{keydown:"passwordKeyDown","loginButton.click":"validatePassword"},observers:["validatingChanged(isValidating, isInvalid)"],computeShowSpinner:function(t,e){return t||e},validatingChanged:function(t,e){t||e||(this.$.passwordInput.value="")},isValidatingChanged:function(t){var e=this;t||this.async(function(){return e.$.passwordInput.focus()},10)},passwordKeyDown:function(t){13===t.keyCode?(this.validatePassword(),t.preventDefault()):this.isInvalid&&(this.isInvalid=!1)},validatePassword:function(){this.$.hideKeyboardOnFocus.focus(),(0,f["default"])(this.$.passwordInput.value,this.$.rememberLogin.checked)}})},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(2),o=r(i),a=n(1),u=r(a);n(8),n(82);var s=o["default"].reactor,c=o["default"].serviceActions,l=o["default"].serviceGetters;e["default"]=new u["default"]({is:"partial-dev-call-service",properties:{narrow:{type:Boolean,value:!1},showMenu:{type:Boolean,value:!1},domain:{type:String,value:""},service:{type:String,value:""},serviceData:{type:String,value:""},description:{type:String,computed:"computeDescription(domain, service)"}},computeDescription:function(t,e){return s.evaluate([l.entityMap,function(n){return n.has(t)&&n.get(t).get("services").has(e)?JSON.stringify(n.get(t).get("services").get(e).toJS(),null,2):"No description available"}])},serviceSelected:function(t){this.domain=t.detail.domain,this.service=t.detail.service},callService:function(){var t=void 0;try{t=this.serviceData?JSON.parse(this.serviceData):{}}catch(e){return void alert("Error parsing JSON: "+e)}c.callService(this.domain,this.service,t)},computeFormClasses:function(t){return"layout "+(t?"vertical":"horizontal")}})},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(2),o=r(i),a=n(1),u=r(a);n(8),n(75);var s=o["default"].eventActions;e["default"]=new u["default"]({is:"partial-dev-fire-event",properties:{narrow:{type:Boolean,value:!1},showMenu:{type:Boolean,value:!1},eventType:{type:String,value:""},eventData:{type:String,value:""}},eventSelected:function(t){this.eventType=t.detail.eventType},fireEvent:function(){var t=void 0;try{t=this.eventData?JSON.parse(this.eventData):{}}catch(e){return void alert("Error parsing JSON: "+e)}s.fireEvent(this.eventType,t)},computeFormClasses:function(t){return"layout "+(t?"vertical":"horizontal")}})},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(2Line truncated
|
||||
authToken:null,host:""})},initialize:function(){this.on(s["default"].VALID_AUTH_TOKEN,i),this.on(s["default"].LOG_OUT,o)}});e["default"]=c},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){var n=e.rememberAuth;return n}Object.defineProperty(e,"__esModule",{value:!0});var o=n(3),a=n(14),u=r(a),s=new o.Store({getInitialState:function(){return!0},initialize:function(){this.on(u["default"].VALID_AUTH_TOKEN,i)}});e["default"]=s},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){t.dispatch(c["default"].SERVER_CONFIG_LOADED,e)}function o(t){(0,u.callApi)(t,"GET","config").then(function(e){return i(t,e)})}function a(t,e){t.dispatch(c["default"].COMPONENT_LOADED,{component:e})}Object.defineProperty(e,"__esModule",{value:!0}),e.configLoaded=i,e.fetchAll=o,e.componentLoaded=a;var u=n(5),s=n(23),c=r(s)},function(t,e){"use strict";function n(t){return[["serverComponent"],function(e){return e.contains(t)}]}Object.defineProperty(e,"__esModule",{value:!0}),e.isComponentLoaded=n,e.locationGPS=[["serverConfig","latitude"],["serverConfig","longitude"],function(t,e){return{latitude:t,longitude:e}}],e.locationName=["serverConfig","location_name"],e.serverVersion=["serverConfig","serverVersion"]},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){var n=e.component;return t.push(n)}function o(t,e){var n=e.components;return(0,u.toImmutable)(n)}function a(){return l.getInitialState()}Object.defineProperty(e,"__esModule",{value:!0});var u=n(3),s=n(23),c=r(s),l=new u.Store({getInitialState:function(){return(0,u.toImmutable)([])},initialize:function(){this.on(c["default"].COMPONENT_LOADED,i),this.on(c["default"].SERVER_CONFIG_LOADED,o),this.on(c["default"].LOG_OUT,a)}});e["default"]=l},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){var n=e.latitude,r=e.longitude,i=e.location_name,o=e.temperature_unit,u=e.time_zone,s=e.version;return(0,a.toImmutable)({latitude:n,longitude:r,location_name:i,temperature_unit:o,time_zone:u,serverVersion:s})}function o(){return c.getInitialState()}Object.defineProperty(e,"__esModule",{value:!0});var a=n(3),u=n(23),s=r(u),c=new a.Store({getInitialState:function(){return(0,a.toImmutable)({latitude:null,longitude:null,location_name:"Home",temperature_unit:"°C",time_zone:"UTC",serverVersion:"unknown"})},initialize:function(){this.on(s["default"].SERVER_CONFIG_LOADED,i),this.on(s["default"].LOG_OUT,o)}});e["default"]=c},function(t,e,n){"use strict";function r(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e["default"]=t,e}function i(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){t.dispatch(f["default"].ENTITY_HISTORY_DATE_SELECTED,{date:e})}function a(t){var e=arguments.length<=1||void 0===arguments[1]?null:arguments[1];t.dispatch(f["default"].RECENT_ENTITY_HISTORY_FETCH_START,{});var n="history/period";return null!==e&&(n+="?filter_entity_id="+e),(0,c.callApi)(t,"GET",n).then(function(e){return t.dispatch(f["default"].RECENT_ENTITY_HISTORY_FETCH_SUCCESS,{stateHistory:e})},function(){return t.dispatch(f["default"].RECENT_ENTITY_HISTORY_FETCH_ERROR,{})})}function u(t,e){return t.dispatch(f["default"].ENTITY_HISTORY_FETCH_START,{date:e}),(0,c.callApi)(t,"GET","history/period/"+e).then(function(n){return t.dispatch(f["default"].ENTITY_HISTORY_FETCH_SUCCESS,{date:e,stateHistory:n})},function(){return t.dispatch(f["default"].ENTITY_HISTORY_FETCH_ERROR,{})})}function s(t){var e=t.evaluate(h.currentDate);return u(t,e)}Object.defineProperty(e,"__esModule",{value:!0}),e.changeCurrentDate=o,e.fetchRecent=a,e.fetchDate=u,e.fetchSelectedDate=s;var c=n(5),l=n(11),f=i(l),d=n(42),h=r(d)},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){var n=e.date;return(0,s["default"])(n)}function o(){return f.getInitialState()}Object.defineProperty(e,"__esModule",{value:!0});var a=n(3),u=n(31),s=r(u),c=n(11),l=r(c),f=new a.Store({getInitialState:function(){var t=new Date;return t.setDate(t.getDate()-1),(0,s["default"])(t)},initialize:function(){this.on(l["default"].ENTITY_HISTORY_DATE_SELECTED,i),this.on(l["default"].LOG_OUT,o)}});e["default"]=f},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){var n=e.date,r=e.stateHistory;return 0===r.length?t.set(n,(0,a.toImmutable)({})):t.withMutations(function(t){r.forEach(function(e){return t.setIn([n,e[0].entity_id],(0,a.toImmutable)(e.map(l["default"].fromJSON)))})})}function o(){return f.getInitialState()}Object.defineProperty(e,"__esModule",{value:!0});var a=n(3),u=n(11),s=r(u),c=n(16),l=r(c),f=new a.Store({getInitialState:function(){return(0,a.toImmutable)({})},initialize:function(){this.on(s["default"].ENTITY_HISTORY_FETCH_SUCCESS,i),this.on(s["default"].LOG_OUT,o)}});e["default"]=f},function(t,e,n){"use strict";fuLine truncated
|
||||
value:!0});var l=n(3),f=n(56),d=r(f),h=new l.Store({getInitialState:function(){return(0,l.toImmutable)({isListening:!1,isTransmitting:!1,interimTranscript:"",finalTranscript:""})},initialize:function(){this.on(d["default"].VOICE_START,i),this.on(d["default"].VOICE_RESULT,o),this.on(d["default"].VOICE_TRANSMITTING,a),this.on(d["default"].VOICE_DONE,u),this.on(d["default"].VOICE_ERROR,s),this.on(d["default"].LOG_OUT,c)}});e["default"]=h},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(3),i=new r.Store({getInitialState:function(){return"webkitSpeechRecognition"in window}});e["default"]=i},function(t,e,n){"use strict";function r(){var t=new i.Reactor({debug:!1});return t.hassId=o++,t}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r;var i=n(3),o=0},function(t,e,n){"use strict";function r(t,e){return(0,i.toImmutable)(t.attributes.entity_id.map(function(t){return e.get(t)}).filter(function(t){return!!t}))}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r;var i=n(3)},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function i(t,e,n){Object.keys(n).forEach(function(r){var i=n[r];"register"in i&&i.register(e),"getters"in i&&Object.defineProperty(t,r+"Getters",{value:i.getters,enumerable:!0}),"actions"in i&&!function(){var n={};Object.getOwnPropertyNames(i.actions).forEach(function(t){(0,a["default"])(i.actions[t])&&Object.defineProperty(n,t,{value:i.actions[t].bind(null,e),enumerable:!0})}),Object.defineProperty(t,r+"Actions",{value:n,enumerable:!0})}()})}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=i;var o=n(61),a=r(o)},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e["default"]={UNIT_TEMP_C:"°C",UNIT_TEMP_F:"°F"}},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(31),o=r(i),a=n(181),u=r(a),s=n(57),c=r(s),l=n(32),f=r(l),d=n(183),h=r(d);e["default"]={dateToStr:o["default"],expandGroup:u["default"],isStaleTime:c["default"],parseDateTime:f["default"],temperatureUnits:h["default"]}},function(t,e,n){var r;(function(t,i,o){(function(){"use strict";function a(t){return"function"==typeof t||"object"==typeof t&&null!==t}function u(t){return"function"==typeof t}function s(t){return"object"==typeof t&&null!==t}function c(t){W=t}function l(t){Z=t}function f(){return function(){t.nextTick(v)}}function d(){return function(){q(v)}}function h(){var t=0,e=new tt(v),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function p(){var t=new MessageChannel;return t.port1.onmessage=v,function(){t.port2.postMessage(0)}}function _(){return function(){setTimeout(v,1)}}function v(){for(var t=0;$>t;t+=2){var e=rt[t],n=rt[t+1];e(n),rt[t]=void 0,rt[t+1]=void 0}$=0}function y(){try{var t=n(201);return q=t.runOnLoop||t.runOnContext,d()}catch(e){return _()}}function m(){}function g(){return new TypeError("You cannot resolve a promise with itself")}function b(){return new TypeError("A promises callback cannot return that same promise.")}function S(t){try{return t.then}catch(e){return ut.error=e,ut}}function w(t,e,n,r){try{t.call(e,n,r)}catch(i){return i}}function O(t,e,n){Z(function(t){var r=!1,i=w(n,e,function(n){r||(r=!0,e!==n?I(t,n):D(t,n))},function(e){r||(r=!0,C(t,e))},"Settle: "+(t._label||" unknown promise"));!r&&i&&(r=!0,C(t,i))},t)}function M(t,e){e._state===ot?D(t,e._result):e._state===at?C(t,e._result):j(e,void 0,function(e){I(t,e)},function(e){C(t,e)})}function E(t,e){if(e.constructor===t.constructor)M(t,e);else{var n=S(e);n===ut?C(t,ut.error):void 0===n?D(t,e):u(n)?O(t,e,n):D(t,e)}}function I(t,e){t===e?C(t,g()):a(e)?E(t,e):D(t,e)}function T(t){t._onerror&&t._onerror(t._result),A(t)}function D(t,e){t._state===it&&(t._result=e,t._state=ot,0!==t._subscribers.length&&Z(A,t))}function C(t,e){t._state===it&&(t._state=at,t._result=e,Z(T,t))}function j(t,e,n,r){var i=t._subscribers,o=i.length;t._onerror=null,i[o]=e,i[o+ot]=n,i[o+at]=r,0===o&&t._state&&Z(A,t)}function A(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r,i,o=t._result,a=0;a<e.length;a+=3)r=e[a],i=e[a+n],r?L(n,r,i,o):i(o);t._subscribers.length=0}}function P(){this.error=null}function k(t,e){try{return t(e)}catch(n){return st.error=n,st}}function L(t,e,n,r){var i,o,a,s,c=u(n);if(c){if(i=k(n,r),i===st?(s=!0,o=i.error,i=null):a=!0,e===i)return void C(e,b())}else i=r,a=!0;e._state!==it||(c&&a?I(e,i):s?C(e,o):t===ot?D(e,i):t===at&&C(e,i))}function N(t,e){try{e(function(e){I(t,e)},function(e){C(t,e)})}catch(n){C(t,n)}}function R(t,e){var n=this;n._instanceConstructor=t,n.promise=new t(m),n._validateInput(e)?(n._input=e,n.length=e.length,n._remaining=e.length,n._init(),0===n.length?D(n.promise,n._result):(n.length=n.length||0,n._enumerate(),0===n._remaining&&D(n.promise,n._result))):C(n.promise,n._validationError())}function z(t){return new ct(this,t).promise}function x(t){function e(t){I(i,t)}funLine truncated
|
||||
@@ -178,12 +178,8 @@ class RequestHandler(SimpleHTTPRequestHandler):
|
||||
""" Does some common checks and calls appropriate method. """
|
||||
url = urlparse(self.path)
|
||||
|
||||
# Read query input
|
||||
data = parse_qs(url.query)
|
||||
|
||||
# parse_qs gives a list for each value, take the latest element
|
||||
for key in data:
|
||||
data[key] = data[key][-1]
|
||||
# Read query input. parse_qs gives a list for each value, we want last
|
||||
data = {key: data[-1] for key, data in parse_qs(url.query).items()}
|
||||
|
||||
# Did we get post input ?
|
||||
content_length = int(self.headers.get(HTTP_HEADER_CONTENT_LENGTH, 0))
|
||||
@@ -363,13 +359,13 @@ class RequestHandler(SimpleHTTPRequestHandler):
|
||||
def set_session_cookie_header(self):
|
||||
""" Add the header for the session cookie and return session id. """
|
||||
if not self.authenticated:
|
||||
return
|
||||
return None
|
||||
|
||||
session_id = self.get_cookie_session_id()
|
||||
|
||||
if session_id is not None:
|
||||
self.server.sessions.extend_validation(session_id)
|
||||
return
|
||||
return session_id
|
||||
|
||||
self.send_header(
|
||||
'Set-Cookie',
|
||||
@@ -426,10 +422,10 @@ def session_valid_time():
|
||||
|
||||
class SessionStore(object):
|
||||
""" Responsible for storing and retrieving http sessions """
|
||||
def __init__(self, enabled=True):
|
||||
def __init__(self):
|
||||
""" Set up the session store """
|
||||
self._sessions = {}
|
||||
self.lock = threading.RLock()
|
||||
self._lock = threading.RLock()
|
||||
|
||||
@util.Throttle(SESSION_CLEAR_INTERVAL)
|
||||
def _remove_expired(self):
|
||||
@@ -441,7 +437,7 @@ class SessionStore(object):
|
||||
|
||||
def is_valid(self, key):
|
||||
""" Return True if a valid session is given. """
|
||||
with self.lock:
|
||||
with self._lock:
|
||||
self._remove_expired()
|
||||
|
||||
return (key in self._sessions and
|
||||
@@ -449,17 +445,19 @@ class SessionStore(object):
|
||||
|
||||
def extend_validation(self, key):
|
||||
""" Extend a session validation time. """
|
||||
with self.lock:
|
||||
with self._lock:
|
||||
if key not in self._sessions:
|
||||
return
|
||||
self._sessions[key] = session_valid_time()
|
||||
|
||||
def destroy(self, key):
|
||||
""" Destroy a session by key. """
|
||||
with self.lock:
|
||||
with self._lock:
|
||||
self._sessions.pop(key, None)
|
||||
|
||||
def create(self):
|
||||
""" Creates a new session. """
|
||||
with self.lock:
|
||||
with self._lock:
|
||||
session_id = util.get_random_string(20)
|
||||
|
||||
while session_id in self._sessions:
|
||||
|
||||
@@ -42,7 +42,7 @@ class WinkLight(WinkToggleDevice):
|
||||
brightness = kwargs.get(ATTR_BRIGHTNESS)
|
||||
|
||||
if brightness is not None:
|
||||
self.wink.set_state(True, brightness / 255)
|
||||
self.wink.set_state(True, brightness=brightness / 255)
|
||||
|
||||
else:
|
||||
self.wink.set_state(True)
|
||||
|
||||
@@ -15,7 +15,7 @@ from homeassistant.const import (
|
||||
from homeassistant.components.media_player import (
|
||||
MediaPlayerDevice,
|
||||
SUPPORT_PAUSE, SUPPORT_VOLUME_SET, SUPPORT_VOLUME_MUTE,
|
||||
SUPPORT_TURN_ON, SUPPORT_TURN_OFF, SUPPORT_YOUTUBE,
|
||||
SUPPORT_TURN_ON, SUPPORT_TURN_OFF, SUPPORT_YOUTUBE, SUPPORT_PLAY_MEDIA,
|
||||
SUPPORT_PREVIOUS_TRACK, SUPPORT_NEXT_TRACK,
|
||||
MEDIA_TYPE_MUSIC, MEDIA_TYPE_TVSHOW, MEDIA_TYPE_VIDEO)
|
||||
|
||||
@@ -24,7 +24,7 @@ CONF_IGNORE_CEC = 'ignore_cec'
|
||||
CAST_SPLASH = 'https://home-assistant.io/images/cast/splash.png'
|
||||
SUPPORT_CAST = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \
|
||||
SUPPORT_TURN_ON | SUPPORT_TURN_OFF | SUPPORT_PREVIOUS_TRACK | \
|
||||
SUPPORT_NEXT_TRACK | SUPPORT_YOUTUBE
|
||||
SUPPORT_NEXT_TRACK | SUPPORT_YOUTUBE | SUPPORT_PLAY_MEDIA
|
||||
KNOWN_HOSTS = []
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
@@ -261,6 +261,10 @@ class CastDevice(MediaPlayerDevice):
|
||||
""" Seek the media to a specific location. """
|
||||
self.cast.media_controller.seek(position)
|
||||
|
||||
def play_media(self, media_type, media_id):
|
||||
""" Plays media from a URL """
|
||||
self.cast.media_controller.play_media(media_id, media_type)
|
||||
|
||||
def play_youtube(self, media_id):
|
||||
""" Plays a YouTube media. """
|
||||
self.youtube.play_video(media_id)
|
||||
|
||||
@@ -21,14 +21,14 @@ from homeassistant.const import (
|
||||
from homeassistant.components.media_player import (
|
||||
MediaPlayerDevice,
|
||||
SUPPORT_PAUSE, SUPPORT_VOLUME_SET, SUPPORT_TURN_OFF,
|
||||
SUPPORT_PREVIOUS_TRACK, SUPPORT_NEXT_TRACK,
|
||||
SUPPORT_TURN_ON, SUPPORT_PREVIOUS_TRACK, SUPPORT_NEXT_TRACK,
|
||||
MEDIA_TYPE_MUSIC)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
REQUIREMENTS = ['python-mpd2==0.5.4']
|
||||
|
||||
SUPPORT_MPD = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_TURN_OFF | \
|
||||
SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK
|
||||
SUPPORT_TURN_ON | SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
@@ -141,7 +141,13 @@ class MpdDevice(MediaPlayerDevice):
|
||||
@property
|
||||
def media_title(self):
|
||||
""" Title of current playing media. """
|
||||
return self.currentsong['title']
|
||||
name = self.currentsong.get('name', None)
|
||||
title = self.currentsong['title']
|
||||
|
||||
if name is None:
|
||||
return title
|
||||
else:
|
||||
return '{}: {}'.format(name, title)
|
||||
|
||||
@property
|
||||
def media_artist(self):
|
||||
@@ -163,9 +169,13 @@ class MpdDevice(MediaPlayerDevice):
|
||||
return SUPPORT_MPD
|
||||
|
||||
def turn_off(self):
|
||||
""" Service to exit the running MPD. """
|
||||
""" Service to send the MPD the command to stop playing. """
|
||||
self.client.stop()
|
||||
|
||||
def turn_on(self):
|
||||
""" Service to send the MPD the command to start playing. """
|
||||
self.client.play()
|
||||
|
||||
def set_volume_level(self, volume):
|
||||
""" Sets volume """
|
||||
self.client.setvol(int(volume * 100))
|
||||
|
||||
@@ -11,9 +11,11 @@ import logging
|
||||
|
||||
import requests
|
||||
|
||||
from homeassistant.const import DEVICE_DEFAULT_NAME
|
||||
from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT, CONF_VALUE_TEMPLATE, \
|
||||
DEVICE_DEFAULT_NAME
|
||||
from homeassistant.exceptions import TemplateError
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
from homeassistant.util import template, Throttle
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -50,36 +52,50 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
arest = ArestData(resource)
|
||||
|
||||
def make_renderer(value_template):
|
||||
""" Creates renderer based on variable_template value """
|
||||
if value_template is None:
|
||||
return lambda value: value
|
||||
|
||||
def _render(value):
|
||||
try:
|
||||
return template.render(hass, value_template, {'value': value})
|
||||
except TemplateError:
|
||||
_LOGGER.exception('Error parsing value')
|
||||
return value
|
||||
|
||||
return _render
|
||||
|
||||
dev = []
|
||||
|
||||
if var_conf is not None:
|
||||
for variable in config['monitored_variables']:
|
||||
for variable in var_conf:
|
||||
if variable['name'] not in response['variables']:
|
||||
_LOGGER.error('Variable: "%s" does not exist',
|
||||
variable['name'])
|
||||
continue
|
||||
|
||||
renderer = make_renderer(variable.get(CONF_VALUE_TEMPLATE))
|
||||
dev.append(ArestSensor(arest,
|
||||
resource,
|
||||
config.get('name', response['name']),
|
||||
variable['name'],
|
||||
variable=variable['name'],
|
||||
unit_of_measurement=variable.get(
|
||||
'unit_of_measurement')))
|
||||
ATTR_UNIT_OF_MEASUREMENT),
|
||||
renderer=renderer))
|
||||
|
||||
if pins is not None:
|
||||
for pinnum, pin in pins.items():
|
||||
renderer = make_renderer(pin.get(CONF_VALUE_TEMPLATE))
|
||||
dev.append(ArestSensor(ArestData(resource, pinnum),
|
||||
resource,
|
||||
config.get('name', response['name']),
|
||||
pin.get('name'),
|
||||
pin=pinnum,
|
||||
unit_of_measurement=pin.get(
|
||||
'unit_of_measurement'),
|
||||
corr_factor=pin.get('correction_factor',
|
||||
None),
|
||||
decimal_places=pin.get('decimal_places',
|
||||
None)))
|
||||
ATTR_UNIT_OF_MEASUREMENT),
|
||||
renderer=renderer))
|
||||
|
||||
add_devices(dev)
|
||||
|
||||
@@ -89,8 +105,7 @@ class ArestSensor(Entity):
|
||||
""" Implements an aREST sensor for exposed variables. """
|
||||
|
||||
def __init__(self, arest, resource, location, name, variable=None,
|
||||
pin=None, unit_of_measurement=None, corr_factor=None,
|
||||
decimal_places=None):
|
||||
pin=None, unit_of_measurement=None, renderer=None):
|
||||
self.arest = arest
|
||||
self._resource = resource
|
||||
self._name = '{} {}'.format(location.title(), name.title()) \
|
||||
@@ -99,8 +114,7 @@ class ArestSensor(Entity):
|
||||
self._pin = pin
|
||||
self._state = 'n/a'
|
||||
self._unit_of_measurement = unit_of_measurement
|
||||
self._corr_factor = corr_factor
|
||||
self._decimal_places = decimal_places
|
||||
self._renderer = renderer
|
||||
self.update()
|
||||
|
||||
if self._pin is not None:
|
||||
@@ -126,17 +140,11 @@ class ArestSensor(Entity):
|
||||
|
||||
if 'error' in values:
|
||||
return values['error']
|
||||
elif 'value' in values:
|
||||
value = values['value']
|
||||
if self._corr_factor is not None:
|
||||
value = float(value) * float(self._corr_factor)
|
||||
if self._decimal_places is not None:
|
||||
value = round(value, self._decimal_places)
|
||||
if self._decimal_places == 0:
|
||||
value = int(value)
|
||||
return value
|
||||
else:
|
||||
return values.get(self._variable, 'n/a')
|
||||
|
||||
value = self._renderer(values.get('value',
|
||||
values.get(self._variable,
|
||||
'N/A')))
|
||||
return value
|
||||
|
||||
def update(self):
|
||||
""" Gets the latest data from aREST API. """
|
||||
|
||||
@@ -10,8 +10,9 @@ import logging
|
||||
import subprocess
|
||||
from datetime import timedelta
|
||||
|
||||
from homeassistant.const import CONF_VALUE_TEMPLATE
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
from homeassistant.util import template, Throttle
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -32,25 +33,24 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||
data = CommandSensorData(config.get('command'))
|
||||
|
||||
add_devices_callback([CommandSensor(
|
||||
hass,
|
||||
data,
|
||||
config.get('name', DEFAULT_NAME),
|
||||
config.get('unit_of_measurement'),
|
||||
config.get('correction_factor', None),
|
||||
config.get('decimal_places', None)
|
||||
config.get(CONF_VALUE_TEMPLATE)
|
||||
)])
|
||||
|
||||
|
||||
# pylint: disable=too-many-arguments
|
||||
class CommandSensor(Entity):
|
||||
""" Represents a sensor that is returning a value of a shell commands. """
|
||||
def __init__(self, data, name, unit_of_measurement, corr_factor,
|
||||
decimal_places):
|
||||
def __init__(self, hass, data, name, unit_of_measurement, value_template):
|
||||
self._hass = hass
|
||||
self.data = data
|
||||
self._name = name
|
||||
self._state = False
|
||||
self._unit_of_measurement = unit_of_measurement
|
||||
self._corr_factor = corr_factor
|
||||
self._decimal_places = decimal_places
|
||||
self._value_template = value_template
|
||||
self.update()
|
||||
|
||||
@property
|
||||
@@ -73,16 +73,10 @@ class CommandSensor(Entity):
|
||||
self.data.update()
|
||||
value = self.data.value
|
||||
|
||||
try:
|
||||
if value is not None:
|
||||
if self._corr_factor is not None:
|
||||
value = float(value) * float(self._corr_factor)
|
||||
if self._decimal_places is not None:
|
||||
value = round(value, self._decimal_places)
|
||||
if self._decimal_places == 0:
|
||||
value = int(value)
|
||||
self._state = value
|
||||
except ValueError:
|
||||
if self._value_template is not None:
|
||||
self._state = template.render_with_possible_json_value(
|
||||
self._hass, self._value_template, value, 'N/A')
|
||||
else:
|
||||
self._state = value
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
"""
|
||||
homeassistant.components.sensor.dweet
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Displays values from Dweet.io.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.dweet/
|
||||
"""
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
import json
|
||||
|
||||
from homeassistant.util import Throttle
|
||||
from homeassistant.util import template
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.const import (STATE_UNKNOWN, CONF_VALUE_TEMPLATE)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
REQUIREMENTS = ['dweepy==0.2.0']
|
||||
|
||||
DEFAULT_NAME = 'Dweet.io Sensor'
|
||||
CONF_DEVICE = 'device'
|
||||
|
||||
# Return cached results if last scan was less then this time ago
|
||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60)
|
||||
|
||||
|
||||
# pylint: disable=unused-variable, too-many-function-args
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
""" Setup the Dweet sensor. """
|
||||
import dweepy
|
||||
|
||||
device = config.get('device')
|
||||
value_template = config.get(CONF_VALUE_TEMPLATE)
|
||||
|
||||
if None in (device, value_template):
|
||||
_LOGGER.error('Not all required config keys present: %s',
|
||||
', '.join(CONF_DEVICE, CONF_VALUE_TEMPLATE))
|
||||
return False
|
||||
|
||||
try:
|
||||
content = json.dumps(dweepy.get_latest_dweet_for(device)[0]['content'])
|
||||
except dweepy.DweepyError:
|
||||
_LOGGER.error("Device/thing '%s' could not be found", device)
|
||||
return False
|
||||
|
||||
if template.render_with_possible_json_value(hass,
|
||||
value_template,
|
||||
content) is '':
|
||||
_LOGGER.error("'%s' was not found", value_template)
|
||||
return False
|
||||
|
||||
dweet = DweetData(device)
|
||||
|
||||
add_devices([DweetSensor(hass,
|
||||
dweet,
|
||||
config.get('name', DEFAULT_NAME),
|
||||
value_template,
|
||||
config.get('unit_of_measurement'))])
|
||||
|
||||
|
||||
# pylint: disable=too-many-arguments
|
||||
class DweetSensor(Entity):
|
||||
""" Implements a Dweet sensor. """
|
||||
|
||||
def __init__(self, hass, dweet, name, value_template, unit_of_measurement):
|
||||
self.hass = hass
|
||||
self.dweet = dweet
|
||||
self._name = name
|
||||
self._value_template = value_template
|
||||
self._state = STATE_UNKNOWN
|
||||
self._unit_of_measurement = unit_of_measurement
|
||||
self.update()
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" The name of the sensor. """
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
""" Unit the value is expressed in. """
|
||||
return self._unit_of_measurement
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
""" Returns the state. """
|
||||
if self.dweet.data is None:
|
||||
return STATE_UNKNOWN
|
||||
else:
|
||||
values = json.dumps(self.dweet.data[0]['content'])
|
||||
value = template.render_with_possible_json_value(
|
||||
self.hass, self._value_template, values)
|
||||
return value
|
||||
|
||||
def update(self):
|
||||
""" Gets the latest data from REST API. """
|
||||
self.dweet.update()
|
||||
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
class DweetData(object):
|
||||
""" Class for handling the data retrieval. """
|
||||
|
||||
def __init__(self, device):
|
||||
self._device = device
|
||||
self.data = None
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||
def update(self):
|
||||
""" Gets the latest data from Dweet.io. """
|
||||
import dweepy
|
||||
|
||||
try:
|
||||
self.data = dweepy.get_latest_dweet_for(self._device)
|
||||
except dweepy.DweepyError:
|
||||
_LOGGER.error("Device '%s' could not be found", self._device)
|
||||
self.data = None
|
||||
@@ -79,7 +79,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
if resource not in SENSOR_TYPES:
|
||||
_LOGGER.error('Sensor type: "%s" does not exist', resource)
|
||||
else:
|
||||
dev.append(GlancesSensor(rest, resource))
|
||||
dev.append(GlancesSensor(rest, config.get('name'), resource))
|
||||
|
||||
add_devices(dev)
|
||||
|
||||
@@ -87,9 +87,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
class GlancesSensor(Entity):
|
||||
""" Implements a Glances sensor. """
|
||||
|
||||
def __init__(self, rest, sensor_type):
|
||||
def __init__(self, rest, name, sensor_type):
|
||||
self.rest = rest
|
||||
self._name = SENSOR_TYPES[sensor_type][0]
|
||||
self._name = name
|
||||
self.type = sensor_type
|
||||
self._state = STATE_UNKNOWN
|
||||
self._unit_of_measurement = SENSOR_TYPES[sensor_type][1]
|
||||
@@ -98,7 +98,10 @@ class GlancesSensor(Entity):
|
||||
@property
|
||||
def name(self):
|
||||
""" The name of the sensor. """
|
||||
return self._name
|
||||
if self._name is None:
|
||||
return SENSOR_TYPES[self.type][0]
|
||||
else:
|
||||
return '{} {}'.format(self._name, SENSOR_TYPES[self.type][0])
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
"""
|
||||
homeassistant.components.sensor.rest
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
The rest sensor will consume JSON responses sent by an exposed REST API.
|
||||
The rest sensor will consume responses sent by an exposed REST API.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.rest/
|
||||
"""
|
||||
from datetime import timedelta
|
||||
from json import loads
|
||||
import logging
|
||||
|
||||
import requests
|
||||
|
||||
from homeassistant.util import Throttle
|
||||
from homeassistant.const import CONF_VALUE_TEMPLATE
|
||||
from homeassistant.util import template, Throttle
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@@ -59,57 +58,31 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
'Please check the URL in the configuration file.')
|
||||
return False
|
||||
|
||||
try:
|
||||
data = loads(response.text)
|
||||
except ValueError:
|
||||
_LOGGER.error('No valid JSON in the response in: %s', data)
|
||||
return False
|
||||
|
||||
try:
|
||||
RestSensor.extract_value(data, config.get('variable'))
|
||||
except KeyError:
|
||||
_LOGGER.error('Variable "%s" not found in response: "%s"',
|
||||
config.get('variable'), data)
|
||||
return False
|
||||
|
||||
if use_get:
|
||||
rest = RestDataGet(resource, verify_ssl)
|
||||
elif use_post:
|
||||
rest = RestDataPost(resource, payload, verify_ssl)
|
||||
|
||||
add_devices([RestSensor(rest,
|
||||
add_devices([RestSensor(hass,
|
||||
rest,
|
||||
config.get('name', DEFAULT_NAME),
|
||||
config.get('variable'),
|
||||
config.get('unit_of_measurement'),
|
||||
config.get('correction_factor', None),
|
||||
config.get('decimal_places', None))])
|
||||
config.get(CONF_VALUE_TEMPLATE))])
|
||||
|
||||
|
||||
# pylint: disable=too-many-arguments
|
||||
class RestSensor(Entity):
|
||||
""" Implements a REST sensor. """
|
||||
|
||||
def __init__(self, rest, name, variable, unit_of_measurement, corr_factor,
|
||||
decimal_places):
|
||||
def __init__(self, hass, rest, name, unit_of_measurement, value_template):
|
||||
self._hass = hass
|
||||
self.rest = rest
|
||||
self._name = name
|
||||
self._variable = variable
|
||||
self._state = 'n/a'
|
||||
self._unit_of_measurement = unit_of_measurement
|
||||
self._corr_factor = corr_factor
|
||||
self._decimal_places = decimal_places
|
||||
self._value_template = value_template
|
||||
self.update()
|
||||
|
||||
@classmethod
|
||||
def extract_value(cls, data, variable):
|
||||
""" Extracts the value using a key name or a path. """
|
||||
if isinstance(variable, list):
|
||||
for variable_item in variable:
|
||||
data = data[variable_item]
|
||||
return data
|
||||
else:
|
||||
return data[variable]
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" The name of the sensor. """
|
||||
@@ -133,18 +106,10 @@ class RestSensor(Entity):
|
||||
if 'error' in value:
|
||||
self._state = value['error']
|
||||
else:
|
||||
try:
|
||||
if value is not None:
|
||||
value = RestSensor.extract_value(value, self._variable)
|
||||
if self._corr_factor is not None:
|
||||
value = float(value) * float(self._corr_factor)
|
||||
if self._decimal_places is not None:
|
||||
value = round(value, self._decimal_places)
|
||||
if self._decimal_places == 0:
|
||||
value = int(value)
|
||||
self._state = value
|
||||
except ValueError:
|
||||
self._state = RestSensor.extract_value(value, self._variable)
|
||||
if self._value_template is not None:
|
||||
value = template.render_with_possible_json_value(
|
||||
self._hass, self._value_template, value, 'N/A')
|
||||
self._state = value
|
||||
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
@@ -164,7 +129,7 @@ class RestDataGet(object):
|
||||
verify=self._verify_ssl)
|
||||
if 'error' in self.data:
|
||||
del self.data['error']
|
||||
self.data = response.json()
|
||||
self.data = response.text
|
||||
except requests.exceptions.ConnectionError:
|
||||
_LOGGER.error("No route to resource/endpoint.")
|
||||
self.data['error'] = 'N/A'
|
||||
@@ -188,7 +153,7 @@ class RestDataPost(object):
|
||||
timeout=10, verify=self._verify_ssl)
|
||||
if 'error' in self.data:
|
||||
del self.data['error']
|
||||
self.data = response.json()
|
||||
self.data = response.text
|
||||
except requests.exceptions.ConnectionError:
|
||||
_LOGGER.error("No route to resource/endpoint.")
|
||||
self.data['error'] = 'N/A'
|
||||
@@ -0,0 +1,82 @@
|
||||
"""
|
||||
homeassistant.components.sensor.twitch
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Twitch stream status.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.twitch/
|
||||
"""
|
||||
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.const import ATTR_ENTITY_PICTURE
|
||||
|
||||
STATE_STREAMING = 'streaming'
|
||||
STATE_OFFLINE = 'offline'
|
||||
ATTR_GAME = 'game'
|
||||
ATTR_TITLE = 'title'
|
||||
ICON = 'mdi:twitch'
|
||||
|
||||
REQUIREMENTS = ['python-twitch==1.2.0']
|
||||
DOMAIN = 'twitch'
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
""" Sets up the Twitch platform. """
|
||||
add_devices(
|
||||
[TwitchSensor(channel) for channel in config.get('channels', [])])
|
||||
|
||||
|
||||
class TwitchSensor(Entity):
|
||||
""" Represents an Twitch channel. """
|
||||
|
||||
# pylint: disable=abstract-method
|
||||
def __init__(self, channel):
|
||||
self._channel = channel
|
||||
self._state = STATE_OFFLINE
|
||||
self._preview = None
|
||||
self._game = None
|
||||
self._title = None
|
||||
self.update()
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
""" Device should be polled. """
|
||||
return True
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" Returns the name of the device. """
|
||||
return self._channel
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
""" State of the sensor. """
|
||||
return self._state
|
||||
|
||||
# pylint: disable=no-member
|
||||
def update(self):
|
||||
""" Update device state. """
|
||||
from twitch.api import v3 as twitch
|
||||
stream = twitch.streams.by_channel(self._channel).get('stream')
|
||||
if stream:
|
||||
self._game = stream.get('channel').get('game')
|
||||
self._title = stream.get('channel').get('status')
|
||||
self._preview = stream.get('preview').get('small')
|
||||
self._state = STATE_STREAMING
|
||||
else:
|
||||
self._state = STATE_OFFLINE
|
||||
|
||||
@property
|
||||
def state_attributes(self):
|
||||
""" Returns the state attributes. """
|
||||
if self._state == STATE_STREAMING:
|
||||
return {
|
||||
ATTR_GAME: self._game,
|
||||
ATTR_TITLE: self._title,
|
||||
ATTR_ENTITY_PICTURE: self._preview
|
||||
}
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
return ICON
|
||||
@@ -11,7 +11,7 @@ import logging
|
||||
from homeassistant.components.switch import SwitchDevice
|
||||
|
||||
DEFAULT_NAME = "Orvibo S20 Switch"
|
||||
REQUIREMENTS = ['orvibo==1.0.1']
|
||||
REQUIREMENTS = ['orvibo==1.1.0']
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/thermostat.heatmiser/
|
||||
"""
|
||||
import logging
|
||||
import heatmiserV3
|
||||
from homeassistant.components.thermostat import ThermostatDevice
|
||||
from homeassistant.const import TEMP_CELCIUS
|
||||
|
||||
@@ -26,6 +25,8 @@ _LOGGER = logging.getLogger(__name__)
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
""" Sets up the heatmiser thermostat. """
|
||||
|
||||
from heatmiserV3 import heatmiser, connection
|
||||
|
||||
ipaddress = str(config[CONF_IPADDRESS])
|
||||
port = str(config[CONF_PORT])
|
||||
|
||||
@@ -34,7 +35,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
CONF_IPADDRESS, CONF_PORT)
|
||||
return False
|
||||
|
||||
serport = heatmiserV3.connection.connection(ipaddress, port)
|
||||
serport = connection.connection(ipaddress, port)
|
||||
serport.open()
|
||||
|
||||
tstats = []
|
||||
@@ -48,6 +49,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
for tstat in tstats:
|
||||
add_devices([
|
||||
HeatmiserV3Thermostat(
|
||||
heatmiser,
|
||||
tstat.get("id"),
|
||||
tstat.get("name"),
|
||||
serport)
|
||||
@@ -58,7 +60,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
class HeatmiserV3Thermostat(ThermostatDevice):
|
||||
""" Represents a HeatmiserV3 thermostat. """
|
||||
|
||||
def __init__(self, device, name, serport):
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
def __init__(self, heatmiser, device, name, serport):
|
||||
self.heatmiser = heatmiser
|
||||
self.device = device
|
||||
self.serport = serport
|
||||
self._current_temperature = None
|
||||
@@ -98,7 +102,7 @@ class HeatmiserV3Thermostat(ThermostatDevice):
|
||||
def set_temperature(self, temperature):
|
||||
""" Set new target temperature """
|
||||
temperature = int(temperature)
|
||||
heatmiserV3.heatmiser.hmSendAddress(
|
||||
self.heatmiser.hmSendAddress(
|
||||
self._id,
|
||||
18,
|
||||
temperature,
|
||||
@@ -107,7 +111,7 @@ class HeatmiserV3Thermostat(ThermostatDevice):
|
||||
self._target_temperature = int(temperature)
|
||||
|
||||
def update(self):
|
||||
self.dcb = heatmiserV3.heatmiser.hmReadAddress(
|
||||
self.dcb = self.heatmiser.hmReadAddress(
|
||||
self._id,
|
||||
'prt',
|
||||
self.serport)
|
||||
@@ -14,3 +14,10 @@ class InvalidEntityFormatError(HomeAssistantError):
|
||||
class NoEntitySpecifiedError(HomeAssistantError):
|
||||
""" When no entity is specified. """
|
||||
pass
|
||||
|
||||
|
||||
class TemplateError(HomeAssistantError):
|
||||
""" Error during template rendering. """
|
||||
def __init__(self, exception):
|
||||
super().__init__('{}: {}'.format(exception.__class__.__name__,
|
||||
exception))
|
||||
@@ -6,10 +6,18 @@ Template utility methods for rendering strings with HA data.
|
||||
"""
|
||||
# pylint: disable=too-few-public-methods
|
||||
import json
|
||||
import logging
|
||||
import jinja2
|
||||
from jinja2.sandbox import ImmutableSandboxedEnvironment
|
||||
from homeassistant.const import STATE_UNKNOWN
|
||||
from homeassistant.exceptions import TemplateError
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
_SENTINEL = object()
|
||||
|
||||
|
||||
def render_with_possible_json_value(hass, template, value):
|
||||
def render_with_possible_json_value(hass, template, value,
|
||||
error_value=_SENTINEL):
|
||||
""" Renders template with value exposed.
|
||||
If valid JSON will expose value_json too. """
|
||||
variables = {
|
||||
@@ -20,7 +28,11 @@ def render_with_possible_json_value(hass, template, value):
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
return render(hass, template, variables)
|
||||
try:
|
||||
return render(hass, template, variables)
|
||||
except TemplateError:
|
||||
_LOGGER.exception('Error parsing value')
|
||||
return value if error_value is _SENTINEL else error_value
|
||||
|
||||
|
||||
def render(hass, template, variables=None, **kwargs):
|
||||
@@ -28,9 +40,13 @@ def render(hass, template, variables=None, **kwargs):
|
||||
if variables is not None:
|
||||
kwargs.update(variables)
|
||||
|
||||
return ENV.from_string(template, {
|
||||
'states': AllStates(hass)
|
||||
}).render(kwargs)
|
||||
try:
|
||||
return ENV.from_string(template, {
|
||||
'states': AllStates(hass),
|
||||
'is_state': hass.states.is_state
|
||||
}).render(kwargs).strip()
|
||||
except jinja2.TemplateError as err:
|
||||
raise TemplateError(err)
|
||||
|
||||
|
||||
class AllStates(object):
|
||||
@@ -45,6 +61,10 @@ class AllStates(object):
|
||||
return iter(sorted(self._hass.states.all(),
|
||||
key=lambda state: state.entity_id))
|
||||
|
||||
def __call__(self, entity_id):
|
||||
state = self._hass.states.get(entity_id)
|
||||
return STATE_UNKNOWN if state is None else state.state
|
||||
|
||||
|
||||
class DomainStates(object):
|
||||
""" Class to expose a specific HA domain as attributes. """
|
||||
@@ -66,8 +86,8 @@ class DomainStates(object):
|
||||
def forgiving_round(value, precision=0):
|
||||
""" Rounding method that accepts strings. """
|
||||
try:
|
||||
return int(float(value)) if precision == 0 else round(float(value),
|
||||
precision)
|
||||
value = round(float(value), precision)
|
||||
return int(value) if precision == 0 else value
|
||||
except ValueError:
|
||||
# If value can't be converted to float
|
||||
return value
|
||||
@@ -81,6 +101,13 @@ def multiply(value, amount):
|
||||
# If value can't be converted to float
|
||||
return value
|
||||
|
||||
ENV = ImmutableSandboxedEnvironment()
|
||||
|
||||
class TemplateEnvironment(ImmutableSandboxedEnvironment):
|
||||
""" Home Assistant template environment. """
|
||||
|
||||
def is_safe_callable(self, obj):
|
||||
return isinstance(obj, AllStates) or super().is_safe_callable(obj)
|
||||
|
||||
ENV = TemplateEnvironment()
|
||||
ENV.filters['round'] = forgiving_round
|
||||
ENV.filters['multiply'] = multiply
|
||||
+1
-1
@@ -2,4 +2,4 @@ requests>=2,<3
|
||||
pyyaml>=3.11,<4
|
||||
pytz>=2015.4
|
||||
pip>=7.0.0
|
||||
vincenty==0.1.3
|
||||
vincenty==0.1.3
|
||||
@@ -63,7 +63,11 @@ https://github.com/pavoni/home-assistant-vera-api/archive/efdba4e63d58a30bc9b36d
|
||||
# homeassistant.components.lock.wink
|
||||
# homeassistant.components.sensor.wink
|
||||
# homeassistant.components.switch.wink
|
||||
<<<<<<< HEAD
|
||||
https://github.com/bradsk88/python-wink/archive/d3fcce7528bd031a2c05363a108628acc4eb03aa.zip#python-wink==0.3.1
|
||||
=======
|
||||
https://github.com/bradsk88/python-wink/archive/91c8e9a5df24c8dd1a5267dc29a00a40c11d826a.zip#python-wink==0.3
|
||||
>>>>>>> 7fb5927ac80273d9b5e087defe72765f2ce3227a
|
||||
|
||||
# homeassistant.components.media_player.cast
|
||||
pychromecast==0.6.12
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
echo "Bootstrapping frontend..."
|
||||
cd homeassistant/components/frontend/www_static/home-assistant-polymer
|
||||
npm install
|
||||
bower install
|
||||
npm run setup_js_dev
|
||||
cd ../../../../..
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
from setuptools import setup, find_packages
|
||||
from homeassistant.const import __version__
|
||||
|
||||
@@ -295,7 +295,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
||||
'trigger': {
|
||||
'platform': 'numeric_state',
|
||||
'entity_id': 'test.entity',
|
||||
'attribute': 'test_attribute',
|
||||
'value_template': '{{ state.attributes.test_attribute }}',
|
||||
'below': 10,
|
||||
},
|
||||
'action': {
|
||||
@@ -314,7 +314,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
||||
'trigger': {
|
||||
'platform': 'numeric_state',
|
||||
'entity_id': 'test.entity',
|
||||
'attribute': 'test_attribute',
|
||||
'value_template': '{{ state.attributes.test_attribute }}',
|
||||
'below': 10,
|
||||
},
|
||||
'action': {
|
||||
@@ -333,7 +333,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
||||
'trigger': {
|
||||
'platform': 'numeric_state',
|
||||
'entity_id': 'test.entity',
|
||||
'attribute': 'test_attribute',
|
||||
'value_template': '{{ state.attributes.test_attribute }}',
|
||||
'below': 10,
|
||||
},
|
||||
'action': {
|
||||
@@ -352,7 +352,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
||||
'trigger': {
|
||||
'platform': 'numeric_state',
|
||||
'entity_id': 'test.entity',
|
||||
'attribute': 'test_attribute',
|
||||
'value_template': '{{ state.attributes.test_attribute }}',
|
||||
'below': 10,
|
||||
},
|
||||
'action': {
|
||||
@@ -371,7 +371,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
||||
'trigger': {
|
||||
'platform': 'numeric_state',
|
||||
'entity_id': 'test.entity',
|
||||
'attribute': 'test_attribute',
|
||||
'value_template': '{{ state.attributes.test_attribute }}',
|
||||
'below': 10,
|
||||
},
|
||||
'action': {
|
||||
@@ -384,13 +384,51 @@ class TestAutomationNumericState(unittest.TestCase):
|
||||
self.hass.pool.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_template_list(self):
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
'platform': 'numeric_state',
|
||||
'entity_id': 'test.entity',
|
||||
'value_template': '{{ state.attributes.test_attribute[2] }}',
|
||||
'below': 10,
|
||||
},
|
||||
'action': {
|
||||
'service': 'test.automation'
|
||||
}
|
||||
}
|
||||
}))
|
||||
# 3 is below 10
|
||||
self.hass.states.set('test.entity', 'entity', { 'test_attribute': [11, 15, 3] })
|
||||
self.hass.pool.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_template_string(self):
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
'platform': 'numeric_state',
|
||||
'entity_id': 'test.entity',
|
||||
'value_template': '{{ state.attributes.test_attribute | multiply(10) }}',
|
||||
'below': 10,
|
||||
},
|
||||
'action': {
|
||||
'service': 'test.automation'
|
||||
}
|
||||
}
|
||||
}))
|
||||
# 9 is below 10
|
||||
self.hass.states.set('test.entity', 'entity', { 'test_attribute': '0.9' })
|
||||
self.hass.pool.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_if_not_fires_on_attribute_change_with_attribute_not_below_multiple_attributes(self):
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
'platform': 'numeric_state',
|
||||
'entity_id': 'test.entity',
|
||||
'attribute': 'test_attribute',
|
||||
'value_template': '{{ state.attributes.test_attribute }}',
|
||||
'below': 10,
|
||||
},
|
||||
'action': {
|
||||
|
||||
@@ -0,0 +1,225 @@
|
||||
"""
|
||||
tests.test_component_alexa
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Tests Home Assistant Alexa component does what it should do.
|
||||
"""
|
||||
# pylint: disable=protected-access,too-many-public-methods
|
||||
import unittest
|
||||
import json
|
||||
from unittest.mock import patch
|
||||
|
||||
import requests
|
||||
|
||||
from homeassistant import bootstrap, const
|
||||
import homeassistant.core as ha
|
||||
from homeassistant.components import alexa, http
|
||||
|
||||
API_PASSWORD = "test1234"
|
||||
|
||||
# Somehow the socket that holds the default port does not get released
|
||||
# when we close down HA in a different test case. Until I have figured
|
||||
# out what is going on, let's run this test on a different port.
|
||||
SERVER_PORT = 8119
|
||||
|
||||
API_URL = "http://127.0.0.1:{}{}".format(SERVER_PORT, alexa.API_ENDPOINT)
|
||||
|
||||
HA_HEADERS = {const.HTTP_HEADER_HA_AUTH: API_PASSWORD}
|
||||
|
||||
hass = None
|
||||
|
||||
|
||||
@patch('homeassistant.components.http.util.get_local_ip',
|
||||
return_value='127.0.0.1')
|
||||
def setUpModule(mock_get_local_ip): # pylint: disable=invalid-name
|
||||
""" Initalizes a Home Assistant server. """
|
||||
global hass
|
||||
|
||||
hass = ha.HomeAssistant()
|
||||
|
||||
bootstrap.setup_component(
|
||||
hass, http.DOMAIN,
|
||||
{http.DOMAIN: {http.CONF_API_PASSWORD: API_PASSWORD,
|
||||
http.CONF_SERVER_PORT: SERVER_PORT}})
|
||||
|
||||
bootstrap.setup_component(hass, alexa.DOMAIN, {
|
||||
'alexa': {
|
||||
'intents': {
|
||||
'WhereAreWeIntent': {
|
||||
'speech': {
|
||||
'type': 'plaintext',
|
||||
'text':
|
||||
"""
|
||||
{%- if is_state('device_tracker.paulus', 'home') and is_state('device_tracker.anne_therese', 'home') -%}
|
||||
You are both home, you silly
|
||||
{%- else -%}
|
||||
Anne Therese is at {{ states("device_tracker.anne_therese") }} and Paulus is at {{ states("device_tracker.paulus") }}
|
||||
{% endif %}
|
||||
""",
|
||||
}
|
||||
},
|
||||
'GetZodiacHoroscopeIntent': {
|
||||
'speech': {
|
||||
'type': 'plaintext',
|
||||
'text': 'You told us your sign is {{ ZodiacSign }}.'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
hass.start()
|
||||
|
||||
|
||||
def tearDownModule(): # pylint: disable=invalid-name
|
||||
""" Stops the Home Assistant server. """
|
||||
hass.stop()
|
||||
|
||||
|
||||
def _req(data={}):
|
||||
return requests.post(API_URL, data=json.dumps(data), timeout=5,
|
||||
headers=HA_HEADERS)
|
||||
|
||||
|
||||
class TestAlexa(unittest.TestCase):
|
||||
""" Test Alexa. """
|
||||
|
||||
def test_launch_request(self):
|
||||
data = {
|
||||
'version': '1.0',
|
||||
'session': {
|
||||
'new': True,
|
||||
'sessionId': 'amzn1.echo-api.session.0000000-0000-0000-0000-00000000000',
|
||||
'application': {
|
||||
'applicationId': 'amzn1.echo-sdk-ams.app.000000-d0ed-0000-ad00-000000d00ebe'
|
||||
},
|
||||
'attributes': {},
|
||||
'user': {
|
||||
'userId': 'amzn1.account.AM3B00000000000000000000000'
|
||||
}
|
||||
},
|
||||
'request': {
|
||||
'type': 'LaunchRequest',
|
||||
'requestId': 'amzn1.echo-api.request.0000000-0000-0000-0000-00000000000',
|
||||
'timestamp': '2015-05-13T12:34:56Z'
|
||||
}
|
||||
}
|
||||
req = _req(data)
|
||||
self.assertEqual(200, req.status_code)
|
||||
resp = req.json()
|
||||
self.assertIn('outputSpeech', resp['response'])
|
||||
|
||||
def test_intent_request_with_slots(self):
|
||||
data = {
|
||||
'version': '1.0',
|
||||
'session': {
|
||||
'new': False,
|
||||
'sessionId': 'amzn1.echo-api.session.0000000-0000-0000-0000-00000000000',
|
||||
'application': {
|
||||
'applicationId': 'amzn1.echo-sdk-ams.app.000000-d0ed-0000-ad00-000000d00ebe'
|
||||
},
|
||||
'attributes': {
|
||||
'supportedHoroscopePeriods': {
|
||||
'daily': True,
|
||||
'weekly': False,
|
||||
'monthly': False
|
||||
}
|
||||
},
|
||||
'user': {
|
||||
'userId': 'amzn1.account.AM3B00000000000000000000000'
|
||||
}
|
||||
},
|
||||
'request': {
|
||||
'type': 'IntentRequest',
|
||||
'requestId': ' amzn1.echo-api.request.0000000-0000-0000-0000-00000000000',
|
||||
'timestamp': '2015-05-13T12:34:56Z',
|
||||
'intent': {
|
||||
'name': 'GetZodiacHoroscopeIntent',
|
||||
'slots': {
|
||||
'ZodiacSign': {
|
||||
'name': 'ZodiacSign',
|
||||
'value': 'virgo'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
req = _req(data)
|
||||
self.assertEqual(200, req.status_code)
|
||||
text = req.json().get('response', {}).get('outputSpeech', {}).get('text')
|
||||
self.assertEqual('You told us your sign is virgo.', text)
|
||||
|
||||
def test_intent_request_without_slots(self):
|
||||
data = {
|
||||
'version': '1.0',
|
||||
'session': {
|
||||
'new': False,
|
||||
'sessionId': 'amzn1.echo-api.session.0000000-0000-0000-0000-00000000000',
|
||||
'application': {
|
||||
'applicationId': 'amzn1.echo-sdk-ams.app.000000-d0ed-0000-ad00-000000d00ebe'
|
||||
},
|
||||
'attributes': {
|
||||
'supportedHoroscopePeriods': {
|
||||
'daily': True,
|
||||
'weekly': False,
|
||||
'monthly': False
|
||||
}
|
||||
},
|
||||
'user': {
|
||||
'userId': 'amzn1.account.AM3B00000000000000000000000'
|
||||
}
|
||||
},
|
||||
'request': {
|
||||
'type': 'IntentRequest',
|
||||
'requestId': ' amzn1.echo-api.request.0000000-0000-0000-0000-00000000000',
|
||||
'timestamp': '2015-05-13T12:34:56Z',
|
||||
'intent': {
|
||||
'name': 'WhereAreWeIntent',
|
||||
}
|
||||
}
|
||||
}
|
||||
req = _req(data)
|
||||
self.assertEqual(200, req.status_code)
|
||||
text = req.json().get('response', {}).get('outputSpeech', {}).get('text')
|
||||
|
||||
self.assertEqual('Anne Therese is at unknown and Paulus is at unknown', text)
|
||||
|
||||
hass.states.set('device_tracker.paulus', 'home')
|
||||
hass.states.set('device_tracker.anne_therese', 'home')
|
||||
|
||||
req = _req(data)
|
||||
self.assertEqual(200, req.status_code)
|
||||
text = req.json().get('response', {}).get('outputSpeech', {}).get('text')
|
||||
self.assertEqual('You are both home, you silly', text)
|
||||
|
||||
def test_session_ended_request(self):
|
||||
data = {
|
||||
'version': '1.0',
|
||||
'session': {
|
||||
'new': False,
|
||||
'sessionId': 'amzn1.echo-api.session.0000000-0000-0000-0000-00000000000',
|
||||
'application': {
|
||||
'applicationId': 'amzn1.echo-sdk-ams.app.000000-d0ed-0000-ad00-000000d00ebe'
|
||||
},
|
||||
'attributes': {
|
||||
'supportedHoroscopePeriods': {
|
||||
'daily': True,
|
||||
'weekly': False,
|
||||
'monthly': False
|
||||
}
|
||||
},
|
||||
'user': {
|
||||
'userId': 'amzn1.account.AM3B00000000000000000000000'
|
||||
}
|
||||
},
|
||||
'request': {
|
||||
'type': 'SessionEndedRequest',
|
||||
'requestId': 'amzn1.echo-api.request.0000000-0000-0000-0000-00000000000',
|
||||
'timestamp': '2015-05-13T12:34:56Z',
|
||||
'reason': 'USER_INITIATED'
|
||||
}
|
||||
}
|
||||
|
||||
req = _req(data)
|
||||
self.assertEqual(200, req.status_code)
|
||||
self.assertEqual('', req.text)
|
||||
@@ -5,10 +5,11 @@ tests.test_component_http
|
||||
Tests Home Assistant HTTP component does what it should do.
|
||||
"""
|
||||
# pylint: disable=protected-access,too-many-public-methods
|
||||
import unittest
|
||||
from contextlib import closing
|
||||
import json
|
||||
from unittest.mock import patch
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
import requests
|
||||
|
||||
@@ -415,3 +416,61 @@ class TestAPI(unittest.TestCase):
|
||||
}),
|
||||
headers=HA_HEADERS)
|
||||
self.assertEqual(200, req.status_code)
|
||||
|
||||
def test_stream(self):
|
||||
listen_count = self._listen_count()
|
||||
with closing(requests.get(_url(const.URL_API_STREAM),
|
||||
stream=True, headers=HA_HEADERS)) as req:
|
||||
|
||||
data = self._stream_next_event(req)
|
||||
self.assertEqual('ping', data)
|
||||
|
||||
self.assertEqual(listen_count + 1, self._listen_count())
|
||||
|
||||
hass.bus.fire('test_event')
|
||||
hass.pool.block_till_done()
|
||||
|
||||
data = self._stream_next_event(req)
|
||||
|
||||
self.assertEqual('test_event', data['event_type'])
|
||||
|
||||
def test_stream_with_restricted(self):
|
||||
listen_count = self._listen_count()
|
||||
with closing(requests.get(_url(const.URL_API_STREAM),
|
||||
data=json.dumps({
|
||||
'restrict': 'test_event1,test_event3'}),
|
||||
stream=True, headers=HA_HEADERS)) as req:
|
||||
|
||||
data = self._stream_next_event(req)
|
||||
self.assertEqual('ping', data)
|
||||
|
||||
self.assertEqual(listen_count + 2, self._listen_count())
|
||||
|
||||
hass.bus.fire('test_event1')
|
||||
hass.pool.block_till_done()
|
||||
hass.bus.fire('test_event2')
|
||||
hass.pool.block_till_done()
|
||||
hass.bus.fire('test_event3')
|
||||
hass.pool.block_till_done()
|
||||
|
||||
data = self._stream_next_event(req)
|
||||
self.assertEqual('test_event1', data['event_type'])
|
||||
data = self._stream_next_event(req)
|
||||
self.assertEqual('test_event3', data['event_type'])
|
||||
|
||||
def _stream_next_event(self, stream):
|
||||
data = b''
|
||||
last_new_line = False
|
||||
for dat in stream.iter_content(1):
|
||||
if dat == b'\n' and last_new_line:
|
||||
break
|
||||
data += dat
|
||||
last_new_line = dat == b'\n'
|
||||
|
||||
conv = data.decode('utf-8').strip()[6:]
|
||||
|
||||
return conv if conv == 'ping' else json.loads(conv)
|
||||
|
||||
def _listen_count(self):
|
||||
""" Return number of event listeners. """
|
||||
return sum(hass.bus.listeners.values())
|
||||
@@ -7,7 +7,7 @@ Tests Home Assistant util methods.
|
||||
# pylint: disable=too-many-public-methods
|
||||
import unittest
|
||||
import homeassistant.core as ha
|
||||
|
||||
from homeassistant.exceptions import TemplateError
|
||||
from homeassistant.util import template
|
||||
|
||||
|
||||
@@ -57,10 +57,10 @@ class TestUtilTemplate(unittest.TestCase):
|
||||
'{{ states.sensor.temperature.state | round(1) }}'))
|
||||
|
||||
def test_rounding_value2(self):
|
||||
self.hass.states.set('sensor.temperature', 12.72)
|
||||
self.hass.states.set('sensor.temperature', 12.78)
|
||||
|
||||
self.assertEqual(
|
||||
'127',
|
||||
'128',
|
||||
template.render(
|
||||
self.hass,
|
||||
'{{ states.sensor.temperature.state | multiply(10) | round }}'))
|
||||
@@ -84,3 +84,44 @@ class TestUtilTemplate(unittest.TestCase):
|
||||
'',
|
||||
template.render_with_possible_json_value(
|
||||
self.hass, '{{ value_json }}', '{ I AM NOT JSON }'))
|
||||
|
||||
def test_render_with_possible_json_value_with_template_error(self):
|
||||
self.assertEqual(
|
||||
'hello',
|
||||
template.render_with_possible_json_value(
|
||||
self.hass, '{{ value_json', 'hello'))
|
||||
|
||||
def test_render_with_possible_json_value_with_template_error_error_value(self):
|
||||
self.assertEqual(
|
||||
'-',
|
||||
template.render_with_possible_json_value(
|
||||
self.hass, '{{ value_json', 'hello', '-'))
|
||||
|
||||
def test_raise_exception_on_error(self):
|
||||
with self.assertRaises(TemplateError):
|
||||
template.render(self.hass, '{{ invalid_syntax')
|
||||
|
||||
def test_if_state_exists(self):
|
||||
self.hass.states.set('test.object', 'available')
|
||||
self.assertEqual(
|
||||
'exists',
|
||||
template.render(
|
||||
self.hass,
|
||||
'{% if states.test.object %}exists{% else %}not exists{% endif %}'))
|
||||
|
||||
def test_is_state(self):
|
||||
self.hass.states.set('test.object', 'available')
|
||||
self.assertEqual(
|
||||
'yes',
|
||||
template.render(
|
||||
self.hass,
|
||||
'{% if is_state("test.object", "available") %}yes{% else %}no{% endif %}'))
|
||||
|
||||
def test_states_function(self):
|
||||
self.hass.states.set('test.object', 'available')
|
||||
self.assertEqual(
|
||||
'available',
|
||||
template.render(self.hass, '{{ states("test.object") }}'))
|
||||
self.assertEqual(
|
||||
'unknown',
|
||||
template.render(self.hass, '{{ states("test.object2") }}'))
|
||||
Reference in new issue
Block a user