Homeassistant create a rest api integration diy Visonic alarm system

Hi, I want to integrate my home alarm system (Visonic) to home assistant. I could not find a integration which works for my parameters and setup. I am using a Visonic PowerMaster 30 with Powerlink ip module. So it is not able to use this project because of the ip module GitHub - davesmeghead/visonic: Visonic Custom Component for integration with Home Assistant

And don’t want to buy a new module.

But I found this project which enabled me with python to enable disable the alarm from the cli using python by connecting to the api of the Visonic go app

So I thought to create a integration by myself using the api if this is easily possible. I am not a programmer or something like this. So is there any easy way to do this? How should I start what is the best tool for it and so on. Is there any good guide how to get there ? I am quite new to home Assistent and never tried to do something like a integration. So I would be thankful for any help I can get.

I also tried postman and could arm disarm and get the device details and so on.
What is the easiest way ? Working with Rest API from scatch or using the python module from github to start.

Thx

1 Like

Considering all of your carefully phrased remarks above, definitely work with the RESTful integration :wink:

I had the same problem. There is an integration that works with the rest api already, which is this.

However, i found it quite basic and didnt include all the functionality i wanted. So i developed my own version. I tried to get the original api developer to update their version but got no response, so it is just in my repo atm. I am planning to release it at some point in the future and will keep updating it as i find more capabilities. You are welcome to clone the repo and use if you wish.

1 Like

Hi your integration looks fantastic.
it also supportes multiple partitions as far as I could read this from the source code.
It seems that this integration can deliver everything I need.

I just can’t get it working so far.
I just did the configuration in the Integration.

I entered in the webgui the following information:
hostname, email, pw.

The Login works I get the correct pannel ID.
Than I entered the User Code and I get a No device or entities Error.

Any hint why ? I typed the same information in like in my other tests (Rest, other integrations…) So this should be correct.

What do you get in the logs? If you turn on debugging too and share that.

Scrap that. I think I was playing with something and maybe comiited a broken update. Update form repo and see if that works now.

NOTE: I am not sure it fully supports multiple partitions, but happy to work with you to be able to do that.

Hi this is awesome that you want to help me here, I really appreciate your help.
We are getting closer :wink: Thx for updateing the code.

The Integration now adds 2 Devices but all the sensors are missing and I can’t arm or disarm the device right now.

and this is the log:

    status = partition.status
             ^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'status'
