Skip to content
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

Feature request: Locks #6

Open
phellarv opened this issue Oct 25, 2018 · 27 comments
Open

Feature request: Locks #6

phellarv opened this issue Oct 25, 2018 · 27 comments

Comments

@phellarv
Copy link

I have a Yale Doorman which is integrated into the alarm system. It would be very nice to control this. I can beta-test if you want to.

@mgejke
Copy link
Owner

mgejke commented Oct 26, 2018

I can try to take a look, but I might need some help to understand how it works...

@phellarv
Copy link
Author

Here is a python library with functional lock control: https://github.com/petterl/python-sectoralarm

@phellarv
Copy link
Author

phellarv commented Nov 7, 2018

Had the time to have a look at it?

@bokaking
Copy link

It wold be great if you can take a look on locks. Lot of people would appreciate this feature.

@mgejke
Copy link
Owner

mgejke commented Nov 19, 2018

Yeah, sorry, I forgot to answer. I did have a short look, but the other project uses a different set of urls than I do so it wasn't as straightforward as I hoped.

If any of you could find the endpoints and payloads that the web-ui uses, that would help:
https://mypagesapi.sectoralarm.net/

@marcusramberg
Copy link

GET https://mypagesapi.sectoralarm.net/Locks/GetLocks/?WithStatus=true&id=<redacted>

response
[{
    "Label": null,
    "PanelId": "redacted",
    "Serial": "redacted",
    "Status": "unlock",
    "SoundLevel": 0,
    "AutoLockEnabled": false,
    "Languages": null
}, {
    "Label": null,
    "PanelId": "redacted",
    "Serial": "redacted",
    "Status": "lock",
    "SoundLevel": 0,
    "AutoLockEnabled": false,
    "Languages": null
}]



POST  https://mypagesapi.sectoralarm.net/Locks/Lock
{"id":"redacted","LockSerial":"redacted","DisarmCode":"redacted"}

response:
{
    "panelData": null,
    "Message": null,
    "Status": "success"
}

@mgejke
Copy link
Owner

mgejke commented Dec 1, 2018

@marcusramberg Awesome!

I've made an initial test:
Clone the branch locks from this repo
Clone the branch locks from https://github.com/mgejke/asyncsector and put in in your <config_folder>\deps\PythonXX\site-packages\asyncsector\

Hopefully fetching the state of the locks should work... It that seems ok, I'll try to get locking/unlocking working as well!

@marcusramberg
Copy link

marcusramberg commented Dec 3, 2018

After loading those I get

2018-12-03 11:40:38 ERROR (MainThread) [homeassistant.loader] Unable to find component lock.sector_alarm
2018-12-03 11:40:38 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform lock.sector_alarm: Platform not found.

@mgejke
Copy link
Owner

mgejke commented Dec 3, 2018

I seem to have missed a folder when committing, will fix tonight...

@mgejke
Copy link
Owner

mgejke commented Dec 3, 2018

Fixed!

@marcusramberg
Copy link

Awesome. This works 🎉 I now have two locked locks in state list :)

@marcusramberg
Copy link

Also trying to unlock triggers the NotImplementedError stubs as expected. 💯

@mgejke
Copy link
Owner

mgejke commented Dec 4, 2018

@marcusramberg Nice!
Is it the same code for locking/unlocking as for arming/disarming?

@marcusramberg
Copy link

marcusramberg commented Dec 4, 2018 via email

@phellarv
Copy link
Author

phellarv commented Dec 4, 2018

Every second time I restart hassio, the component consistently fails with a timeout-error (branch: Locks):

2018-12-04 17:41:49 ERROR (MainThread) [homeassistant.setup] Error during setup of component sector_alarm
Traceback (most recent call last):
File "/config/deps/lib/python3.6/site-packages/asyncsector/asyncsector.py", line 37, in login
AsyncSector.Base + AsyncSector.Login, json=self._auth)
File "/usr/local/lib/python3.6/site-packages/aiohttp/client.py", line 391, in _request
await resp.start(conn)
File "/usr/local/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 757, in start
message, payload = await self._protocol.read()
File "/usr/local/lib/python3.6/site-packages/aiohttp/streams.py", line 543, in read
await self._waiter
concurrent.futures._base.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/homeassistant/setup.py", line 145, in _async_setup_component
hass, processed_config)
File "/config/custom_components/sector_alarm.py", line 60, in async_setup
if not await async_sector.login():
File "/config/deps/lib/python3.6/site-packages/asyncsector/asyncsector.py", line 43, in login
return True
File "/usr/local/lib/python3.6/site-packages/async_timeout/init.py", line 45, in exit
self._do_exit(exc_type)
File "/usr/local/lib/python3.6/site-packages/async_timeout/init.py", line 92, in _do_exit
raise asyncio.TimeoutError
concurrent.futures._base.TimeoutError

@phellarv
Copy link
Author

phellarv commented Dec 4, 2018

But the other times it works like a charm.

@mgejke
Copy link
Owner

mgejke commented Dec 5, 2018

@phellarv That seems to be related to the login, strange.

@mgejke
Copy link
Owner

mgejke commented Dec 5, 2018

Pushed some new code that perhaps makes it possible to lock/unlock. Please try it out!

@marcusramberg The post command you posted only has a Locks/Lock endpoint, and there's nothing in the payload to indicate unlock/lock, so for this iteration I just implemented it as a toggle...

@marcusramberg
Copy link

@mgejke I don't see the new code. perhaps you forgot to push? The endpoint for unlock is Locks/Unlock btw.

@mgejke
Copy link
Owner

mgejke commented Dec 6, 2018

Odd. I'm pretty sure I pushed, and the latest command left in the console was push...

It's pushed now anyway, with the added Unlock endpoint.

@phellarv
Copy link
Author

2018-12-12 00:40:35 ERROR (MainThread) [homeassistant.components.lock] Error while setting up platform sector_alarm
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
return fut.result()
File "/config/custom_components/lock/sector_alarm.py", line 22, in async_setup_platform
code = discovery_info[sector_alarm.CONF_CODE]
KeyError: 'code'

@mgejke
Copy link
Owner

mgejke commented Dec 12, 2018

@phellarv Fixed, I think...

@phellarv
Copy link
Author

Yes - No errors now. But locking and unlocking does not do anything. And there is no error message. Anything I can do to debug this?

@marcusramberg
Copy link

Same for me fwiw

Sent with GitHawk

@marcusramberg
Copy link

Is there an ENV variable or something to set to dump the http request being made for debugging?

@Lintan83
Copy link

How is it going with the locks or how can i get them integrated to my hass.io?

@phellarv
Copy link
Author

Is this branch dead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants