HTTP Agent is a powerful Home Assistant custom integration that creates individual HTTP sensor instances with advanced data extraction capabilities supporting both JSON, XML and even HTML/CSS-Selectors. Unlike traditional hub-based integrations, each HTTP endpoint becomes its own integration instance and then you can define multiple sensors for that request.
- Open HACS in Home Assistant
- Go to "Integrations"
- Click the "+" button
- Search for "HTTP Agent"
- Install the integration
- Restart Home Assistant
- Copy the
custom_components/http_agent
folder to yourcustom_components
directory - Restart Home Assistant
- Go to Configuration β Integrations
- Click + Add Integration
- Search for "HTTP Agent"
- Follow the setup wizard to configure your integration
- URL: The HTTP endpoint to poll (supports templates)
- Method: HTTP method (GET, POST, PUT, DELETE, PATCH)
- Timeout: Request timeout in seconds (1-300)
- Update Interval: How often to poll in seconds (5-86400)
Add any HTTP headers needed for authentication or content negotiation.
Configure request body with content type selection. The field supports templates.
Define sensors to extract data from the response:
- Name: Sensor name
- Extraction Method: JSON, XML or CSS selectors.
- State: Main sensor value selector/template
- Icon: Icon selector/template (auto-prefixed with
mdi:
) - Color: Color selector/template
Use dot notation to access JSON properties:
temperature # Simple property
sensors.0.value # Array index
metadata.device.id # Nested objects
Use XPath expressions:
./temperature # Direct child
.//sensor[@name='temp1']/@value # Attribute search
./metadata/battery # Nested elements
Use CSS selectors for HTML content:
.temperature # Class selector
#sensor-value # ID selector
div[data-sensor="temp"] # Attribute selector
All configuration fields support Home Assistant templates:
http://api.example.com/sensors/{{ states('input_text.device_id') }}
Key: Authorization
Value: Bearer {{ states('input_text.api_token') }}
{
"device": "{{ states('input_text.device_name') }}",
"timestamp": "{{ now().isoformat() }}"
}
URL: https://api.weather.com/v1/current
Method: GET
Headers:
- API-Key: your-api-key
Sensors:
- Name: Temperature
Method: JSON
State: current.temperature
Icon: current.condition_icon
Attributes:
- Humidity: current.humidity
- Pressure: current.pressure
URL: https://api.example.com/data.xml
Method: GET
Sensors:
- Name: Sensor Value
Method: XML
State: ./sensors/sensor[@id='temp1']/value
Icon: ./sensors/sensor[@id='temp1']/icon
URL: https://example.com/status
Method: GET
Sensors:
- Name: Status
Method: CSS
State: .status-value
Color: .status-indicator
Icon: .status-icon
Add to configuration.yaml
:
logger:
logs:
custom_components.http_agent: debug
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- π Report a Bug
- π‘ Request a Feature
- π Documentation
See CHANGELOG.md for version history.