Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion homeassistant/components/hangouts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/hangouts/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

SERVICE_SEND_MESSAGE = 'send_message'
SERVICE_UPDATE = 'update'
SERVICE_RECONNECT = 'reconnect'


TARGETS_SCHEMA = vol.All(
Expand Down
5 changes: 5 additions & 0 deletions homeassistant/components/hangouts/hangouts_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,11 @@ async def async_handle_update_users_and_conversations(self, _=None):
"""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)
5 changes: 4 additions & 1 deletion homeassistant/components/hangouts/services.yaml
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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.