Getting Started with Home Assistant Webhooks & Writing to InfluxDB
By
Cole Bowden
May 28, 2026
Getting Started
Developer
Navigate to:
If you’re already running or are familiar with Home Assistant, you’ve likely worked with integrations, maybe a few automations, and possibly MQTT as a way to wire devices together. But webhooks add another layer of flexibility that lets you level up your smart home into a fully-customized, intelligent network. Instead of relying on built-in integrations and being confined to the same local network, you can let external devices and services push events directly into Home Assistant. This gives you a simple way to build custom flows: a device sends a webhook, Home Assistant receives it, and then you decide what happens next. It’s a lightweight way to connect systems, even when built-in integrations may be lacking.
Once you have the webhook flow in place, the next question is what to do with the data generated from your webhook calls, where to store it, and how to best leverage it. That’s where InfluxDB fits in. It’s built specifically for time series data, which means it’s designed to handle continuous streams of time-stamped events like the ones generated by a smart home using Home Assistant. Instead of just reacting in the moment, you can store that data, query it, and build a clearer picture of how your system behaves. Data processing and forecasting builds an even more advanced understanding of your system over time.
In this blog, we’ll walk through both sides of that setup. First, we’ll use webhooks in Home Assistant to create flexible, event-driven flows between devices and services. Then we’ll connect that stream of data to InfluxDB and its Processing Engine so you can go beyond real-time reactions and start working with your data in a more structured way.
What is Home Assistant?
Home Assistant is an open source platform that ties all your smart home devices together in one place. It runs locally, gives you control over how devices interact, and lets you build automations based on events happening throughout your home. Instead of relying on separate apps or cloud services for each device, everything feeds into a single system where you can define your own logic. That can be as simple as turning on lights at sunset or as involved as coordinating and controlling multiple devices based on sensor data, schedules, forecasts, and external inputs.
It’s easy to get started with Home Assistant by connecting a few common integrations. Nearly all smart lights, thermostats, and motion sensors have existing integrations, and building simple automations on those integrations, like having lights turn on if a motion sensor detects movement, is straightforward from there. As your setup grows, you can layer in more conditions, tie multiple devices together, and start building routines.
At some point, though, you may want to bring in data or events from devices and services that don’t have a native integration. That’s where webhooks come in. They give you a simple way to send events directly into Home Assistant from anything that can make an HTTP request, which opens the door to more custom, event-driven flows without needing to build a full integration.
Setting Up a Home Assistant Webhook
To get started on the Home Assistant side of things, a webhook is just another type of trigger. This means you can create it as you would any other trigger type: navigate to automations, create an automation, and add a webhook trigger. Home Assistant has documentation on exactly how this trigger works. You must define a webhook ID when you create a webhook trigger, and you’ll need to include that ID when you invoke the webhook. Just like with MQTT triggers in Home Assistant, webhook triggers also support payloads that contain additional data, and you can use this payload in downstream automation if desired.
For testing purposes, make sure that a downstream action is invoked by the trigger. Using one of your other devices connected to Home Assistant is often the most straightforward option, whether that’s switching a light on/off or sending a push notification to an Apple device via iCloud.
Then, to invoke your trigger, simply call your webhook. The easiest way to do this is to open up a terminal window on a computer connected to the same network as Home Assistant and run:
curl -X POST -d 'key=value' https://"your-home-assistant":8123/api/webhook/"id"
Any other means of sending an HTTP POST request will work fine. Note that you’ll need to replace "id" with the webhook ID that you defined when you created the trigger and "your-home-assistant" with the local IP of the device running Home Assistant. The ‘key=value’ is where you can provide your payload. If you want multiple keys and values, you can separate them with &, or you can provide it in a JSON format, which is covered in the Home Assistant documentation.
If you want to send HTTP requests from devices or servers that aren’t on your home network, you’ll need to make sure you set the local_only option to “false” and port forward the port Home Assistant uses for webhooks, which is 8123 by default. Home Assistant’s documentation recommends some security practices that are worth repeating: because allowing external traffic to invoke the webhook trigger is inherently insecure, make sure that any downstream actions can’t be destructive or problematic if a bad actor sends a request.
Full-Stack Example: Energy Price Monitoring
Suppose you want to monitor energy prices on the grid and use those prices to inform when you should turn certain devices in your smart home on or off.
You’ll need to start with a script to monitor grid pricing. Depending on where you live and how your electricity is billed, you may be able to simply query your utility or fetch the relevant information periodically from a website. Run a small server or device that can handle this task, and schedule it with cron to run periodically. When the script runs and retrieves that data, you can invoke a webhook with a JSON payload into your Home Assistant:
import requests
WEBHOOK_URL = "https://192.168.1.20:8123/api/webhook/electricity_price"
PRICE_THRESHOLD_KWH = 0.20
# fetch local electricity prices, then...
payload = {
"price_per_kwh": current_electricity_price,
"threshold": PRICE_THRESHOLD_KWH,
}
response = requests.post(
WEBHOOK_URL,
json=payload,
timeout=10,
)
response.raise_for_status()
Then, in Home Assistant, your trigger could be set up as:
alias: Energy price spike response
description: Adjust to eco mode when electricity prices go above threshold
triggers:
- trigger: webhook
webhook_id: energy_price_monitor
allowed_methods:
- POST
local_only: false
conditions:
- condition: template
value_template: >
{{ trigger.json.price_per_kwh | float >= trigger.json.threshold | float }}
actions:
- action: switch.turn_off
target:
entity_id:
- switch.ev_charger
- switch.garage_ac
With a scheduled Python script and the Home Assistant trigger, you can now run a scheduled task to check the web, invoke the trigger, pass in relevant data as a payload, and have other devices connected to Home Assistant take necessary actions. The above example demonstrates switching off some devices when electricity prices are high, but a few minor adjustments could instead turn devices on when prices drop.
Adding more intelligence to your smart home with InfluxDB
Webhooks and automation are a good start, but there’s still much more you can do. Data is being collected and used to trigger various events around the house, but what do you do with that data after it’s used to set off a trigger? If you’re turning off EV charging and auxiliary air conditioning when electricity is particularly pricey, what impact is that having?
Fortunately, Home Assistant has an integration with InfluxDB that can help you take your system from smart home to smarter home with minimal setup. Install InfluxDB, add the Home Assistant integration for InfluxDB, then configure the authentication to an existing InfluxDB instance. By default, it’ll write all actions directly into InfluxDB, though you can explicitly set it to exclude or include certain devices if you wish:
influxdb:
api_version: 2
ssl: false
host: 192.168.1.50
port: 8181
token: "YOUR_INFLUXDB_TOKEN"
organization: home
bucket: home_assistant
To write the data from the earlier webhook script into InfluxDB, we can use the InfluxDB 3 Python client:
from influxdb_client_3 import InfluxDBClient3, Point
import requests
WEBHOOK_URL = "https://192.168.1.20:8123/api/webhook/electricity_price"
PRICE_THRESHOLD_KWH = 0.20
INFLUXDB_URL = "192.168.1.50:8181"
INFLUXDB_TOKEN = "your_influxdb_token"
INFLUXDB_DATABASE = "home"
def main():
client = InfluxDBClient3(
host=INFLUXDB_HOST,
token=INFLUXDB_TOKEN,
database=INFLUXDB_DATABASE,
)
# fetch local electricity prices, then...
write_to_influx(current_electricity_price)
post_request_to_home_assistant(current_electricity_price)
def post_request_to_home_assistant(price):
payload = {
"price_per_kwh": price,
"threshold": PRICE_THRESHOLD_KWH,
}
response = requests.post(
WEBHOOK_URL,
json=payload,
timeout=10,
)
response.raise_for_status()
def write_to_influx(price):
point = (
Point("grid_prices")
.field("price_per_kwh", float(price))
)
client.write(point)
With all the data for triggers and actions, you can retain a long-term memory of what your smart home is doing. With the InfluxDB Processing Engine, you can do further analysis and processing of data as it’s written.
To continue with the example above, you could connect your electricity grid up to Home Assistant, then persist the meter data into InfluxDB. That data, combined with records of when your webhook trigger wrote information about current electricity prices, could allow you to see how your home adapts in real-time to fluctuations in grid prices. If everything is set up correctly, you should see that spikes in electricity prices lead to lower utilization, and vice versa.
Better yet, you could use the Prophet forecasting plugin, trained on the same data, to create a smart home that isn’t just reactive but predictive. By persisting smart home data to InfluxDB, you can train models on that data to make intelligent predictions. For example, you could forecast electricity prices relatively easily. First, create an instance of the forecasting plugin:
influxdb3 create trigger \
--database home \
--path "gh:influxdata/prophet_forecasting/prophet_forecasting.py" \
--trigger-spec "every:1h" \
--trigger-arguments "measurement=grid_prices,field=price_per_kwh,window=30d,forecast_horizont=12h,target_measurement=grid_price_forecast,model_mode=train,unique_suffix=home_prices_v1,seasonality_mode=additive,inferred_freq=1H" \
grid_price_forecast
Then enable it:
influxdb3 enable trigger \
--database home \
grid_price_forecast
With forecasting enabled, there’s now a grid_price_forecast table that will be populated, which you can query to view predicted spikes in prices. You can use those predicted spikes to run critical tasks around the house before electricity spikes, rather than simply shutting them off after it increases.
Continual improvement
If you’ve followed along with every part of this blog, you should have a full loop in place. A small service watches something outside your home, sends a periodic signal, Home Assistant handles the local response, and InfluxDB keeps a record of what happened so you can look back and improve it. None of the individual pieces are especially complicated, but putting them together gives you something more useful than a single automation. You’re building a system that can learn from its own behavior and get smarter over time.
Get started with InfluxDB 3 and its Home Assistant integration today.