2023-07-22 20:31:05.940 ERROR (MainThread) [homeassistant.components.sensor] Platform visonicalarm does not generate unique IDs. ID visonicalarm-123456-Partition Ready already exists - ignoring sensor.partition_ready
2023-07-22 20:31:05.945 ERROR (MainThread) [homeassistant.components.sensor] Platform visonicalarm does not generate unique IDs. ID visonicalarm-123456-098765state already exists - ignoring sensor.outdoor_state
2023-07-22 20:31:43.165 DEBUG (MainThread) [custom_components.visonicalarm] Unload Visonic integration platforms
2023-07-22 20:31:43.174 DEBUG (MainThread) [custom_components.visonicalarm] Unload integration
2023-07-22 20:31:43.177 DEBUG (MainThread) [custom_components.visonicalarm.coordinator] Initiating Visonic API
2023-07-22 20:31:43.384 DEBUG (MainThread) [custom_components.visonicalarm.coordinator] Supported rest versions: ['9.0']
2023-07-22 20:31:43.468 DEBUG (MainThread) [custom_components.visonicalarm.coordinator] Not logged in - so do it now!
2023-07-22 20:31:43.887 DEBUG (MainThread) [custom_components.visonicalarm.coordinator] Finished fetching visonicalarm ([email protected]) data in 0.710 seconds (success: True)
2023-07-22 20:31:43.942 INFO (MainThread) [custom_components.visonicalarm] Visonic Alarm Setup Completed
2023-07-22 20:31:43.951 INFO (MainThread) [homeassistant.components.alarm_control_panel] Setting up alarm_control_panel.visonicalarm
2023-07-22 20:31:43.953 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.visonicalarm
2023-07-22 20:31:43.956 INFO (MainThread) [homeassistant.components.switch] Setting up switch.visonicalarm
2023-07-22 20:31:43.961 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: VISONIC_PANEL, CONTROL_PANEL
2023-07-22 20:31:43.962 DEBUG (MainThread) [custom_components.visonicalarm.sensor] New device found [Type: CONTROL_PANEL VISONIC_PANEL ] [ID: 098765]
2023-07-22 20:31:43.962 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Adding panel status sensor
2023-07-22 20:31:43.963 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: CONTACT_AUX, ZONE
2023-07-22 20:31:43.964 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: CONTACT_AUX, ZONE
2023-07-22 20:31:43.965 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: CONTACT_AUX, ZONE
2023-07-22 20:31:43.967 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: CONTACT_AUX, ZONE
2023-07-22 20:31:43.968 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: BASIC_KEYFOB, KEYFOB
2023-07-22 20:31:43.969 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: BASIC_KEYFOB, KEYFOB
2023-07-22 20:31:43.970 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: BASIC_KEYFOB, KEYFOB
2023-07-22 20:31:43.971 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: OUTDOOR, WL_SIREN
2023-07-22 20:31:43.971 DEBUG (MainThread) [custom_components.visonicalarm.sensor] New device found [Type: WL_SIREN OUTDOOR ] [ID: 098765]
2023-07-22 20:31:43.971 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: None, GSM
2023-07-22 20:31:43.972 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: POWER_LINK, POWER_LINK
2023-07-22 20:31:43.973 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: PGM_ON_PANEL, PGM
2023-07-22 20:31:43.973 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: GENERIC_PROXY_TAG, PROXY_TAG
2023-07-22 20:31:43.975 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: GENERIC_PROXY_TAG, PROXY_TAG
2023-07-22 20:31:43.976 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: GENERIC_PROXY_TAG, PROXY_TAG
2023-07-22 20:31:43.983 ERROR (MainThread) [homeassistant.components.alarm_control_panel] Error while setting up visonicalarm platform for alarm_control_panel
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 353, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/visonicalarm/alarm_control_panel.py", line 48, in async_setup_entry
    visonic_alarm = [VisonicAlarm(coordinator, hass)]
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/visonicalarm/alarm_control_panel.py", line 92, in __init__
    self._state = self.get_partition_state(self._partition)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/visonicalarm/alarm_control_panel.py", line 172, in get_partition_state
    status = partition.status
             ^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'status'
2023-07-22 20:31:44.031 ERROR (MainThread) [homeassistant.components.sensor] Platform visonicalarm does not generate unique IDs. ID visonicalarm-123456-Partition Ready already exists - ignoring sensor.partition_ready
2023-07-22 20:31:44.034 ERROR (MainThread) [homeassistant.components.sensor] Platform visonicalarm does not generate unique IDs. ID visonicalarm-123456-098765state already exists - ignoring sensor.outdoor_state

I assume you have multiple partitions? Looking through code, as I said above, not really supporting multiple partitions. Give me a few days and I will make some amends to see if we can support this.

Are you able to download the diagnostics? The three dots menu on the screen in your screenshot and download diagnostics option. This may help me see how the data is presented.

yes exactly I have 2 Partitions.
Yes this would be perfect if it is possible to support this.

I will send you the diagnostic data via. PM.
Thanks for the help.

OK, have pushed some updates. Do you want to give this a go?

Hi,
I have now the sensors, the Partitions and the panel. But I can’t arm or disarm.
Also the Sensors don’t have a name just a number and I can not see the state or status.

If I click on device info for a sensor: I get this message: Device / service not found.

