Coder Social home page Coder Social logo

Push Notifications about imou_life HOT 10 CLOSED

user2684 avatar user2684 commented on June 5, 2024
Push Notifications

from imou_life.

Comments (10)

Ameglialuna avatar Ameglialuna commented on June 5, 2024

Same here, Imou Life is working but also if I made all the settings needed I don't receive any push notification

from imou_life.

user2684 avatar user2684 commented on June 5, 2024

Hi, first of all, you are not doing anything wrong, it is a known issue with which we are struggling since a few weeks now so I decided to do some more troubleshooting in order to try identifying the problem and looking for a workaround.

First of all, I've setup up a test HA environment, configured an automation and the callback pointing to it. I triggered a motion on my webcam and nothing happened on HA. I then installed tcpdump on HA to see if the incoming request was entering my network and why HA refused it. This is what I got:

b

A POST with the full URL in the URI and HA responding with 404 Not Found. Is the full URL acceptable in a POST? Don't know but looks HA doesn't like it. Then I copied and pasted the entire request, using netcat to connect to HA and replying the request. Again 404. Of course. Then I tried REMOVING the full URL leaving the URI only and it worked, 200 OK and I see the automation triggering:

d

I then must assume the full URL is the problem. Now, how to fix it? Unfortunately we cannot control what the remote Imou server is sending over. Let's see if a reverse proxy can help. I've then set up a nginx with the following configuration:

    server {
        listen       80;
        listen  [::]:80;
        server_name  localhost;

        proxy_buffering off;

        location /{
            access_log /dev/stdout postdata;
            proxy_pass http://192.168.0.159:8124/;
        }

Nginx "cleans" the request. When calling HA, it removes automatically the full URL, the request reaches HA and the automation triggers. I then tried to make nginx pointing back to my production HA. And again it worked out.

Last test was to use the NGINX Home Assistant SSL proxy Addon on HA which is basically just a simple nginx server pointing to the local HA. And it did NOT work for me. I then tried to replicate the nginx configuration from https://github.com/home-assistant/addons/blob/master/nginx_proxy/data/nginx.conf into my test nginx. Still my nginx works, HA nginx doesn't.

This is where I am right now. I'm pretty sure the problem is the malformed request passed by Imou which HA cannot handle. I'm pretty use a reverse proxy can help in cleaning up the request. I'm just missing the last mile: why nginx running on HA is not behaving like my test nginx...
I'll go on with additional tests, meanwhile if anybody has any idea, please share :-)

from imou_life.

array81 avatar array81 commented on June 5, 2024

I have understand the problem, probably send a wrong POST request then HA does not accept it.
This is a problem because on the one hand I think it is difficult to communicate it to IMOU, on the other hand HA blocks the request immediately and therefore there is no way to intervene except from the outside (as you did with NGINX).

Besides this in my case I think there is also the problem that I don't have a fixed IP and I use duckdns, so IMOU should be given the duckdns address otherwise the request will never arrive, right?

from imou_life.

array81 avatar array81 commented on June 5, 2024

Have you already tried writing in the HA developer forum to see if there is a way around this?

https://community.home-assistant.io/c/development/10

from imou_life.

user2684 avatar user2684 commented on June 5, 2024

Ok, now I think I finally found a solution which finally WORKS :-)
The problem with NGINX Home Assistant SSL proxy Addon encountered in the test above was that there was a catch all server_name in the nginx configuration which was intercepting and rejecting the request. This is because ALSO the Host header sent by the Imou server is malformed, so never reaching the right server directive and hence HA.
Unfortunately with that addon is not possible to customize nginx configuration.

I then installed Nginx Proxy Manager Add-on (which requires Maria DB Addon FYI) and now everything works just fine!!
Bottomline:

  • Callbacks are correctly sent by the Imou Server to the configured webhook
    • Keep in mind that if you change the URL, sometimes it may take up to 5 minutes for a change to apply on Imou side
  • However the requests are malformed:
    • the full URL is used in the POST request instead of the URI
    • the Host header contains the port number
  • This makes HA rejecting the request (404 error, without any evidence in the logs)
  • A reverse proxy in front of HA without any special configuration takes care of cleaning out the request
  • If running HA in Supervised mode, " Nginx Proxy Manager Add-on" just works . "NGINX Home Assistant SSL proxy Addon" instead does not

Now I would need somebody to confirm that this solution is actually working also somewhere else.
Thanks!

@array81 correct, I'm using the duckdns address indeed

from imou_life.

user2684 avatar user2684 commented on June 5, 2024

Closing the issue since the workaround above seems to work and instructions have been updated accordingly in v1.0.5. Feel free to reopen again if anything is not working as expected, thanks

from imou_life.

jrb80 avatar jrb80 commented on June 5, 2024

Nice update on the v1.0.5 release, however I am using "Nginx Proxy Manager Add-on" v0.12.2 in "Supervised" mode and the callback is never received.

With the addition of the callback sensor I notice the full URL path is not shown, only the protocol and domain name https://subdomain.domain/

Whereas my configured callback URL is https://subdomain.domain/api/webhook/callback_id

Should the sensor value be truncated or display the full path? When I call the webhook in Postman it receives it fine, so I am guessing the issue is related to the path truncation?

from imou_life.

user2684 avatar user2684 commented on June 5, 2024

The callback url sensor should display the full path, this is what I get here at least. Try in HA going to Developer Tools, States and search for the sensor. If you see the truncated url, try disabling push notifications, setting the callback url again in options and re-enabling push notifications.

I'm using the same version of Nginx Proxy Manager Add-on so it is very strange :-/ In terms of configuration, I have websocket support on, and in SSL "Force SSL" and "HTTP/2 Support" only enabled and gets those notifications consistently:

a

I don't understand why it is random somewhere else :-(

from imou_life.

jrb80 avatar jrb80 commented on June 5, 2024

try disabling push notifications, setting the callback url again in options and re-enabling push notifications.

After doing this, the callback URL is now reporting correctly. Thanks for the tip. After a few basic tests I can confirm I now receive event notifications, nice work! :-)

from imou_life.

user2684 avatar user2684 commented on June 5, 2024

Fantastic thanks for the feedback!

from imou_life.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.