Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Esp Mqtt Json Multisensor | 304 | 4 years ago | 39 | apache-2.0 | C++ | |||||
(OBSOLETE) ESP MQTT JSON Multisensor for Home Assistant. Supported sensors include the TEMT6000 light, AM312 PIR, DHT22 temperature/humidity sensors. RGB led supports flash, fade, and transition. Over-The-Air (OTA) uploading, too! | ||||||||||
Ha Hpprinter | 62 | 10 months ago | 8 | Python | ||||||
HP Printer Integration | ||||||||||
Nettemp | 52 | 2 years ago | mit | PHP | ||||||
Interface for controlling the temperature sensors DS18B20, supports; serial DS9097, usb DS9097U, usb DS2490, Raspberry Pi GPIO | ||||||||||
C Json Path | 14 | 8 years ago | mit | C | ||||||
Basic Pure C implementation of XPath like query library for JSON-data. No allocs, No c++. Suitable to microcontrollers and sensors. | ||||||||||
Ext Processor Sample | 12 | 4 years ago | Java | |||||||
数据预处理模块 | ||||||||||
Smartthings Capabilities | 11 | 6 days ago | ||||||||
SmartThings Capabilities | ||||||||||
Fusion360_steamvr_json | 10 | 6 years ago | mit | Python | ||||||
A Fusion360 add-in for generating SteamVR Tracking JSON files from 3D CAD Data | ||||||||||
Endpoint Scripts | 8 | 9 years ago | 4 | PHP | ||||||
PHP scripts for the JSON generation and the status display page | ||||||||||
Kafka Sensors | 8 | 2 years ago | apache-2.0 | Java | ||||||
Kafka Serialization Playground | ||||||||||
Pms5003 | 7 | a year ago | 1 | apache-2.0 | C | |||||
PMS5003 air quality sensor data grabbing in C, to JSON, on Linux, with averaging over time |
The provided scripts are for generating the JSON but also for displaying the space status.
Given the following apache configuration,
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/srv/http/spaceapi"
ServerName spaceapi.your-space.com
<Directory />
AllowOverride ALL
</Directory>
</VirtualHost>
the scripts are in /srv/http/spaceapi
while the following URLs are now available:
If you deploy the endpoint scripts by cloning the repo, you should forbid public access to the .git
directory. If you're using Apache as the web server with the module rewrite
enabled, you don't need to do anything, .htaccess
is already protecting it.
There's not much to say. Simply adapt spaceapi.json
to your needs and add here your URL http://spaceapi.your-space.com/status/json
.
Your space status is displayed on http://spaceapi.your-space.com or on http://spaceapi.your-space.com/status respectively.
The status can be displayed either by a button or by a monster.
To select one of both edit the following section in template.html
$(document).ready(function(){
// uncomment one of both in order to use either the
// monster or a simple button to display the status
$("#svg4534").fadeIn();
//$("#button").fadeIn();
});
To push data to the endpoint scripts the data structure to be sent to the server is a subset of the specification version 13.
E.g. to push the door status and two temperature sensor values your measurement unit (Raspberry Pi, Arduino, ...) must use the following structure.
{
"state": {
"open": true
},
"sensors": {
"temperature": [
{ "value": 31 },
{ "value": 23 }
]
}
}
Note: if you need to update an array of sensors this must be done in the same request since the order matters. This means that at the moment it's impossible to update the first temperature sensor by one microcontroller and the second by another. However different sensor arrays can be updated independently so in this case the
state/open
andsensors/temperature
sensors could be updated in a separate request. An array is anything between the brackets[]
so if you also hadsensors/barometer
you could update this in a separate request as well.
After urlencoding the json you make a GET request to the URL schema as shown below.
http://spaceapi.your-space.com/sensors/set/?&key=<api_key>&sensors=<urlencoded_json>
These parameters must be provided:
config.json
.Example URL for updating the hackerspace/door status:
http://spaceapi.your-space.com/sensor/set/?key=86f7896f97asdf89u0a9s7d7fdasgsda88af&sensors={%22state%22:{%22open%22:false}}
The following PHP code shows how to push data to your endpoint.
// change this to your actual endpoint URL without a trailing slash
$endpoint_url = "http://my.hackerspace.com";
// if you changed the default api key in the endpoint script(s)
// you must change this key here too, otherwise no sensor data
// are updated server-side
$key = "86f7896f97asdf89u0a9s7d7fdasgsda88af";
$sensors = <<<JSON
{
"state": {
"open": true
},
"sensors": {
"temperature": [
{ "value": 31 },
{ "value": 23 }
]
}
}
JSON;
// minify the json
$sensors = json_encode(json_decode($sensors));
$sensors = urlencode($sensors);
$ch = curl_init("$endpoint_url/sensor/set/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "sensors=$sensors&key=$key");
$data = curl_exec($ch);
curl_close($ch);
If the URL, where you're trying to push, is a redirect, the snippet might not work under certain conditions. Read this to find out why.
Curl:
curl --data-urlencode sensors='{"state":{"open":false}}' --data key=86f7896f97asdf89u0a9s7d7fdasgsda88af http://spaceapi.your-space.com/sensor/set
Appearance > Widgets
in the left sidebar<iframe src="http://spaceapi.my-hackerspace.com/">