2023-07-23 20:28:18.299 DEBUG (MainThread) [custom_components.visonicalarm] Unload Visonic integration platforms
2023-07-23 20:28:18.347 DEBUG (MainThread) [custom_components.visonicalarm] Unload integration
2023-07-23 20:28:18.349 DEBUG (MainThread) [custom_components.visonicalarm.coordinator] Initiating Visonic API
2023-07-23 20:28:18.562 DEBUG (MainThread) [custom_components.visonicalarm.coordinator] Supported rest versions: ['9.0']
2023-07-23 20:28:18.651 DEBUG (MainThread) [custom_components.visonicalarm.coordinator] Not logged in - so do it now!
2023-07-23 20:28:19.034 DEBUG (MainThread) [custom_components.visonicalarm.coordinator] Finished fetching visonicalarm ([email protected]) data in 0.685 seconds (success: True)
2023-07-23 20:28:19.087 INFO (MainThread) [custom_components.visonicalarm] Visonic Alarm Setup Completed
2023-07-23 20:28:19.098 INFO (MainThread) [homeassistant.components.alarm_control_panel] Setting up alarm_control_panel.visonicalarm
2023-07-23 20:28:19.101 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.visonicalarm
2023-07-23 20:28:19.103 INFO (MainThread) [homeassistant.components.switch] Setting up switch.visonicalarm
2023-07-23 20:28:19.119 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: VISONIC_PANEL, CONTROL_PANEL
2023-07-23 20:28:19.120 DEBUG (MainThread) [custom_components.visonicalarm.sensor] New device found [Type: CONTROL_PANEL VISONIC_PANEL ] [ID: 372897 ]
2023-07-23 20:28:19.120 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Adding panel status sensor
2023-07-23 20:28:19.121 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: CONTACT_AUX, ZONE
2023-07-23 20:28:19.123 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: CONTACT_AUX, ZONE
2023-07-23 20:28:19.124 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: CONTACT_AUX, ZONE
2023-07-23 20:28:19.125 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: BASIC_KEYFOB, KEYFOB
2023-07-23 20:28:19.140 DEBUG (MainThread) [custom_components.visonicalarm.sensor] New device found [Type: KEYFOB BASIC_KEYFOB ] [ID: 372908 ]
2023-07-23 20:28:19.140 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: BASIC_KEYFOB, KEYFOB
2023-07-23 20:28:19.140 DEBUG (MainThread) [custom_components.visonicalarm.sensor] New device found [Type: KEYFOB BASIC_KEYFOB ] [ID: 372909 ]
2023-07-23 20:28:19.141 DEBUG (MainThread) [custom_components.visonicalarm.sensor] New device found [Type: KEYFOB BASIC_KEYFOB ] [ID: 372910 ]
2023-07-23 20:28:19.141 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: BASIC_KEYFOB, KEYFOB
2023-07-23 20:28:19.141 DEBUG (MainThread) [custom_components.visonicalarm.sensor] New device found [Type: KEYFOB BASIC_KEYFOB ] [ID: 372911 ]
2023-07-23 20:28:19.142 DEBUG (MainThread) [custom_components.visonicalarm.sensor] New device found [Type: KEYFOB BASIC_KEYFOB ] [ID: 372912 ]
2023-07-23 20:28:19.142 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: OUTDOOR, WL_SIREN
2023-07-23 20:28:19.144 DEBUG (MainThread) [custom_components.visonicalarm.sensor] New device found [Type: WL_SIREN OUTDOOR ] [ID: 372907 ]
2023-07-23 20:28:19.150 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: None, GSM
2023-07-23 20:28:19.150 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: POWER_LINK, POWER_LINK
2023-07-23 20:28:19.150 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: PGM_ON_PANEL, PGM
2023-07-23 20:28:19.150 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: GENERIC_PROXY_TAG, PROXY_TAG
2023-07-23 20:28:19.150 DEBUG (MainThread) [custom_components.visonicalarm.sensor] New device found [Type: PROXY_TAG GENERIC_PROXY_TAG ] [ID: 372916 ]
2023-07-23 20:28:19.151 DEBUG (MainThread) [custom_components.visonicalarm.sensor] Found: GENERIC_PROXY_TAG, PROXY_TAG
2023-07-23 20:28:19.151 DEBUG (MainThread) [custom_components.visonicalarm.sensor] New device found [Type: PROXY_TAG GENERIC_PROXY_TAG ] [ID: 372917 ]
2023-07-23 20:28:19.151 DEBUG (MainThread) [custom_components.visonicalarm.sensor] New device found [Type: PROXY_TAG GENERIC_PROXY_TAG ] [ID: 372918 ]
2023-07-23 20:28:19.200 ERROR (MainThread) [homeassistant.components.alarm_control_panel] Error while setting up visonicalarm platform for alarm_control_panel
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 353, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/visonicalarm/alarm_control_panel.py", line 50, in async_setup_entry
    alarms.append(VisonicAlarm(coordinator, hass, partition.id))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/visonicalarm/alarm_control_panel.py", line 95, in __init__
    self._state = self.get_partition_state(self._partition_status)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/visonicalarm/alarm_control_panel.py", line 187, in get_partition_state
    status = partition_status.status
             ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'status'
