Skip to content

Instantly share code, notes, and snippets.

View devjourney's full-sized avatar

W. Kevin Hazzard devjourney

View GitHub Profile
@devjourney
devjourney / ShellySyncWithPairedLight.js
Created December 27, 2025 03:31
Use this Shelly smart relay script to sync the switch state of the relay with that of another device using MQTT.
function subscribeToStatusUpdates(topic) {
MQTT.subscribe(topic , function(t, message) {
if (typeof message === "undefined" || message === null) {
print("Received undefined or null message - ignoring");
return;
}
try {
let payload = JSON.parse(message);
if (payload.source === "button") {
@devjourney
devjourney / bthome_ble_motion_and_lux_trigger.js
Last active January 16, 2026 20:51
Script to trigger Gen2 Shelly devices from BTHome messages with motion and lux data from Shelly BLU devices.
let CONFIG = {
// the BTHome motion and light sensors that will report to this device
// add a Bluetooth MAC address for each reporting sensor
sensorMACs: [
"3c:2e:f5:ba:e8:bd".toLowerCase() // Shelly BLU Motion sensor
],
lightId: 0, // Channel 0 in Lights x4 mode
fullBrightness: 100, // max when very bright ambient
minBrightness: 5, // min when very dark (soft night light)
timeoutSec: 300, // shared timeout for motion
@devjourney
devjourney / bthome_ble_lux_control_only.js
Created January 16, 2026 20:53
Control the brightness of a Shelly RGBW PM channel with BTHome messages over BLE from a Shelly BLU Motion sensor.
let CONFIG = {
debug: false,
active: false, // passive BLE scanning is sufficient
// BTHome light sensor(s) that will report to this device
sensorMACs: [
"3c:2e:f5:ba:e8:bd" // Shelly BLU Motion sensor
],
lightId: 0, // Channel 0 in Lights x4 mode
fullBrightness: 100, // max brightness
minBrightness: 5, // min brightness (avoid completely dark)