Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamhowardtheduck/45196ddc89cf53216a642b0509a8cc24 to your computer and use it in GitHub Desktop.
Save iamhowardtheduck/45196ddc89cf53216a642b0509a8cc24 to your computer and use it in GitHub Desktop.
Home-Assistant_Data_Ingestion_for_Elasticsearch
# Comprises of the following and to be installed in this order:
# - Index template for field mapping
# - DevTool command for index creation
# - Ingest pipelines for conditional parsing (1 main and 16 conditional)
# - Logstash pipeline to query Home-Assistant states via an API; use this link to obtain your authorization from your Home-Assistant instance:
# -- https://developers.home-assistant.io/docs/api/rest/ --
# - A lot of blood, sweat, and tears (not really, this was fun!) ☺
### INDEX TEMPLATE ### (updated: 20220928)
PUT _index_template/home-assistant
{
"template": {
"mappings": {
"properties": {
"weather.forecast.pressure_unit": {
"type": "keyword"
},
"media_player.name": {
"type": "keyword"
},
"sun.next_noon": {
"type": "date"
},
"sun.next_rising": {
"type": "date"
},
"climate.target_temp_low": {
"type": "long"
},
"climate.state": {
"type": "keyword"
},
"weather.temperature_unit": {
"type": "keyword"
},
"sensor.restored": {
"type": "boolean"
},
"light.brightness": {
"type": "long"
},
"update.latest_version": {
"type": "keyword"
},
"media_player.supported_features": {
"type": "long"
},
"light.min_mireds": {
"type": "long"
},
"light.xy_color": {
"type": "half_float"
},
"sun.id": {
"eager_global_ordinals": false,
"index_phrases": false,
"fielddata": false,
"norms": false,
"index": true,
"store": false,
"type": "text",
"index_options": "positions"
},
"select.name": {
"type": "keyword"
},
"update.type": {
"type": "keyword"
},
"weather.forecast.temperature": {
"type": "long"
},
"weather.visibility_unit": {
"type": "keyword"
},
"weather.wind_bearing": {
"coerce": true,
"index": true,
"ignore_malformed": false,
"store": false,
"type": "half_float",
"doc_values": true
},
"weather.forecast.precipitation_unit": {
"type": "keyword"
},
"climate.min_temp": {
"type": "long"
},
"climate.preset_mode": {
"type": "keyword"
},
"update.in_progress": {
"type": "boolean"
},
"switch.name": {
"type": "keyword"
},
"media_player.state": {
"type": "keyword"
},
"weather.temperature": {
"coerce": true,
"index": true,
"ignore_malformed": false,
"store": false,
"type": "long",
"doc_values": true
},
"climate.id": {
"eager_global_ordinals": false,
"index_phrases": false,
"fielddata": false,
"norms": false,
"index": true,
"store": false,
"type": "text",
"index_options": "positions"
},
"update.installed_version": {
"type": "keyword"
},
"climate.max_temp": {
"type": "long"
},
"sun.name": {
"type": "keyword"
},
"weather.forecast.timestamp": {
"type": "date"
},
"light.max": {
"type": "long"
},
"light.state": {
"type": "keyword"
},
"zone.passive": {
"type": "boolean"
},
"person.state": {
"type": "keyword"
},
"last.changed": {
"type": "date"
},
"select.options": {
"type": "keyword"
},
"script.state": {
"type": "keyword"
},
"switch.ip": {
"type": "ip"
},
"sensor.level": {
"type": "keyword"
},
"binary_sensor.name": {
"type": "keyword"
},
"climate.dehumidify_setpoint": {
"type": "long"
},
"weather.id": {
"eager_global_ordinals": false,
"index_phrases": false,
"fielddata": false,
"norms": false,
"index": true,
"store": false,
"type": "text",
"index_options": "positions"
},
"automation.last.triggered": {
"type": "date"
},
"weather.description": {
"type": "text"
},
"light.supported_features": {
"type": "long"
},
"sun.next_dusk": {
"type": "date"
},
"sun.azimuth": {
"coerce": true,
"index": true,
"ignore_malformed": false,
"store": false,
"type": "float",
"doc_values": true
},
"light.supported_color_modes": {
"type": "keyword"
},
"binary_sensor.id": {
"eager_global_ordinals": false,
"index_phrases": false,
"fielddata": false,
"norms": false,
"index": true,
"store": false,
"type": "text",
"index_options": "positions"
},
"sensor.name": {
"type": "keyword"
},
"person.name": {
"type": "keyword"
},
"select.state": {
"type": "keyword"
},
"weather.forecast.humidity": {
"type": "long"
},
"event.action": {
"type": "keyword"
},
"light.max_mireds": {
"type": "long"
},
"@timestamp": {
"type": "date"
},
"climate.max_humidity": {
"type": "long"
},
"last.updated": {
"type": "date"
},
"climate.fan_modes": {
"eager_global_ordinals": false,
"index_phrases": false,
"fielddata": false,
"norms": false,
"index": true,
"store": false,
"type": "text",
"index_options": "positions"
},
"weather.visibility": {
"type": "long"
},
"light.step": {
"type": "long"
},
"sun.elevation": {
"type": "float"
},
"light.color_temp": {
"type": "long"
},
"update.supported_features": {
"type": "long"
},
"update.url": {
"type": "text"
},
"climate.hvac_action": {
"type": "keyword"
},
"weather.condition": {
"type": "keyword"
},
"weather.forecast.location": {
"type": "keyword"
},
"person.id": {
"eager_global_ordinals": false,
"index_phrases": false,
"fielddata": false,
"norms": false,
"index": true,
"store": false,
"type": "text",
"index_options": "positions"
},
"climate.supported_features": {
"type": "long"
},
"script.name": {
"type": "keyword"
},
"zone.radius": {
"type": "long"
},
"event.reason": {
"type": "keyword"
},
"weather.forecast.wind_bearing": {
"coerce": true,
"index": true,
"ignore_malformed": false,
"store": false,
"type": "float",
"doc_values": true
},
"weather.wind_speed": {
"type": "float"
},
"climate.target_temp_high": {
"type": "long"
},
"switch.description": {
"type": "text"
},
"light.effect_list": {
"type": "keyword"
},
"climate.name": {
"type": "keyword"
},
"person.user_name": {
"type": "keyword"
},
"light.mode": {
"type": "keyword"
},
"update.auto": {
"type": "boolean"
},
"event.original": {
"eager_global_ordinals": false,
"index_phrases": false,
"fielddata": false,
"norms": false,
"index": false,
"store": false,
"type": "text"
},
"weather.forecast.condition": {
"type": "keyword"
},
"script.supported_features": {
"type": "long"
},
"sensor.measurement": {
"type": "keyword"
},
"light.color_mode": {
"type": "keyword"
},
"light.dynamics": {
"type": "keyword"
},
"sensor.description": {
"type": "text"
},
"light.rgb_color": {
"type": "long"
},
"update.id": {
"eager_global_ordinals": false,
"index_phrases": false,
"fielddata": false,
"norms": false,
"index": true,
"store": false,
"type": "text",
"index_options": "positions"
},
"sensor.type": {
"type": "keyword"
},
"climate.current_temperature": {
"type": "long"
},
"light.min": {
"type": "long"
},
"sun.next_dawn": {
"type": "date"
},
"script.mode": {
"type": "keyword"
},
"weather.forecast.pressure": {
"type": "long"
},
"climate.hvac_modes": {
"eager_global_ordinals": false,
"index_phrases": false,
"fielddata": false,
"norms": false,
"index": true,
"store": false,
"type": "text",
"index_options": "positions"
},
"weather.forecast.precipitation": {
"type": "long"
},
"automation.name": {
"type": "keyword"
},
"light.name": {
"type": "keyword"
},
"automation.id": {
"eager_global_ordinals": false,
"index_phrases": false,
"fielddata": false,
"norms": false,
"index": true,
"store": false,
"type": "text",
"index_options": "positions"
},
"sun.rising": {
"type": "boolean"
},
"zone.id": {
"eager_global_ordinals": false,
"index_phrases": false,
"fielddata": false,
"norms": false,
"index": true,
"store": false,
"type": "text",
"index_options": "positions"
},
"automation.current": {
"type": "keyword"
},
"binary_sensor.status": {
"type": "keyword"
},
"climate.humidity": {
"type": "long"
},
"sensor.ip": {
"type": "ip"
},
"zone.name": {
"type": "keyword"
},
"light.effect": {
"type": "keyword"
},
"sensor.supported_features": {
"type": "keyword"
},
"update.picture": {
"type": "text"
},
"event.module": {
"eager_global_ordinals": false,
"norms": false,
"index": true,
"store": false,
"type": "keyword",
"split_queries_on_whitespace": false,
"index_options": "docs",
"doc_values": true
},
"sensor.state": {
"type": "keyword"
},
"sensor.id": {
"eager_global_ordinals": false,
"index_phrases": false,
"fielddata": false,
"norms": false,
"index": true,
"store": false,
"type": "text",
"index_options": "positions"
},
"light.ip": {
"type": "ip"
},
"automation.state": {
"type": "keyword"
},
"zone.editable": {
"type": "boolean"
},
"weather.forecast.templow": {
"type": "long"
},
"media_player.id": {
"eager_global_ordinals": false,
"index_phrases": false,
"fielddata": false,
"norms": false,
"index": true,
"store": false,
"type": "text",
"index_options": "positions"
},
"climate.preset_modes": {
"eager_global_ordinals": false,
"index_phrases": false,
"fielddata": false,
"norms": false,
"index": true,
"store": false,
"type": "text",
"index_options": "positions"
},
"climate.target_temp_step": {
"type": "long"
},
"update.state": {
"type": "keyword"
},
"light.hs_color": {
"type": "half_float"
},
"weather.forecast.wind_speed": {
"type": "half_float"
},
"sun.next_midnight": {
"type": "date"
},
"weather.wind_speed_unit": {
"type": "keyword"
},
"light.id": {
"eager_global_ordinals": false,
"index_phrases": false,
"fielddata": false,
"norms": false,
"index": true,
"store": false,
"type": "text",
"index_options": "positions"
},
"select.ip": {
"type": "ip"
},
"climate.fan_mode": {
"type": "keyword"
},
"media_player.sources": {
"type": "keyword"
},
"person.editable": {
"type": "boolean"
},
"sun.state": {
"eager_global_ordinals": false,
"norms": false,
"index": true,
"store": false,
"type": "keyword",
"split_queries_on_whitespace": false,
"index_options": "docs",
"doc_values": true
},
"person.user_id": {
"type": "keyword"
},
"sun.next_setting": {
"type": "date"
},
"button.id": {
"eager_global_ordinals": false,
"index_phrases": false,
"fielddata": false,
"norms": false,
"index": true,
"store": false,
"type": "text",
"index_options": "positions"
},
"climate.current_humidity": {
"type": "long"
},
"select.id": {
"eager_global_ordinals": false,
"index_phrases": false,
"fielddata": false,
"norms": false,
"index": true,
"store": false,
"type": "text",
"index_options": "positions"
},
"script.id": {
"eager_global_ordinals": false,
"index_phrases": false,
"fielddata": false,
"norms": false,
"index": true,
"store": false,
"type": "text",
"index_options": "positions"
},
"sensor.dimensions": {
"type": "keyword"
},
"event.dataset": {
"type": "keyword"
}
}
}
},
"index_patterns": [
"dev*",
"dev-home-assistant*",
"home-assistant*"
],
"composed_of": []
}
### DEVTOOL COMMAND ###
PUT home-assistant-000001
{
"aliases": {
"home-assistant":{
"is_write_index": true
}
}
}
### INGEST PIPELINES ###
## MAIN PIPELINE ##
PUT _ingest/pipeline/home-assistant
{
"processors": [
{
"set": {
"field": "geopoint",
"value": "{{latitude}},{{longitude}}",
"ignore_failure": true
}
},
{
"remove": {
"field": "geopoint",
"ignore_missing": true,
"if": "ctx.geopoint == ','",
"description": "Removes empty geopoint field"
}
},
{
"remove": {
"field": [
"attributes.icon",
"attributes.release_summary",
"attributes.latitude",
"attributes.longitude",
"event.name.original"
],
"ignore_missing": true
}
},
{
"grok": {
"ignore_failure": true,
"field": "entity_id",
"patterns": [
"(?<event.module>[^\\.]+)\\.%{GREEDYDATA:message}"
],
"ignore_missing": true
}
},
{
"pipeline": {
"name": "home-assistant_light",
"if": "ctx.event?.module == 'light'"
}
},
{
"pipeline": {
"name": "home-assistant_number",
"if": "ctx.event?.module == 'number'"
}
},
{
"pipeline": {
"name": "home-assistant_automation",
"if": "ctx.event?.module == 'automation'"
}
},
{
"pipeline": {
"name": "home-assistant_sensor",
"if": "ctx.event?.module == 'sensor'"
}
},
{
"pipeline": {
"name": "home-assistant_select",
"if": "ctx.event?.module == 'select'"
}
},
{
"pipeline": {
"name": "home-assistant_button",
"if": "ctx.event?.module == 'button'"
}
},
{
"pipeline": {
"name": "home-assistant_switch",
"if": "ctx.event?.module == 'switch'"
}
},
{
"pipeline": {
"name": "home-assistant_update",
"if": "ctx.event?.module == 'update'"
}
},
{
"pipeline": {
"name": "home-assistant_binary_sensor",
"if": "ctx.event?.module == 'binary_sensor'"
}
},
{
"pipeline": {
"name": "home-assistant_weather",
"if": "ctx.event?.module == 'weather'"
}
},
{
"pipeline": {
"name": "home-assistant_media_player",
"if": "ctx.event?.module == 'media_player'"
}
},
{
"pipeline": {
"name": "home-assistant_climate",
"if": "ctx.event?.module == 'climate'"
}
},
{
"pipeline": {
"name": "home-assistant_person",
"if": "ctx.event?.module == 'person'"
}
},
{
"pipeline": {
"name": "home-assistant_sun",
"if": "ctx.event?.module == 'sun'"
}
},
{
"pipeline": {
"name": "home-assistant_script",
"if": "ctx.event?.module == 'script'"
}
},
{
"pipeline": {
"name": "home-assistant_zone",
"if": "ctx.event?.module == 'zone'"
}
}
],
"on_failure": [
{
"set": {
"field": "_index",
"value": "failed-{{_index}}"
}
}
]
}
## CONDITIONAL PIPELINES ##
1
PUT _ingest/pipeline/home-assistant_zone
{
"processors": [
{
"rename": {
"field": "context.id",
"target_field": "zone.id",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.editable",
"target_field": "zone.editable",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.friendly_name",
"target_field": "zone.name",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.passive",
"target_field": "zone.passive",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.radius",
"target_field": "zone.radius",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_changed",
"target_field": "last.changed",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_updated",
"target_field": "last.updated",
"ignore_missing": true
}
},
{
"rename": {
"field": "state",
"target_field": "zone.state",
"ignore_missing": true
}
},
{
"remove": {
"field": [
"entity_id",
"message"
],
"ignore_missing": true
}
}
],
"on_failure": [
{
"set": {
"field": "_index",
"value": "failed-{{_index}}"
}
}
]
}
2
PUT _ingest/pipeline/home-assistant_script
{
"processors": [
{
"rename": {
"field": "context.id",
"target_field": "script.id",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.current",
"target_field": "script.supported_features",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.friendly_name",
"target_field": "script.name",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.mode",
"target_field": "script.mode",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_changed",
"target_field": "last.changed",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_updated",
"target_field": "last.updated",
"ignore_missing": true
}
},
{
"rename": {
"field": "state",
"target_field": "script.state",
"ignore_missing": true
}
},
{
"remove": {
"field": [
"entity_id",
"message"
],
"ignore_missing": true
}
}
],
"on_failure": [
{
"set": {
"field": "_index",
"value": "failed-{{_index}}"
}
}
]
}
3
PUT _ingest/pipeline/home-assistant_sun
{
"processors": [
{
"rename": {
"field": "context.id",
"target_field": "sun.id",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.azimuth",
"target_field": "sun.azimuth",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.elevation",
"target_field": "sun.elevation",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.friendly_name",
"target_field": "sun.name",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.next_dawn",
"target_field": "sun.next_dawn",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.next_dusk",
"target_field": "sun.next_dusk",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.next_midnight",
"target_field": "sun.next_midnight",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.next_noon",
"target_field": "sun.next_noon",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.next_rising",
"target_field": "sun.next_rising",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.next_setting",
"target_field": "sun.next_setting",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.rising",
"target_field": "sun.rising",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_changed",
"target_field": "last.changed",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_updated",
"target_field": "last.updated",
"ignore_missing": true
}
},
{
"rename": {
"field": "state",
"target_field": "sun.state",
"ignore_missing": true
}
},
{
"remove": {
"field": [
"entity_id",
"message"
],
"ignore_missing": true
}
}
],
"on_failure": [
{
"set": {
"field": "_index",
"value": "failed-{{_index}}"
}
}
]
}
4
PUT _ingest/pipeline/home-assistant_person
{
"processors": [
{
"rename": {
"field": "context.id",
"target_field": "person.id",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.editable",
"target_field": "person.editable",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.friendly_name",
"target_field": "person.name",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.id",
"target_field": "person.user_name",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.user_id",
"target_field": "person.user_id",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_changed",
"target_field": "last.changed",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_updated",
"target_field": "last.updated",
"ignore_missing": true
}
},
{
"rename": {
"field": "state",
"target_field": "person.state",
"ignore_missing": true
}
},
{
"remove": {
"field": [
"message",
"entity_id"
],
"ignore_missing": true
}
}
],
"on_failure": [
{
"set": {
"field": "_index",
"value": "failed-{{_index}}"
}
}
]
}
5
PUT _ingest/pipeline/home-assistant_climate
{
"processors": [
{
"rename": {
"field": "context.id",
"target_field": "climate.id",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.attribution",
"target_field": "sensor.description",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.current_humidity",
"target_field": "climate.current_humidity",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.current_temperature",
"target_field": "climate.current_temperature",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.dehumidify_setpoint",
"target_field": "climate.dehumidify_setpoint",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.fan_mode",
"target_field": "climate.fan_mode",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.fan_modes",
"target_field": "climate.fan_modes",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.friendly_name",
"target_field": "climate.name",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.humidity",
"target_field": "climate.humidity",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.hvac_action",
"target_field": "climate.hvac_action",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.hvac_modes",
"target_field": "climate.hvac_modes",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.max_humidity",
"target_field": "climate.max_humidity",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.max_temp",
"target_field": "climate.max_temp",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.min_temp",
"target_field": "climate.min_temp",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.preset_mode",
"target_field": "climate.preset_mode",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.preset_modes",
"target_field": "climate.preset_modes",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.supported_features",
"target_field": "climate.supported_features",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.target_temp_high",
"target_field": "climate.target_temp_high",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.target_temp_low",
"target_field": "climate.target_temp_low",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.target_temp_step",
"target_field": "climate.target_temp_step",
"ignore_missing": true
}
},
{
"rename": {
"field": "state",
"target_field": "climate.state",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_changed",
"target_field": "last.changed",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_updated",
"target_field": "last.updated",
"ignore_missing": true
}
},
{
"remove": {
"field": [
"message",
"entity_id"
],
"ignore_missing": true
}
}
],
"on_failure": [
{
"set": {
"field": "_index",
"value": "failed-{{_index}}"
}
}
]
}
6
PUT _ingest/pipeline/home-assistant_media_player
{
"processors": [
{
"rename": {
"field": "attributes.device_class",
"target_field": "event.dataset",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.friendly_name",
"target_field": "media_player.name",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.source_list",
"target_field": "media_player.sources",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.supported_features",
"target_field": "media_player.supported_features",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_changed",
"target_field": "last.changed",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_updated",
"target_field": "last.updated",
"ignore_missing": true
}
},
{
"rename": {
"field": "state",
"target_field": "media_player.state",
"ignore_missing": true
}
},
{
"rename": {
"field": "context.id",
"target_field": "media_player.id",
"ignore_missing": true
}
},
{
"remove": {
"field": [
"message",
"entity_id"
],
"ignore_missing": true
}
}
],
"on_failure": [
{
"set": {
"field": "_index",
"value": "failed-{{_index}}"
}
}
]
}
7
PUT _ingest/pipeline/home-assistant_weather
{
"processors": [
{
"rename": {
"field": "attributes.forecast.templow",
"target_field": "weather.forecast.templow",
"ignore_missing": true
}
},
{
"rename": {
"field": "context.id",
"target_field": "weather.id",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.attribution",
"target_field": "weather.description",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.forecast.condition",
"target_field": "weather.forecast.condition",
"ignore_missing": true
}
},
{
"rename": {
"field": "weather.forecast.datetime",
"target_field": "weather.forecast.timestamp",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.forecast.precipitation",
"target_field": "weather.forecast.precipitation",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.forecast.temperature",
"target_field": "weather.forecast.temperature",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.forecast.wind_bearing",
"target_field": "weather.forecast.wind_bearing",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.forecast.wind_speed",
"target_field": "weather.forecast.wind_speed",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.friendly_name",
"target_field": "weather.forecast.location",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.humidity",
"target_field": "weather.forecast.humidity",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.precipitation_unit",
"target_field": "weather.forecast.precipitation_unit",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.pressure",
"target_field": "weather.forecast.pressure",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.pressure_unit",
"target_field": "weather.forecast.pressure_unit",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.temperature",
"target_field": "weather.temperature",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.temperature_unit",
"target_field": "weather.temperature_unit",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.visibility",
"target_field": "weather.visibility",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.visibility_unit",
"target_field": "weather.visibility_unit",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.wind_bearing",
"target_field": "weather.wind_bearing",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.wind_speed",
"target_field": "weather.wind_speed",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.wind_speed_unit",
"target_field": "weather.wind_speed_unit",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_changed",
"target_field": "last.changed",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_updated",
"target_field": "last.updated",
"ignore_missing": true
}
},
{
"rename": {
"field": "state",
"target_field": "weather.condition",
"ignore_missing": true
}
},
{
"remove": {
"field": [
"message",
"entity_id"
],
"ignore_missing": true
}
}
],
"on_failure": [
{
"set": {
"field": "_index",
"value": "failed-{{_index}}"
}
}
]
}
8
PUT _ingest/pipeline/home-assistant_update
{
"processors": [
{
"rename": {
"field": "attributes.entity_picture",
"target_field": "update.picture",
"ignore_missing": true
}
},
{
"rename": {
"field": "context.id",
"target_field": "update.id",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.auto_update",
"target_field": "update.auto",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.in_progress",
"target_field": "update.in_progress",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.installed_version",
"target_field": "update.installed_version",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.latest_version",
"target_field": "update.latest_version",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.release_url",
"target_field": "update.url",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.supported_features",
"target_field": "update.supported_features",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.title",
"target_field": "update.type",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.friendly_name",
"target_field": "event.action",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_changed",
"target_field": "last.changed",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_updated",
"target_field": "last.updated",
"ignore_missing": true
}
},
{
"rename": {
"field": "state",
"target_field": "update.state",
"ignore_missing": true
}
},
{
"rename": {
"field": "message",
"target_field": "event.dataset",
"ignore_missing": true
}
},
{
"remove": {
"field": "entity_id",
"ignore_missing": true
}
}
],
"on_failure": [
{
"set": {
"field": "_index",
"value": "failed-{{_index}}"
}
}
]
}
9
PUT _ingest/pipeline/home-assistant_switch
{
"processors": [
{
"rename": {
"field": "attributes.attribution",
"target_field": "switch.description",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.friendly_name",
"target_field": "switch.name",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.ip_address",
"target_field": "switch.ip",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_changed",
"target_field": "last.changed",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_updated",
"target_field": "last.updated",
"ignore_missing": true
}
},
{
"rename": {
"field": "state",
"target_field": "switch.state",
"ignore_missing": true
}
},
{
"remove": {
"field": [
"entity_id",
"message"
],
"ignore_missing": true
}
}
],
"on_failure": [
{
"set": {
"field": "_index",
"value": "failed-{{_index}}"
}
}
]
}
10
PUT _ingest/pipeline/home-assistant_button
{
"processors": [
{
"rename": {
"field": "attributes.device_class",
"target_field": "event.dataset",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.friendly_name",
"target_field": "event.action",
"ignore_missing": true
}
},
{
"rename": {
"field": "context.id",
"target_field": "button.id",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_changed",
"target_field": "last.changed",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_updated",
"target_field": "last.updated",
"ignore_missing": true
}
},
{
"rename": {
"field": "state",
"target_field": "event.reason",
"ignore_missing": true
}
},
{
"remove": {
"field": [
"entity_id",
"message"
],
"ignore_missing": true
}
}
],
"on_failure": [
{
"set": {
"field": "_index",
"value": "failed-{{_index}}"
}
}
]
}
11
PUT _ingest/pipeline/home-assistant_select
{
"processors": [
{
"rename": {
"field": "attributes.friendly_name",
"target_field": "select.name",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.ip_address",
"target_field": "select.ip",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.options",
"target_field": "select.options",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_changed",
"target_field": "last.changed",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_updated",
"target_field": "last.updated",
"ignore_missing": true
}
},
{
"rename": {
"field": "state",
"target_field": "select.state",
"ignore_missing": true
}
},
{
"rename": {
"field": "context.id",
"target_field": "select.id",
"ignore_missing": true
}
},
{
"remove": {
"field": [
"message",
"entity_id"
],
"ignore_missing": true
}
}
],
"on_failure": [
{
"set": {
"field": "_index",
"value": "failed-{{_index}}"
}
}
]
}
12
PUT _ingest/pipeline/home-assistant_light
{
"processors": [
{
"rename": {
"field": "attributes.hs_color",
"target_field": "light.hs_color",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.rgb_color",
"target_field": "light.rgb_color",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.brightness",
"target_field": "light.brightness",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.color_mode",
"target_field": "light.color_mode",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.effect",
"target_field": "light.effect",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.effect_list",
"target_field": "light.effect_list",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.supported_color_modes",
"target_field": "light.supported_color_modes",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.supported_features",
"target_field": "light.supported_features",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.xy_color",
"target_field": "light.xy_color",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.max_mireds",
"target_field": "light.max_mireds",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.min_mireds",
"target_field": "light.min_mireds",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.dynamics",
"target_field": "light.dynamics",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.color_temp",
"target_field": "light.color_temp",
"ignore_missing": true
}
},
{
"rename": {
"field": "state",
"target_field": "light.state",
"ignore_missing": true
}
},
{
"rename": {
"field": "context.id",
"target_field": "light.id",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_changed",
"target_field": "last.changed",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_updated",
"target_field": "last.updated",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.friendly_name",
"target_field": "light.name",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.mode",
"target_field": "light.mode",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.ip_address",
"target_field": "light.ip",
"ignore_missing": true
}
},
{
"remove": {
"field": [
"message",
"entity_id"
],
"ignore_missing": true
}
}
],
"on_failure": [
{
"set": {
"field": "_index",
"value": "failed-{{_index}}"
}
}
]
}
13
PUT _ingest/pipeline/home-assistant_number
{
"processors": [
{
"rename": {
"field": "attributes.max",
"target_field": "light.max",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.min",
"target_field": "light.min",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.step",
"target_field": "light.step",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.mode",
"target_field": "light.mode",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.friendly_name",
"target_field": "light.effect",
"ignore_missing": true
}
},
{
"rename": {
"field": "state",
"target_field": "light.state",
"ignore_missing": true
}
},
{
"rename": {
"field": "context.id",
"target_field": "light.id",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.ip_address",
"target_field": "light.ip",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_changed",
"target_field": "last.changed",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_updated",
"target_field": "last.updated",
"ignore_missing": true
}
},
{
"remove": {
"field": [
"message",
"entity_id"
],
"ignore_missing": true
}
}
]
}
14
PUT _ingest/pipeline/home-assistant_sensor
{
"processors": [
{
"rename": {
"field": "context.id",
"target_field": "sensor.id",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.friendly_name",
"target_field": "sensor.name",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.device_class",
"target_field": "sensor.type",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.level",
"target_field": "sensor.level",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.restored",
"target_field": "sensor.restored",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.state_class",
"target_field": "sensor.dimensions",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.supported_features",
"target_field": "sensor.supported_features",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.unit_of_measurement",
"target_field": "sensor.measurement",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.attribution",
"target_field": "sensor.description",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_changed",
"target_field": "last.changed",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_updated",
"target_field": "last.updated",
"ignore_missing": true
}
},
{
"rename": {
"field": "state",
"target_field": "sensor.state",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.ip_address",
"target_field": "sensor.ip",
"ignore_missing": true
}
},
{
"remove": {
"field": [
"message",
"entity_id"
],
"ignore_missing": true
}
}
],
"on_failure": [
{
"set": {
"field": "_index",
"value": "failed-{{_index}}"
}
}
]
}
15
PUT _ingest/pipeline/home-assistant_automation
{
"processors": [
{
"rename": {
"field": "attributes.friendly_name",
"target_field": "automation.name",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.current",
"target_field": "automation.current",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.id",
"target_field": "automation.id",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.last_triggered",
"target_field": "automation.last.triggered",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.mode",
"target_field": "automation.mode",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_updated",
"target_field": "last.updated",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_changed",
"target_field": "last.changed",
"ignore_missing": true
}
},
{
"rename": {
"field": "state",
"target_field": "automation.state",
"ignore_missing": true
}
},
{
"remove": {
"field": [
"message",
"context.id",
"entity_id"
],
"ignore_missing": true
}
}
],
"on_failure": [
{
"set": {
"field": "_index",
"value": "failed-{{_index}}"
}
}
]
}
16
PUT _ingest/pipeline/home-assistant_binary_sensor
{
"processors": [
{
"rename": {
"field": "attributes.device_class",
"target_field": "binary_sensor.status",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.attribution",
"target_field": "sensor.description",
"ignore_missing": true
}
},
{
"rename": {
"field": "attributes.friendly_name",
"target_field": "binary_sensor.name",
"ignore_missing": true
}
},
{
"rename": {
"field": "state",
"target_field": "binary_sensor.state",
"ignore_missing": true
}
},
{
"rename": {
"field": "context.id",
"target_field": "binary_sensor.id",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_changed",
"target_field": "last.changed",
"ignore_missing": true
}
},
{
"rename": {
"field": "last_updated",
"target_field": "last.updated",
"ignore_missing": true
}
},
{
"remove": {
"field": [
"entity_id",
"message"
],
"ignore_missing": true
}
}
],
"on_failure": [
{
"set": {
"field": "_index",
"value": "failed-{{_index}}"
}
}
]
}
### LOGSTASH PIPELINE ###
input {
http_poller {
urls => {
states => {
url => "http://home-assistant:8123/api/states"
method => get
headers => {
"Content-Type" => "application/json"
"Authorization" => "Bearer PUT_YOUR_BEARER_AUTHORIZATION_HERE"
}
}
}
request_timeout => 59
schedule => {"every" => "30s"}
codec => "json"
}
}
filter {
if [attributes][forecast] {
mutate { rename => {"[attributes][forecast]" => "[weather][forecast]"}}
split { field => "[weather][forecast]" }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment