mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
add service to reconnect the bot (#18142)
This commit is contained in:
parent
8ee0e0c6c6
commit
8de79ed57c
@ -22,7 +22,7 @@ from .const import (
|
||||
SERVICE_UPDATE, CONF_SENTENCES, CONF_MATCHERS,
|
||||
CONF_ERROR_SUPPRESSED_CONVERSATIONS, INTENT_SCHEMA, TARGETS_SCHEMA,
|
||||
CONF_DEFAULT_CONVERSATIONS, EVENT_HANGOUTS_CONVERSATIONS_RESOLVED,
|
||||
INTENT_HELP)
|
||||
INTENT_HELP, SERVICE_RECONNECT)
|
||||
|
||||
# We need an import from .config_flow, without it .config_flow is never loaded.
|
||||
from .config_flow import HangoutsFlowHandler # noqa: F401
|
||||
@ -130,6 +130,12 @@ async def async_setup_entry(hass, config):
|
||||
async_handle_update_users_and_conversations,
|
||||
schema=vol.Schema({}))
|
||||
|
||||
hass.services.async_register(DOMAIN,
|
||||
SERVICE_RECONNECT,
|
||||
bot.
|
||||
async_handle_reconnect,
|
||||
schema=vol.Schema({}))
|
||||
|
||||
intent.async_register(hass, HelpIntent(hass))
|
||||
|
||||
return True
|
||||
|
@ -39,6 +39,7 @@ CONF_CONVERSATION_NAME = 'name'
|
||||
|
||||
SERVICE_SEND_MESSAGE = 'send_message'
|
||||
SERVICE_UPDATE = 'update'
|
||||
SERVICE_RECONNECT = 'reconnect'
|
||||
|
||||
|
||||
TARGETS_SCHEMA = vol.All(
|
||||
|
@ -313,6 +313,11 @@ class HangoutsBot:
|
||||
"""Handle the update_users_and_conversations service."""
|
||||
await self._async_list_conversations()
|
||||
|
||||
async def async_handle_reconnect(self, _=None):
|
||||
"""Handle the reconnect service."""
|
||||
await self.async_disconnect()
|
||||
await self.async_connect()
|
||||
|
||||
def get_intents(self, conv_id):
|
||||
"""Return the intents for a specific conversation."""
|
||||
return self._conversation_intents.get(conv_id)
|
||||
|
@ -1,5 +1,5 @@
|
||||
update:
|
||||
description: Updates the list of users and conversations.
|
||||
description: Updates the list of conversations.
|
||||
|
||||
send_message:
|
||||
description: Send a notification to a specific target.
|
||||
@ -13,3 +13,6 @@ send_message:
|
||||
data:
|
||||
description: Other options ['image_file' / 'image_url']
|
||||
example: '{ "image_file": "file" } or { "image_url": "url" }'
|
||||
|
||||
reconnect:
|
||||
description: Reconnect the bot.
|
Loading…
x
Reference in New Issue
Block a user