New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MQTT Cover - Tilt command template is ignored #63024
Comments
mqtt documentation |
Hey there @emontnemery, mind taking a look at this issue as it has been labeled with an integration ( |
Green works. |
Right, the buttons result in different service calls, and a command_template is not applied. I am preparing a fix. |
I would be okay if we could just send any kind of payload with |
The linked PR should fix the issues you are having now. |
Hmm, my HASS isn't 100% up to date, I adapted it a little and it does the trick. async def async_open_cover_tilt(self, **kwargs):
"""Tilt the cover open."""
template = self._config.get(CONF_TILT_COMMAND_TEMPLATE)
tilt_open_position = self._config[CONF_TILT_OPEN_POSITION]
variables = {
"tilt_position": tilt_open_position,
"entity_id": self.entity_id,
"position_open": self._config.get(CONF_POSITION_OPEN),
"position_closed": self._config.get(CONF_POSITION_CLOSED),
"tilt_min": self._config.get(CONF_TILT_MIN),
"tilt_max": self._config.get(CONF_TILT_MAX),
}
tilt_payload = tilt_open_position
if template is not None:
tilt_payload = template.async_render(parse_result=False, variables=variables)
await mqtt.async_publish(
self.hass,
self._config.get(CONF_TILT_COMMAND_TOPIC),
tilt_payload,
self._config[CONF_QOS],
self._config[CONF_RETAIN],
)
if self._tilt_optimistic:
self._tilt_value = self.find_percentage_in_range(
float(self._config[CONF_TILT_OPEN_POSITION])
)
self.async_write_ha_state()
async def async_close_cover_tilt(self, **kwargs):
"""Tilt the cover closed."""
template = self._config.get(CONF_TILT_COMMAND_TEMPLATE)
tilt_closed_position = self._config[CONF_TILT_CLOSED_POSITION]
variables = {
"tilt_position": tilt_closed_position,
"entity_id": self.entity_id,
"position_open": self._config.get(CONF_POSITION_OPEN),
"position_closed": self._config.get(CONF_POSITION_CLOSED),
"tilt_min": self._config.get(CONF_TILT_MIN),
"tilt_max": self._config.get(CONF_TILT_MAX),
}
tilt_payload = tilt_closed_position
if template is not None:
tilt_payload = template.async_render(parse_result=False, variables=variables)
await mqtt.async_publish(
self.hass,
self._config.get(CONF_TILT_COMMAND_TOPIC),
tilt_payload,
self._config[CONF_QOS],
self._config[CONF_RETAIN],
)
if self._tilt_optimistic:
self._tilt_value = self.find_percentage_in_range(
float(self._config[CONF_TILT_CLOSED_POSITION])
)
self.async_write_ha_state() |
The problem
Trying to communicate with a MQTT cover actuator that supports JSON commands, I am having trouble with the "tilt" command.
The device supports payloads of this sort :
Motion = 0 : stop
Motion = 1 : up
Motion = 2 : down
Position : send position in percent
Lamella : send tilt in percent
You can send one or more objects in the json, but you don't have to.
What does work :
Actuating the blinds up or down, and to a certain position works well. The tilt open/close commands are the issue. Whatever I do in the config, HASS seems to completely ignore the
tilt_command_template
option that I provide it, and keeps sending 100 for tilt up, and 0 for tilt down.I also tried to change the value of
tilt_opened_value
andtilt_closed_value
to the JSON that I want, but HASS complains that MQTT.Cover only supports integers.What version of Home Assistant Core has the issue?
core-2021.12.6
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/#tilt_command_template
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
I keep receiving "100" or "0" in MQTT.
The status works fine, it's just the TILT commands that don't work.
The text was updated successfully, but these errors were encountered: