XaF / qolsysgw

Qolsys IQ Panel 2+ gateway to an Home Assistant Alarm Control Panel
MIT License
131 stars 13 forks source link

Qolsys gateway not receiving sensor change states #133

Open amogh79 opened 1 year ago

amogh79 commented 1 year ago

Hi,

My qolysys gateway is not receiving sensor change states whenever the sensor state changes and is displayed on the panel. If I reboot the panel, then on panel startup I receive all the sensor states and other panel info. I checked this using a MQTT client listening to Homeassistant MQTT broker.

Any reason why I am not receiving the sensor change states.

Help will be much updated.

Thanks

shivamchoudhary commented 11 months ago

Would you be able to run the below snippet from your local network by adapting the Qolsys Parameters and check if you get the INFO messages when the sensor changes states ?

#!/usr/bin/python3

import json
import socket
import ssl
import sys
import time

# Qolsys Parameters
qolsysPanel     = "your_panel_ip"
qolsysPort      = yourport 
qolsysToken     = "yourtoken"
qolsysTimeout   = 20

################################################################################
# Code

statusString    = {
                    "nonce":        "test",
                    "action":       "INFO",
                    "info_type":    "SUMMARY",
                    "version":      0,
                    "source":       "C4",
                    "token":        qolsysToken,
                }

def main():
    try:
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.settimeout(qolsysTimeout)
    except socket.error:
        print('Could not create a socket')
        sys.exit()

    # Wrap SSL
    wrappedSocket = ssl.wrap_socket(sock, cert_reqs=ssl.CERT_NONE, ssl_version=ssl.PROTOCOL_TLSv1_2)

    # Connect to server
    try:
        wrappedSocket.connect((qolsysPanel, qolsysPort))
    except socket.error:
        print('Could not connect to server')
        sys.exit()

    # Send message and print reply
    online = True
    while online:
        wrappedSocket.send((json.dumps(statusString)).encode())
        while True:
            response = wrappedSocket.recv(4096).decode()
            if is_json(response):
                print(response)
            break  # stop receiving
        time.sleep(qolsysTimeout / 4)

def is_json(myjson):
    try:
        json_object = json.loads(myjson)
    except ValueError as e:
        return False
    return True

# Start client
main()
amogh79 commented 10 months ago

I get status messages for all the sensors. When I open one of the sensor I get ZONE_EVENT stating the sensor is open. Its kinda weird that it shows the ZONE_EVENT = open then closed then again open wherein the sensor is always open and no changes are done to the sensor state. The status of all the sensors also gets updated with that particular sensor showing it open.

Do you have code snippet and the actual command to arm and disarm? I would like to try that from the code. Those actions dont work from my home assistant either.

kg5iru commented 10 months ago

I have the same issue but haven't had time to sit down and look at it.

My system also appears to send [Zone_Event = open] when the sensor is open and [Zone_Event = closed] when closed to MQTT.

amogh79 commented 10 months ago

I also observed that after I close the sensor it still send the status in json as open. Its been 5 minutes now and it still shows it as open.

amogh79 commented 10 months ago

@kg5iru Does the sensor state change in home assistant UI for you? For me it doesn't change.

kg5iru commented 10 months ago

The only changes I get are back and forth from unavailable to closed when I'm restarting AppDaemon when I thought something was wrong with my config and started over.

amogh79 commented 10 months ago

The only changes I get are back and forth from unavailable to closed when I'm restarting AppDaemon when I thought something was wrong with my config and started over.

I have the same issue I only get sensor states on startup and never after that.

kg5iru commented 10 months ago

That is exactly what I have going on. Homeassistant only show the initial change from unavailable to closed. Homeassistant only ever changes back to unavailable (after stopping appdaemon) after that.

MQTT Zone_Event does show the correct status of the sensors.

XaF commented 10 months ago

What hardware and software versions of the qolsys panel are you using?

kg5iru commented 10 months ago

What hardware and software versions of the qolsys panel are you using?

IQPanel4 Model: IQP4006 HW Version: Rev 1

SW Version: 4.3.0-ADCS 10.9.2 Last Software Version Upgrade: 4.3.0.20230417.rc2183_full_upgrade_generic.zip

halfordfan commented 4 months ago

I ran into something like this. I wasn't getting state changes for sensors added since the 0.14->0.15 upgrade. Also had issues with name changes and changes in zone types not showing up. Reboots of the panel and HA did not help. I tried purging the entities and they wouldn't budge. I ended up uninstalling appdaemon and mqtt add-ons, re-pulling the qolsysgw code, and setting it all up again (took 5 minutes). No problems since.