Add MQTT fan direction feature (#27087)

Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
rubenbe 2023-04-24 12:39:19 +02:00 committed by GitHub
parent a7e3b2d1d0
commit af07a465e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 0 deletions

View File

@ -160,6 +160,22 @@ optimistic:
required: false required: false
type: boolean type: boolean
default: "`true` if no state topic defined, else `false`." default: "`true` if no state topic defined, else `false`."
direction_command_template:
description: Defines a [template](/docs/configuration/templating/#using-templates-with-the-mqtt-integration) to generate the payload to send to `direction_command_topic`.
required: false
type: template
direction_command_topic:
description: The MQTT topic to publish commands to change the direction state.
required: false
type: string
direction_state_topic:
description: The MQTT topic subscribed to receive direction state updates.
required: false
type: string
direction_value_template:
description: "Defines a [template](/docs/configuration/templating/#using-templates-with-the-mqtt-integration) to extract a value from the direction."
required: false
type: template
oscillation_command_template: oscillation_command_template:
description: Defines a [template](/docs/configuration/templating/#using-templates-with-the-mqtt-integration) to generate the payload to send to `oscillation_command_topic`. description: Defines a [template](/docs/configuration/templating/#using-templates-with-the-mqtt-integration) to generate the payload to send to `oscillation_command_topic`.
required: false required: false
@ -309,6 +325,9 @@ mqtt:
- name: "Bedroom Fan" - name: "Bedroom Fan"
state_topic: "bedroom_fan/on/state" state_topic: "bedroom_fan/on/state"
command_topic: "bedroom_fan/on/set" command_topic: "bedroom_fan/on/set"
direction_state_topic: "bedroom_fan/direction/state"
direction_command_topic: "bedroom_fan/direction/set"
oscillation_command_topic: "bedroom_fan/oscillation/set"
oscillation_state_topic: "bedroom_fan/oscillation/state" oscillation_state_topic: "bedroom_fan/oscillation/state"
oscillation_command_topic: "bedroom_fan/oscillation/set" oscillation_command_topic: "bedroom_fan/oscillation/set"
percentage_state_topic: "bedroom_fan/speed/percentage_state" percentage_state_topic: "bedroom_fan/speed/percentage_state"
@ -343,6 +362,8 @@ mqtt:
- name: "Bedroom Fan" - name: "Bedroom Fan"
command_topic: "bedroom_fan/on/set" command_topic: "bedroom_fan/on/set"
command_template: "{ state: '{{ value }}'}" command_template: "{ state: '{{ value }}'}"
direction_command_template: "{{ iif(value == 'forward', 'fwd', 'rev') }}"
direction_value_template: "{{ iif(value == 'fwd', 'forward', 'reverse') }}"
oscillation_command_topic: "bedroom_fan/oscillation/set" oscillation_command_topic: "bedroom_fan/oscillation/set"
oscillation_command_template: "{ oscillation: '{{ value }}'}" oscillation_command_template: "{ oscillation: '{{ value }}'}"
percentage_command_topic: "bedroom_fan/speed/percentage" percentage_command_topic: "bedroom_fan/speed/percentage"
@ -358,3 +379,18 @@ mqtt:
``` ```
{% endraw %} {% endraw %}
This example shows how to configure a fan that doesn't use `forward` and `backward` as directions.
{% raw %}
```yaml
# Example configuration.yaml with direction templates
mqtt:
fan:
- name: "Bedroom Fan"
direction_command_template: "{{ iif(value == 'forward', 'fwd', 'rev') }}"
direction_value_template: "{{ iif(value == 'fwd', 'forward', 'reverse') }}"
```
{% endraw %}

View File

@ -280,6 +280,10 @@ Configuration variable names in the discovery payload may be abbreviated to cons
'curr_temp_tpl': 'current_temperature_template', 'curr_temp_tpl': 'current_temperature_template',
'dev': 'device', 'dev': 'device',
'dev_cla': 'device_class', 'dev_cla': 'device_class',
'dir_cmd_t': 'direction_command_topic',
'dir_cmd_tpl': 'direction_command_template',
'dir_stat_t': 'direction_state_topic',
'dir_val_tpl': 'direction_value_template',
'dock_t': 'docked_topic', 'dock_t': 'docked_topic',
'dock_tpl': 'docked_template', 'dock_tpl': 'docked_template',
'e': 'encoding', 'e': 'encoding',
@ -369,6 +373,8 @@ Configuration variable names in the discovery payload may be abbreviated to cons
'pl_cln_sp': 'payload_clean_spot', 'pl_cln_sp': 'payload_clean_spot',
'pl_cls': 'payload_close', 'pl_cls': 'payload_close',
'pl_disarm': 'payload_disarm', 'pl_disarm': 'payload_disarm',
'pl_dir_fwd': 'payload_direction_forward',
'pl_dir_rev': 'payload_direction_reverse',
'pl_home': 'payload_home', 'pl_home': 'payload_home',
'pl_inst': 'payload_install', 'pl_inst': 'payload_install',
'pl_lock': 'payload_lock', 'pl_lock': 'payload_lock',