bkbilly / AlarmPI

🚨 Home Security Intrusion Detection for Raspberry PI or any other linux OS
http://bkbilly.github.io/AlarmPI/
MIT License
105 stars 13 forks source link

Cannot connect via https #31

Open steppatrik opened 7 months ago

steppatrik commented 7 months ago

Describe the problem Hi, I have problem right after installation - installation went OK with no issue, after that, I cannot load web page for configuring.. tryied https/http variant, various ports and logins, nothing worked.. I have raspberry 3B

localhost address giving me: This site can’t be reached 192.168.1.110 refused to connect

Code after running main script:

pi@raspberrypi:/opt/AlarmPI $ sudo python3 run.py
Exception in thread Thread-1:
2024-03-29 23:13:57 [INFO] [notifier:__init__:445]  ------------ INIT FOR DOOR SENSOR CLASS! ----------------
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
Exception ignored in: <function Client.__del__ at 0x751f9928>
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 874, in __del__
    self.run()
  File "/usr/lib/python3.9/threading.py", line 892, in run
    self._reset_sockets()
  File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 1133, in _reset_sockets
    self._target(*self._args, **self._kwargs)
  File "/opt/AlarmPI/alarmcode/logs.py", line 83, in trimLogFile
    with open(self.logfile, 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/opt/AlarmPI/alert.log'
    self._sock_close()
  File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 1119, in _sock_close
    if not self._sock:
AttributeError: 'Client' object has no attribute '_sock'
2024-03-29 23:13:57 [ERROR] [run:<module>:53]  Unknown error has occured Contact Author:
Traceback (most recent call last):
  File "/opt/AlarmPI/run.py", line 50, in <module>
    myserver.startMyApp()
  File "/opt/AlarmPI/alarmcode/alarmpi.py", line 367, in startMyApp
    self.users[user]['obj'] = Worker(
  File "/opt/AlarmPI/alarmcode/Worker.py", line 44, in __init__
    self.mynotify = Notify(self.wd, self.settings, self.optsUpdateUI, self.mylogs)
  File "/opt/AlarmPI/alarmcode/notifier.py", line 449, in __init__
    self.mqtt = notifyMQTT(self.settings, self.optsUpdateUI, self.mylogs, self.callbacks)
  File "/opt/AlarmPI/alarmcode/notifier.py", line 103, in __init__
    self.setupMQTT()
  File "/opt/AlarmPI/alarmcode/notifier.py", line 122, in setupMQTT
    self.mqttclient = mqtt.Client(client_id=str(random.randint(1,10000)), clean_session=False)
TypeError: __init__() missing 1 required positional argument: 'callback_api_version'

OS Version

pi@raspberrypi:/opt/AlarmPI $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 11 (bullseye)
Release:    11
Codename:   bullseye

AlarmPI version

pi@raspberrypi:/opt/AlarmPI $ sudo git rev-parse HEAD
5f7beedc8e3ce2a283912becc427d21cf7b1276a

Error Logs - last run after restart

2024-03-29 23:17:22 [INFO] [notifier:__init__:445]  ------------ INIT FOR DOOR SENSOR CLASS! ----------------
2024-03-29 23:17:22 [ERROR] [run:<module>:53]  Unknown error has occured Contact Author:
Traceback (most recent call last):
  File "/opt/AlarmPI/run.py", line 50, in <module>
    myserver.startMyApp()
  File "/opt/AlarmPI/alarmcode/alarmpi.py", line 367, in startMyApp
    self.users[user]['obj'] = Worker(
  File "/opt/AlarmPI/alarmcode/Worker.py", line 44, in __init__
    self.mynotify = Notify(self.wd, self.settings, self.optsUpdateUI, self.mylogs)
  File "/opt/AlarmPI/alarmcode/notifier.py", line 449, in __init__
    self.mqtt = notifyMQTT(self.settings, self.optsUpdateUI, self.mylogs, self.callbacks)
  File "/opt/AlarmPI/alarmcode/notifier.py", line 103, in __init__
    self.setupMQTT()
  File "/opt/AlarmPI/alarmcode/notifier.py", line 122, in setupMQTT
    self.mqttclient = mqtt.Client(client_id=str(random.randint(1,10000)), clean_session=False)
TypeError: __init__() missing 1 required positional argument: 'callback_api_version'

Configuration

{
  "http": {
    "enable": false,
    "host": "",
    "https": true,
    "password": "",
    "port": 443,
    "username": "test1"
  },
  "mail": {
    "enable": false,
    "messageBody": "Alert",
    "messageSubject": "Home Security",
    "password": "",
    "recipients": [],
    "smtpPort": 587,
    "smtpServer": "smtp.gmail.com",
    "username": ""
  },
  "mqtt": {
    "authentication": false,
    "command_topic": "home/alarm2/set",
    "enable": false,
    "host": "",
    "password": "",
    "port": 1883,
    "state_topic": "home/alarm2",
    "username": "",
    "homeassistant": false
  },
  "sensors": {},
  "serene": {
    "enable": false,
    "http_start": "",
    "http_stop": "",
    "pin": 14
  },
  "settings": {
    "alarmState": "disarmed",
    "timezone": "Europe/Athens",
    "trim": 1000
  },
  "voip": {
    "domain": "",
    "enable": false,
    "numbersToCall": [],
    "password": "",
    "timesOfRepeat": "",
    "username": ""
  }
}

Thanks in advance. I really like your work, hope I can run it sometime :) 👍

bkbilly commented 7 months ago

I've looked into it and it seems that the latest versions of paho-mqtt have changed how it's used. You could try installing an older version until I fix it:

pip install paho-mqtt==1.6.1

EDIT: I've pushed a fix for this. You can do a git pull to get the latest version.

steppatrik commented 7 months ago

Firstly I tried just update through: bash <(curl -s "https://raw.githubusercontent.com/bkbilly/AlarmPI/master/install.sh") but still I cant run web interface after that.. Then tried: pip install paho-mqtt==1.6.1 and now I can log in via http, but only with default credentials test1/secret, even if I had changed that during installation and double check it in settings.json file - from here:

{
  "ui": {
    "https": true,
    "key": "my.cert.key",
    "cert": "my.cert.crt",
    "port": 5000
  },
  "users": {
    "pi": {
      "admin": false,
      "logfile": "alert.log",
      "pw": "xxx",
      "settings": "settings.json"
    }
  }
}

:/

bkbilly commented 7 months ago

This is the server.json file which once changed, the AlarmPI should be restarted.

steppatrik commented 7 months ago

I did restart but still, I can use only defaults.. But I assume, that this is another problem, maybe in my setting.. Original post is solved :) Thx

steppatrik commented 7 months ago

Hi, I also writ you personal mail - I have another question: Does AlarmPI phone app has ability to send push notifications? For example when is alarm trigerred? Thanks. Patrik

ne 31. 3. 2024 v 14:22 odesílatel Vasilis Koulis @.***> napsal:

This is the server.json file which once changed, the AlarmPI should be restarted.

— Reply to this email directly, view it on GitHub https://github.com/bkbilly/AlarmPI/issues/31#issuecomment-2028692807, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHN46ANXXDCTZDUE5PUSVCDY275WTAVCNFSM6AAAAABFO7XQSWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRYGY4TEOBQG4 . You are receiving this because you authored the thread.Message ID: @.***>

bkbilly commented 7 months ago

Unfortunately push notifications are not supported... The only supported notifications I've created are the email, voip and mqtt. If you need other methods, I would recommend using the Home Assistant MQTT integration.

steppatrik commented 7 months ago

Ok, I will try that. Thanks again! :) Patrik

Dne út 2. 4. 2024 0:17 uživatel Vasilis Koulis @.***> napsal:

Unfortunately push notifications are not supported... The only supported notifications I've created are the email, voip and mqtt. If you need other methods, I would recommend using the Home Assistant MQTT integration.

— Reply to this email directly, view it on GitHub https://github.com/bkbilly/AlarmPI/issues/31#issuecomment-2030668901, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHN46APHVNX4IOI65NJ3PJTY3HMHZAVCNFSM6AAAAABFO7XQSWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZQGY3DQOJQGE . You are receiving this because you authored the thread.Message ID: @.***>