SensorsIot / IOTstack

Docker stack for getting started on IOT on the Raspberry PI
GNU General Public License v3.0
1.43k stars 303 forks source link

Support for ring-mqtt #632

Closed basil-dsouza closed 1 year ago

basil-dsouza commented 1 year ago

Has anyone considered adding ring-mqtt support into IOTStack? Based on my limited knowledge of IOTStack, it seems like it should be possible to integrate this: https://github.com/tsightler/ring-mqtt/wiki/Installation-(Docker)

  ring-mqtt:
    container_name: ring-mqtt
    restart: unless-stopped
    image: tsightler/ring-mqtt
    ports:
      - 8554:8554                      # Enable RTSP port for external media player access
    volumes:
      - <host_path>:/data           # Mapping of local folder to provide persistent storage
    logging:                           #limit logs to 10m and 3 files
      options:
        max-size: 10m
        max-file: "3"

Am interested in hearing if anyone has already tried this? or if anyone is interested in trying it? I know enough docker to add this locally to my docker-compose file and try to get it working, but do not know enough IOTStack to integrate this well into the menu system.

Paraphraser commented 1 year ago

I've submitted pull requests to implement this suggestion:

I've no idea how long it will take before the PRs are accepted/rejected.

If you want to try it out in the meantime, follow these instructions to apply #633 to your local copy of IOTstack. That assumes you are running on master branch ("new menu").

I've also added some documentation to the IOTstack Wiki which explains a couple of changes (setting time zone and the MQTT broker) that are either recommended or necessary when running ring-mqtt in a container. As a convention, we only add/update documentation on master branch because that is what drives the Wiki. In the interim, you can see the documentation here.

basil-dsouza commented 1 year ago

Wow that was a really fast response and solution!

I had a look through the PRs, and I notice that for 633 (the PR to master) you have made a change to only the service.yml (ignoring the md file for a sec) and not any menu files. I dont know much about IOT Stack, but will that mean the menu picks it up automatically?

And reading through the MD file, the instructions are really helpful, I spent several hours trying to figure out some of those things! The part that I didnt find in there was on how to generate the refresh token. This was something I still havent tried either, mainly cause I wasnt sure if there was any difference in running the command when the image is in a docker compose file as opposed to a stand alone docker run. And also if that then needs the generated token to be stored somewhere or not.

https://github.com/tsightler/ring-mqtt/wiki/Installation-(Docker)#acquire-the-refresh-token docker run -it --rm --mount type=bind,source=<host_path>,target=/data --entrypoint /app/ring-mqtt/init-ring-mqtt.js tsightler/ring-mqtt

Paraphraser commented 1 year ago

I had a look through the PRs, and I notice that for 633 (the PR to master) you have made a change to only the service.yml (ignoring the md file for a sec) and not any menu files. I dont know much about IOT Stack, but will that mean the menu picks it up automatically?

Yes. To give you a more complete answer, IOTstack has three "menus":

Anyway, I hope that answers your question and helps you to see what's going on.

And reading through the MD file, the instructions are really helpful, I spent several hours trying to figure out some of those things! The part that I didnt find in there was on how to generate the refresh token.

Full disclosure: I don't have any "ring" devices and I don't understand anything about the "ring" ecosystem or environment. For me, this is all seat-of-the-pants.

When I constructed the pull requests, I:

  1. Did a skim-read of the docs you pointed me at;
  2. Re-jigged a couple of things in your original service definition to make it IOTstack-friendly;
  3. Spun-up the container and nosed around.

My nosing around led me to discover the issue with localhost:1883 so I made sure the "obvious solution" (editing the config file and restarting the container) would work and persist properly, and documented it.

Having done that, I fleshed-out the old-menu and experimental branches, wrote the doc, and turned it all into pull requests.

That was as far as I went. I don't recall focusing on the specific issue of the token in my skim-read but if I noticed it, I probably looked at the docker run and assumed it would be taken care of correctly in a docker-compose scenario. And that assumption was well-founded … but I missed a step. My bad.

I won't give you a blow by blow but a bit more nosing around led me to this in the log:

2022-12-26T22:33:09.254Z ring-mqtt No refresh token was found in the state file, use the Web UI at http://<host_ip_address>:55123/ to generate a token.
2022-12-26T22:33:09.254Z ring-mqtt Succesfully started the token generator web UI

I did see those lines before but did not appreciate their significance. What they are telling us is:

  1. The container also needs to map port 55123; and
  2. The doc needs to include the instruction to fire-up the web page.

I've just amended the PRs accordingly. I can see the UI but, not having an account, I can't really test the process end-to-end with 2FA etc. I'll leave that to you. Please let me know if it works.

Paraphraser commented 1 year ago

Doco with extra material is here