So I have a couple covers, one for a gate and one for a garage door. Both function fine and have sensors for open/close. Both work fine in Home Assistant.
Within Google, commands will activate the covers. Opening is fine but closing returns an error as if Google expected a response within a few seconds that the door closed, rather than waiting for the state change to occur.
The error says “sorry, it looks like Home Assistant is not available right now.”
Can I configure how long Google expects the action to take?
I think you’re onto it - the sensor is a simple contact sensor that detects when a magnet makes contact as “closed” and when they’re not making contact, they’re “open.” It immediately changes from open to closed as soon as the contact breaks.
Here’s where my noobness comes in - the cover was added automatically through an integration with Meross. How can I modify the existing entity to add the “opening” and “closing” states as recommended in the MQTT example you linked? As far as I can tell, the sensor and the opener are one entity.
Ah, scroll up a bit to where I gave them 2 options. Option 1 was to create a template cover.
A template cover is a way to create a new cover and combine multiple things. You could add a new sensor (tilt sensor, another reed sensor, light sensor…) and use this sensor to help determine the template cover’s state. You can use anything as a sensor really.
In that example, they had a sensor for open and one for closed. So we could determine which way the door was moving.
In your example, you only have one sensor. So we only know 2 things. It’s either closed, or opening (it’s opening if the closed state changed in the last X seconds).
For example, you could create an input boolean that turns on when the cover.close command is called. Then use that boolean as another ‘sensor’.
- alias: 'garage door cover called'
trigger:
platform: event
event_type: call_service
event_data:
domain: cover
condition:
condition: template
# Match this cover.garage_door to your actual garage door
value_template: "{{ trigger.event.as_dict()['data']['service_data']['entity_id'] == 'cover.garage_door' }}"
action:
- service: input_boolean.turn_on
entity_id: input_boolean.garage_moving
# Make this delay close to how long it normally takes to fully open/close
- delay: "00:00:30"
- service: input_boolean.turn_off
entity_id: input_boolean.garage_moving
cover:
- platform: template
covers:
garage_door:
friendly_name: "Garage Door"
# With only one sensor, we'll have to guess.
# If the sensor reports closed, the door is closed. No guessing needed.
# If the sensor reports open, it could
value_template: >-
{% if is_state('sensor.garage_door_open_sensor', 'off') %}
closed
{% elif is_state('input_boolean.garage_moving', 'on') %}
moving
{% else %}
open
{% endif %}
open_cover:
service: cover.open_cover
# Update the entity_id to point to your current cover
entity_id: cover.garage_door
close_cover:
service: cover.close_cover
entity_id: cover.garage_door
stop_cover:
service: cover.stop_cover
entity_id: cover.garage_door
It’s just an example, but now you would use your new template cover in place of your other cover. The other cover still needs to be there, and the template cover is calling it. We’re just adding more sensors to it.
Excellent. So I wouldn’t use the Meross cover at all in the interface. It just becomes an input to my template cover, which uses both the real sensor and the template sensor to report position, which really becomes closed, opening, closing, and open (open being a presumed period after breaking close since it can’t open forever).
Any time it moves away from close, it goes to opening until x seconds after breaking contact, when it goes to open. Any time it moves away from open, it goes to closing until the contact sensor reads closed.
Ok - I’m going to leave that marked as solved, because that definitely added the new state. It didin’t fix the overall problem though. Google still chokes when closing a cover, but not when opening it.
I checked to make sure I was controlling the new cover, not the original one in the Google Assistant.
Any other ideas as to why Google is choking when closing covers, but not opening them? The error is “sorry, it looks like Home Assistant is not available right now.” Despite the error, it still activates the device and reports the state accurately when it updates.
@jocnnor Very interesting coding for those of us with just one sensor. Is there a way to create a template with these variables (for a better integration with HomeKit)?:
If the reed sensor reports closed, the HA door sensor reports closed.
If the reed sensor reports open, the HA door sensor reports opening for the first 24 seconds (or whatever your door takes to open) and then reports open
When close.cover has been called while the reed sensor reports open, the HA door sensor reports closing until the reed sensor reports closed.
Extra bonus: if 24 seconds after calling close.cover the reed sensor does not report closed, the HA sensor reports obstruction.
Next thing I’m going to try is to have the state change when close is called to immediately closed for 2 seconds, then change it to “closing” so that HA maintains an appropriate status until the sensor goes to “closed” for real. If that tricks Google but leaves the state intact with HA I think that is good enough.
That did it. Apparently, Google is expecting the state to change from “Open” to “Closed” in a very short timeframe when passed from Home Assistant. I tried a number of different transitional states, including “closing,” “moving,” “transitioning,” and none of them made Google happy. The only solution was to have the status immediately change to closed, wait 1 second, then change it to “closing” so that the status is correct in Home Assistant, and then allow the sensor to report as normal.
I bet the real answer is to learn what the transitional state is expected to be by Google to recognize that the door has not completely closed, but is on the way toward closing.I know it can support it because if I connect Meross directly to Google instead of using Home Assistant as the middle man it correctly recognizes that the command was successful. I have no idea where to look.
Interesting. It’s possible Meross is faking it out by sending “closed” to google. I mean, it’s what you are doing. Only difference is they can control the outgoing packets and display a separate state while you have to manipulate the state instead. I’d have to read the Google Home API to find the expected results.
I’m very interested by this topic.
I have a gate, that i want to show in homekit (i know that i have to use garage cover, because homekit is shit).
This gate i call it:
portail : for 2 leaves
portillon : for 1 leaf, for pedestrian
I have 0 sensor on it. I can’t know exactly when it’s open or close.
They auto close if nobody is there after around 1 minute.
I have this code, but after pushing the open button, both seems to stay in “opening” state
Here is my code