CyberDNS / Lupusec2Mqtt

Lupusec Alarm System to Mqtt
MIT License
11 stars 5 forks source link

Lupusec https Login Error #1

Closed rkupfer2020 closed 4 years ago

rkupfer2020 commented 4 years ago

Hi, I am looking for a solution to integrate our Lupusec XT2plus to Home Assistant. I followed the documentation but receive a "Unhandled exception. System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception." in the container logs and the container quit working (Synology NAS). May be you can give me some advice on this problem?

Regards Roger

CyberDNS commented 4 years ago

Hi, I already have an idea what it could be. I have the Lupusec XT2 with an additional stick to upgrade to the plus version. But my version is not using HTTPS, so I think it is a problem with the certificate validation. I will build a new version that logs the inner exception, only to be sure that this is the problem. I will come back to you when I the new version is available. Best regards, David

CyberDNS commented 4 years ago

Hi Roger, Sorry for the delay, I had some problems updating my Windows 10 Home to version 2004, got bluescreens etc. Now I am up and running again.

I uploaded a new version to docker hub that will (hopefully) log the inner exception, can you give it a try and send me the results please?

You have to change your docker-compose file to use lupusec2mqtt:issue1 in place of latest. Best regards, David

rkupfer2020 commented 4 years ago

Hi David,

yes, there are sometimes occur problems when updating win10 at the moment as far as I know too...

Thanks for the quick reply and your effort to solve our problem.

I just tried it a couple of minutes ago. The Container is running constantly now but I have still following error in the log:

Host terminated unexpectedly System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure. System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.

I have no chance to change the certificate as far as I know.

Or, may be it's related to the fact that I am not runnig Docker Compose? Just ran it as a further Docker Container with following additional variables:

DOTNET_LUPUSEC__PASSWORD xxxxxxx

DOTNET_LUPUSEC__LOGIN xxxxxxx

DOTNET_LUPUSEC__URL https://192.168.20.2

DOTNET_MQTT__SERVER 192.168.20.3

Best regards Roger

CyberDNS commented 4 years ago

Hi Roger,

The error is what I thought. I changed the code so that even when the certificate cannot be validated it is still accepted. This should only be used in local and secure network. I republished it under tag issue1, so you have to do a new pull to update. Running the container without docker-compose should be fine.

Only one question, if you open the lupusec site in a browser, does it show the certificate to be invalidate, too?

Best regards, David

rkupfer2020 commented 4 years ago

Hi David,

perfect! Now I receive the sensors in our local network.

To answer your question: Yes it comes up with the error for self signed certificates: Error code: MOZILLA_PKIX_ERROR_SELF_SIGNED_CERT Valid until: 5.10.2029, 10:25:27 (Mitteleuropäische Sommerzeit)

I don't know if it's possible to change the certificate. But I can ask Lupusec...

What I realised is that the current status of a sensor doesn't change (e.g. when I open a door/window) in Home Assistant.

May be this is related to errors which are in the logs: [17:51:41 FTL] Unable to start Kestrel. {"SourceContext": "Microsoft.AspNetCore.Server.Kestrel"} System.IO.IOException: Failed to bind to address http://[::]:80: address already in use.

I don't know if the port is the right one in our case: ASPNETCORE_URLS: http://+:80

Best regards Roger

CyberDNS commented 4 years ago

Hi Roger,

The container is not exposed anymore on an tcp port, this should solve the kestrel problem. Indeed, it is not necessary to be exposed because all the outside communication is done by MQTT.

Regarding the problem of current status not being reflected, can you try to execute following url in your browser and send me the output (json), please? You need to be logged in, in the same browser to your lupusec. https://{yourip}/action/deviceListGet The best would be to have some windows open and others closed so that I can see the difference.

Another thing: In the logs of the container, can you see every 5 seconds a log like this?

[19:56:35 INF] Received 33 sensors {"SourceContext": "Lupusec2Mqtt.Lupusec.PollingHostedService"}
[19:56:35 INF] Received alarm panel information (Area 1: disarmed, Area 2: disarmed) {"SourceContext": "Lupusec2Mqtt.Lupusec.PollingHostedService"}
[19:56:40 INF] Received 33 sensors {"SourceContext": "Lupusec2Mqtt.Lupusec.PollingHostedService"}
[19:56:40 INF] Received alarm panel information (Area 1: disarmed, Area 2: disarmed) {"SourceContext": "Lupusec2Mqtt.Lupusec.PollingHostedService"}
[19:56:45 INF] Received 33 sensors {"SourceContext": "Lupusec2Mqtt.Lupusec.PollingHostedService"}
[19:56:45 INF] Received alarm panel information (Area 1: disarmed, Area 2: disarmed) {"SourceContext": "Lupusec2Mqtt.Lupusec.PollingHostedService"}

Do you have a tool to diagnose MQTT? e.g. MQTT.fx. In that case you could inspect what is going through your MQTT.

If I can't detect a difference between my lupusec box, I will add more logging to diagnose the problem.

Best regards, David

rkupfer2020 commented 4 years ago

Hi David, I changed the port 30 minutes ago to 8888. Now there are no more errors in the log and everything works perfect. The ASPNETCORE_URLS paramter was added automatically by Docker. Thank you!

Still one more question for a better understanding: Is it possible to receive the status in case of a "burglary alarm"? I can't check it right now because it's already 10PM... I would like to "activate" some additional light sensors. As far as I know Zigbee sensors can't be connected in both systems (Lupusec and Home Assistant).

Best regards Roger

CyberDNS commented 4 years ago

Hi Roger,

Glad to hear that it is working now.

For the moment it is not yet possible to see if an alarm is ongoing, that is something similar what I always planned to do, but never did for the moment :wink:. I wanted to integrate my movement detectors and smoke detectors and thought that I could use the Event History to get this information. I will not promise you that I will do this in the next week, but it is something that I always planned. I don't have any Zigbee lights connected to my lupusec central because I have all my other SmartHome things integrated by Homematic.

Anyway, can I kindly ask you to create 2 new issues for the burglary alarm and Zigbee lights. I will then close this issue and create a new release and docker container for the current version. For the Zigbee lights I will then come back to you on that issue to help me out in the reverse engineering.

Best regards, David