Skip to content

Instantly share code, notes, and snippets.

@LucaTNT
LucaTNT / apritiSesamo.py
Last active July 26, 2017 18:00
Script that triggers a relay connected to GPIO 25 on a Raspberry Pi in order to open a garage door
#!/usr/bin/env python
from gpiozero import LED, Button
from time import sleep
from flask import Flask
import datetime
portone = LED(25)
app = Flask(__name__)
@LucaTNT
LucaTNT / azure-text-to-speech.py
Last active April 20, 2022 15:53
Script that synthesizes EasyApple intros with Azure's text-to-speech APIs
import requests
def getToken():
req = requests.post("https://westeurope.api.cognitive.microsoft.com/sts/v1.0/issuetoken",
headers={"Ocp-Apim-Subscription-Key": "YOUR_AZURE_API_KEY_HERE"},
)
return req.text
def textToMp3(text, voice="it-IT-ElsaNeural"):
@LucaTNT
LucaTNT / sign-stripe-webhook-request.sh
Created June 26, 2022 15:45
Shell script to sign a Stripe webhook event
#!/usr/bin/env bash
WEBHOOK_DESTINATION="http://localhost:3000/stripe/webhook"
WEBHOOK_SECRET="whsec_ENTER_YOURS_HERE"
if [[ ! "$#" -eq 1 ]]; then
echo "USAGE: $0 /path/to/event.json";
exit 1;
fi
timestamp="$(date +%s)."
@LucaTNT
LucaTNT / tesla-wall-connector-esp-power-meter.yaml
Created January 16, 2026 14:00
ESPHome configuration to run a Modbus adapter that can talk to the Tesla Wall Charger 3 to dynamically adjust power. Includes API connection to a Shelly Pro EM 50 (easily adaptable to another type of Shelly meter)
substitutions:
device_name: esp-tesla
friendly_name: ESPHome Tesla
mqtt_broker: 10.42.1.10 # CHANGE!
tx_pin: GPIO32 # connect to RX on modbus bridge # CHANGE!
rx_pin: GPIO33 # connect to TX on modbus bridge # CHANGE!
ct1_value_id: internal_meter_reading # Name of the (number) variable that needs to be set as ct reading
min_value: 0.0
max_value: 35.0 # adjust to a value above configured max-value in Wall Connector config
start_value: 0.0 # Initial value at boot - determines the behavior when home assistant