You could create automations to set the value of a input_text.
Not very fancy but will work just fine I believe.
@qoheleth my garage motor does stop if it senses any blockage while running, but I don’t think there’s any way for me to get at that data. At least based on the pins I can connect to.
@Hellis81 that could work yes, it has crossed my mind. I want to try a cleaner approach first.
So far I have created my own custom component based on the Cover Template and augmented that to support closing
and opening
states. That seems to be working.
Only thing left is have it refresh automatically after a configurable set of time. So when state changes to opening
or closing
I’ll set a timer to update the entity state.
I’ve only recent started using Home Assistant so I’m not entirely sure how these custom components work (nor am I that experienced in Python…). I’ll try to find another component that does something similar (with a timer) and base it off that.
I run into a similar issue a year ago. I also wanted to use the cover in HomeKit, but turns out the HA cover component, as you said, did not support opening
and closing
states, only open
and closed
. I wonder if your implementation, when used with HA HomeKit controller, gives HomeKit opening
and closing
values. My goal is to implement a fully working HomeKit garage cover integration with a Shelly 2.5 and 2 reeds (or 2 Shelly 1 and 2 reeds) like it’s done with this firmware or via MQTT. This is the one I’m using now and it works great. Two reeds give you real open
and closed
status and can also give HomeKit a jammed
alert if the door does not close in more than X seconds. Let me know what you think.
I think you’d have to make a few changes. IIRC my code assumes 1 reed that’s active for the closed position, and “opening” state is “faked” with a timer (configurable).
So to take advantage of the two reeds there would have to be some changes. You would not need a timer in this case.
Would you be able to share your config utilising this custom cover?
I see one of your issues was solved in Core recently enough (template covers can now support opening/closing states):
It’s cool that was merged. Still not enough to replace my custom cover though.
Here’s my config:
cover:
- platform: pcc
covers:
pcc_garage_door:
friendly_name: "Garage Door"
value_template: "{{ is_state('binary_sensor.garage_door_sensor', 'on') }}"
open_cover:
service: switch.toggle
data:
entity_id: switch.mqtt_garage_door_button
close_cover:
service: switch.toggle
data:
entity_id: switch.mqtt_garage_door_button
travelling_time_down: 22
travelling_time_up: 22
device_class: "garage"
unique_id: "pcc_garage_door"
I tried to use your repo but HA complained that the manifest had no version key.
More info here:
When you get a chance, it would good if you could add this to your repo.
Thanks
Malcolm
Thanks for mentioning that. I wasn’t aware. I don’t have time to look at this right now, but a Pull Request is welcome.
Edit: Never mind, I just realized it was really just a “version” field. I just added it.
Hey man, thanks for the script!! I’d like to use the same setup as yours, I uploaded your custom cover to homeassistant, and used your same config. Still it closes after n° seconds, but when opening it remains “in opening state”.
I tried to create a binary sensor with default close value but still, no luck:
binary_sensor:
- platform: template
sensors:
garage_door_sensor:
value_template: 'off'
Could you try to take a look at it, please? I opened an issue in your github
Thanks!!
Has anyone using this component upgraded to core-2022.2.x yet?
I’ve hit a problem - logs show the following:
Logger: homeassistant.components.cover
Source: custom_components/pcc/cover.py:152
Integration: Cover (documentation, issues)
First occurred: 10:22:50 (1 occurrences)
Last logged: 10:22:50
Error while setting up pcc platform for cover
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/pcc/cover.py", line 128, in async_setup_platform
async_add_entities(await _async_create_entities(hass, config))
File "/config/custom_components/pcc/cover.py", line 103, in _async_create_entities
PCCCover(
File "/config/custom_components/pcc/cover.py", line 152, in __init__
super().__init__(
TypeError: __init__() missing 1 required positional argument: 'hass'
It’s not obvious how to fix this, because it was working well for me.
It looks like CoverTemplate has changed from the version the code was based on
(https://github.com/home-assistant/core/blob/c41ec6f941252300cb4d0e50cbb2896ff28b95da/homeassistant/components/template/cover.py).
This version has a hass 1st parameter in the super.init. When I modify the pcc cover.py to match , the error goes away and my garage door is back working.
I’ll create an issue on the pcc GitHub for this.
I came up with my own solution using 2 magnetic reed switches on a D1 mini and HA’s native cover template.
Thanks to @pfandrade for the piece of code, it’s working for my Shelly 1 with one reed switch to get away from MyQ.
For the case of opening
to open
not occurring immediately, I added this automation:
- id: change_garage_door_state
alias: Change Garage Door State
trigger:
- platform: state
entity_id: cover.garage_door
to: 'opening'
action:
- delay: '00:00:13'
- service: homeassistant.update_entity
entity_id:
- cover.garage_door
Would you mind sharing where you found the garage icons?
You can never have too many icons!
I just wish KNX had vacant garage icons to match!
Apologies for resurrecting this topic, but is this custom component still a working solution 2.5 years later?
I’ve finally updated my Home Assistant and have also updated the code in the repo to work with the newer versions ( 2023.11.3).
This is great, thank you. I’m also running a setup with just one magnetic reed sensor for closed and with your component I’ve got this faking the opening and closing status.
This is the code that I’m using:
cover:
- platform: pcc
covers:
garage_door:
device_class: garage
friendly_name: "Garage Door"
unique_id: garage_door_cover
# travelling_time_down: 17 #not needed with closed sensor
travelling_time_up: 15
value_template: >-
{{ is_state('binary_sensor.garage_door_garage_door_contact', 'on') }}
open_cover:
service: switch.turn_on
target:
entity_id: switch.garage_door_trigger
close_cover:
service: switch.turn_off
target:
entity_id: switch.garage_door_trigger
stop_cover:
service: switch.turn_off
target:
entity_id: switch.garage_door_trigger
Two things that I’ve noticed:
- While home assistant is booting, the cover shows as
open
whilebinary_sensor.garage_door_garage_door_contact
isunavailable
. I would have thought the template would return false in that condition. travelling_time_up: 15
seems to overridevalue_template:
- I can see this by closing the door shortly after opening it. The state stays asopening
for the full 15 seconds, then goes straight to closed.
Great custom component, maybe this can be done with the template platform but I wasn’t able to achieve it - thankyou
For anyone using this in late 2024. ( me, I just started using it. =) )
Noted that when I tried to use it the PCC-entity was not created.
Found in the logs that it had some deprecation warnings and was not thread safe.
Created a pull request that solves these issues and now the entity is created successfully.
Removed SUPPORT_* will be deprecaded in 2025 warning
Note: There is still a unfixed issue when restarting HA that I did not solve (noted in the pull req).