I’m pleased to report that I’ve successfully modified MQTT HVAC and it now supports templates for command topics. I learned how it uses templates for state topics and it was fairly easy to extend it to do the same magic for command topics. So now I can specify:
- state topic and state template (existing capability)
- command topic and command template (new capability)
Here’s a sample:
modes:
- auto
- heat
- cool
- 'off'
mode_state_topic: "home/thermostat/temperaturemode"
mode_state_template: >-
{% set values = { '0':'auto', '1':'heat', '2':'cool', '4':'off'} %}
{{ values[value] if value in values.keys() else 'off' }}
mode_command_topic: "home/command/thermostat/temperaturemode"
mode_command_template: >-
{% set values = { 'auto':'0', 'heat':'1', 'cool':'2', 'off':'4'} %}
{{ values[value] if value in values.keys() else '4' }}
fan_modes:
- auto
- 'on'
fan_mode_state_topic: "home/thermostat/fancontrol"
fan_mode_state_template: >-
{% set values = { '0':'auto', '1':'on'} %}
{{ values[value] if value in values.keys() else 'auto' }}
fan_mode_command_topic: "home/command/thermostat/fancontrol"
fan_mode_command_template: >-
{% set values = { 'auto':'0', 'on':'1'} %}
{{ values[value] if value in values.keys() else '0' }}
Works like a charm. Now I just need to figure out why the UI doesn’t render a widget for controlling the Hold mode. One problem at a time!
EDIT
It appears the reason why there’s no Hold mode in the UI is because the frontend code does not support it. A quick glance through the code shows nothing for rendering a Hold widget.
Thank you and, yes, I would still like to learn how to do that. I haven’t explored input_select or automations yet so this is a perfect opportunity.