Hi there,
I’m having a command line sensor that is causing an issue after updating Home Assistant. Sadly, I don’t know which version my solution worked last ![]()
Ok start first:
I’m having a command line sensor to retrieve public information about pollen activity from: https://opendata.dwd.de/climate_environment/health/alerts/s31fg.json
This is my command line sensor template:
# Frontend input number controls:
- sensor:
unique_id: pollen
name: pollen
scan_interval: 600
availability: "{{- is_state('binary_sensor.pollen_ready', 'on') -}}"
command: |-
if {{
(
is_state('binary_sensor.pollen_ready', 'on')
and is_number(states('sensor.pollen_region_id'))
and is_number(states('sensor.pollen_partregion_id'))
) | lower
-}};
then
curl -L '{{- states('sensor.pollen_url') -}}' |
jq -cn -f /config/custom_packages/pollen/jq/process_json_response.jq \
--argjson regionid {{ states('sensor.pollen_region_id') }} \
--argjson partregionid {{ states('sensor.pollen_partregion_id') }};
else
python3 /config/scripts/check_data.py;
fi
value_template: |-
{%- if value_json is defined -%}
{{- value_json.status -}}
{%- else -%}
{{- 'unavailable' -}}
{%- endif -%}
json_attributes:
- status
- data
This is the JQ formatting I apply:
input? // null |
(if $ARGS.named.regionid == null then 30 else $ARGS.named.regionid end) as $regionid |
(if $ARGS.named.partregionid == null then 32 else $ARGS.named.partregionid end) as $partregionid |
. as $raw |
$raw.legend |
[
try keys[] catch empty |
capture("^id(?<id>\\d+$)"; "ig").id
] as $ids |
$ids |
map(
{
(. | tonumber -1 | tostring):
{
id: ($raw.legend["id" + .]),
description: ($raw.legend["id" + . + "_desc"]),
severity: (. | tonumber -1)
}
}
) |
add |
flatten as $legend |
$raw.content |
try .[] catch null |
(if (.partregion_id == null | not) and (.region_id == null | not) then
select(.partregion_id == $partregionid) |
select(.region_id == $regionid)
else
null
end) as $content |
$content.Pollen |
(try with_entries(.value |= with_entries(.value |= . as $item | ($legend[] | select(.id == $item)))) catch null) as $pollen |
(if $legend == null or $pollen == null then "ERROR" else "OK" end) as $status |
(if $status == "OK" then
{
name: $raw.name,
sender: $raw.sender,
region_id: $content.region_id,
region_name: $content.region_name,
partregion_id: $content.partregion_id,
partregion_name: $content.partregion_name,
last_update: $raw.last_update,
next_update: $raw.next_update,
legend: $legend,
content: $pollen
}
else null end ) as $response |
{
status: $status,
data: $response
}
When I’m running the command line prompt from console the result is correct:
{
"status": "OK",
"data": {
"name": "Pollenflug-Gefahrenindex für Deutschland ausgegeben vom Deutschen Wetterdienst",
"sender": "Deutscher Wetterdienst - Medizin-Meteorologie",
"region_id": 30,
"region_name": "Niedersachsen und Bremen",
"partregion_id": 32,
"partregion_name": "Östl. Niedersachsen",
"last_update": "2025-10-27 11:00 Uhr",
"next_update": "2025-10-28 11:00 Uhr",
"legend": [
{
"id": "0",
"description": "keine Belastung",
"severity": 0
},
{
"id": "0-1",
"description": "keine bis geringe Belastung",
"severity": 1
},
{
"id": "1",
"description": "geringe Belastung",
"severity": 2
},
{
"id": "1-2",
"description": "geringe bis mittlere Belastung",
"severity": 3
},
{
"id": "2",
"description": "mittlere Belastung",
"severity": 4
},
{
"id": "2-3",
"description": "mittlere bis hohe Belastung",
"severity": 5
},
{
"id": "3",
"description": "hohe Belastung",
"severity": 6
}
],
"content": {
"Hasel": {
"tomorrow": {
"id": "0",
"description": "keine Belastung",
"severity": 0
},
"dayafter_to": {
"id": "0",
"description": "keine Belastung",
"severity": 0
},
"today": {
"id": "0",
"description": "keine Belastung",
"severity": 0
}
},
"Esche": {
"today": {
"id": "0",
"description": "keine Belastung",
"severity": 0
},
"dayafter_to": {
"id": "0",
"description": "keine Belastung",
"severity": 0
},
"tomorrow": {
"id": "0",
"description": "keine Belastung",
"severity": 0
}
},
"Ambrosia": {
"tomorrow": {
"id": "0",
"description": "keine Belastung",
"severity": 0
},
"dayafter_to": {
"id": "0",
"description": "keine Belastung",
"severity": 0
},
"today": {
"id": "0",
"description": "keine Belastung",
"severity": 0
}
},
"Beifuss": {
"tomorrow": {
"id": "0",
"description": "keine Belastung",
"severity": 0
},
"dayafter_to": {
"id": "0",
"description": "keine Belastung",
"severity": 0
},
"today": {
"id": "0",
"description": "keine Belastung",
"severity": 0
}
},
"Roggen": {
"tomorrow": {
"id": "0",
"description": "keine Belastung",
"severity": 0
},
"dayafter_to": {
"id": "0",
"description": "keine Belastung",
"severity": 0
},
"today": {
"id": "0",
"description": "keine Belastung",
"severity": 0
}
},
"Birke": {
"dayafter_to": {
"id": "0",
"description": "keine Belastung",
"severity": 0
},
"tomorrow": {
"id": "0",
"description": "keine Belastung",
"severity": 0
},
"today": {
"id": "0",
"description": "keine Belastung",
"severity": 0
}
},
"Erle": {
"today": {
"id": "0",
"description": "keine Belastung",
"severity": 0
},
"tomorrow": {
"id": "0",
"description": "keine Belastung",
"severity": 0
},
"dayafter_to": {
"id": "0",
"description": "keine Belastung",
"severity": 0
}
},
"Graeser": {
"today": {
"id": "0",
"description": "keine Belastung",
"severity": 0
},
"dayafter_to": {
"id": "0",
"description": "keine Belastung",
"severity": 0
},
"tomorrow": {
"id": "0",
"description": "keine Belastung",
"severity": 0
}
}
}
}
}
But the sensor is missing crucial information in the attributes content:
It looks like there is no data below data.content.%TypeOfPollen%
Was there a change to HomeAssistant that limits the depth of attribute fields?
