Page 1 of 1

Climate template support

Posted: Tuesday 22 August 2023 18:21
by lwolf
I am trying to add a climate device to MQTT Autodiscovery, but the following two (config) templates simply does not work.

Code: Select all

"temperature_state_template": "{{ value_json.thermostats[0].target_t.value}}"
"current_temperature_template": "{{ value_json.thermostats[0].tmp.value }}"
At least i got these errors from Domoticz log:

Code: Select all

Climate device unhandled temperature_state_template
Climate device unhandled current_temperature_template
Here are an example payload for the above:

Code: Select all

{
    "thermostats": [
        {
            "pos": -1,
            "target_t": {
                "enabled": true,
                "value": 24.0,
                "units": "C"
            },
            "tmp": {
                "value": 17.4,
                "units": "C",
                "is_valid": true
            },
            "schedule": false,
            "schedule_profile": 2,
            "boost_minutes": 0
        }
    ]
}

Re: Climate template support

Posted: Wednesday 23 August 2023 11:40
by waltervl
There is some support in 2023.2 stable. Check also this issue https://github.com/domoticz/domoticz/issues/5676

Re: Climate template support

Posted: Wednesday 23 August 2023 20:47
by lwolf
waltervl wrote: Wednesday 23 August 2023 11:40 There is some support in 2023.2 stable. Check also this issue https://github.com/domoticz/domoticz/issues/5676
Updated to latest Domoticz V2023.2 (build 15512)

Still the same error, but i think it is because the JSON nesting level is too much for MQTTAD to handle...

Used config template:

homeassistant/climate/thermostat1/config

Code: Select all

{"unique_id":"TRV-1","name": "TRV1-setpoint",
"~":"shellies/trv-xxx/",
"temperature_command_topic": "~thermostat/0/command/target_t",
"temperature_state_template": "{{ value_json.thermostats[0].target_t.value }}",
"temperature_state_topic": "~info",
"temperature_unit": "C",
"precision": 0.1,
"temp_step": 0.5,
"max_temp": 31,
"min_temp": 4
}
Test data:

shellies/trv-xxx/info

Code: Select all

{
    "thermostats": [
        {
            "pos": -1,
            "target_t": {
                "enabled": true,
                "value": 24.0,
                "units": "C"
            },
            "tmp": {
                "value": 17.4,
                "units": "C",
                "is_valid": true
            },
            "schedule": false,
            "schedule_profile": 2,
            "boost_minutes": 0
        }
    ]
}
2023-08-23 18:39:57.714 [7f39adffb640] Error: mqttad: Climate device unhandled temperature_state_template (TRV-1)

I tried to replace value_json.thermostats[0].target_t.value with a simpler value and it works.. should i raise a new issue at Domoticz github?

Re: Climate template support

Posted: Thursday 24 August 2023 0:19
by waltervl
Or perhaps add your findings in the current issue. It is not closed yet ;)

Re: Climate template support

Posted: Friday 25 August 2023 20:06
by lwolf
waltervl wrote: Thursday 24 August 2023 0:19 Or perhaps add your findings in the current issue. It is not closed yet ;)
Okay i found a climate related issue on github, however the problem and the template is different i've added the above.

Re: Climate template support

Posted: Friday 01 September 2023 19:42
by lwolf
Thanx, gizmocuz added support for array in templates in beta 15515, and now, the above example works!

Re: Climate template support

Posted: Friday 01 September 2023 21:01
by waltervl
Great!