Skip to content

Instantly share code, notes, and snippets.

@ispiropoulos
ispiropoulos / shelly.py
Created August 28, 2018 09:16
Shelly Switch Home Assistant Component
"""
Support for The Shelly Wifi switch.
Save this file inside ".homeassistant/custom_components/switch" (create the folders if not present) and restart HASS.
usage example:
switch:
- platform: shelly
switches:
registers:
- name: L1 Voltage
unit_of_measurement: V
register: 0
data_type: float
precision: 2
count: 2
- name: L2 Voltage
unit_of_measurement: V
register: 2
@jovianlin
jovianlin / SVY21.py
Last active November 25, 2022 10:49
Singapore has a special coordinate system called SVY21. This converts the special coordinates to lat/lng.
#! /usr/bin/python
import math
class SVY21:
# Ref: http://www.linz.govt.nz/geodetic/conversion-coordinates/projection-conversions/transverse-mercator-preliminary-computations/index.aspx
# WGS84 Datum
a = 6378137
f = 1 / 298.257223563
#!/usr/bin/python
import os
import socket
import sys
def encode_packet(data):
output = bytearray()
for i in range(0, len(data)):
tmpoutput = bytearray([0, data[i]])