Skip to content

Instantly share code, notes, and snippets.

View nbuchwitz's full-sized avatar
hi there

Nicolai nbuchwitz

hi there
View GitHub Profile
rpi_revision_code() {
# see
code=$(grep Revision /proc/cpuinfo | cut -f 2 -d \: | xargs)
echo $((16#${code}))
rpi_type() {
set -e
nm_files="dhcp-eth0.nmconnection dhcp-eth1.nmconnection fallback-link-local-eth0.nmconnection fallback-link-local-eth1.nmconnection 99-revpi.conf"
download_dir=$(mktemp -d)
echo -n "This script will change the network configuration from dhcpcd to NetworkManager. Do you want to proceed? [yN] "
read choice
if [[ $(id -u) != 0 ]]; then
echo "usage: sudo $(basename $0)"
exit 1
pibridge_static_mac() {
# find all devices which match our product id
for f in $(grep --include='idProduct' -rlw "$PRODUCT_ID" /sys/bus/usb/devices/usb* 2>/dev/null); do
device=$(dirname $f)
# ensure that vendor id also matches
nbuchwitz /
Created March 11, 2022 12:59
RevPi: Copy data from virtual modbus registers to gateway component
#!/usr/bin/env python3
import revpimodio2
def loop_function(ct):
# copy 5 input register from modbus to gateway = = = =
import os
import revpimodio2
class Application():
def __init__(self):
self.rpi = revpimodio2.RevPiModIO(autorefresh=True)
self.rpi.core.x2in.reg_event(self.event_shutdown, edge=revpimodio2.RISING)
#!/usr/bin/env python3
import sys
import json
import argparse
import os.path
DEFAULT_CONFIG_NEW = "/var/www/revpi/pictory/projects/_config.rsc"
DEFAULT_CONFIG_OLD = "/var/www/pictory/projects/_config.rsc"
import revpimodio2
def ev(name, value):
# payload is bytes, so we need to know the enconding (eg. ascii, utf-8, etc...)
print(name, value.decode('ascii'))
rpi = revpimodio2.RevPiModIO(autorefresh=True, monitoring=True)
# define IO: change length of string in the frm argument
nbuchwitz / dashboard.json
Last active January 10, 2022 21:54
esphome gas meter
"annotations": {
"list": [
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
- name: schedule downtime
url: "https://{{ icinga_host }}:{{ icinga_port | default(5665) }}/v1/actions/schedule-downtime"
user: "{{ icinga_user }}"
password: "{{ icinga_password }}"
force_basic_auth: True
validate_certs: False
method: POST
Accept: "application/json"