Home Assistant release with the issue:
0.90
Operating environment (Hass.io/Docker/Windows/etc.):
Debian Stretch
Component/platform:
cover, platform mqtt
Description of problem:
The problem is that when I use at my automations
cover.close_cover or cover.open_cover it doesn't check the state of the cover.
So if cover is already close automation ""closes""" it again.
Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):
action:
- service: cover.close_cover
entity_id: cover.bedroom_curtains
cover:
- platform: mqtt
name: "DreamRoom Curtains"
command_topic: "home/curtains/bedroom/action"
state_topic: "home/curtains/bedroom/state"
device_class: "curtain"
qos: 0
retain: false
payload_open: "on"
payload_close: "off"
state_open: "on"
state_closed: "off"
optimistic: false
At lovelace it works as expected:
https://i.imgur.com/TXQl8xY.png
Any help?
You could add a condition to your automation to check the state before calling the service.
conditions:
- condition: state
entity_id: 'cover.bedroom_curtains'
state: 'off'
Thank you for your reply. But the close cover action is a part of a more generic automation. (close lights media players and cover)
So this condition isn't appropriate for me.
Also I think that just like the front-end knows the state of the cover and don't let you close it, if it is already open the same approach should exist at the automation part.
@ppanagiotis
Also I think that just like the front-end knows the state of the cover and don't let you close it, if it is already open the same approach should exist at the automation part.
Not necessarily. Frontend has to deal with users, so that kind of 'smartness' can be very nice, but in the automation you're calling a service directly, it is supposed that you know what you are doing (triggers and conditions apply) and you want that to happen.
There are lots of components where 2 calls to the same service can have some meaning or usefulness, like entities that have no state pulled (thinking in RF outlets, for example), so I think that the answer @cgtobi gave you is the best one.
If you're calling more things in that automation, you can replace the calling to close covers for a call to a new script (script.close_covers_if_open), and inside it you can insert the condition :) (conditions can be used in automations and scripts).
If your logics are more complex, another idea could be using a python_script, where you can access all states in HA and call the services you could need.
No the script solution is just fine. I just wanted to know if it is the right way or if I should try to fix it at mqtt cover components and open a pull request. Than you very much both of you. I am closing it.
I am facing almost the same problem, I am not using automations in Home Assistant but the problem present itself while using apple HomeKit.
If the garage door is closed and I issue the close command it ignores the fact that the door is closed and it ""closes"" it again resulting in my garage door being open.
Any ideas how I can solve this? Thank you.
Most helpful comment
No the script solution is just fine. I just wanted to know if it is the right way or if I should try to fix it at mqtt cover components and open a pull request. Than you very much both of you. I am closing it.