Skip to content

Instantly share code, notes, and snippets.

View fabaff's full-sized avatar

Fabian Affolter fabaff

View GitHub Profile
@fabaff
fabaff / xy-md02.py
Last active June 7, 2024 08:31
Get the temperature and the humidity from a XY-MD02 sensor
#!/usr/bin/env python
"""Get the temperature and the humidity from a XY-MD02 sensor."""
from pymodbus.client import ModbusSerialClient as ModbusClient
from pymodbus.constants import Endian
from pymodbus.payload import BinaryPayloadDecoder
SERIAL_PORT = "/dev/ttyUSB0"
BAUDRATE = 9600
SLAVE_ID = 1
@fabaff
fabaff / __init__.py
Last active January 7, 2023 02:34
Update SpaceAPi component with support for SpaceAPI v14
"""Support for the SpaceAPI."""
from contextlib import suppress
import voluptuous as vol
from homeassistant.components.http import HomeAssistantView
from homeassistant.const import (
ATTR_ENTITY_ID,
ATTR_ICON,
ATTR_LOCATION,
@fabaff
fabaff / gases.yaml
Created December 30, 2019 09:53
GAses sensor with ESPHome
esphome:
name: gas_quadrat
platform: ESP8266
board: nodemcuv2
logger:
level: VERBOSE
wifi:
ssid: SSID
@fabaff
fabaff / prg320.py
Created May 12, 2019 08:51
Reading one number from a PRG320
import asyncio
import binascii
import json
import serial_asyncio
class Prg320Output(asyncio.Protocol):
"""Get the output of PRG320."""
def connection_made(self, transport):
@fabaff
fabaff / power-monitoring.yaml
Created May 10, 2019 20:14
Power monitoring with ESP32, INA219, esphome and Home Assistant
esphome:
name: pm
platform: ESP32
board: esp32dev
wifi:
ssid: 'YOUR_SSID'
password: 'YOUR_PASSWORD'
mqtt:
@fabaff
fabaff / 0_reuse_code.js
Created February 25, 2017 20:17
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@fabaff
fabaff / keybase.md
Created August 19, 2016 15:42
keybase.md

Keybase proof

I hereby claim:

  • I am fabaff on github.
  • I am fabaff (https://keybase.io/fabaff) on keybase.
  • I have a public key whose fingerprint is 2F6C 930F D3C4 7E38 6AFA 4EB4 E23C D2DD 36A4 397F

To claim this, I am signing this object:

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>
/* ------------------ */
/* SKETCH CREDENTIALS */
/* ------------------ */
char* deviceId = "<DEVICE-ID>"; // * set your device id (will be the MQTT client username)
@fabaff
fabaff / set-bridge.sh
Last active December 25, 2015 14:58
Simple script to setup a bridge on Fedora.
#!/bin/bash
#
# Copyright (c) 2011-2013 Fabian Affolter <[email protected]>
# Released under the MIT license.
#
# This bash script setup a transparent and non-permanent bridge for
# wire-tapping.
#
BRNAME=br0 # Bridge name
IFNAME1=em1 # Primary card