2023-07-23 20:28:49.478 DEBUG (MainThread) [custom_components.visonicalarm.coordinator] Finished fetching visonicalarm ([email protected]) data in 0.249 seconds (success: True)

I also send you the diagnostics via PM agin.
And thx for the fast adoption of the integration. I guess its just a bit to get everything running.

So, I enabled partitions on my alarm to better test this. If you update the code now, it should be working to allow arm/disarm for each partition.

I need to think more about a way to arm both partitions at once as the HA alarm panel entity expects a status and there isn’t one for the -1 ALL partition when multi partitions are enabled. So for now, you will have to arm each one individually but I am sure I will find an answer in the next few days.

Wooow awesome this works great. Thx so much.
And it is totlly fine to just activate each partion seperatly for now. This helps me already alot.

Something else maybe this could also be interesting to get this working:

In the HA GUI I can just see theAccessories: like Keyfob and Tags.

In the Visonic-Go App and in the Python script I can also see the window and door contacts and if a window is open. Maybe it is also possible to integrate this also. So that we can see if a window or door is open and which sensor it is. They al beling to the Contact + AUX Sensors.

Cool it is now working. The contact sensors should have shown up but there was a typo in the name - I have them as AUX_CONTACT instead of CONTACT_AUX. Update again and they will show with their open/closed status.

image

NOTE: You will not see bypass switch as your panel is set to no bypass, but if you chnage it to manual bypass, you will get this on each sensor

Hi,
thx Mark, currently I don’t have any bypass switches. Just the Door and Window Sensors.
The Window Sensors are now in Home Assistant. But the Sensor State of all the CONTACT Sensors is Unknown. I opened the door multiple times and let it open for a few minutes, but no changes.

Sorry about this, wrote this some time ago and have forgotten all the bits to add new device types (I may have to simplify it! :grinning:) and its quite hard to test when I don’t have the same devices/setup.

Another update is available and this should now show the status of your contact sensors.

sure no problem I am very happy that we could get this working so fast an quick.
Awesome now its perfect for my needs. Thx so much.
To Arm all Partitions would be also a nice feature.
But this is already so great.

@keamas, you may find this breaks with the 2023.8.0 and above realeases of HA. I have provided an updated fixed version in the master branch, so if you just update it will work again.

Wooow you are so fast. I didn’t Update so fast ;-).
But just did the Update of HA and the Visonic Integration.
So far everything works great. Thx for Updatin the Repo so fast.

Hello MSP1974,
I tried your application with a DSC WP8030 alarm, which is a copy of the Visonic Powermaster 30 alarm. I can arm and disarm the alarm, the sensors have been identified by the application, the bypass control works well, but they are all an “unknown” status.
Can you help me ?
Sincerely