Skip to content

Instantly share code, notes, and snippets.

View zkniebel's full-sized avatar

Zachary Kniebel zkniebel

View GitHub Profile
@zkniebel
zkniebel / gist:51e7725ff9705b57b20dce0f19b14244
Created August 23, 2023 18:19
Circadian Lighting v2 Node-Red Flow
[{"id":"621a939e.0e87fc","type":"subflow","name":"influxdb write measurement","info":"# influxdb write measurement\n\nWrites a measurement to InfluxDB via the InfluxDB API. Note that the request body is sent to the API in plain-text format so plan accordingly.\n\n### Important note about string fields\n\nAs the request body is sent to the API in plain-text format, it is up to you to ensure that your string field values are properly escaped by surrounding them with quotes at the beginning and end of the string value.\n\nFor example, you might have a string value of `\"world\"`. To properly excape the string, you would need to update its value to `\"\\\"world\\\"\"`;","category":"storage","in":[{"x":40,"y":40,"wires":[{"id":"e12474f4.e0b5d8"}]}],"out":[{"x":540,"y":40,"wires":[{"id":"a6367839.7d92e8","port":0}]}],"env":[{"name":"Server_Host","type":"str","value":"","ui":{"icon":"font-awesome/fa-server","label":{"en-US":"Server Host"},"type":"input","opts":{"types":["str","json","bin","env"]}}},{"name":"Database
@zkniebel
zkniebel / circadian_lighting_ct.js
Last active February 26, 2020 14:07
Node.js helper functions meant to support the creation of automated circadian lighting scripts. These scripts are based on a port of the Python code from claytonjn's hass-circadian_lighting repository (https://github.com/claytonjn/hass-circadian_lighting)
/**
* CREDIT: The below is a modified JS port of the Python code from claytonjn's hass-circadian_lighting repository
* URL : https://github.com/claytonjn/hass-circadian_lighting
*/
// weather is expected to be a darksky weather response JSON object with at least today and tomorrow as daily forcast objects
// NOTE: this implementation could be made more accurate by making a Time Machine request to darksky, but this would be an
// additional API call and could possibly result in hitting the daily API call limit. As such, yesterday's weather is
// optional and can be omitted in favor of an estimation based on today's values if desired
function getPercent(weather, yesterdayWeather) {