mirror of
https://github.com/home-assistant/core.git
synced 2026-01-07 16:17:18 +01:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1135446de4 | ||
|
|
a262d0f9e4 | ||
|
|
d425aabae3 | ||
|
|
8d44b721c6 | ||
|
|
baa1801e13 | ||
|
|
965e47eb6a | ||
|
|
16c0301227 | ||
|
|
37096a2b65 | ||
|
|
bead08840e | ||
|
|
b7b55f941c | ||
|
|
4231775e04 | ||
|
|
14d90b5484 | ||
|
|
afa48c54e9 | ||
|
|
6603b3eccd | ||
|
|
e2bf3ac095 | ||
|
|
ced96775fe | ||
|
|
f65e57bf7b | ||
|
|
88cda043ac | ||
|
|
404fbe388c | ||
|
|
a0bc96c20d | ||
|
|
e98476e026 | ||
|
|
aa45ff83bd | ||
|
|
029d006beb |
@@ -14,7 +14,7 @@ from homeassistant.const import (
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.discovery import async_load_platform
|
||||
|
||||
REQUIREMENTS = ['aioasuswrt==1.1.13']
|
||||
REQUIREMENTS = ['aioasuswrt==1.1.15']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -423,9 +423,7 @@ class XiaomiButton(XiaomiBinarySensor):
|
||||
})
|
||||
self._last_action = click_type
|
||||
|
||||
if value in ['long_click_press', 'long_click_release']:
|
||||
return True
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
class XiaomiCube(XiaomiBinarySensor):
|
||||
|
||||
@@ -59,15 +59,21 @@ async def async_setup_platform(hass, config, async_add_entities,
|
||||
|
||||
def extract_image_from_mjpeg(stream):
|
||||
"""Take in a MJPEG stream object, return the jpg from it."""
|
||||
data = bytes()
|
||||
data_start = b"\xff\xd8"
|
||||
data_end = b"\xff\xd9"
|
||||
for chunk in stream:
|
||||
end_idx = chunk.find(data_end)
|
||||
if end_idx != -1:
|
||||
return data[data.find(data_start):] + chunk[:end_idx + 2]
|
||||
data = b''
|
||||
|
||||
for chunk in stream:
|
||||
data += chunk
|
||||
jpg_end = data.find(b'\xff\xd9')
|
||||
|
||||
if jpg_end == -1:
|
||||
continue
|
||||
|
||||
jpg_start = data.find(b'\xff\xd8')
|
||||
|
||||
if jpg_start == -1:
|
||||
continue
|
||||
|
||||
return data[jpg_start:jpg_end + 2]
|
||||
|
||||
|
||||
class MjpegCamera(Camera):
|
||||
|
||||
@@ -252,8 +252,7 @@ class Cloud:
|
||||
return json.loads(file.read())
|
||||
|
||||
info = await self.hass.async_add_job(load_config)
|
||||
|
||||
await self.prefs.async_initialize(bool(info))
|
||||
await self.prefs.async_initialize()
|
||||
|
||||
if info is None:
|
||||
return
|
||||
|
||||
@@ -16,19 +16,17 @@ class CloudPreferences:
|
||||
self._store = hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY)
|
||||
self._prefs = None
|
||||
|
||||
async def async_initialize(self, logged_in):
|
||||
async def async_initialize(self):
|
||||
"""Finish initializing the preferences."""
|
||||
prefs = await self._store.async_load()
|
||||
|
||||
if prefs is None:
|
||||
# Backwards compat: we enable alexa/google if already logged in
|
||||
prefs = {
|
||||
PREF_ENABLE_ALEXA: logged_in,
|
||||
PREF_ENABLE_GOOGLE: logged_in,
|
||||
PREF_ENABLE_ALEXA: True,
|
||||
PREF_ENABLE_GOOGLE: True,
|
||||
PREF_GOOGLE_ALLOW_UNLOCK: False,
|
||||
PREF_CLOUDHOOKS: {}
|
||||
}
|
||||
await self._store.async_save(prefs)
|
||||
|
||||
self._prefs = prefs
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ async def websocket_get_entity(hass, connection, msg):
|
||||
|
||||
@async_response
|
||||
async def websocket_update_entity(hass, connection, msg):
|
||||
"""Handle get camera thumbnail websocket command.
|
||||
"""Handle update entity websocket command.
|
||||
|
||||
Async friendly.
|
||||
"""
|
||||
@@ -106,6 +106,10 @@ async def websocket_update_entity(hass, connection, msg):
|
||||
|
||||
if 'new_entity_id' in msg:
|
||||
changes['new_entity_id'] = msg['new_entity_id']
|
||||
if hass.states.get(msg['new_entity_id']) is not None:
|
||||
connection.send_message(websocket_api.error_message(
|
||||
msg['id'], 'invalid_info', 'Entity is already registered'))
|
||||
return
|
||||
|
||||
try:
|
||||
if changes:
|
||||
|
||||
@@ -316,14 +316,19 @@ async def async_handle_waypoints_message(hass, context, message):
|
||||
@HANDLERS.register('encrypted')
|
||||
async def async_handle_encrypted_message(hass, context, message):
|
||||
"""Handle an encrypted message."""
|
||||
plaintext_payload = _decrypt_payload(context.secret, message['topic'],
|
||||
if 'topic' not in message and isinstance(context.secret, dict):
|
||||
_LOGGER.error("You cannot set per topic secrets when using HTTP")
|
||||
return
|
||||
|
||||
plaintext_payload = _decrypt_payload(context.secret, message.get('topic'),
|
||||
message['data'])
|
||||
|
||||
if plaintext_payload is None:
|
||||
return
|
||||
|
||||
decrypted = json.loads(plaintext_payload)
|
||||
decrypted['topic'] = message['topic']
|
||||
if 'topic' in message and 'topic' not in decrypted:
|
||||
decrypted['topic'] = message['topic']
|
||||
|
||||
await async_handle_message(hass, context, decrypted)
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ from homeassistant.core import callback
|
||||
from homeassistant.helpers.translation import async_get_translations
|
||||
from homeassistant.loader import bind_hass
|
||||
|
||||
REQUIREMENTS = ['home-assistant-frontend==20181210.1']
|
||||
REQUIREMENTS = ['home-assistant-frontend==20181211.0']
|
||||
|
||||
DOMAIN = 'frontend'
|
||||
DEPENDENCIES = ['api', 'websocket_api', 'http', 'system_log',
|
||||
|
||||
@@ -42,7 +42,7 @@ class LutronLight(LutronDevice, Light):
|
||||
def __init__(self, area_name, lutron_device, controller):
|
||||
"""Initialize the light."""
|
||||
self._prev_brightness = None
|
||||
super().__init__(self, area_name, lutron_device, controller)
|
||||
super().__init__(area_name, lutron_device, controller)
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
@@ -75,8 +75,7 @@ class LutronLight(LutronDevice, Light):
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
attr = {}
|
||||
attr['lutron_integration_id'] = self._lutron_device.id
|
||||
attr = {'lutron_integration_id': self._lutron_device.id}
|
||||
return attr
|
||||
|
||||
@property
|
||||
|
||||
@@ -60,7 +60,8 @@ CONFIG_SCHEMA = vol.Schema({
|
||||
ALL_EVENT_TYPES = [
|
||||
EVENT_STATE_CHANGED, EVENT_LOGBOOK_ENTRY,
|
||||
EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP,
|
||||
EVENT_ALEXA_SMART_HOME, EVENT_HOMEKIT_CHANGED
|
||||
EVENT_ALEXA_SMART_HOME, EVENT_HOMEKIT_CHANGED,
|
||||
EVENT_AUTOMATION_TRIGGERED, EVENT_SCRIPT_STARTED
|
||||
]
|
||||
|
||||
LOG_MESSAGE_SCHEMA = vol.Schema({
|
||||
@@ -468,6 +469,14 @@ def _exclude_events(events, entities_filter):
|
||||
domain = event.data.get(ATTR_DOMAIN)
|
||||
entity_id = event.data.get(ATTR_ENTITY_ID)
|
||||
|
||||
elif event.event_type == EVENT_AUTOMATION_TRIGGERED:
|
||||
domain = 'automation'
|
||||
entity_id = event.data.get(ATTR_ENTITY_ID)
|
||||
|
||||
elif event.event_type == EVENT_SCRIPT_STARTED:
|
||||
domain = 'script'
|
||||
entity_id = event.data.get(ATTR_ENTITY_ID)
|
||||
|
||||
elif event.event_type == EVENT_ALEXA_SMART_HOME:
|
||||
domain = 'alexa'
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ from .config_flow import CONF_SECRET
|
||||
|
||||
DOMAIN = "owntracks"
|
||||
REQUIREMENTS = ['libnacl==1.6.1']
|
||||
DEPENDENCIES = ['device_tracker', 'webhook']
|
||||
DEPENDENCIES = ['webhook']
|
||||
|
||||
CONF_MAX_GPS_ACCURACY = 'max_gps_accuracy'
|
||||
CONF_WAYPOINT_IMPORT = 'waypoints'
|
||||
@@ -137,15 +137,16 @@ async def handle_webhook(hass, webhook_id, request):
|
||||
user = headers.get('X-Limit-U')
|
||||
device = headers.get('X-Limit-D', user)
|
||||
|
||||
if user is None:
|
||||
if user:
|
||||
topic_base = re.sub('/#$', '', context.mqtt_topic)
|
||||
message['topic'] = '{}/{}/{}'.format(topic_base, user, device)
|
||||
|
||||
elif message['_type'] != 'encrypted':
|
||||
_LOGGER.warning('No topic or user found in message. If on Android,'
|
||||
' set a username in Connection -> Identification')
|
||||
# Keep it as a 200 response so the incorrect packet is discarded
|
||||
return json_response([])
|
||||
|
||||
topic_base = re.sub('/#$', '', context.mqtt_topic)
|
||||
message['topic'] = '{}/{}/{}'.format(topic_base, user, device)
|
||||
|
||||
hass.helpers.dispatcher.async_dispatcher_send(
|
||||
DOMAIN, hass, context, message)
|
||||
return json_response([])
|
||||
|
||||
@@ -5,6 +5,7 @@ For more details about this component, please refer to the documentation at
|
||||
https://home-assistant.io/components/tts.amazon_polly/
|
||||
"""
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.tts import Provider, PLATFORM_SCHEMA
|
||||
@@ -56,7 +57,7 @@ SUPPORTED_VOICES = [
|
||||
'Cristiano', 'Ines', # Portuguese, European
|
||||
'Carmen', # Romanian
|
||||
'Maxim', 'Tatyana', # Russian
|
||||
'Enrique', 'Conchita', 'Lucia' # Spanish European
|
||||
'Enrique', 'Conchita', 'Lucia', # Spanish European
|
||||
'Mia', # Spanish Mexican
|
||||
'Miguel', 'Penelope', # Spanish US
|
||||
'Astrid', # Swedish
|
||||
|
||||
@@ -100,6 +100,6 @@ class ZhaEntity(entity.Entity):
|
||||
'identifiers': {(DOMAIN, ieee)},
|
||||
'manufacturer': self._endpoint.manufacturer,
|
||||
'model': self._endpoint.model,
|
||||
'name': self._device_state_attributes['friendly_name'],
|
||||
'name': self._device_state_attributes.get('friendly_name', ieee),
|
||||
'via_hub': (DOMAIN, self.hass.data[DATA_ZHA][DATA_ZHA_BRIDGE_ID]),
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"""Constants used by Home Assistant components."""
|
||||
MAJOR_VERSION = 0
|
||||
MINOR_VERSION = 84
|
||||
PATCH_VERSION = '0b3'
|
||||
PATCH_VERSION = '2'
|
||||
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
|
||||
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
|
||||
REQUIRED_PYTHON_VER = (3, 5, 3)
|
||||
|
||||
@@ -297,7 +297,8 @@ class EntityPlatform:
|
||||
self.domain, self.platform_name, entity.unique_id,
|
||||
suggested_object_id=suggested_object_id,
|
||||
config_entry_id=config_entry_id,
|
||||
device_id=device_id)
|
||||
device_id=device_id,
|
||||
known_object_ids=self.entities.keys())
|
||||
|
||||
if entry.disabled:
|
||||
self.logger.info(
|
||||
|
||||
@@ -117,7 +117,7 @@ class EntityRegistry:
|
||||
@callback
|
||||
def async_get_or_create(self, domain, platform, unique_id, *,
|
||||
suggested_object_id=None, config_entry_id=None,
|
||||
device_id=None):
|
||||
device_id=None, known_object_ids=None):
|
||||
"""Get entity. Create if it doesn't exist."""
|
||||
entity_id = self.async_get_entity_id(domain, platform, unique_id)
|
||||
if entity_id:
|
||||
@@ -126,7 +126,8 @@ class EntityRegistry:
|
||||
device_id=device_id)
|
||||
|
||||
entity_id = self.async_generate_entity_id(
|
||||
domain, suggested_object_id or '{}_{}'.format(platform, unique_id))
|
||||
domain, suggested_object_id or '{}_{}'.format(platform, unique_id),
|
||||
known_object_ids)
|
||||
|
||||
entity = RegistryEntry(
|
||||
entity_id=entity_id,
|
||||
|
||||
@@ -87,7 +87,7 @@ abodepy==0.14.0
|
||||
afsapi==0.0.4
|
||||
|
||||
# homeassistant.components.asuswrt
|
||||
aioasuswrt==1.1.13
|
||||
aioasuswrt==1.1.15
|
||||
|
||||
# homeassistant.components.device_tracker.automatic
|
||||
aioautomatic==0.6.5
|
||||
@@ -493,7 +493,7 @@ hole==0.3.0
|
||||
holidays==0.9.8
|
||||
|
||||
# homeassistant.components.frontend
|
||||
home-assistant-frontend==20181210.1
|
||||
home-assistant-frontend==20181211.0
|
||||
|
||||
# homeassistant.components.zwave
|
||||
homeassistant-pyozw==0.1.1
|
||||
|
||||
@@ -101,7 +101,7 @@ hdate==0.7.5
|
||||
holidays==0.9.8
|
||||
|
||||
# homeassistant.components.frontend
|
||||
home-assistant-frontend==20181210.1
|
||||
home-assistant-frontend==20181211.0
|
||||
|
||||
# homeassistant.components.homematicip_cloud
|
||||
homematicip==0.9.8
|
||||
|
||||
@@ -17,7 +17,7 @@ def mock_cloudhooks(hass):
|
||||
cloud.iot = Mock(async_send_message=Mock(return_value=mock_coro()))
|
||||
cloud.cloudhook_create_url = 'https://webhook-create.url'
|
||||
cloud.prefs = prefs.CloudPreferences(hass)
|
||||
hass.loop.run_until_complete(cloud.prefs.async_initialize(True))
|
||||
hass.loop.run_until_complete(cloud.prefs.async_initialize())
|
||||
return cloudhooks.Cloudhooks(cloud)
|
||||
|
||||
|
||||
|
||||
@@ -411,7 +411,7 @@ async def test_refresh_token_expired(hass):
|
||||
async def test_webhook_msg(hass):
|
||||
"""Test webhook msg."""
|
||||
cloud = Cloud(hass, MODE_DEV, None, None)
|
||||
await cloud.prefs.async_initialize(True)
|
||||
await cloud.prefs.async_initialize()
|
||||
await cloud.prefs.async_update(cloudhooks={
|
||||
'hello': {
|
||||
'webhook_id': 'mock-webhook-id',
|
||||
|
||||
@@ -277,6 +277,8 @@ def setup_comp(hass):
|
||||
"""Initialize components."""
|
||||
mock_component(hass, 'group')
|
||||
mock_component(hass, 'zone')
|
||||
hass.loop.run_until_complete(async_setup_component(
|
||||
hass, 'device_tracker', {}))
|
||||
hass.loop.run_until_complete(async_mock_mqtt_component(hass))
|
||||
|
||||
hass.states.async_set(
|
||||
|
||||
@@ -265,22 +265,50 @@ class TestComponentLogbook(unittest.TestCase):
|
||||
def test_exclude_automation_events(self):
|
||||
"""Test if automation entries can be excluded by entity_id."""
|
||||
name = 'My Automation Rule'
|
||||
message = 'has been triggered'
|
||||
domain = 'automation'
|
||||
entity_id = 'automation.my_automation_rule'
|
||||
entity_id2 = 'automation.my_automation_rule_2'
|
||||
entity_id2 = 'sensor.blu'
|
||||
|
||||
eventA = ha.Event(logbook.EVENT_LOGBOOK_ENTRY, {
|
||||
eventA = ha.Event(logbook.EVENT_AUTOMATION_TRIGGERED, {
|
||||
logbook.ATTR_NAME: name,
|
||||
logbook.ATTR_MESSAGE: message,
|
||||
logbook.ATTR_DOMAIN: domain,
|
||||
logbook.ATTR_ENTITY_ID: entity_id,
|
||||
})
|
||||
eventB = ha.Event(logbook.EVENT_LOGBOOK_ENTRY, {
|
||||
eventB = ha.Event(logbook.EVENT_AUTOMATION_TRIGGERED, {
|
||||
logbook.ATTR_NAME: name,
|
||||
logbook.ATTR_ENTITY_ID: entity_id2,
|
||||
})
|
||||
|
||||
config = logbook.CONFIG_SCHEMA({
|
||||
ha.DOMAIN: {},
|
||||
logbook.DOMAIN: {logbook.CONF_EXCLUDE: {
|
||||
logbook.CONF_ENTITIES: [entity_id, ]}}})
|
||||
events = logbook._exclude_events(
|
||||
(ha.Event(EVENT_HOMEASSISTANT_STOP), eventA, eventB),
|
||||
logbook._generate_filter_from_config(config[logbook.DOMAIN]))
|
||||
entries = list(logbook.humanify(self.hass, events))
|
||||
|
||||
assert 2 == len(entries)
|
||||
self.assert_entry(
|
||||
entries[0], name='Home Assistant', message='stopped',
|
||||
domain=ha.DOMAIN)
|
||||
self.assert_entry(
|
||||
entries[1], name=name, domain=domain, entity_id=entity_id2)
|
||||
|
||||
def test_exclude_script_events(self):
|
||||
"""Test if script start can be excluded by entity_id."""
|
||||
name = 'My Script Rule'
|
||||
domain = 'script'
|
||||
entity_id = 'script.my_script'
|
||||
entity_id2 = 'script.my_script_2'
|
||||
entity_id2 = 'sensor.blu'
|
||||
|
||||
eventA = ha.Event(logbook.EVENT_SCRIPT_STARTED, {
|
||||
logbook.ATTR_NAME: name,
|
||||
logbook.ATTR_ENTITY_ID: entity_id,
|
||||
})
|
||||
eventB = ha.Event(logbook.EVENT_SCRIPT_STARTED, {
|
||||
logbook.ATTR_NAME: name,
|
||||
logbook.ATTR_MESSAGE: message,
|
||||
logbook.ATTR_DOMAIN: domain,
|
||||
logbook.ATTR_ENTITY_ID: entity_id2,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user