Skip to content

Instantly share code, notes, and snippets.

@Bouni
Bouni / broadcast.py
Created October 1, 2019 16:55
Luxtronik Broadcast detection
import struct
import socket
import time
def searchHeatpumps(own_ip, brdcast):
"""Multicast shout out for luxtronik heatpumps."""
for p in (4444, 47808):
server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
server.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
homeassistant:
latitude: 47.0
longitude: 8.0
elevation: 340
unit_system: metric
time_zone: Europe/Berlin
name: Home
homeassistant:
latitude: 47.0
@Bouni
Bouni / hass-loxone.html
Created September 20, 2019 10:53
HA custom icon font
<ha-iconset-svg name="lox" size="1024"><svg><defs>
<g id="valve-open" transform="scale(2.00 2.00)"><path d="M257.48009 16.048248C-50.77526 0 -90.67008 28.50765 -90.67008 64.790019V90.706023C0 7.77472 7.2536 12.958 18.13402 12.958H18.134V12.95801H108.8041V-12.95801C10.88041 0 18.134 -5.18328 18.134 -12.958V29.006252C0 -7.774719 -7.25359 -12.958004 -18.134 -12.958004ZM27.20103 25.916007C5.44019 0 9.067 2.591643 9.067 6.479002V152.10729C0 3.88736 -3.62681 6.479 -9.067 6.479-5.44021,0 -9.06702,-2.59164 -9.06702,-6.479 V48.443257C0 -3.887359 3.62681 -6.479002 9.06702 -6.479002ZM-54.40205 25.916008C5.4402 0 9.067 2.591643 9.067 6.479002V77.748025C0 3.88736 -3.6268 6.479 -9.067 6.479-5.44021,0 -9.06701,-2.59164 -9.06701,-6.479 V74.359265C0 -3.887359 3.6268 -6.479002 9.06701 -6.479002ZM456.95422 324.39845V0C-10.88041 0 -18.13402 7.25353 -18.13402 18.13393V90.67007C0 9.06707 7.25361 18.13393 18.13402 18.13393V0C9.067 0 18.13401 -7.25352 18.13401 -18.13393V-90.67007C0 -10.8804 -7.25359 -18.13393 -18.13401 -18.13393ZM-3
@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
@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 / 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 / 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 / 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:
  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/

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).