lawtancool / hass-control4

Control4 integration for Home Assistant
Apache License 2.0
29 stars 9 forks source link

Add door locks that act as relays #11

Closed mellis closed 11 months ago

mellis commented 1 year ago

This change adds support for locks category items that present themselves as basic relays within Control4.

On my system I noticed the lock presented itself both as a generic relay device as well as a model-specific one. I've opted to ignore the latter as the additional information wasn't needed to integrate it with Home Assistant's lock entity and it was unclear how much of it was specific to my particular lock.

mellis commented 1 year ago

@lawtancool do you know when you might have a chance to take a look at this?

gadgetbazza commented 1 year ago

Hi @mellis , I'd love to be able to see my "relays" from my C4 system, so I swapped out the standard C4 integration for this custom_component installation and then made the changes you have in this commit to see if it would work for me.

At this point (following a restart), I'm not seeing any more entities. I was just wondering if you would expect my relays to appear as they aren't locks.

The relays I am trying to integrate are for two garage doors and open/close sensors, a pump relay (which is actually connected to a switchable light controller - where the lights are detected, but because one of the circuits has been re-classified as a pump in C4 it's not exposed in the integration) and also a gate with open/close sensor.

Am I hoping for too much? Appreciate your time in what you have done and any response. Thanks Barry

mellis commented 1 year ago

@gadgetbazza this change specifically looks at items that are categorized as locks in Control4. I wouldn't be surprised if they work similarly but I'd need more information on what fields (and their values) the items have.

gadgetbazza commented 1 year ago

Thanks for replying @mellis .

where will I find the category? I have the Composer Home Edition (not Pro), so I can see all the devices and the details, just can’t change anything?

asafalfa commented 1 year ago

@gadgetbazza jailbreak and get the composer Pro... it will show you that it used device file - Relaysingle door lock c4.c4i ANy how let hope @lawtancool will approve that... im also having some door look that i want to control via home assistant .. and also blind (shade) that can get up and down Oo...

asafalfa commented 1 year ago

@mellis Thank you for the code - i just tried it out and indeed it took the lock configuration from the control4! Works like a champ !

asafalfa commented 1 year ago

@mellis Can i ask you question - how complicate it will be to create also the ability to pull the Blind (Shade) from Control4? Is that complicate to do?

gadgetbazza commented 1 year ago

@mellis Can i ask you question - how complicate it will be to create also the ability to pull the Blind (Shade) from Control4? Is that complicate to do?

I can’t answer your question directly, but since c4 doesn’t have its own blinds, i assume that your blinds are 3rd party. Mine are Lutron and they integrate directly with HA and since it’s two way the state updates in both apps. HTH

asafalfa commented 1 year ago

@gadgetbazza Are you a control4 guy ;) since i have zero knowlege on this but i do have the Composer pro - if that is true as you stated i should have the driver that handle those .. but how can i look in the composer and understand what driver control the blind? Do you know how to do that ? I found it !!

image

So that comes from apperently some KNX blind driver ? Do you have any suggestion what will be the best to control it via HA ?

gadgetbazza commented 1 year ago

Hi, no just a c4 user. I just know what I have I guess. I’m pretty sure there is a knx integration for HA. I don’t know how knx works, but I suspect there is a knx hub/controller somewhere and when you add the knx integration to ha that you will need to know the ip address and then hopefully it will expose all your knx devices.

asafalfa commented 1 year ago

@mellis seems ilke something stopped working in your solution:

`Logger: homeassistant.components.websocket_api.http.connection Source: custom_components/control4/lock.py:124 Integration: Home Assistant WebSocket API First occurred: 1:34:01 PM (7 occurrences) Last logged: 1:37:17 PM

[139867099706176] { "error": "Unauthorized", "details": "Expired or invalid token" } [139866917378240] { "error": "Unauthorized", "details": "Expired or invalid token" } [139866899683520] { "error": "Unauthorized", "details": "Expired or invalid token" } [139867098108224] { "error": "Unauthorized", "details": "Expired or invalid token" } Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 226, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1974, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2011, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service return await service.entity_service_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 870, in entity_service_call response_data = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 942, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/lock/init.py", line 111, in _async_unlock await entity.async_unlock(**remove_entity_service_fields(service_call)) File "/config/custom_components/control4/lock.py", line 124, in async_unlock await c4_relay.close() File "/usr/local/lib/python3.11/site-packages/pyControl4/relay.py", line 70, in close await self.director.sendPostRequest( File "/usr/local/lib/python3.11/site-packages/pyControl4/director.py", line 99, in sendPostRequest await checkResponseForError(await resp.text()) File "/usr/local/lib/python3.11/site-packages/pyControl4/error_handling.py", line 114, in checkResponseForError raise exception(response_text) pyControl4.error_handling.BadToken: { "error": "Unauthorized", "details": "Expired or invalid token" }` are you familiar with this issue?

asafalfa commented 1 year ago

Unforthenetly also light.py having the same problem ... how can we renew token ?

asafalfa commented 1 year ago

Restart home assistant replace the token

lawtancool commented 11 months ago

@mellis Thanks for this contribution! Before I merge this, could you confirm that it still works in the latest version of Home Assistant (2023.11)

mellis commented 11 months ago

@lawtancool yup, still works fine for me on the latest 2023.11 release.

lawtancool commented 11 months ago

This is available in the latest release of this integration (v1.2.1)