mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-18 14:56:53 +00:00
MQTT cover config to integration key (#22828)
This commit is contained in:
parent
512a074493
commit
e7189e6c56
@ -31,11 +31,30 @@ To use your MQTT cover in your installation, add the following to your `configur
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Example configuration.yaml entry
|
# Example configuration.yaml entry
|
||||||
|
mqtt:
|
||||||
|
cover:
|
||||||
|
- command_topic: "home-assistant/cover/set"
|
||||||
|
```
|
||||||
|
|
||||||
|
<a id='new_format'></a>
|
||||||
|
|
||||||
|
{% details "Previous configuration format" %}
|
||||||
|
|
||||||
|
The configuration format of manual configured MQTT items has changed.
|
||||||
|
The old format that places configurations under the `cover` platform key
|
||||||
|
should no longer be used and is deprecated.
|
||||||
|
|
||||||
|
The above example shows the new and modern way,
|
||||||
|
this is the previous/old example:
|
||||||
|
|
||||||
|
```yaml
|
||||||
cover:
|
cover:
|
||||||
- platform: mqtt
|
- platform: mqtt
|
||||||
command_topic: "home-assistant/cover/set"
|
command_topic: "home-assistant/cover/set"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
{% enddetails %}
|
||||||
|
|
||||||
{% configuration %}
|
{% configuration %}
|
||||||
availability:
|
availability:
|
||||||
description: "A list of MQTT topics subscribed to receive availability (online/offline) updates. Must not be used together with `availability_topic`."
|
description: "A list of MQTT topics subscribed to receive availability (online/offline) updates. Must not be used together with `availability_topic`."
|
||||||
@ -324,26 +343,26 @@ The example below shows a full configuration for a cover without tilt with state
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Example configuration.yaml entry
|
# Example configuration.yaml entry
|
||||||
cover:
|
mqtt:
|
||||||
- platform: mqtt
|
cover:
|
||||||
name: "MQTT Cover"
|
- name: "MQTT Cover"
|
||||||
command_topic: "home-assistant/cover/set"
|
command_topic: "home-assistant/cover/set"
|
||||||
state_topic: "home-assistant/cover/state"
|
state_topic: "home-assistant/cover/state"
|
||||||
availability:
|
availability:
|
||||||
- topic: "home-assistant/cover/availability"
|
- topic: "home-assistant/cover/availability"
|
||||||
qos: 0
|
qos: 0
|
||||||
retain: true
|
retain: true
|
||||||
payload_open: "OPEN"
|
payload_open: "OPEN"
|
||||||
payload_close: "CLOSE"
|
payload_close: "CLOSE"
|
||||||
payload_stop: "STOP"
|
payload_stop: "STOP"
|
||||||
state_open: "open"
|
state_open: "open"
|
||||||
state_opening: "opening"
|
state_opening: "opening"
|
||||||
state_closed: "closed"
|
state_closed: "closed"
|
||||||
state_closing: "closing"
|
state_closing: "closing"
|
||||||
payload_available: "online"
|
payload_available: "online"
|
||||||
payload_not_available: "offline"
|
payload_not_available: "offline"
|
||||||
optimistic: false
|
optimistic: false
|
||||||
value_template: "{{ value.x }}"
|
value_template: "{{ value.x }}"
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
@ -356,25 +375,25 @@ The example below shows a full configuration for a cover without tilt with posit
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Example configuration.yaml entry
|
# Example configuration.yaml entry
|
||||||
cover:
|
mqtt:
|
||||||
- platform: mqtt
|
cover:
|
||||||
name: "MQTT Cover"
|
- name: "MQTT Cover"
|
||||||
command_topic: "home-assistant/cover/set"
|
command_topic: "home-assistant/cover/set"
|
||||||
position_topic: "home-assistant/cover/position"
|
position_topic: "home-assistant/cover/position"
|
||||||
availability:
|
availability:
|
||||||
- topic: "home-assistant/cover/availability"
|
- topic: "home-assistant/cover/availability"
|
||||||
set_position_topic: "home-assistant/cover/set_position"
|
set_position_topic: "home-assistant/cover/set_position"
|
||||||
qos: 0
|
qos: 0
|
||||||
retain: true
|
retain: true
|
||||||
payload_open: "OPEN"
|
payload_open: "OPEN"
|
||||||
payload_close: "CLOSE"
|
payload_close: "CLOSE"
|
||||||
payload_stop: "STOP"
|
payload_stop: "STOP"
|
||||||
position_open: 100
|
position_open: 100
|
||||||
position_closed: 0
|
position_closed: 0
|
||||||
payload_available: "online"
|
payload_available: "online"
|
||||||
payload_not_available: "offline"
|
payload_not_available: "offline"
|
||||||
optimistic: false
|
optimistic: false
|
||||||
value_template: "{{ value.x }}"
|
value_template: "{{ value.x }}"
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
@ -387,35 +406,35 @@ The example below shows a full configuration for a cover with position, state &
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Example configuration.yaml entry
|
# Example configuration.yaml entry
|
||||||
cover:
|
mqtt:
|
||||||
- platform: mqtt
|
cover:
|
||||||
name: "MQTT Cover"
|
- name: "MQTT Cover"
|
||||||
command_topic: "home-assistant/cover/set"
|
command_topic: "home-assistant/cover/set"
|
||||||
state_topic: "home-assistant/cover/state"
|
state_topic: "home-assistant/cover/state"
|
||||||
position_topic: "home-assistant/cover/position"
|
position_topic: "home-assistant/cover/position"
|
||||||
availability:
|
availability:
|
||||||
- topic: "home-assistant/cover/availability"
|
- topic: "home-assistant/cover/availability"
|
||||||
qos: 0
|
qos: 0
|
||||||
retain: true
|
retain: true
|
||||||
payload_open: "OPEN"
|
payload_open: "OPEN"
|
||||||
payload_close: "CLOSE"
|
payload_close: "CLOSE"
|
||||||
payload_stop: "STOP"
|
payload_stop: "STOP"
|
||||||
state_open: "open"
|
state_open: "open"
|
||||||
state_opening: "opening"
|
state_opening: "opening"
|
||||||
state_closed: "closed"
|
state_closed: "closed"
|
||||||
state_closing: "closing"
|
state_closing: "closing"
|
||||||
payload_available: "online"
|
payload_available: "online"
|
||||||
payload_not_available: "offline"
|
payload_not_available: "offline"
|
||||||
optimistic: false
|
optimistic: false
|
||||||
value_template: "{{ value.x }}"
|
value_template: "{{ value.x }}"
|
||||||
position_template: "{{ value.y }}"
|
position_template: "{{ value.y }}"
|
||||||
tilt_command_topic: "home-assistant/cover/tilt"
|
tilt_command_topic: "home-assistant/cover/tilt"
|
||||||
tilt_status_topic: "home-assistant/cover/tilt-state"
|
tilt_status_topic: "home-assistant/cover/tilt-state"
|
||||||
tilt_status_template: "{{ value_json["PWM"]["PWM1"] }}"
|
tilt_status_template: "{{ value_json["PWM"]["PWM1"] }}"
|
||||||
tilt_min: 0
|
tilt_min: 0
|
||||||
tilt_max: 180
|
tilt_max: 180
|
||||||
tilt_closed_value: 70
|
tilt_closed_value: 70
|
||||||
tilt_opened_value: 180
|
tilt_opened_value: 180
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
@ -428,27 +447,27 @@ The example below shows a full configuration for a cover using stopped state.
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Example configuration.yaml entry
|
# Example configuration.yaml entry
|
||||||
cover:
|
mqtt:
|
||||||
- platform: mqtt
|
cover:
|
||||||
name: "MQTT Cover"
|
- name: "MQTT Cover"
|
||||||
command_topic: "home-assistant/cover/set"
|
command_topic: "home-assistant/cover/set"
|
||||||
state_topic: "home-assistant/cover/state"
|
state_topic: "home-assistant/cover/state"
|
||||||
position_topic: "home-assistant/cover/position"
|
position_topic: "home-assistant/cover/position"
|
||||||
availability:
|
availability:
|
||||||
- topic: "home-assistant/cover/availability"
|
- topic: "home-assistant/cover/availability"
|
||||||
qos: 0
|
qos: 0
|
||||||
retain: true
|
retain: true
|
||||||
payload_open: "OPEN"
|
payload_open: "OPEN"
|
||||||
payload_close: "CLOSE"
|
payload_close: "CLOSE"
|
||||||
payload_stop: "STOP"
|
payload_stop: "STOP"
|
||||||
state_opening: "opening"
|
state_opening: "opening"
|
||||||
state_closed: "closed"
|
state_closed: "closed"
|
||||||
state_stopped: "stopped"
|
state_stopped: "stopped"
|
||||||
payload_available: "online"
|
payload_available: "online"
|
||||||
payload_not_available: "offline"
|
payload_not_available: "offline"
|
||||||
optimistic: false
|
optimistic: false
|
||||||
value_template: "{{ value.x }}"
|
value_template: "{{ value.x }}"
|
||||||
position_template: "{{ value.y }}"
|
position_template: "{{ value.y }}"
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
@ -462,11 +481,11 @@ Setting `payload_close` empty or to `null` disables the close command and will n
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Example configuration.yaml entry
|
# Example configuration.yaml entry
|
||||||
cover:
|
mqtt:
|
||||||
- platform: mqtt
|
cover:
|
||||||
payload_open: "on"
|
- payload_open: "on"
|
||||||
payload_close:
|
payload_close:
|
||||||
payload_stop: "on"
|
payload_stop: "on"
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
@ -479,7 +498,6 @@ For auto discovery message the payload needs to be set to `null`, example for co
|
|||||||
{
|
{
|
||||||
"cover": [
|
"cover": [
|
||||||
{
|
{
|
||||||
"platform": "mqtt",
|
|
||||||
"payload_open": "on",
|
"payload_open": "on",
|
||||||
"payload_close": null,
|
"payload_close": null,
|
||||||
"payload_stop": "on"
|
"payload_stop": "on"
|
||||||
@ -498,30 +516,30 @@ The example below shows an example of how to correct the state of the blind depe
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Example configuration.yaml entry
|
# Example configuration.yaml entry
|
||||||
cover:
|
mqtt:
|
||||||
- platform: mqtt
|
cover:
|
||||||
name: "MQTT Cover"
|
- name: "MQTT Cover"
|
||||||
command_topic: "home-assistant/cover/set"
|
command_topic: "home-assistant/cover/set"
|
||||||
state_topic: "home-assistant/cover/state"
|
state_topic: "home-assistant/cover/state"
|
||||||
position_topic: "home-assistant/cover/position"
|
position_topic: "home-assistant/cover/position"
|
||||||
set_position_topic: "home-assistant/cover/position/set"
|
set_position_topic: "home-assistant/cover/position/set"
|
||||||
payload_open: "open"
|
payload_open: "open"
|
||||||
payload_close: "close"
|
payload_close: "close"
|
||||||
payload_stop: "stop"
|
payload_stop: "stop"
|
||||||
state_opening: "open"
|
state_opening: "open"
|
||||||
state_closing: "close"
|
state_closing: "close"
|
||||||
state_stopped: "stop"
|
state_stopped: "stop"
|
||||||
optimistic: false
|
optimistic: false
|
||||||
position_template: |-
|
position_template: |-
|
||||||
{% if not state_attr(entity_id, "current_position") %}
|
{% if not state_attr(entity_id, "current_position") %}
|
||||||
{{ value }}
|
{{ value }}
|
||||||
{% elif state_attr(entity_id, "current_position") < (value | int) %}
|
{% elif state_attr(entity_id, "current_position") < (value | int) %}
|
||||||
{{ (value | int + 1) }}
|
{{ (value | int + 1) }}
|
||||||
{% elif state_attr(entity_id, "current_position") > (value | int) %}
|
{% elif state_attr(entity_id, "current_position") > (value | int) %}
|
||||||
{{ (value | int - 1) }}
|
{{ (value | int - 1) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ value }}
|
{{ value }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
@ -542,60 +560,60 @@ Following variable might be used in `position_template`, `set_position_template`
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Example configuration.yaml entry
|
# Example configuration.yaml entry
|
||||||
cover:
|
mqtt:
|
||||||
- platform: mqtt
|
cover:
|
||||||
name: "MQTT Cover"
|
- name: "MQTT Cover"
|
||||||
command_topic: "home-assistant/cover/set"
|
command_topic: "home-assistant/cover/set"
|
||||||
state_topic: "home-assistant/cover/state"
|
state_topic: "home-assistant/cover/state"
|
||||||
position_topic: "home-assistant/cover/position"
|
position_topic: "home-assistant/cover/position"
|
||||||
set_position_topic: "home-assistant/cover/position/set"
|
set_position_topic: "home-assistant/cover/position/set"
|
||||||
tilt_command_topic: "home-assistant/cover/position/set" # same as `set_position_topic`
|
tilt_command_topic: "home-assistant/cover/position/set" # same as `set_position_topic`
|
||||||
qos: 1
|
qos: 1
|
||||||
retain: false
|
retain: false
|
||||||
payload_open: "open"
|
payload_open: "open"
|
||||||
payload_close: "close"
|
payload_close: "close"
|
||||||
payload_stop: "stop"
|
payload_stop: "stop"
|
||||||
state_opening: "open"
|
state_opening: "open"
|
||||||
state_closing: "close"
|
state_closing: "close"
|
||||||
state_stopped: "stop"
|
state_stopped: "stop"
|
||||||
position_open: 100
|
position_open: 100
|
||||||
position_closed: 0
|
position_closed: 0
|
||||||
tilt_min: 0
|
tilt_min: 0
|
||||||
tilt_max: 6
|
tilt_max: 6
|
||||||
tilt_opened_value: 3
|
tilt_opened_value: 3
|
||||||
tilt_closed_value: 0
|
tilt_closed_value: 0
|
||||||
optimistic: false
|
optimistic: false
|
||||||
position_template: |-
|
position_template: |-
|
||||||
{% if not state_attr(entity_id, "current_position") %}
|
{% if not state_attr(entity_id, "current_position") %}
|
||||||
{
|
{
|
||||||
"position" : value,
|
"position" : value,
|
||||||
"tilt_value" : 0
|
"tilt_value" : 0
|
||||||
}
|
}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set position = state_attr(entity_id, "current_position") %}
|
{% set position = state_attr(entity_id, "current_position") %}
|
||||||
{% set tilt_percent = (state_attr(entity_id, "current_tilt_position")) %}
|
{% set tilt_percent = (state_attr(entity_id, "current_tilt_position")) %}
|
||||||
|
|
||||||
{% set movement = value | int - position %}
|
{% set movement = value | int - position %}
|
||||||
{% set tilt = (tilt_percent / 100 * (tilt_max - tilt_min)) %}
|
{% set tilt = (tilt_percent / 100 * (tilt_max - tilt_min)) %}
|
||||||
{% set tilt_value = min(max((tilt + movement), tilt_min), max) %}
|
{% set tilt_value = min(max((tilt + movement), tilt_min), max) %}
|
||||||
|
|
||||||
{
|
{
|
||||||
"position": value,
|
"position": value,
|
||||||
"pos": position,
|
"pos": position,
|
||||||
"tilt": tilt,
|
"tilt": tilt,
|
||||||
"tilt_value": tilt_value,
|
"tilt_value": tilt_value,
|
||||||
"tilt_percent" : tilt_percent,
|
"tilt_percent" : tilt_percent,
|
||||||
"mov" : movement
|
"mov" : movement
|
||||||
}
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
tilt_command_template: >-
|
tilt_command_template: >-
|
||||||
{% set position = state_attr(entity_id, "current_position") %}
|
{% set position = state_attr(entity_id, "current_position") %}
|
||||||
{% set tilt = state_attr(entity_id, "current_tilt_position") %}
|
{% set tilt = state_attr(entity_id, "current_tilt_position") %}
|
||||||
{% set movement = (tilt_position - tilt) / 100 * tilt_max %}
|
{% set movement = (tilt_position - tilt) / 100 * tilt_max %}
|
||||||
{{ position + movement }}
|
{{ position + movement }}
|
||||||
payload_open: "on"
|
payload_open: "on"
|
||||||
payload_close:
|
payload_close:
|
||||||
payload_stop: "on"
|
payload_stop: "on"
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user