Skip to content

Instantly share code, notes, and snippets.

View devjourney's full-sized avatar

W. Kevin Hazzard devjourney

View GitHub Profile
@devjourney
devjourney / SetSpeakerVolumeOnSchedule.yaml
Created February 13, 2025 15:45
A Home Assistant automation to set the volume of several media players at a specific time of day.
alias: Speakers - Set Sleep Volume
description: Set the volume of speakers lower overnight.
triggers:
- trigger: time
at: "23:00:00"
conditions: []
actions:
- action: media_player.volume_set
metadata: {}
data:
@devjourney
devjourney / AlertOnPoolGateHelpOpen.yaml
Created February 13, 2025 15:43
A Home Assistant automation that will play an audio message when a gate has been held open too long.
alias: Alert on Pool Gate Opened
description: ""
mode: single
triggers:
- type: opened
device_id: 896de4d80d8fa631e58804be71b50b51
entity_id: f40b16da6652e7402e9b819f707cedf3
domain: binary_sensor
for:
hours: 0
@devjourney
devjourney / SwitchesSync.yaml
Created February 13, 2025 15:41
A Home Assistant automation to have several switches follow the on-off state of another switch.
alias: Office Lights - Follow Moulding Lights
triggers:
- entity_id:
- switch.ofc_moulding_lights
from: "on"
to: "off"
trigger: state
- entity_id:
- switch.ofc_moulding_lights
from: "off"
@devjourney
devjourney / ILI9341_TFT_LCD_Simple_Counter.py
Last active January 7, 2024 01:23
CircuitPython ILI9341 TFT Showing Second Counter
import board
import time
import terminalio
import displayio
import digitalio
from adafruit_display_text import label
import adafruit_ili9341
# Release any resources currently in use for the displays
displayio.release_displays()
@devjourney
devjourney / flashingledswithbuttoncontrolleddelay.py
Last active December 8, 2019 04:36
Python script for Raspberry Pi to alternate flashing of two LEDs with two buttons for modifying the duration of the delays between alternations.
from gpiozero import LED, Button
from time import sleep
minimum = 0.0625
maximum = 1.00
increment = 0.0625
delay = minimum
def set_delay(offset):
global delay, minimum, maximum
@devjourney
devjourney / UpsertProcedureAndExecuteV1.js
Last active December 9, 2018 21:09
A Node.js app that creates a Cosmos DB stored procedure and executes it.
var CosmosClient = require('@azure/cosmos').CosmosClient;
var config = require('./config.js');
var client = new CosmosClient({
endpoint: config.connection.endpoint,
auth: { masterKey: config.connection.authKey }
});
async function upsertProcedureAndExecute(sprocDef, docToInsert) {
const { database } = await client.databases
.createIfNotExists({ id: config.names.database });
@devjourney
devjourney / GetStationWeatherDataWithJmesPathQuery.js
Created September 2, 2018 16:35
A Node.js function to fetch weather station data then filter and shape it with JMESPath.
let documentClient = require('documentdb').DocumentClient;
let jmespath = require('jmespath');
let cosmos_uri = process.env["STATION_COSMOS_URI"];
let cosmos_key = process.env["STATION_COSMOS_READONLY_KEY"];
let databaseId = process.env["STATION_COSMOS_DATABASE_NAME"];
let collectionId = process.env["STATION_COSMOS_COLLECTION_NAME"];
let client = new documentClient(cosmos_uri, { 'masterKey': cosmos_key });
let collectionLink = "/dbs/" + databaseId + "/colls/" + collectionId + "/";
module.exports = function (context, req) {
@devjourney
devjourney / GetStationWeatherData.js
Last active September 2, 2018 16:35
A Node.js function to fetch weather station data.
let documentClient = require('documentdb').DocumentClient;
let cosmos_uri = process.env["STATION_COSMOS_URI"];
let cosmos_key = process.env["STATION_COSMOS_READONLY_KEY"];
let databaseId = process.env["STATION_COSMOS_DATABASE_NAME"];
let collectionId = process.env["STATION_COSMOS_COLLECTION_NAME"];
let client = new documentClient(cosmos_uri, { 'masterKey': cosmos_key });
let collectionLink = "/dbs/" + databaseId + "/colls/" + collectionId + "/";
module.exports = function (context, req) {
let filterQuery = `SELECT * FROM c WHERE c.State = "${req.params.state}"`;
@devjourney
devjourney / CreateCosmosDbAuthTokenInPostman.js
Created August 31, 2018 23:58
Create an authorization token for CosmosDB in a Postman Pre-test Script
var now = new Date().toUTCString();
pm.environment.set("utcDate", now);
var verb = 'GET';
var resourceType = pm.variables.get("resourceType");
var resourceId = pm.variables.get("resourceId");
var text = (verb || "").toLowerCase() + "\n" + (resourceType || "").toLowerCase() + "\n" + (resourceId || "") + "\n" + now.toLowerCase() + "\n" + "" + "\n";
var key = CryptoJS.enc.Base64.parse(pm.variables.get("masterKey"));
var signature = CryptoJS.HmacSHA256(text, key).toString(CryptoJS.enc.Base64);