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

Support for partitionless panels e.g. iConnect2. #2

Closed
wants to merge 1 commit into from

Conversation

SimonThoustrup
Copy link

Hey there.
I've added support for partitionless control panels such as the iConnect2 ref. home-assistant/core#40290. I've tested the changes in my Home Assistant and I have no errors in the log from the Risco integration. I hope I haven't broken anything for the panels that support partitions.
Please let me know if you think anything should be done differently.
Thanks.

@SimonThoustrup SimonThoustrup changed the title Added support for partitionless panels e.g. iConnect2. Support for partitionless panels e.g. iConnect2. Feb 2, 2021
Copy link
Owner

@OnFreund OnFreund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @SimonThoustrup. Let's figure out a more object oriented approach. This will also ensure less risk of changes to one systems breaking the other.
Ideally, I would like the decision point to be as early as possible, say another RiscoAPI implementation, and a single method that return either implementation depending on what type of system you have. From then on, the implementation should be separate with common base classes.

Thanks again!

@@ -36,41 +44,60 @@


class Partition:
"""A representation of a Risco partition."""
"""A representation of a Risco partition (or panel in case of no partitions)."""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a different class in the no partition case, since basically all properties now have the same if self._partitions_available: pattern. They can have a common base.

@@ -131,7 +161,10 @@ def __init__(self, raw):
def partitions(self):
"""Alarm partitions."""
if self._partitions is None:
self._partitions = {p["id"]: Partition(p) for p in self._raw["partitions"]}
if self._raw["partitions"] is not None:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this, but maybe better to return an empty collection and have a different property to return the partition-like object for non partition systems? Or maybe rename this property to panels?

@@ -329,28 +363,50 @@ async def login(self, session=None):
async def get_state(self):
"""Get partitions and zones."""
resp = await self._site_post(STATE_URL, {})
if resp["state"]["status"]["partitions"] is None:
self._partition_panel = False
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once again, we're repeating the same if self._partition_panel: in multiple locations. Let's find an OO way to represent this better.

@SimonThoustrup
Copy link
Author

Thanks @OnFreund. I won’t have time to work on this for the next few weeks so if somebody else want’s to pick it up please feel free to do so. If not I’ll have a go when time permits. :-)

@Rookie-Ron
Copy link

@SimonThoustrup Hi Simon, are there any developments in this area since February? I am still struggling with my 'Partitionless' Risco (MyElas) iConnect2 alarmsystem.
Any workarounds that you are aware of?

@SimonThoustrup
Copy link
Author

SimonThoustrup commented Dec 30, 2021 via email

@Rookie-Ron
Copy link

@SimonThoustrup Thanks for the hint, no luck however. Maybe I do not have the process clear?
First I installed pyrisco in my Python3.9 /site-packages subfolder. Thereafter I overwrote 'risco.py' by your patched file (dated February 2, 2021). After restarting Home Assistant the old error message remains: "File "/usr/local/lib/python3.9/site-packages/pyrisco/risco.py", line 134, in partitions self._partitions = {p["id"]: Partition(p) for p in self._raw["partitions"]}".

This seems strange, as the file the error points to is your patched one, in which line 134 has your updated content.
Probable I need to a different installation process? Can you help me?

@Rookie-Ron
Copy link

@SimonThoustrup @OnFreund
Being a 'rookie' in Docker indeed (running Home Assistant core-2021.12.7 in Docker), I discovered I needed to replace the 'risco.py' within the Home Assistant container, rather than in the host OS directory... After a restart of HAss the patched 'risco.py' resulted in the proper 'alarm_control_panel' domain and panel status indication, also in Lovelace:
image
Some issues remain for this moment:

  1. "inschakelen voor thuis" (= arm_home) does not function (Risco 'partial_arm'?), and results in the log:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
