Skip to content

Instantly share code, notes, and snippets.

View kristofer84's full-sized avatar
🙂

Kristofer Nilsson kristofer84

🙂
  • Stockholm, Sweden
View GitHub Profile
@kristofer84
kristofer84 / tasmota-dms.sh
Created January 11, 2024 19:51
Dead man's switch for RPi connected via Tasmota controlled switch
#!/bin/bash
# Dead man's switch for Tasmota
# Presmues that timers has been enabled
# Continuously move the restart timers forward
read -r day hour <<< $(date -d "+2 hours" +"%u %H")
# Convert date output where Monday is 1 to timer format where Sunday is 1
day=$((day%7+1))
@kristofer84
kristofer84 / jwt-files.sh
Created December 4, 2023 13:57
Create files needed for signing and verifying JWT
# npm install -g eckles
openssl ecparam -genkey -name prime256v1 -out private_key.pem
openssl ec -in private_key.pem -pubout -out public_key.pem
eckles public_key.pem > public_key.jwk
openssl req -x509 -key private_key.pem -subj /CN=localhost -days 1000 > certificate.pem
echo $(openssl x509 -in certificate.pem -fingerprint -noout) | sed 's/SHA1 Fingerprint=//g' | sed 's/://g' | xxd -r -ps | base64
@kristofer84
kristofer84 / page-scroll.html
Created November 13, 2023 14:08
Page by page scroll html
<html>
<head>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans&family=Work+Sans:wght@400;500&display=swap" rel="stylesheet" />
<style>
:root {
font-size: 14px;
font-family: "Work Sans", sans-serif;
}
body {
@kristofer84
kristofer84 / index.js
Created January 26, 2023 12:08 — forked from fabulator/index.js
Google export json to gpx
const fs = require('fs');
const createGpx = require('gps-to-gpx').default;
const program = require('commander');
program
.version('0.1.0')
.command('parse <inputFile>')
.option('--from <from>', 'From which date parse data YYYY-MM-DDTHH:ii.')
.option('--to <to>', 'To which date parse data YYYY-MM-DDTHH:ii.')
.option('--accuracy <accuracy>', 'Minimal accuracy.')
@kristofer84
kristofer84 / index.js
Created January 26, 2023 12:08 — forked from fabulator/index.js
Google export json to gpx
const fs = require('fs');
const createGpx = require('gps-to-gpx').default;
const program = require('commander');
program
.version('0.1.0')
.command('parse <inputFile>')
.option('--from <from>', 'From which date parse data YYYY-MM-DDTHH:ii.')
.option('--to <to>', 'To which date parse data YYYY-MM-DDTHH:ii.')
.option('--accuracy <accuracy>', 'Minimal accuracy.')
@kristofer84
kristofer84 / z2m_ikea_tradfri_5button_remote_custom.yaml
Last active March 12, 2022 10:55 — forked from niro1987/z2m_ikea_tradfri_5button_remote_custom.yaml
Home Assistant - Blueprint - Zigbee2MQTT - IKEA TRADFRI - 5 Button Remote - Custom Actions
---
# This automation simulates the use of the IKEA TRADFRI Remote control
# connected through Zigbee2MQTT.
blueprint:
source_url: https://gist.github.com/niro1987/f60ab7ec01facdc7d9cab861f4a4abe5
name: Zigbee2MQTT - IKEA TRADFRI - 5 Button Remote - Custom Actions
description: >-
@kristofer84
kristofer84 / ha-flic.yaml
Last active March 19, 2023 23:01
Home Assistant Flic button integration
blueprint:
name: Flic button
description: |
Create automations to react to Flic button clicks. Triggered by event type 'flic_click'.
The event data should contain flic_name and click_type (single/double/hold).
domain: automation
input:
flic_name:
blueprint:
name: ZWave-JS - Fibaro Dimmer 2 and Single/Double Switch (FGD212/FGS213/FGS223) Scenes
description: |
Create automations to react button scenes from Fibaro Dimmer 2 or Single/Double Switch.
Make sure that device Z-wave parameters 27 and 28 are set correctly.
domain: automation
input:
device:
blueprint:
name: Generic trigger template (two triggers)
description: Turn one or more devices on/off based on a trigger
domain: automation
input:
trigger_device:
name: First trigger
description: Either trigger will alter the state of the devices.
selector:
entity:
blueprint:
name: Generic trigger template (one trigger)
description: Turn one or more devices on/off based on a trigger
domain: automation
input:
trigger_device:
name: Trigger
description: The trigger that will alter the state of the devices.
selector:
entity: