Skip to content

Instantly share code, notes, and snippets.

@Mictronics
Mictronics / status2telegram.py
Last active April 28, 2024 15:58
Python script sends status report to Telegram bot
#!/usr/bin/env python3
from pisugar import *
import asyncio
import os
import sys
import logging
from telegram import Update
from telegram.ext import filters, MessageHandler, ApplicationBuilder, CommandHandler, ContextTypes
import gammu.smsd
@Mictronics
Mictronics / sms2telegram.py
Created April 28, 2024 12:14
Python script forwarding Gammu service SMS to Telegram
#!/usr/bin/env python3
from pisugar import *
import asyncio
import os
import sys
import telegram
async def main():
# Get Pisugar battery level
conn, event_conn = connect_tcp('localhost')
@Mictronics
Mictronics / call2telegram.py
Created April 28, 2024 12:12
Python script forwarding Gammu service caller ID to Telegram
#!/usr/bin/env python3
import asyncio
import os
import sys
import telegram
from datetime import datetime
async def main():
if len(sys.argv) == 1:
print("Phone number missing")
@Mictronics
Mictronics / automation.yaml
Created August 18, 2023 13:29
Home Assistant HASS configuration for chines diesel heater controller Afterburner Mk2
alias: Get Heater Status
description: ""
trigger:
# - platform: homeassistant
# event: start
- platform: time_pattern
# Matches every hour at 5 minutes past whole
minutes: "/1"
condition: []
action:
@Mictronics
Mictronics / dbhub.io.md
Last active August 16, 2023 20:22
dbhub.io development environment setup

Here is how to setup a development environment for dbhub.io.

dbhub.io project on Github

First I tried Docker which was a PITA this time, see issue 211, but ended up with a manual installation on a fresh Alpine Linux image, based von 3.18 edge.

Built and tested with dbhub.io master branch up to commit 5c9e1ab.

Following steps in order to run on the root shell. (initial ALpine Linux login is root without password)

@Mictronics
Mictronics / sndway_simple_readout.ino
Last active April 4, 2023 06:19
Readout distance from a Sndway Laser Distance Meter SW-A40 with Arduino Mini
/**
* Reading actual measured distance from LCD of a Sndway SW-A40 laser distance meter.
*
* Developed and tested on Arduino Mini 328P@16MHz.
* See https://www.mictronics.de/2018/02/laser-distance-meter-hack/
* Mictronics 2018 @ www.mictronics.de
*/
/**
* Pin connection to LCD SPI bus.
@Mictronics
Mictronics / readsb-mqtt-stats-json.py
Last active January 22, 2022 10:07
Reads statistics from readsb stats.json and forwards to homeassistant (HASS) via MQTT broker.
#! /usr/bin/python3
# Reads statistics from readsb stats.json and forwards to homeassistant (HASS)
# via MQTT broker.
#
# Dependencies:
# pip3 install paho-mqtt
# pip3 install watchdog
import sys
@Mictronics
Mictronics / readsb-mqtt-stats.py
Last active January 22, 2022 10:06
Reads statistics from readsb stats.json or stats.pb and forwards to homeassistant (HASS) via MQTT broker.
#! /usr/bin/python3
# Reads statistics from readsb stats.json or stats.pb and forwards to homeassistant (HASS)
# via MQTT broker.
#
# Dependencies:
# pip3 install paho-mqtt
# pip3 install watchdog
# https://github.com/protocolbuffers/protobuf
@Mictronics
Mictronics / sndway_control2.ino
Created July 23, 2018 08:52
Controls and reads actual measured distance from LCD bus of a Sndway SW-A40 laser distance meter. Improved version not using Arduino delay that causes random problems with serial interface.
/**
* Controls and reads actual measured distance from LCD bus of a Sndway SW-A40 laser distance meter.
* Improved version not using Arduino delay that causes random problems with serial interface.
*
* Serial control characters:
*
* ? Return identifier string.
* c Clears measurement results and turns off laser.
* Can be used as keep alive command to prevent auto power off after 150s.
* M Turns on device when off and triggers a measurement.
@Mictronics
Mictronics / main.c
Last active March 21, 2018 20:29
Creates sinus and cosinus lookup tables for IQ signal generation for AD9361 (ADALM-Pluto) simulating TX channel settings.
/*
* Creates sinus and cosinus lookup tables for IQ signal generation
* for AD9361 (ADALM-Pluto) simulating TX channel settings.
*
* channel_convert_inverse Converts I or Q sample from host format into hardware format.
* channel_convert Converts I or Q sample from hardware format into host format.
*
* See https://github.com/analogdevicesinc/libiio/blob/master/channel.c
*
*/