Skip to content

Instantly share code, notes, and snippets.

# Basic sensor, read everything from MQTT
- platform: mqtt
name: "WLANThermo"
# change topic to your modelname!
state_topic: "WLanThermo/NANOv3/status/data"
value_template: "{{ value_json.system.soc }}"
# change topic to your modelname!
json_attributes_topic: "WLanThermo/NANOv3/status/data"
json_attributes_template: "{{ value_json | tojson }}"
device_class: battery
@adrianmihalko
adrianmihalko / gist:abd30eb6f3dd458d81b73c80885b52ae
Created January 21, 2022 19:06
Fix empty tvg-name for IPTV playlist
If for some reason you got an IPTV playlist which has empty tvg-name, but actual channel names are exists at the end of line, example:
#EXTINF:-1 tvg-id="none" tvg-name="none" tvg-logo="" group-title="Testing", Test_Title_CC (GER)
#EXTINF:-1 tvg-id="none" tvg-name="none" tvg-logo="" group-title="Testing", Cup Mus (GER)
#EXTINF:-1 tvg-id="none" tvg-name="New World (NED)" tvg-logo="" group-title="Apple", New World (NED)
you can use awk to fix this issue:
awk 'BEGIN{FS=", "}/^#EXTINF:-1/&&/tvg-name="none"/{sub(/tvg-name="none"/,"tvg-name=\x22" $NF "\x22")}{print}' file.txt
@adrianmihalko
adrianmihalko / gist:336d422bf8ec0852c9947b4b8437fa22
Created December 12, 2021 19:14
"None of the ports were configured to use SSL certificate" - Dymo Web Service
I can't describe how much I hate Dymo developers. Long hours of annoyance were caused by their negligence.
So you are here, because you are looking for solution for "None of the ports were configured to use SSL certificate"
- when you try to diagnose Dymo Web Service.
The good developers at Dymo forgot to delete/check/reinstall (call as you want) certificates when you uninstall/reinstall the web service.
After hours (days!) I found the solution.
@adrianmihalko
adrianmihalko / routing.txt
Created November 25, 2021 19:40
Destination based routing on Unifi USG and Edgerouter
@UniFiSecurityGateway3P:/config$ configure
@UniFiSecurityGateway3P# set protocols static table 5 interface-route 0.0.0.0/0 next-hop-interface wg0
@UniFiSecurityGateway3P# set firewall modify VPN_Gateway rule 2502 action modify
@UniFiSecurityGateway3P# set firewall modify VPN_Gateway rule 2502 modify table 5
@UniFiSecurityGateway3P# set firewall modify VPN_Gateway rule 2502 destination group address-group 6029c3e9e4f9411eca96870f
@UniFiSecurityGateway3P# set firewall modify VPN_Gateway rule 2502 protocol all
@UniFiSecurityGateway3P# set interfaces ethernet eth1 firewall in modify VPN_Gateway
@UniFiSecurityGateway3P# commit
@adrianmihalko
adrianmihalko / gist:f2082454232c92d1905c01c310c28c64
Created November 25, 2021 14:45
Policy based routing on USG
policy-based routing on USG.
NOTES & REQUIREMENTS:
Applicable to all UniFi Security Gateway models (USG / USG-PRO-4 / USG-XG-8).
This article does not apply to the UniFi Dream Machine (UDM) models.
This article contains advanced JSON configurations using the CLI and should only be attempted by advanced users.
See the Configuration Using config.gateway.json help center article for more information on JSON configurations.
Introduction
{
"firewall": {
"modify": {
"LOAD_BALANCE": {
"description": "LOAD_BALANCE",
"rule": {
"2501": {
"action": "modify",
"modify": {
"table": "5"
@adrianmihalko
adrianmihalko / gist:62ed2ea8dc1f75780d3bf5d2a292cc86
Created February 26, 2021 21:42
One line webserver with request logging with python twisted
python -c 'from twisted.web.server import Site; from twisted.web.static import File; from twisted.internet import reactor; from twisted.python import log; import sys; log.startLogging(sys.stdout); reactor.listenTCP(1990, Site(File("."))); reactor.run()'
@adrianmihalko
adrianmihalko / agistfile1.txt
Last active August 29, 2022 03:41
Selective routing trough VPN with Unifi USG.
I wanted to route only specific IPs trough a Wireguard interface. I am not expert in any way, but I am trying to explain you as best I can how I did it.
Setup a WG connection as usual on one of your device in your network (In my example I will call it "Ubuntu server", 192.168.1.54):
[Interface]
Address = something/24
PrivateKey = longprivatekeyR5FE=
Table = 43
PostUp = ip rule add from 192.168.1.91 table 43; iptables -w -A FORWARD -i %i -j ACCEPT; iptables -w -A FORWARD -o %i -j ACCEPT; iptables -w -t nat -A POSTROUTING -o ens160 -j MASQUERADE; iptables -t nat -A POSTROUTING -o %i -j MASQUERADE
@adrianmihalko
adrianmihalko / networkmap1.png
Last active April 30, 2022 15:07
wireguard edgerouter mullvad config
!!!NOT WORKING!!!
configure
set interfaces wireguard wg0 address 10.xx.xxx.253/32
set interfaces wireguard wg0 listen-port 51820
set interfaces wireguard wg0 route-allowed-ips false
set interfaces wireguard wg0 peer JuE+ endpoint mullvadserverip:51820
set interfaces wireguard wg0 peer JuE+ allowed-ips 0.0.0.0/0
@adrianmihalko
adrianmihalko / gist:cfc076b28a3ff4652766a295972a9945
Created February 6, 2019 21:58
Convert all white transparent icons into transparent black (change icon color)
for f in *.png ; do convert "$f" -fill black -colorize 100 "${f%.png}.png" ; done