def webhook_flow_conf(hass): """Register a handler.""" with patch.dict(config_entries.HANDLERS): config_entry_flow.register_webhook_flow("test_single", "Test Single", {}, False) config_entry_flow.register_webhook_flow("test_multiple", "Test Multiple", {}, True) yield {}
def webhook_flow_conf(hass): """Register a handler.""" with patch.dict(config_entries.HANDLERS): config_entry_flow.register_webhook_flow( 'test_single', 'Test Single', {}, False) config_entry_flow.register_webhook_flow( 'test_multiple', 'Test Multiple', {}, True) yield {}
"""Config flow for DialogFlow.""" from homeassistant.helpers import config_entry_flow from .const import DOMAIN config_entry_flow.register_webhook_flow( DOMAIN, "Dialogflow Webhook", { "dialogflow_url": "https://dialogflow.com/docs/fulfillment#webhook", "docs_url": "https://www.home-assistant.io/integrations/dialogflow/", }, )
"""Config flow for IFTTT.""" from homeassistant.helpers import config_entry_flow from .const import DOMAIN config_entry_flow.register_webhook_flow( DOMAIN, "IFTTT Webhook", { "applet_url": "https://ifttt.com/maker_webhooks", "docs_url": "https://www.home-assistant.io/integrations/ifttt/", }, )
"""Config flow for Traccar.""" from homeassistant.helpers import config_entry_flow from .const import DOMAIN config_entry_flow.register_webhook_flow( DOMAIN, "Traccar Webhook", {"docs_url": "https://www.home-assistant.io/integrations/traccar/"}, )
text="Setting location for {}".format(device), status=HTTP_OK ) async def async_setup_entry(hass, entry): """Configure based on config entry.""" hass.components.webhook.async_register( DOMAIN, 'Geofency', entry.data[CONF_WEBHOOK_ID], handle_webhook) hass.async_create_task( hass.config_entries.async_forward_entry_setup(entry, DEVICE_TRACKER) ) return True async def async_unload_entry(hass, entry): """Unload a config entry.""" hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) await hass.config_entries.async_forward_entry_unload(entry, DEVICE_TRACKER) return True config_entry_flow.register_webhook_flow( DOMAIN, 'Geofency Webhook', { 'docs_url': 'https://www.home-assistant.io/components/geofency/' } )
async_dispatcher_send(hass, TRACKER_UPDATE, device, (data[ATTR_LATITUDE], data[ATTR_LONGITUDE]), data[ATTR_BATTERY], data[ATTR_ACCURACY], attrs) return web.Response(body='Setting location for {}'.format(device), status=HTTP_OK) async def async_setup_entry(hass, entry): """Configure based on config entry.""" hass.components.webhook.async_register(DOMAIN, 'GPSLogger', entry.data[CONF_WEBHOOK_ID], handle_webhook) hass.async_create_task( hass.config_entries.async_forward_entry_setup(entry, DEVICE_TRACKER)) return True async def async_unload_entry(hass, entry): """Unload a config entry.""" hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) await hass.config_entries.async_forward_entry_unload(entry, DEVICE_TRACKER) return True config_entry_flow.register_webhook_flow( DOMAIN, 'GPSLogger Webhook', {'docs_url': 'https://www.home-assistant.io/components/gpslogger/'})
async def async_setup_entry(hass, entry): """Configure based on config entry.""" hass.components.webhook.async_register( DOMAIN, 'Locative', entry.data[CONF_WEBHOOK_ID], handle_webhook) hass.async_create_task( hass.config_entries.async_forward_entry_setup(entry, DEVICE_TRACKER) ) return True async def async_unload_entry(hass, entry): """Unload a config entry.""" hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) await hass.config_entries.async_forward_entry_unload(entry, DEVICE_TRACKER) return True # pylint: disable=invalid-name async_remove_entry = config_entry_flow.webhook_async_remove_entry config_entry_flow.register_webhook_flow( DOMAIN, 'Locative Webhook', { 'docs_url': 'https://www.home-assistant.io/components/locative/' } )
_LOGGER.error('Received unidentified message from Locative: %s', direction) return web.Response( text='Received unidentified message: {}'.format(direction), status=HTTP_UNPROCESSABLE_ENTITY) async def async_setup_entry(hass, entry): """Configure based on config entry.""" hass.components.webhook.async_register(DOMAIN, 'Locative', entry.data[CONF_WEBHOOK_ID], handle_webhook) hass.async_create_task( hass.config_entries.async_forward_entry_setup(entry, DEVICE_TRACKER)) return True async def async_unload_entry(hass, entry): """Unload a config entry.""" hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) await hass.config_entries.async_forward_entry_unload(entry, DEVICE_TRACKER) return True # pylint: disable=invalid-name async_remove_entry = config_entry_flow.webhook_async_remove_entry config_entry_flow.register_webhook_flow( DOMAIN, 'Locative Webhook', {'docs_url': 'https://www.home-assistant.io/components/locative/'})
try: data = json.loads(body) if body else {} except ValueError: return None if isinstance(data, dict): data['webhook_id'] = webhook_id hass.bus.async_fire(EVENT_RECEIVED, data) async def async_setup_entry(hass, entry): """Configure based on config entry.""" hass.components.webhook.async_register( DOMAIN, 'IFTTT', entry.data[CONF_WEBHOOK_ID], handle_webhook) return True async def async_unload_entry(hass, entry): """Unload a config entry.""" hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) return True config_entry_flow.register_webhook_flow( DOMAIN, 'IFTTT Webhook', { 'applet_url': 'https://ifttt.com/maker_webhooks', 'docs_url': 'https://www.home-assistant.io/components/ifttt/' } )
"""Config flow for GPSLogger.""" from homeassistant.helpers import config_entry_flow from .const import DOMAIN config_entry_flow.register_webhook_flow( DOMAIN, "GPSLogger Webhook", {"docs_url": "https://www.home-assistant.io/components/gpslogger/"}, )
"""Config flow for GPSLogger.""" from homeassistant.helpers import config_entry_flow from .const import DOMAIN config_entry_flow.register_webhook_flow( DOMAIN, "Webhook", {"docs_url": "https://www.home-assistant.io/components/plaato/"})
from twilio.twiml import TwiML data = dict(await request.post()) data['webhook_id'] = webhook_id hass.bus.async_fire(RECEIVED_DATA, dict(data)) return TwiML().to_xml() async def async_setup_entry(hass, entry): """Configure based on config entry.""" hass.components.webhook.async_register( DOMAIN, 'Twilio', entry.data[CONF_WEBHOOK_ID], handle_webhook) return True async def async_unload_entry(hass, entry): """Unload a config entry.""" hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) return True config_entry_flow.register_webhook_flow( DOMAIN, 'Twilio Webhook', { 'twilio_url': 'https://www.twilio.com/docs/glossary/what-is-a-webhook', 'docs_url': 'https://www.home-assistant.io/components/twilio/' } )
"""Config flow for Geofency.""" from homeassistant.helpers import config_entry_flow from .const import DOMAIN config_entry_flow.register_webhook_flow( DOMAIN, "Geofency Webhook", {"docs_url": "https://www.home-assistant.io/integrations/geofency/"}, )
"""Config flow for Locative.""" from homeassistant.helpers import config_entry_flow from .const import DOMAIN config_entry_flow.register_webhook_flow( DOMAIN, "Locative Webhook", {"docs_url": "https://www.home-assistant.io/integrations/locative/"}, )
async def async_setup_entry(hass, entry): """Configure based on config entry.""" hass.components.webhook.async_register( DOMAIN, 'GPSLogger', entry.data[CONF_WEBHOOK_ID], handle_webhook) hass.async_create_task( hass.config_entries.async_forward_entry_setup(entry, DEVICE_TRACKER) ) return True async def async_unload_entry(hass, entry): """Unload a config entry.""" hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) await hass.config_entries.async_forward_entry_unload(entry, DEVICE_TRACKER) return True # pylint: disable=invalid-name async_remove_entry = config_entry_flow.webhook_async_remove_entry config_entry_flow.register_webhook_flow( DOMAIN, 'GPSLogger Webhook', { 'docs_url': 'https://www.home-assistant.io/components/gpslogger/' } )
"""Config flow for Mailgun.""" from homeassistant.helpers import config_entry_flow from .const import DOMAIN config_entry_flow.register_webhook_flow( DOMAIN, "Mailgun Webhook", { "mailgun_url": "https://documentation.mailgun.com/en/latest/user_manual.html#webhooks", # noqa: E501 pylint: disable=line-too-long "docs_url": "https://www.home-assistant.io/integrations/mailgun/", }, )
"""Config flow for Twilio.""" from homeassistant.helpers import config_entry_flow from .const import DOMAIN config_entry_flow.register_webhook_flow( DOMAIN, "Twilio Webhook", { "twilio_url": "https://www.twilio.com/docs/glossary/what-is-a-webhook", "docs_url": "https://www.home-assistant.io/components/twilio/", }, )
if isinstance(data, dict): data['webhook_id'] = webhook_id hass.bus.async_fire(EVENT_RECEIVED, data) async def async_setup_entry(hass, entry): """Configure based on config entry.""" hass.components.webhook.async_register( DOMAIN, 'IFTTT', entry.data[CONF_WEBHOOK_ID], handle_webhook) return True async def async_unload_entry(hass, entry): """Unload a config entry.""" hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) return True # pylint: disable=invalid-name async_remove_entry = config_entry_flow.webhook_async_remove_entry config_entry_flow.register_webhook_flow( DOMAIN, 'IFTTT Webhook', { 'applet_url': 'https://ifttt.com/maker_webhooks', 'docs_url': 'https://www.home-assistant.io/components/ifttt/' } )
data = dict(await request.post()) data['webhook_id'] = webhook_id hass.bus.async_fire(RECEIVED_DATA, dict(data)) return TwiML().to_xml() async def async_setup_entry(hass, entry): """Configure based on config entry.""" hass.components.webhook.async_register(DOMAIN, 'Twilio', entry.data[CONF_WEBHOOK_ID], handle_webhook) return True async def async_unload_entry(hass, entry): """Unload a config entry.""" hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) return True # pylint: disable=invalid-name async_remove_entry = config_entry_flow.webhook_async_remove_entry config_entry_flow.register_webhook_flow( DOMAIN, 'Twilio Webhook', { 'twilio_url': 'https://www.twilio.com/docs/glossary/what-is-a-webhook', 'docs_url': 'https://www.home-assistant.io/components/twilio/' })
).hexdigest() return hmac.compare_digest(signature, hmac_digest) async def async_setup_entry(hass, entry): """Configure based on config entry.""" hass.components.webhook.async_register( DOMAIN, 'Mailgun', entry.data[CONF_WEBHOOK_ID], handle_webhook) return True async def async_unload_entry(hass, entry): """Unload a config entry.""" hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) return True # pylint: disable=invalid-name async_remove_entry = config_entry_flow.webhook_async_remove_entry config_entry_flow.register_webhook_flow( DOMAIN, 'Mailgun Webhook', { 'mailgun_url': 'https://documentation.mailgun.com/en/latest/user_manual.html#webhooks', # noqa: E501 pylint: disable=line-too-long 'docs_url': 'https://www.home-assistant.io/components/mailgun/' } )
async def async_unload_entry(hass, entry): """Unload a config entry.""" hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) return True # pylint: disable=invalid-name async_remove_entry = config_entry_flow.webhook_async_remove_entry config_entry_flow.register_webhook_flow( DOMAIN, 'Dialogflow Webhook', { 'dialogflow_url': 'https://dialogflow.com/docs/fulfillment#webhook', 'docs_url': 'https://www.home-assistant.io/components/dialogflow/' } ) def dialogflow_error_response(message, error): """Return a response saying the error message.""" dialogflow_response = DialogflowResponse(message['result']['parameters']) dialogflow_response.add_speech(error) return dialogflow_response.as_dict() async def async_handle_message(hass, message): """Handle a DialogFlow message.""" req = message.get('result')
hmac_digest = hmac.new( key=bytes(hass.data[DOMAIN][CONF_API_KEY], 'utf-8'), msg=bytes('{}{}'.format(timestamp, token), 'utf-8'), digestmod=hashlib.sha256 ).hexdigest() return hmac.compare_digest(signature, hmac_digest) async def async_setup_entry(hass, entry): """Configure based on config entry.""" hass.components.webhook.async_register( DOMAIN, 'Mailgun', entry.data[CONF_WEBHOOK_ID], handle_webhook) return True async def async_unload_entry(hass, entry): """Unload a config entry.""" hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) return True config_entry_flow.register_webhook_flow( DOMAIN, 'Mailgun Webhook', { 'mailgun_url': 'https://documentation.mailgun.com/en/latest/user_manual.html#webhooks', # noqa: E501 pylint: disable=line-too-long 'docs_url': 'https://www.home-assistant.io/components/mailgun/' } )
return web.Response(text="Setting location for {}".format(device), status=HTTP_OK) async def async_setup_entry(hass, entry): """Configure based on config entry.""" hass.components.webhook.async_register(DOMAIN, 'Geofency', entry.data[CONF_WEBHOOK_ID], handle_webhook) hass.async_create_task( hass.config_entries.async_forward_entry_setup(entry, DEVICE_TRACKER)) return True async def async_unload_entry(hass, entry): """Unload a config entry.""" hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) await hass.config_entries.async_forward_entry_unload(entry, DEVICE_TRACKER) return True # pylint: disable=invalid-name async_remove_entry = config_entry_flow.webhook_async_remove_entry config_entry_flow.register_webhook_flow( DOMAIN, 'Geofency Webhook', {'docs_url': 'https://www.home-assistant.io/components/geofency/'})
"""Config flow for csgo_gamestate.""" from homeassistant.helpers import config_entry_flow from .const import DOMAIN config_entry_flow.register_webhook_flow( DOMAIN, "Webhook", { "docs_url": "https://github.com/lociii/homeassistant-csgo/blob/master/info.md" }, )