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 {}
示例#3
0
"""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/",
    },
)
示例#4
0
"""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/",
    },
)
示例#5
0
"""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/"},
)
示例#6
0
        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/'
    }
)
示例#7
0
    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/'})
示例#8
0
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/'
    }
)
示例#9
0
    _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/'})
示例#10
0
    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/'
    }
)
示例#11
0
"""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/"},
)
示例#12
0
"""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/"})
示例#13
0
    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/'
    }
)
示例#14
0
"""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/"},
)
示例#16
0
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/'
    }
)
示例#17
0
"""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/",
    },
)
示例#18
0
"""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/",
    },
)
示例#19
0
    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/'
    }
)
示例#20
0
    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/'
    })
示例#21
0
    ).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/'
    }
)
示例#22
0

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')
示例#23
0
    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/'
    }
)
示例#24
0
    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/'})
示例#25
0
"""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"
    },
)