OnFreund / pyrisco

MIT License
9 stars 9 forks source link

Panel support for RP432MP #9

Closed maartenweyns closed 1 year ago

maartenweyns commented 1 year ago

As explained in home-assistant/core#82209, it looks like this library does not support my RP432MP panel for local connections. I have tried binding it to _rw432_capabilities in panels.py, but that seems to not work.

OnFreund commented 1 year ago

Can you share some more info:

  1. The log that you're basing this on
  2. The change you made to the code
  3. What happens after that change
OnFreund commented 1 year ago

Also, what are the right parameters for this system?

maartenweyns commented 1 year ago

These are the parameters you asked for:

When creating a basic script that connects, print the name of zones[1], and disconnects, I get the zone name, but also some errors about encoding:

zone-name-here
Error handler: 'utf-8' codec can't decode byte 0x9b in position 26: invalid start byte
Error handler: 'utf-8' codec can't decode byte 0xaf in position 30: invalid start byte

In risco_socket.py, I had to change the following:

panel_id = int(await self.send_result_command('RID'))
# Changed to
panel_id = int(await self.send_result_command('RID'), 16)
maartenweyns commented 1 year ago

I added a capabilities entry for the panel, and it all seems to work now. The errors that were appearing were probably due to my script, as those have also disappeared now.

OnFreund commented 1 year ago

OK, great. Can you create a PR with your changes?

maartenweyns commented 1 year ago

Yes, I will! It is however not really working correctly in HA. Should I make a new issue in home-assistant/core?

OnFreund commented 1 year ago

What exactly isn't working?

maartenweyns commented 1 year ago

HomeAssistant isn't able to generate an Alarm Panel, with the following in the logs:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 414, in async_add_entities
tasks = [
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 414, in <listcomp>
tasks = [
File "/config/custom_components/risco/alarm_control_panel.py", line 65, in <genexpr>
RiscoLocalAlarm(
File "/config/custom_components/risco/alarm_control_panel.py", line 229, in __init__
super().__init__(
File "/config/custom_components/risco/alarm_control_panel.py", line 113, in __init__
self._attr_supported_features |= STATES_TO_SUPPORTED_FEATURES[state]
TypeError: unsupported operand type(s) for |=: 'NoneType' and 'AlarmControlPanelEntityFeature'

Maybe this has to do with pyrisco? Otherwise this new issue is a better fit for on the home-assistant repo

OnFreund commented 1 year ago

This doesn't look related to your changes or your panel. Seems more likely to be some mistake in copying the code over to the custom component, or a config entry in a bad state.

maartenweyns commented 1 year ago

I tried setting the self._attr_supported_features to an empty dict before the |= operation. While it does resole the error (obviously), it still does not generate an alarm panel. The integration leaves me with a device for every zone but no central alarm panel.

OnFreund commented 1 year ago

I released version 0.5.7 with your changes: https://pypi.org/project/pyrisco/0.5.7/

My suggestion is that you start the custom component from scratch, and delete any config entry. Since you seem to know python, you can also open up a console and play with PyRisco directly to see if get partitions (you can use something like aioconsole to make it easy to work with async/await).

maartenweyns commented 1 year ago

I have re-installed the risco integration as a custom integration to use the new pyrisco version, and now everything seems to function! Great plugin, I'm glad it works now :) Thanks for your work @OnFreund!

OnFreund commented 1 year ago

Awesome. Do you want to create a PR in HA to upgrade the PyRisco version?