Skip to content

Instantly share code, notes, and snippets.

View johnlpage's full-sized avatar

John Page johnlpage

  • MongoDB Inc.
  • Glasgow
View GitHub Profile
from PyP100 import PyP110
import json
from pprint import pprint
import pymongo
with open("/home/pi/.mongo_uri.txt") as f:
uri = f.readline().strip()
mongoclient = pymongo.MongoClient(uri)
tapoplugs = {
import aiohttp
import pysmartthings
import pymongo
import json
import asyncio
from pprint import pprint
import datetime
with open("/home/pi/.smartthing_token") as f:
from phue import Bridge
from pprint import pprint
import pymongo
b = Bridge("192.168.1.214")
# If the app is not registered and the button is not pressed, press the button and call connect() (this only needs to be run a single time)
b.connect()
# Get the bridge state (This returns the full dictionary that you can explore)
import requests
from pprint import pprint
import json
import pymongo
with open("/home/pi/.mongo_uri.txt") as f:
uri = f.readline().strip()
mongoclient = pymongo.MongoClient(uri)
[
{$limit:1},
{$set: { x : {$range:[-144,0]}, y : {$range:[-120,0]} }},
{$unwind :"$x"},
{$unwind: "$y"},
{$set : { r: {$add: [{$divide:["$x",8000]},-0.73]}, i: {$add:[{$divide:["$y",8000]},0.15]}}},
{$set : { c : { $reduce : { input: {$range:[0,300]}, initialValue : { r:0,i:0,it:0 }, in :
{ $cond : { if: { $lt:["$$value.r",4]}, then: { it:{$add:["$$value.it",1]},
r: {$add:[{$subtract:[{$pow:["$$value.r",2]}, {$pow:["$$value.i",2]} ]},"$r"]},
i: {$add: [{$multiply:[2,"$$value.r","$$value.i"]},"$i"]} } ,else: "$$value"}}}}}},
{
$let: {
vars: {
targetdoc: {
$max: {
$filter: {
input: "$location_lookup_targettemps",
cond: {
$gte: ["$$this.to", "$miltime"]
}
{
$set: {
miltime: {
$add: [{
$minute: "$date"
}, {
$multiply: [{
$hour: "$date"
}, 100]
}]
{
$concat: ["Until ", {
$cond: [{
$lt: ["$to", 1000]
}, "0", ""]
}, {
$toString: "$to"
}]
}
{
_id: ObjectId("6218cae28a77eb66ed8b372b"),
room: 'GamesRoom',
to: 900,
target: 17
}
[{
$sort: {
date: -1
}
}, {
$group: {
_id: "$location",
currentTemp: {
$first: "$temp"
}