I have the following working template sensor - additional 14 sensors more.with the same structure
sensor:
- name: 201_flur_moldAlarm
unique_id: 201_flur_moldAlarm
#friendly_name: "201_Flur-moldAlarm"
icon: "mdi:water-percent-alert"
state: "{{ moldAlarm }}"
attributes:
last_updated: "{{ t }}"
advisory: "{{ advisory }}"
advisory_dehumidifier: "{{ dehumidifierAdvisory }}"
advisory_heating: "{{ heatingAdvisory }}"
advisory_ventilation: "{{ ventilationAdvisory }}"
wallsurface_temperature: "{{ wallSurfaceTemperature }}"
wallsurface_humidity: "{{ wallSurfaceHumidity }}"
wallsurface_humidity_max: "{{ maxWallSurfaceHumidity }}"
insulation_factor: "{{ insulationKCalculated}}"
insulation_factor_estimated: "{{ insulationK }}"
indoor_temp_heating_target: "{{ indoor_temp_heating_target }}"
indoor_temp: "{{ indoorTemp }}"
indoor_humidity: "{{ indoorRelHumidity }}"
indoor_wall_temp: "{{ indoorWallTemp }}"
indoor_humidity_absolute: "{{ indoorAbsHumidity }}"
indoor_dew_point: "{{ indoorDewPoint }}"
outdoor_temp: "{{ outdoorTemp }}"
outdoor_humidity: "{{ outdoorRelHumidity }}"
outdoor_humidity_absolute: "{{ outdoorAbsHumidity }}"
outdoor_dew_point: "{{ outdoorDewPoint }}"
I’ve created a marco which will output a JSON object (Result type: dict):
{
"last_updated": "2024-07-18T11:27:36.889855+02:00",
"advisory": "\n\n \nVentilation possible\n \n\n",
"advisory_dehumidifier": "\n\nOn\n\n",
"advisory_heating": "\n\n\n\n \n \n \n \n-8.010810810810812\n \n \n\n",
"advisory_ventilation": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nNo\n\n",
"wallsurface_temperature": 19.369999999999997,
"wallsurface_humidity": 78.90809816947974,
"wallsurface_humidity_max": 71.3542036519378,
"insulation_factor": -3.8111111111111207,
"insulation_factor_estimated": 0.74,
"indoor_temp_heating_target": 20.5,
"indoor_temp": 23.7,
"indoor_humidity": 61,
"indoor_wall_temp": 19.369999999999997,
"indoor_humidity_absolute": 13.0490577027299,
"indoor_dew_point": 15.7521871827347,
"outdoor_temp": 22.8,
"outdoor_humidity": 85.4,
"outdoor_humidity_absolute": 17.3333339825414,
"outdoor_dew_point": 20.2188904140976
}
Trying to substitute above attributes with the JSON Object is failing:
sensor:
- name: 101_buero_moldAlarm
unique_id: 101_buero_moldAlarm
#friendly_name: "101_Buero-moldAlarm"
icon: "mdi:water-percent-alert"
state: "{{ moldAlarm }}"
attributes: >-
{% from '036-mold-indicator.jinja' import moldIndicatorAttributes %}
{{ moldIndicatorAttributes(insulationK, indoor_temp_heating_target, indoorTempt)|from_json }}
Logger: homeassistant.config
Source: config.py:590
First occurred: 11:19:40 (2 occurrences)
Last logged: 11:19:42
Invalid config for 'template' at packages/mold-indicator-package.yaml, line 102: expected a dictionary for dictionary value 'sensor->0->attributes', got "{% from '036-mold-indicator.jinja' import moldIndicatorAttributes %} {{ moldIndicatorAttributes(insulationK, indoor_temp_heating_target, indoorTemp, indoorRelHumidity, indoorWallTemp, indoorAbsHumidity, indoorDewPoint, outdoorTemp, outdoorRelHumidity, outdoorAbsHumidity, outdoorDewPoint) }}"
Any help is highly appreciated - Thanks