Skip to content

Instantly share code, notes, and snippets.

View ndfred's full-sized avatar

Frédéric Sagnes ndfred

  • Facebook
  • London, UK
View GitHub Profile

⚠️ There is now an official way to connect Glow to Home Assistant via MQTT, I would suggest using that instead of the method described below. Here are the sensor templates for that (replace GLOW_DEVICE_ID with the relevant information for your device):

mqtt:
  sensor:
    - name: "Home Power"
      state_topic: "glow/GLOW_DEVICE_ID/SENSOR/electricitymeter"
      unit_of_measurement: 'W'
      value_template: "{{ (value_json['electricitymeter']['power']['value'] * 1000) | int }}"
      icon: 'mdi:flash'
@ndfred
ndfred / glowmqtt.py
Last active July 23, 2023 07:21
Fetch data from a Hildebrand Glow device over MQTT
import datetime
import logging
import json
import paho.mqtt.client as mqtt # pip3 install paho-mqtt
GLOW_LOGIN = "GLOW_LOGIN"
GLOW_PASSWORD = "GLOW_PASSWORD"
GLOW_DEVICE_ID = "GLOW_DEVICE_ID"
# Fields gathered from the ZigBee Smart Energy Standard document
@ndfred
ndfred / status.sh
Created January 31, 2020 09:37
Server status commands
ps -eo cmd:100,%mem,%cpu,rss,time --sort=-time
free -mh
@ndfred
ndfred / D32 Setup.mdown
Last active September 13, 2020 07:29
Wemos LOLIN D32 Pro + SHT30 macOS Setup

To get USB access:

  • install the USB serial driver, check that you see a /dev/cu.wchusbserial1410 device when plugging in the board over USB

To deploy MicroPython on the board:

  • get the MicroPython firmware (get the SPIRAM variant to get access to the 4MB of RAM)
  • install esptool by running sudo pip install esptool
  • clear the flash by running esptool.py --chip esp32 --port /dev/cu.usbserial-1410 erase_flash
  • flash MicroPython by running esptool.py --chip esp32 --port /dev/cu.usbserial-1410 --baud 460800 write_flash -z 0x1000 esp32spiram-idf3-20190125-v1.10.bin
@ndfred
ndfred / reconfigure.diff
Created April 27, 2017 21:59
Run configure scripts for node-lame
diff --git a/deps/lame/config/linux/x87/config.h b/deps/lame/config/linux/x87/config.h
index efc3d93..d9405c0 100644
--- a/deps/lame/config/linux/x87/config.h
+++ b/deps/lame/config/linux/x87/config.h
@@ -22,7 +22,7 @@
/* #undef DEBUG */
/* allow to compute a more accurate replaygain value */
-/* #undef DECODE_ON_THE_FLY */
+#define DECODE_ON_THE_FLY 1
class Trace2html < Formula
desc "Utility from Google Trace Viewer to convert JSON traces to HTML"
homepage "https://github.com/catapult-project/catapult"
url "https://github.com/ndfred/catapult/archive/9ee5e561160a0f62302b5fbe32c4d5454512b233.tar.gz"
version "2016-05-04"
sha256 "e839d313be02ef1f4adf6351d49810561eda1094945649941ea7a0c065279cb9"
bottle :unneeded
depends_on :python if MacOS.version <= :snow_leopard
@ndfred
ndfred / main.m
Created December 10, 2012 18:53
Fix iOS 5 not finding iPad / iPhone specific resources on iPhone-only apps running on the iPad
#import <UIKit/UIKit.h>
#import <objc/runtime.h>
#import "MainViewController.h"
@interface NSBundle (TPPathForResourceFix)
- (NSString *)tp_pathForResource:(NSString *)name ofType:(NSString *)ext;
@end
@ndfred
ndfred / install_airport_utility_5.6.1.sh
Created November 8, 2012 22:22
Download and install the Airport Utility 5.6.1 app on Mac OS X Lion and up
#!/bin/sh -e
# Download and install the Airport Utility 5.6.1 app on Mac OS X Lion and up
if [ ! -d "/Applications/Utilities/AirPort Utility 5.6.1.app" ]
then
[ -d /Volumes/AirPortUtility ] && hdiutil detach /Volumes/AirPortUtility
rm -rf /tmp/AirPortUtility5.6.1.dmg /tmp/AirPortUtility5.6.1
echo "Downloading Airport Utility 5.6.1"
@ndfred
ndfred / push.py
Created October 30, 2012 21:41
A simple standalone script to test an Apple Push Notification setup
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
A simple standalone script to test an Apple Push Notification setup.
Uses the feedback packets to provide the best information on how to fix things.
Steps to send a push notification:
@ndfred
ndfred / UIView+NibLoadedView.m
Created June 14, 2012 10:49
Load a view from a nib file
+ (id)nibLoadedView {
BOOL isTableViewCell = [self isSubclassOfClass:[UITableViewCell class]];
UIView *view = isTableViewCell ? [[self alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass(self)] : [[self alloc] initWithFrame:CGRectZero];
UINib *nib = [UINib nibWithNibName:[self nibName] bundle:nil];
UIView *rootView = [[nib instantiateWithOwner:view options:nil] lastObject];
if (![rootView isKindOfClass:self]) {
view.frame = rootView.frame;
view.backgroundColor = rootView.backgroundColor;