tzachi-dar / LibreAllHouse

Use Raspberry pi devices to have all house coverage using the miaomiao device.
16 stars 12 forks source link

MongoDB connection string after migration to Mongodb Atlas #9

Open bordeb opened 3 years ago

bordeb commented 3 years ago

After migration from MLab sandbox to free MongoDB Atlas database I am having trouble to properly configure db_uri parameter. I am not seeing any uploads have been done. I have tried with mongodb+srv://username:password@cluster.name.mongodb.net/dbname?retryWrites=true&w=majority but unfortunately without sucess. What is the proper way to configure db_uri ? Tnx in advance

tzachi-dar commented 3 years ago

Just making sure you are aware that xDrip can read directly from the pis.

Moving to write to atlas should be easy. 1) update to the latest code. (git pull ) 2) sudo pip3 install dnspython 3) use a db_uri in the format: mongodb+srv://heroku_b6k1n0tj:@cluster-b6k1n0tj.bg18m.mongodb.net/heroku_b6k1n0tj

After this, you should be able to see writes to the mongo-db.

Reading from the mongdb by xDrip requires to create a site that will allow to read the DB. See https://github.com/NightscoutFoundation/xDrip/pull/1557 for how to do it.

Let me know if things work for you.

bordeb commented 3 years ago

Dear @tzachi-dar thank you on the fast response. Yes, I am aware of the xdrip+ capability to read from the pis. I am using it and this software is so useful and great to cover all the house in order to not worry any more about the libre full coverage arround the house. On the other side, I am not fully aware about the purpose of the mongodb upload, so I am thinking that it might have some synchronisation purpose between pis, but probably I am not right. I was using mlab for years without beeing fully aware about the exact purpose and now after migration to MongoDB Atlas I am not sure do I need it any more. If you have couple of minutes, it would be great if you could explain it little bit more. Many tnx

tzachi-dar commented 3 years ago

If both xDrip and the pis are on the same wifi network you don't need the mongodb. If for some reason they are not (for example you left the phone at your car, or the phone did not connect to wifi on your house) the mongo allows them to continue talking. It is completely optional, but I think it is nice to have.

bordeb commented 3 years ago

Tnx for the info! I have looked following the link https://github.com/NightscoutFoundation/xDrip/pull/1557 you have provided but honestly I can not figure it out what kind of site it would be needed to allow me to extract data from mongodb using xdrip. I will continue reading and trying to figure it out. Thank you very much

tzachi-dar commented 3 years ago

In order to create a sight, you need to follow: https://devcenter.heroku.com/articles/getting-started-with-nodejs?singlepage=true

But when asked for a git page, replace it with: https://github.com/tzachi-dar/node-js-getting-started

Once the site is up and running, you need to set two environment variables: heroku config:set db_uri="mongodb+srv://heroku_b6k1n0tj:@cluster-b6k1n0tj.bg18m.mongodb.net/nightscout3?retryWrites=true&w=majority" heroku config:set password="pass"