Skip to content

Instantly share code, notes, and snippets.

View jamesabruce's full-sized avatar

James Bruce jamesabruce

  • Cornwall, UK
View GitHub Profile
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.matter.onoff</string>
<key>ProgramArguments</key>
<array>
<string>/Users/jamie/.nvm/versions/node/v22.14.0/bin/node</string>
<string>/Users/jamie/Documents/VirtualSwitch/dist/main.js</string>
@jamesabruce
jamesabruce / main.ts
Created February 21, 2025 17:13
Matter.js PC/Mac remote suspend virtual device
import {
DeviceTypeId,
Endpoint,
EndpointServer,
Environment,
ServerNode,
StorageService,
Time,
VendorId,
} from "@matter/main";
// how long each led stays on for
int delayTime = 1;
//how long between each
int charBreak = 3;
//how long to wait after the message is finished before it repeats
int resetTime = 20;
int LED1 = 2;
int LED2 = 3;
int LED3 = 4;
<form data-fv-framework="bootstrap" novalidate="novalidate" class="fv-form fv-form-bootstrap"><button type="submit" class="fv-hidden-submit" style="display: none; width: 0px; height: 0px;"></button>
<div class="items">
<div class="item">
<input type="hidden" name="topics[0][type]" value="category">
<input type="hidden" name="topics[0][id]" value="4893">
<input type="hidden" name="topics[0][checked]" value="0">
<label><div class="checker"><span><input name="topics[0][checked]" value="1" type="checkbox"></span></div><span>Smart Home</span></label>
</div>
<div class="item">
<input type="hidden" name="topics[1][type]" value="post_tag">
@jamesabruce
jamesabruce / flora-clutch.ino
Created March 10, 2016 10:02
Light-Up Clutch Demo of Element14 Flora Arduino Starter Kit
// things from the color sensor library
#include
#include "Adafruit_TCS34725.h"
/* Initialise with specific int time and gain values */
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);
// including things from light sensor library
@jamesabruce
jamesabruce / sonos.js
Created March 1, 2016 13:33
If-This-Then-Node plugin to send voice notifications to Sonos through Sonos-HTTP-API
var request = require('request');
module.exports = {
run: function (params, log, callback) {
request('http://localhost:5005/sayall/'+params.message+'/en-gb', function (error, response, body) {
console.log("Sent message \""+params.message+"\" to device "+params.device);
})
callback({
'success': true,
'output': 'all good!'
@jamesabruce
jamesabruce / ESP_RELAY_MQTT.ino
Created February 12, 2016 10:40
Simple MQTT controlled relay running on NodeMCU dev board on pin d2/gpio4
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <PubSubClient.h>
#define RELAY 4 // pin labelled d2
// Update these with values suitable for your network.
const char* ssid = "YOURWIFI";
@jamesabruce
jamesabruce / Bedroomplug_accessory.js
Created February 12, 2016 10:18
A simple HAP-NodeJS accessory for a DIY power socket device
var Accessory = require('../').Accessory;
var Service = require('../').Service;
var Characteristic = require('../').Characteristic;
var uuid = require('../').uuid;
var mqtt = require('mqtt');
var options = {
port: 1883,
host: '192.168.1.99',
clientId: 'Bedroom plug accessory'
};
@jamesabruce
jamesabruce / Romantic_accessory.js
Created February 11, 2016 15:56
An accessory for HAP-NodeJS that integrates with Sonos HTTP API server running on localhost
var Accessory = require('../').Accessory;
var Service = require('../').Service;
var Characteristic = require('../').Characteristic;
var uuid = require('../').uuid;
var request = require('request');
// here's a fake hardware device that we'll expose to HomeKit
var FAKELIGHT = {
powerOn: false,
brightness: 100, // percentage
@jamesabruce
jamesabruce / Officelight_accessory.js
Last active September 5, 2018 19:20
HAB-NodeJS accessory for MakeUseOf Wi-Fi light tutorial
// MQTT Setup
var mqtt = require('mqtt');
console.log("Connecting to MQTT broker...");
var mqtt = require('mqtt');
var options = {
port: 1883,
host: '192.168.1.99',
clientId: 'MakeUseOf Wifi Light'
};
var client = mqtt.connect(options);