Atlas Data API Driven Christmas Tree Lights and Camera

The tree was packed away on the 6th of January, it may return in December 2022 The video has been replaced by a static image.

You can still call the API and change the state if you want to but you won't see the tree change. Thanks to all of you who painted your national flags on my tree.

The lights on this tree take their colours from a Digital Twin held in MongoDB Atlas. They are controlled by $10 a DOIT ESP32 DEVKIT Microcontroller which is using the Atlas Data API to retrieve the latest light pattern

The Camera watching the tree below is also an ESP32 ($12 AI Thinker ESP32-CAM), This is uploading JPEG images using the Atlas Data API and this page is retrieving them and displaying using MongoDB Realm.

MongoDB Realm Application Services is hosting a Webhook to allow you, the viewer, to post new patterns. The lights run from bottom (0) to top (50), if you have the time you could enable them one at a time and work out an exact pixel mapping. I'd love to see vertical candy cane stripes.

Current:
...
POST request to
https://data.mongodb-api.com/app/xmastree-lpeci/endpoint/lights in the format above you can set the lights, state needs to be an array of 50 RGB tuple.

Example:
curl \
        -H "Content-Type: application/json" \
        -d '{ "state": [
                {"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},
                {"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},
                {"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},
                {"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},
                {"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},
                {"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},
                {"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},
                {"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},
                {"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},
                {"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},
                {"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},
                {"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},
                {"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},
                {"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},
                {"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},
                {"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0},
                {"g": 0,"r": 255,"b": 0},{"g": 0,"r": 255,"b": 0}]}' \
        https://data.mongodb-api.com/app/xmastree-lpeci/endpoint/lights

If it helps - the Pixel positions of the lights are as follows:
        [{"n": 0, "x": 248, "y": 443}, {"n": 1, "x": 205, "y": 400},
        {"n": 2, "x": 171, "y": 398}, {"n": 3, "x": 225, "y": 376}, 
        {"n": 4, "x": 235, "y": 450}, {"n": 5, "x": 269, "y": 411}, 
        {"n": 6, "x": 339, "y": 388}, {"n": 7, "x": 361, "y": 392}, 
        {"n": 8, "x": 379, "y": 374}, {"n": 9, "x": 367, "y": 352},
        {"n": 10, "x": 350, "y": 392}, {"n": 11, "x": 319, "y": 448}, 
        {"n": 12, "x": 359, "y": 357}, {"n": 13, "x": 355, "y": 368},
        {"n": 14, "x": 351, "y": 402}, {"n": 15, "x": 307, "y": 383},
        {"n": 16, "x": 279, "y": 417}, {"n": 17, "x": 239, "y": 415},
        {"n": 18, "x": 213, "y": 389}, {"n": 19, "x": 216, "y": 354},
        {"n": 20, "x": 287, "y": 375}, {"n": 21, "x": 332, "y": 359},
        {"n": 22, "x": 341, "y": 347}, {"n": 23, "x": 329, "y": 330},
        {"n": 24, "x": 325, "y": 335}, {"n": 25, "x": 300, "y": 344}, 
        {"n": 26, "x": 244, "y": 351}, {"n": 27, "x": 198, "y": 337},
        {"n": 28, "x": 241, "y": 312}, {"n": 29, "x": 250, "y": 327},
        {"n": 30, "x": 312, "y": 307}, {"n": 31, "x": 343, "y": 309}, 
        {"n": 32, "x": 310, "y": 297}, {"n": 33, "x": 253, "y": 274},
        {"n": 34, "x": 215, "y": 300}, {"n": 35, "x": 250, "y": 292}, 
        {"n": 36, "x": 283, "y": 295}, {"n": 37, "x": 317, "y": 281}, 
        {"n": 38, "x": 312, "y": 239}, {"n": 39, "x": 321, "y": 254},
        {"n": 40, "x": 264, "y": 255}, {"n": 41, "x": 210, "y": 274},
        {"n": 42, "x": 220, "y": 251}, {"n": 43, "x": 283, "y": 240},
        {"n": 44, "x": 312, "y": 221}, {"n": 45, "x": 251, "y": 224},
        {"n": 46, "x": 260, "y": 214}, {"n": 47, "x": 272, "y": 152},
        {"n": 48, "x": 288, "y": 88}, {"n": 49, "x": 288, "y": 280}]