Closed ThePatricide closed 3 years ago
Hey there @emontnemery, mind taking a look at this issue as its been labeled with an integration (mqtt
) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)
value_template
is not deprecated, it is only not allowed to be used for extracting position, your configuration simply have an error in the value_template
, after each %
you have an extra space before the }
, see the fixed configuration bellow:
cover:
- platform: mqtt
name: "Rolgordijn zolder noord"
availability_topic: "tele/TasCH4zolder/LWT"
state_topic: "stat/TasCH4zolder/RESULT"
value_template: >
{% if value_json.Shutter1.Direction == 1 %}
opening
{% elif value_json.Shutter1.Direction == -1 %}
closing
{% elif value_json.Shutter1.Direction == 0 %}
stopped
{% endif %}
state_closing: "-1"
state_opening: "1"
state_stopped: "0"
payload_available: "Online"
payload_not_available: "Offline"
position_topic: "stat/TasCH4zolder/SHUTTER1"
position_open: 100
position_closed: 0
set_position_topic: "cmnd/TasCH4zolder/ShutterPosition1"
command_topic: "cmnd/TasCH4zolder/Backlog"
payload_open: "ShutterOpen1"
payload_close: "ShutterClose1"
payload_stop: "ShutterStop1"
retain: false
optimistic: false
qos: 1
tilt_opened_value: 100
My mistake, my sincere apologies! Will look into fixing it (still getting same error on your fix ;)).
Thanks @frenck! In the end figured out that the code works (see https://community.home-assistant.io/t/vscode-string-does-not-match-the-pattern-of-deprecated/224939) so thought coming back here to ask to verify this, but your two steps ahead!
The problem
Continuation of https://github.com/home-assistant/core/issues/47786
Removing value_template as stated in #46059, which is used for state_topic will remove the ability to show the states opening and closing.
It was declared there that value_template would not be removed by @thecode However, I wanted to add
'state_closing: "close" state_opening: "open" state_stopped: "stop"' to my covers, since that was introduced (super!)
It works perfectly with my Shelly2.5 (super!), configured as mqtt cover, which simply has a topic for this closing and opening state and therefore does not need a value_template. However, my Tasmota relays, configured as mqtt covers, do not have such a topic just for this state, but have this 'hidden' in a JSON attribute called direction in the topic RESULT (and as I use a 4CH relay, it has Shutter1 and Shutter2 on it). So I want to use the following code (might not work, first time templating, but that is not the issue to report ;)) (see example)
However, I get (from VSCode) the following error on value_template: 'String does not match the pattern of "DEPRECATED^"
So value_template seems to be fully deprecated for covers after all? On accident maybe? In the documentation value_template is still shown as a valid config.
What is version of Home Assistant Core has the issue?
2021.5.4
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Core
Integration causing the issue
mqtt cover
Link to integration documentation on our website
https://www.home-assistant.io/integrations/cover.mqtt/
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information