Azure Event Hub
The Azure Event Hub
integration allows you to hook into the Home Assistant event bus and send events to Azure Event Hub
First time setup
This assumes you already have an Azure account. Otherwise create a Free account here
You need to create an Event Hub namespace and an Event Hub in that namespace, you can follow this guide
You must then create a Shared Access Policy for the Event Hub with ‘Send’ claims or use the RootManageAccessKey from your namespace (this key has additional claims, including managing the event hub and listening, which are not needed for this purpose), for more details on the security of Event Hubs go here
Once you have the name of your namespace, instance, Shared Access Policy and the key for that policy, you can setup the integration itself.
The alternative approach is to use a connection string and instance name, this can be retrieved in the same way as the Shared Access Policy and this can also be gotten for a device in an IoT Hub (Event Hub-compatible connection string). In the case of IoT Hub, you need to put the Device ID as the instance name.
The final thing to consider is how often you want the integration to send messages in a batch to your hub, this is set with the send_interval
, with a default of 5 seconds. Since this component runs in an asynchronous way there is no guarantee that the sending happens exactly on time, and because your Home Assistant might be very busy with lots of events happening it might discard several events that are older then 20 seconds plus the send_interval
.
Configuration
To add the Azure Event Hub integration to your Home Assistant instance, use this My button:
Manual configuration steps
If the above My button doesn’t work, you can also perform the following steps manually:
-
Browse to your Home Assistant instance.
-
In the bottom right corner, select the
Add Integration button. -
From the list, select Azure Event Hub.
-
Follow the instructions on screen to complete the setup.
You can setup filters through the configuration.yaml
The configuration.yaml file is the main configuration file for Home Assistant. It lists the integrations to be loaded and their specific configurations. In some cases, the configuration needs to be edited manually directly in the configuration.yaml file. Most integrations can be configured in the UI. [Learn more].
Not filtering domains or entities will send every event to Azure Event Hub, thus taking up a lot of space and bandwidth.
Event Hubs have a retention time of at most 7 days, if you do not capture or use the events they are deleted automatically from the Event Hub, the default retention is 1 day.
Filter configuration
By default, no entity will be excluded. To limit which entities are being exposed to Azure Event Hub
, you can use the filter
parameter.
# Example filter to include specified domains and exclude specified entities
azure_event_hub:
filter:
include_domains:
- alarm_control_panel
- light
include_entity_globs:
- binary_sensor.*_occupancy
exclude_entities:
- light.kitchen_light
Filters are applied as follows:
- No filter
- All entities included
- Only includes
- Entity listed in entities include: include
- Otherwise, entity matches domain include: include
- Otherwise, entity matches glob include: include
- Otherwise: exclude
- Only excludes
- Entity listed in exclude: exclude
- Otherwise, entity matches domain exclude: exclude
- Otherwise, entity matches glob exclude: exclude
- Otherwise: include
- Domain and/or glob includes (may also have excludes)
- Entity listed in entities include: include
- Otherwise, entity listed in entities exclude: exclude
- Otherwise, entity matches glob include: include
- Otherwise, entity matches glob exclude: exclude
- Otherwise, entity matches domain include: include
- Otherwise: exclude
- Domain and/or glob excludes (no domain and/or glob includes)
- Entity listed in entities include: include
- Otherwise, entity listed in exclude: exclude
- Otherwise, entity matches glob exclude: exclude
- Otherwise, entity matches domain exclude: exclude
- Otherwise: include
- No Domain and/or glob includes or excludes
- Entity listed in entities include: include
- Otherwise: exclude
The following characters can be used in entity globs:
*
- The asterisk represents zero, one, or multiple characters
?
- The question mark represents zero or one character
Configuration Variables
Filter domains and entities for Event Hub.
Includes all entities from all domains
Include all entities matching a listed pattern (e.g., sensor.weather_*
).
Exclude all entities matching a listed pattern (e.g., sensor.weather_*
).
Using the data in Azure
There are a number of ways to stream the data that comes into the Event Hub into storages in Azure, the easiest way is to use the built-in Capture function and this allows you to capture the data in Azure Blob Storage or Azure Data Lake store, details here
Other storages in Azure (and outside) are possible with an Azure Stream Analytics job
On the analytical side, Event Hub can be directly fed into Azure Databricks Spark
The final way to use the data in Azure is to connect an Azure Function to the Event Hub using the Event Hub trigger binding