Skip to content

Instantly share code, notes, and snippets.

View simmikolon's full-sized avatar

Simon Kemper simmikolon

View GitHub Profile
@simmikolon
simmikolon / datacake_milesight_uc300_cellular_1nceos.js
Last active July 3, 2024 11:15
Datacake - Milesight UC300 Cellular Decoder for 1NCE OS Integration
// Datacake - Milesight UC300 Cellular Decoder for 1NCE OS
// (c) 2024 Simon Kemper
// Works for all analog and digital inputs and output, not yet for:
// - RS232
// - Modbus
// Note for RS232 and Modbus: If you need those, ask us ...
/*
import requests
import json
class DatacakeGraphQlClient:
def __init__(self, url, token):
self.url = url
self.headers = {"Content-Type": "application/json", "Authorization": f"Token {token}"}
def run(self, query, variables=None):
data = {"query": query, "variables": variables}
@simmikolon
simmikolon / streamlit_datacake_energy_monitor.py
Created August 28, 2023 16:39
How to use Streamlit and Datacake for custom energy dashboard
import plotly.express as px
import streamlit as st
import requests
import pandas as pd
import json
import time
# URL deines GraphQL-Endpunkts
url = 'https://api.datacake.co/graphql/'
@simmikolon
simmikolon / datacake_decoder_single.js
Created May 9, 2023 15:09
Datacake Decoder for Node-RED API Ingestion
function Decoder(request) {
var payload = JSON.parse(request.body);
var device = payload.serial_number;
var readings = [];
for (var field in payload) {
if (field !== "serial_number") {
readings.push({
field: field,
value: payload[field],
@simmikolon
simmikolon / noderedflow.js
Created May 9, 2023 15:07
Node-RED Flow for Datacake API Ingestion
[{"id":"dc44d96a.e622a8","type":"http request","z":"7ead4a25.118974","name":"","method":"POST","ret":"txt","paytoqs":false,"url":"https://api.datacake.co/integrations/api/3701c2b6-1c74-4d0a-95e1-8ce6a49493dd/","tls":"abfd8aeb.337298","persist":false,"proxy":"","authType":"","x":590,"y":120,"wires":[["da293a28.815628"]]},{"id":"da293a28.815628","type":"debug","z":"7ead4a25.118974","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":850,"y":120,"wires":[]},{"id":"916a2d32.c8ae4","type":"function","z":"7ead4a25.118974","name":"","func":"data = {\n \"serial_number\": \"ABC123\",\n \"temperature\": 56.5,\n \"humidity\": 53.2,\n \"pressure\": 4513.25,\n \"acceleration_x\": 0.12,\n \"acceleration_y\": -0.23,\n \"acceleration_z\": 1.01,\n \"magnetic_field_x\": 0.85,\n \"magnetic_field_y\": -0.92,\n \"magnetic_field_z\": 0.12,\n \"gyroscope_x\": -0.02,\n \"gyroscope_y\": 4.3,\n \"gyroscope_z\": -0.08,\n \"uv_index\": 5.2,\n \"amb
@simmikolon
simmikolon / datacake-graphql-flows.txt
Created April 19, 2021 07:48
Node Red Flow - Datacake GraphQL Example
[{"id":"72ef688a.928ce8","type":"function","z":"3bbe52a3.6ecd96","name":"GraphQL Call","func":"// Datacake API Token and Workspace\nvar token = \"123456mytoken123456\";\nvar workspace = \"1234myworkspace1234\";\n\n// GraphQL API URL\nmsg.url = \"https://api.datacake.co/graphql\";\n\n// GraphQL Header\nmsg.headers = {\n \"Authorization\": \"Token \"+token,\n \"Content-Type\": \"application/json\"\n};\n\n// GraphQL Query\nvar query = `query {\n allDevices(inWorkspace:${workspace}) {\n id\n serialNumber\n verboseName\n currentMeasurements(allActiveFields: true) {\n field {\n fieldName\n verboseFieldName\n }\n value\n }\n }\n}`;\n\nmsg.payload = {\"query\": query};\nmsg.body = {\"query\": query};\n\nreturn msg;\n","outputs":1,"noerr":0,"x":340,"y":260,"wires":[["37ecf05e.a3995"]]},{"id":"37ecf05e.a3995","type":"http request","z":"3bbe52a3.6ecd96","name":"","method":"GET","ret":"obj","paytoqs":true,"url":"","tls":"36a29eca.14f2f2","persist":false,"proxy":"","auth
@simmikolon
simmikolon / notecarddatacake.js
Created March 26, 2021 10:09
Generic Notecard Decoder for Datacake IoT Platform
function Decoder(request) {
var data = JSON.parse(request.body);
var device = data.device;
var file = data.file;
var decoded = {};
if (file === "locations.qos") {
/*
* Project AirWatch2
* Description:
* Author:
* Date:
*/
#include "Particle.h"
#include "neopixel.h"
#include "Serial4/Serial4.h"
#!/usr/bin/env python
# -*- coding: utf-8 -*-
HOST = "192.168.178.50"
PORT = 4223
UID = "Bdp" # Change XYZ to the UID of your Industrial Digital Out 4 Bricklet
import time
from tinkerforge.ip_connection import IPConnection
#!/usr/bin/env python
# -*- coding: utf-8 -*-
HOST = "192.168.178.50"
PORT = 4223
UID = "Bdp" # Change XYZ to the UID of your Industrial Digital Out 4 Bricklet
import time
from tinkerforge.ip_connection import IPConnection