Skip to content

Instantly share code, notes, and snippets.

View LeoDJ's full-sized avatar

LeoDJ

View GitHub Profile
# ESPHome Configuration for Tuya Smart Life RGBW Controller (AP-Future) by LeoDJ
# https://s.click.aliexpress.com/e/_De97s2j
# Implemented using ESPHome package feature, for semi-easy configuration of multiple devices
packages:
common: !include common/tuya-ap-future-rgbw.yaml
substitutions:
node_name: "rgbw-example-device"
node_friendly_name: "RGBW Example Device"
api_key: !secret generic_api_key
@LeoDJ
LeoDJ / drawer_control_SP-850.py
Created July 16, 2023 19:17
Python script to control/open a Partner Tech SP-850 cash drawer
# Control a Partner Tech SP-850 cash drawer
# Needs root
import portio
import time
# request permission to I/O port range
portio.ioperm(0x5a8, 4, 1)
# Has to be 32bit access, otherwise the EC won't respond
@LeoDJ
LeoDJ / README.md
Last active May 3, 2023 09:07
Opening .pl Interleaf WorldView PrinterLeaf files (and converting them to .pdf)

This is more of a note to myself / a try to give the problem a bit more SEO visibility, so please excuse the probably weird writing style and structure.

tl;dr at the bottom

  • .PL extension is for "PrinterLeaf" files
    • They start with the magic bytes D0 4F 50 53 (ÐOPS)
    • Commonly contain header strings like:
      For: / Printed on: / From book: / Document: / Last saved on:
      Name: / Ausgedruckt: / Aus dem Buch: / Dokument: / Zuletzt gespeichert:
  • And for my test file they contained references to font files like:
@LeoDJ
LeoDJ / ha_volume_helper_scripts.yaml
Created May 3, 2022 22:40
HomeAssistant helper scripts for controlling volume of media_player entities
volume_down:
alias: Volume Down
description: Volume Down with user defined step size
fields:
entity_id:
selector:
entity:
domain: media_player
step:
default: 0.05
@LeoDJ
LeoDJ / printHexdump.c
Last active May 1, 2022 22:33
Print hexdump of a buffer. Quickly hacked together but works.
// Quick way to print a hexdump of a buffer. Output will look like this:
//
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
// 0000 54 68 69 73 20 69 73 20 61 20 74 65 73 74 20 68 This is a test h
// 0010 65 78 64 75 6D 70 21 20 46 6F 6F 2E 20 01 02 03 exdump! Foo. ...
// 0020 04 .
inline void printHexdumpAscii(uint16_t index, uint8_t byte) {
if (index % 16 == 8) { // some spacing for orientation
printf(" ");
@LeoDJ
LeoDJ / ttn_mapper_uplink_payload_formatter.js
Created March 10, 2022 23:18
Uplink Payload Formatter for TTN Mapper LoRa node (including generic function for converting raw C struct integer values to JavaScript number)
@LeoDJ
LeoDJ / xpv2bin.py
Created April 27, 2021 23:57
Convert XPV/XDV files to binary (CSR Blueflash Bluecore firmware files)
#!/usr/bin/env python3
# Convert XPV/XDV files to binary (CSR Blueflash / Bluecore firmware files)
# Quickly hacked together by LeoDJ
import sys
import os
def xpv2bin(input_file, output_file):
with open(input_file) as f_in, open(output_file, "wb") as f_out:
@LeoDJ
LeoDJ / _cm1106_co2_sensor_esphome.yaml
Last active November 24, 2022 01:01
ESPHome Custom Sensor CM1106 CO2
esphome:
name: cm1106_sensor
platform: ESP32
board: wemos_d1_mini32
includes:
- "cm1106.h"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_pass
@LeoDJ
LeoDJ / spacenav_raw.py
Created January 6, 2021 13:55
Read raw values for 3DConnexion SpacePilot / SpaceMouse / SpaceNavigator
import spacenavigator
import time
def callback(s):
print("X: %5.2f Y: %5.2f Z: %5.2f Roll: %5.2f Pitch: %5.2f Yaw: %5.2f Buttons:" % (s.x, s.y, s.z, s.roll, s.pitch, s.yaw), s.buttons)
success = spacenavigator.open(callback)
if success:
while 1:
time.sleep(0.1)
@LeoDJ
LeoDJ / led_strip.yaml
Last active October 31, 2020 14:52
MagicHome ESPHome RGB Strip Effects
esphome:
name: led_strip
platform: ESP8266
board: esp01_1m
wifi:
ssid: ""
password: ""
# Enable fallback hotspot (captive portal) in case wifi connection fails