Skip to content

Instantly share code, notes, and snippets.

View jbouwh's full-sized avatar

Jan Bouwhuis jbouwh

View GitHub Profile
@jbouwh
jbouwh / z2m_ikea_styrbar_remote.yaml
Last active December 11, 2024 13:16 — forked from klaasnicolaas/z2m_ikea_styrbar_remote.yaml
Home Assistant - Blueprint - Zigbee2MQTT - IKEA STYRBAR - 4 Button/Tradfri On/Off Remote
---
blueprint:
name: Z2M - IKEA styrbar (4 button)/Tradfi (On/Off) remote for lights
description: |
Control lights with a:
- IKEA styrbar (4 button) remote [E2001/E2002](https://www.zigbee2mqtt.io/devices/E2001_E2002.html#ikea-e2001%252Fe2002).
- TRADFRI on/off switch [E1743](https://www.zigbee2mqtt.io/devices/E1743.html#ikea-e1743).
There are 3 different features:
- Turn the light group on or off
"""Script to test the subscribing performance with device based discovery.
See: https://github.com/home-assistant/core/pull/109030
Test script to to assert the HomeAssistant MQTT discovery.
"""
import copy
import json
import sys
@jbouwh
jbouwh / postfix_hold_queue_cleanup.py
Last active December 28, 2023 11:37
Script to remove emails from the postfix holdqueue after a fixed time and send an email notification. This script can be used with the `HoldQuarantinedMessages` setting set to `True` in `opendmarc`. Then script can be executed hourly from a cronjob on you mail system.
#! /usr/bin/python3
"""Postfix hold queue clean up tool."""
from datetime import datetime, timedelta
import json
from pathlib import Path
import subprocess
import logging
import os
import smtplib
@jbouwh
jbouwh / certinit.bash
Last active December 11, 2023 15:21
Expose Home Assistant using haproxy and letsencrypt using DNS chalenge with TransIP API
#! /usr/bin/bash
sudo docker run -it --rm --name="certbot" \
--mount type=bind,source=/etc/letsencrypt,target="/etc/letsencrypt" \
--mount type=bind,source=/var/log/letsencrypt,target="/opt/certbot-dns-transip/logs" \
--mount type=bind,source=/etc/transip,target="/opt/certbot-dns-transip/config" \
rbongers/certbot-dns-transip certonly --reuse-key \
--manual --preferred-challenges=dns --manual-auth-hook /opt/certbot-dns-transip/auth-hook \
--manual-cleanup-hook /opt/certbot-dns-transip/cleanup-hook \
--cert-name certname.example.com \
-d '*.example.com' \
"""The tests for MQTT subscribing performance.
Test script to to assert the HomeAssistant MQTT discovery.
"""
import copy
import json
import sys
from typing import Any
from time import sleep
@jbouwh
jbouwh / graphapi-dmarc-mail.py
Last active October 15, 2022 13:15
Read DMARC XML data from M365 mailbox with GRAPH API and application credentials
"""Process DMARC report mail items from an MS365 online mail folder via the GRAPH API using app_id and secret.
fill config template below and save this in `config.cfg` (same folder)
[graph-dmarc-mail]
clientId = xxxxx
clientSecret = xxxxx
tenantId = xxxxx
mailbox = something@example.com
@jbouwh
jbouwh / build-openssl.sh
Last active October 5, 2021 14:53 — forked from bmaupin/build-openssl.sh
Build openssl (with SSLv2/3 support for security testing)
#!/bin/bash
# Cache sudo password
sudo -v
# Get latest OpenSSL 1.0.2 version from https://openssl.org/source/
# v1.1.0 seems to have removed SSLv2/3 support
openssl_version=1.0.2k
# Install perl modules, makedepends and gcc and build dependencies
@jbouwh
jbouwh / test_init.py
Created July 21, 2021 13:15
tests/components/select
"""The tests for the Select component."""
from unittest.mock import MagicMock
import pytest
from homeassistant.components.select import (
ATTR_OPTION,
ATTR_OPTIONS,
SelectEntity,
DOMAIN,
@jbouwh
jbouwh / select.py
Last active July 21, 2021 13:17
tests/testing_config/custom_components/test
"""
Provide a mock select platform.
Call init before using it in your tests to ensure clean test data.
"""
from tests.common import MockEntity
UNIQUE_SELECT_1 = "unique_select_1"
UNIQUE_SELECT_2 = "unique_select_2"
UNIQUE_SELECT_3 = "unique_select_3"