await handler.job.target(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 209, in handle_service
await self.hass.helpers.service.entity_service_call(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 663, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 896, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 700, in _handle_entity_call
await result
File "/usr/src/homeassistant/homeassistant/components/risco/alarm_control_panel.py", line 148, in async_alarm_arm_home
await self._arm(STATE_ALARM_ARMED_HOME, code)
File "/usr/src/homeassistant/homeassistant/components/risco/alarm_control_panel.py", line 174, in _arm
await self._call_alarm_method(risco_state)
File "/usr/src/homeassistant/homeassistant/components/risco/alarm_control_panel.py", line 177, in _call_alarm_method
alarm = await getattr(self._risco, method)(self._partition_id, *args)
File "/usr/local/lib/python3.9/site-packages/pyrisco/risco.py", line 409, in partial_arm
return Alarm(await self._site_post(CONTROL_URL_NO_PARTITIONS, body))
File "/usr/local/lib/python3.9/site-packages/pyrisco/risco.py", line 300, in _site_post
return await self._authenticated_post(site_url, site_body)
File "/usr/local/lib/python3.9/site-packages/pyrisco/risco.py", line 287, in _authenticated_post
raise OperationError(str(json))
pyrisco.risco.OperationError: {'result': 52, 'validationErrors': None, 'errorText': None, 'errorTextCodeID': '0', 'status': 200, 'response': {'classVersion': 0, 'partitions': None, 'systemStatus': 0, 'systemReady': True, 'trouble': False, 'bellStatus': 0, 'alarmPending': False, 'batteryLow': False, 'acLost': False, 'haEnabled': False, 'bellOn': False, 'zones': None, 'haDevices': None, 'users': None, 'devCollection': None, 'exitDelayTimeout': 0, 'armNotAllowed': False, 'disarmNotAllowed': False, 'cpTime': '2022-01-02T21:05:01.9332344+00:00', 'partReadySupported': False, 'partFullReady': False, 'part1Ready': False, 'part2Ready': False, 'type': 2}}

Function "inschakelen voor vertrek" (=arm_away) does work as expected.

  1. If I activate "inschakelen voor thuis" (= arm_home) through the alarm panel itself (and my mobile phone) it results in status 'unknown' when the alarm is (partially)armed:

image

For this: Comments on the Log? Is there something I should do in the mapping of 'arm_home' versus 'partial_arm'? Is 'arm_home' supported anyway?

@ASOUAMES
Copy link

Hi @Rookie-Ron

How did you replace the 'risco.py' within the Home Assistant container? I cant find the path. I am running HA OS on oracle virtualbox.

Can you please post a guide on how you did it?

Thank you.

@Rookie-Ron
Copy link

Hi @Rookie-Ron

How did you replace the 'risco.py' within the Home Assistant container? I cant find the path. I am running HA OS on oracle virtualbox.

Can you please post a guide on how you did it?

Thank you.

I am running Home Assistant (core) in a Docker Container. The container has his own file structure, which you can access with command:

sudo docker exec -it homeassistant sh

When you change to the main directory with cd /, the ls command will show you the file structure.

'risco.py' is under /usr/local/lib/python3.9/site-packages/pyrisco

To replace the default file with the patched one, from the directory where you saved the patch, use:

sudo docker cp risco.py homeassistent:/usr/local/lib/python3.9/site-packages/pyrisco/risco.py

One downside: after each update of Home Assistant you need to copy the patch to replace the original file.

Good luck!

@ASOUAMES
Copy link

ASOUAMES commented Aug 4, 2022

Hey there,

Are you having issues after update Homeassistant 2022.8.0?

I replaced the default file with the patched one:
sudo docker cp risco.py homeassistant:/usr/local/lib/python3.10/site-packages/pyrisco/risco.py

and I get an error: Error while setting up risco platform for alarm_control_panel

It worked flawlessly before the update.

Any ideas?

Thank you!

@OnFreund
Copy link
Owner

OnFreund commented Aug 4, 2022

The API has changed with the latest version, so whatever patch you're using will have to change accordingly.

@ASOUAMES
Copy link

ASOUAMES commented Aug 4, 2022

Thank you @OnFreund for the explanation.

I am using @SimonThoustrup 's patch. Is this something that can be done easily?

@OnFreund
Copy link
Owner

OnFreund commented Aug 4, 2022

Don't know - you'll have to ask Simon...

@OnFreund
Copy link
Owner

There hasn't been any real activity here for over 18 months, and the library has changed quite significantly in the mean time, so I'm closing this.

@OnFreund OnFreund closed this Aug 25, 2022
@ASOUAMES
Copy link

Hi @SimonThoustrup are you planning to make changes to your patch?

@Rookie-Ron
Copy link

Hi @SimonThoustrup, same issue and question from my side as @ASOUAMES. Are you planning an update to your patch to match the new API? Any hints how to do it myself?

@ASOUAMES
Copy link

Perhaps @SimonThoustrup is busy and cannot deal with this at the moment. Our only solution is for partitionless panels to be supported by @OnFreund. Hopefully one day.

@OnFreund
Copy link
Owner

OnFreund commented Sep 20, 2022

@ASOUAMES as I mentioned multiple times - I don't have a partition-less panel and I don't have a way to develop and test for it.
I'm happy to provide assistance, but someone else will have to make it happen.

@ASOUAMES
Copy link

Understood, what if I gave you access to my panel? My knowledge of python is s..t.

@OnFreund
Copy link
Owner

  1. That's not something I can develop remotely. It requires quick iterations
  2. I don't have the API for local communication

@ASOUAMES
Copy link

lucacalcaterra/risco-mqtt-bridge#52

Found a work around. Perhaps it will help.

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

Successfully merging this pull request may close these issues.

4 participants