Skip to content

Instantly share code, notes, and snippets.

# #######################################
#
# HAL file for HostMot2 with 3 steppers
#
# Derived from Ted Hyde's original hm2-servo config
#
# Based up work and discussion with Seb & Peter & Jeff
# GNU license references - insert here. www.linuxcnc.org
#
#
# Load our handwheel.py script as handwheel (symlinked from ~/linuxcnc/handwheel.py -> /usr/bin/handwheel)
loadusr -Wn handwheel handwheel
#net handwheel.plus
# Jog Pendant
# loadrt encoder num_chan=1
# addf encoder.capture-position servo-thread
# addf encoder.update-counters base-thread
#
@Bouni
Bouni / abfall.py
Created February 7, 2019 16:12
Scrape disposal dates from Abfallwirtschaft Landkreis Waldshut website
import re
import requests
import html
# Hole Webseite
url = "https://www.abfall-landkreis-waldshut.de/de/termine/abfuhrtage.php?ort=78"
r = requests.get(url)
# baue Regex der alle notwendigen Mülltypen findet <td>Mülltyp</td><td>Daten</td>
trash_types = ["Restmüll","Biotonne","Grünabfälle","Gelber Sack","Blaue Tonne"]

Installing Python 3.7.0 on Raspbian

As of July 2018, Raspbian does not yet include the latest Python release, Python 3.7.0 This means we will have to build it ourselves, and here is how to do it.

  1. Install the required build-tools (some might already be installed on your system).
  1. Install python 3.6.8 from sources (maybe not necessary)
  2. Build libcec from source like described here, but instead of cmake -DRPI_INCLUDE_DIR=/opt/vc/include -DRPI_LIB_DIR=/opt/vc/lib .. do cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1 -DRPI_INCLUDE_DIR=/opt/vc/include -DRPI_LIB_DIR=/opt/vc/lib -DCMAKE_INSTALL_PREFIX=/usr ..
  3. sudo make install copies cec.py and _cec.so to /usr/lib/python3.6/dist-packages/ but we need the in /usr/local/lib/python3.6/site-packages/, so do a sudo cp /usr/lib/python3.6/dist-packages/cec.py /usr/local/lib/python3.6/site-packages/ and a sudo cp /usr/lib/python3.6/dist-packages/_cec.so /usr/local/lib/python3.6/site-packages/
@Bouni
Bouni / export.py
Created May 8, 2019 19:27
Export KNX Adresses from Loxone project
#!/usr/bin/env python
import sys
import re
if len(sys.argv) != 2:
print("please pass .loxone file as argument")
sys.exit(1)
with open(sys.argv[1]) as lox, open("export.txt","w") as ex:
@Bouni
Bouni / export.py
Created May 8, 2019 19:54
Export KNX Adresses from .knxproj file
#!/usr/bin/env python
import sys
import re
import zipfile
if len(sys.argv) != 2:
print("Please pass .knxproj file as argument")
@Bouni
Bouni / wg-configurator.py
Last active May 10, 2019 15:27
Small script that helps with the wireguard configuration
#!/usr/bin/env python
import os
import sys
import re
import click
import subprocess
class WGConfigurator:
@Bouni
Bouni / template_sensor_proposal.yaml
Created September 6, 2019 10:39
HA template sensor proposal
## Working example
- platform: template
sensors:
person_count:
friendly_name: "Number of Person at home"
unit_of_measurement: 'person'
entity_id:
- person.person1
- person.person2
@Bouni
Bouni / letsencrypt-renewal.service
Created September 9, 2019 06:14
Systemd LetsEncrypt timer for cert renewal
[Unit]
Description=Certbot certificate renewal
[Service]
ExecStart=/usr/bin/certbot renew --pre-hook "systemctl stop nginx" --post-hook "systemctl start nginx"
ExecStartPost=/usr/bin/systemctl restart nginx