mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
commit
6603b3eccd
@ -316,14 +316,19 @@ async def async_handle_waypoints_message(hass, context, message):
|
|||||||
@HANDLERS.register('encrypted')
|
@HANDLERS.register('encrypted')
|
||||||
async def async_handle_encrypted_message(hass, context, message):
|
async def async_handle_encrypted_message(hass, context, message):
|
||||||
"""Handle an encrypted 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'])
|
message['data'])
|
||||||
|
|
||||||
if plaintext_payload is None:
|
if plaintext_payload is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
decrypted = json.loads(plaintext_payload)
|
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)
|
await async_handle_message(hass, context, decrypted)
|
||||||
|
|
||||||
|
@ -60,7 +60,8 @@ CONFIG_SCHEMA = vol.Schema({
|
|||||||
ALL_EVENT_TYPES = [
|
ALL_EVENT_TYPES = [
|
||||||
EVENT_STATE_CHANGED, EVENT_LOGBOOK_ENTRY,
|
EVENT_STATE_CHANGED, EVENT_LOGBOOK_ENTRY,
|
||||||
EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP,
|
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({
|
LOG_MESSAGE_SCHEMA = vol.Schema({
|
||||||
|
@ -137,15 +137,16 @@ async def handle_webhook(hass, webhook_id, request):
|
|||||||
user = headers.get('X-Limit-U')
|
user = headers.get('X-Limit-U')
|
||||||
device = headers.get('X-Limit-D', user)
|
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,'
|
_LOGGER.warning('No topic or user found in message. If on Android,'
|
||||||
' set a username in Connection -> Identification')
|
' set a username in Connection -> Identification')
|
||||||
# Keep it as a 200 response so the incorrect packet is discarded
|
# Keep it as a 200 response so the incorrect packet is discarded
|
||||||
return json_response([])
|
return json_response([])
|
||||||
|
|
||||||
topic_base = re.sub('/#$', '', context.mqtt_topic)
|
|
||||||
message['topic'] = '{}/{}/{}'.format(topic_base, user, device)
|
|
||||||
|
|
||||||
hass.helpers.dispatcher.async_dispatcher_send(
|
hass.helpers.dispatcher.async_dispatcher_send(
|
||||||
DOMAIN, hass, context, message)
|
DOMAIN, hass, context, message)
|
||||||
return json_response([])
|
return json_response([])
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"""Constants used by Home Assistant components."""
|
"""Constants used by Home Assistant components."""
|
||||||
MAJOR_VERSION = 0
|
MAJOR_VERSION = 0
|
||||||
MINOR_VERSION = 84
|
MINOR_VERSION = 84
|
||||||
PATCH_VERSION = '0'
|
PATCH_VERSION = '1'
|
||||||
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
|
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
|
||||||
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
|
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
|
||||||
REQUIRED_PYTHON_VER = (3, 5, 3)
|
REQUIRED_PYTHON_VER = (3, 5, 3)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user