rs1932 / ring-alarm-hassio-addon

19 stars 16 forks source link

add-on don't work on HASSIO #6

Open brainsop opened 5 years ago

brainsop commented 5 years ago

Hi, i am trying to use the add-on but it dont work :( in the MQTT Server logs no appears connection from the add-on, by the way, the mqtt servers is working well because i use it with sonoff device with tasmota firmware, and is working well.

the add-on log is the following:

Ring Alarm Integration
Node Version
v10.16.0
NPM Version
6.9.0
git version 2.22.0
added 121 packages from 89 contributors and audited 427 packages in 22.573s
found 0 vulnerabilities
up to date in 5.262s
fixed 0 of 0 vulnerabilities in 427 scanned packages

the strangest situation is that sometime (without touch anything) the add-on starts to work, but if i do a restart (only the add-on) it dont working anymore :frowning:

regards.

juampick commented 5 years ago

It happened also to me. Yesterday I was able to fix it. The problem is configuration. Please make sure your mqtt broker is well configured together with this addon configuration.

If you use mosquitto mqtt broker addon, and the version is 4.1 or later check documentation because now is trickier to make it to work. After that is well setup, you should start seeing working.

Another SW you can download (on your pc) to debug is MQTT Explorer, to see all the mqtt activity and check if actually is working.

I hope this helps

brainsop commented 5 years ago

thanks a lot Juan! I will try with MQTT Explorer to see if i can see anything related with the issue, because the MQTT is working well (i use it with Tasmota), and more... Originally I used the Mosquitto broker from the Official add-ons repository, and right now I'm using the MQTT Server & Web client from the Community Hass.io Add-ons, and the result is the same.

related with the add-on configuration, it is the following:

{
  "host": "192.168.2.6",
  "port": 1883,
  "ring_topic": "ring",
  "hass_topic": "hass/status",
  "mqtt_user": "sonoff",
  "mqtt_pass": "<mqtt_password>",
  "ring_user": "user_ring@email.com",
  "ring_pass": "<ring_password>"
}

thanks a lot Juan regards

juampick commented 5 years ago

Great 👍

Ok, using MQTT Explorer, are you seeing the topics coming from ring alarm? also have you setup the auto discovery in configuration.yaml ?

Thanks,

brainsop commented 5 years ago

in the MQTT Explorer no appears any topics from ring :(

this is the screenshot (only appears some topics from sonoff with Tasmota) image

Related with autodiscovery, yes, I have added in the configuration.yaml

the strangest thing is only 2 or 3 times, without change anything, the add-on worked, but when I restarted the add-on, it never works again:

image

thanks and regards!

brainsop commented 5 years ago

Hi, i made some progress in the troubleshooting, i have created a clone of the add-on on github, and modify the line in the file run.sh from:

DEBUG=ring-alarm-mqtt /ring-alarm-mqtt/ring-alarm-mqtt.js

to:

DEBUG=* /ring-alarm-mqtt/ring-alarm-mqtt.js

and the error that appears in the log is:

2019-07-21T18:48:53.138Z ring Making request: {
  "method": "GET",
  "url": "https://app.ring.com/rhq/v1/devices/v1/locations",
  "data": "",
  "headers": {
    "content-type": "application/x-www-form-urlencoded",
    "authorization": "Bearer here_appears_a_big_hash_like_GV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwidGV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwidGV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwidGV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwidGV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwidGV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwidGV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwidGV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwidGV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwidGV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwidGV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwid",
    "hardware_id": "xx77x550-x530-xxx0-8xxx-xx027x69396x"
  }
}
2019-07-21T18:48:53.141Z follow-redirects options { protocol: 'https:',
  maxRedirects: 21,
  maxBodyLength: 10485760,
  path: '/rhq/v1/devices/v1/locations',
  method: 'GET',
  headers:
   { Accept: 'application/json, text/plain, */*',
     authorization:
      'Bearer here_appears_a_big_hash_like_GV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwidGV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwidGV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwidGV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwidGV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwidGV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwidGV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwidGV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwidGV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwidGV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwidGV5aklmUSIsInNjb3BlcyI6WyJjbGllbnQiXSwid",
     hardware_id: 'xx77x550-x530-xxx0-8xxx-xx027x69396x',
     'Content-Type': 'application/x-www-form-urlencoded',
     'User-Agent': 'axios/0.19.0' },
  agent: undefined,
  auth: undefined,
  hostname: 'app.ring.com',
  port: null,
  nativeProtocols:
   { 'http:':
      { _connectionListener: [Function: connectionListener],
        METHODS: [Array],
        STATUS_CODES: [Object],
        Agent: [Function],
        ClientRequest: [Function],
        IncomingMessage: [Function],
        OutgoingMessage: [Function],
        Server: [Function],
        ServerResponse: [Function],
        createServer: [Function: createServer],
        get: [Function: get],
        request: [Function: request],
        maxHeaderSize: [Getter],
        globalAgent: [Getter/Setter] },
     'https:':
      { Agent: [Function],
        globalAgent: [Agent],
        Server: [Function],
        createServer: [Function: createServer],
        get: [Function: get],
        request: [Function: request] } } }
2019-07-21T18:48:53.158Z ring Failed to reach Ring server at https://app.ring.com/rhq/v1/devices/v1/locations.  Trying again in 5 seconds...

I have obfuscated the following 2 fields in the logs, because i think it are private fields: authorization: hardware_id:

do you know why appears this error?

thanks and regards

tsightler commented 5 years ago

Hi Brainsop, thanks for doing this. The error pretty much implies that the Ring API is unable to communicate with the Ring servers, mostly likely due to a networking issue of some sort. Perhaps failed DNS resolution as that's the most common cause I see. It's difficult for me to see why manually creating a docker container works but this plugin does not as they both do basically the same thing, the plugin mostly just automates the creation of the docker container.

brainsop commented 5 years ago

Hi @tsightler I did some tests outside the RPi to verify if DNS is responding well, etc (during the issue). when start the add-on appears some logs in URL filtering of my firewall, only two hits, but after that don't appears anymore:

image

in the logs of the add-on, appears continuously the log:

2019-07-21T18:48:53.158Z ring Failed to reach Ring server at https://app.ring.com/rhq/v1/devices/v1/locations. Trying again in 5 seconds...

so, i did a packet capture in the firewall and see the DNS request, with the correct response (it continuously is repeating:

image

i filtered the traffic looking for the IP: 52.71.170.210 or 18.235.204.250 or 35.172.59.155 (that appears in the DNS answers) but dont appears traffic to these hosts.

regards

tsightler commented 5 years ago

Thanks BrainSop, that's interesting. By any chance are you using any filtering on your hassio system, perhaps something like the pi-hole addon? I'm struggling to understand this issue because it's failing at such a basic point, really, outside of the script (it's completely up to the ring-client-api code to make the connection). Any chance you could grab a packet trace of the traffic coming from the docker container when it's in this state? That should be telling.

brainsop commented 5 years ago

Hi @tsightler I only have the following add-ons:

image

and installed from cli your ring add-on :) installed manually as a Docker container. (when I did the test I stop the docker container and install the hassio addon.

is helpful for you a network packet capture in the firewall? (i can filter by source IP, but you will see traffic from a lot of things (mqtt messages, etc etc etc) not only from the container. or do you prefer other trace only from the container? if you help me to obtain i can generate it.

Grey-Lancaster commented 5 years ago

Pardon me for jumping in, but I did not get it to work with MQTT Server and Client. I uninstalled and just did Mosquitto broker

Grey-Lancaster commented 5 years ago

ring

brainsop commented 5 years ago

Hi Grey-Lancaster, I recommend you read this post: https://community.home-assistant.io/t/ring-device-integration-via-mqtt/102105/127?u=brainsop There you will found information about the config.

Grey-Lancaster commented 5 years ago

My point is I could not get it to work with what you have installed. It works perfectly with the Mosquito Broker. I am suggesting you give this a try.

brainsop commented 5 years ago

thanks Grey, i have tried with Mosquito Broker (from the Official add-ons) and because it doesnt work, right now migrate to MQTT Server & Web client, and it doesn't work either.

it appears to be an issue with the add-on connection with ring.com, only if i use it with the add-on from https://github.com/rs1932/ring-alarm-hassio-addon because if i create manually a docker with the add-on from @tsightler like I have mention here https://community.home-assistant.io/t/ring-device-integration-via-mqtt/102105/163?u=brainsop it works without issue.

tsightler commented 5 years ago

@brainsop It seems you already know how to connect and run things in the container so grabbing a tcpdump from there should be as easy as connecting to the container and installing tcpdump with: apk add tcpdump From there just run tcpdump and lets see what it's doing every 5 seconds, if you want you can capture to a file with: tcpdump -s 0 -w mycap.pcap and then copy it out with rsync (you can install rsync with apk add rsync). It would be very interesting to see what is happening within the container on your system and hopefully will shed some light on the system.

brainsop commented 5 years ago

Hi @tsightler sorry for the delay, i did two tests ;) one add the "apk add tcpdump" when the Docker container was running, but i think it not be good to see all connections. so, I created a copy of add-on (https://github.com/brainsop/ring-alarm-hassio-addon) and add the tcpdump in the container creation and execute the tcp dump on background at start up :)

how can i share the dumps with you on private? because i dont found a way to share it on github as private message.

regards

brainsop commented 5 years ago

@tsightler done. i have shared it with you ;)