Skip to content

Instantly share code, notes, and snippets.

@matbor
matbor / Wemo-switch-v2.py
Last active December 29, 2015 05:39
Belkin Wemo discover switches and automatically subscribe to events. Needs the https://github.com/iancmcc/ouimeaux library to work.
import datetime
from ouimeaux.environment import Environment
def on_switch(switch): #discover light switches and register listeners
print('******** Switch found:'+ switch.name+ ', Current state : '+str(switch.get_state()))
x = switch.name.replace(" ", "") #remove spaces
x = env.get_switch(switch.name)
x.register_listener(on_change)
def on_change(value):
@matbor
matbor / subscribetotopic.html
Created February 6, 2014 03:29
Simply connects to a mqtt broker that is running websockets, subscribes to the topics and displays the messages in the console. Requires mqttws31.js to work. Get it from http://git.eclipse.org/c/paho/org.eclipse.paho.mqtt.javascript.git/tree/src
<html>
<title>Test subcriber</title>
<head>
<script src="vendor/mqttws31.js" type="text/javascript"></script>
<script type="text/javascript">
//mqtt broker setup
@matbor
matbor / json_hs_temps.php
Created February 6, 2014 22:36
This is what is used by index_hs_temps_multi.php to get my temperature data in json format for my highcharts (highstock)
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/dbconnection/temperature_dbinfo.php";
require($path);
$interval = $_GET['interval'];
$location = $_GET['location'];
$con = mysql_connect($mysqlserver,$username,$password);
@matbor
matbor / index_hs_temps_multi.php
Last active June 9, 2016 15:12
creates a temperature chart from JSON data, uses the highcharts(highstock) js.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Upwey Temperatures</title>
</head>
<script type="text/javascript" src="/javascript/jquery_1.8.2/jquery.min.js"></script>
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<script src="http://code.highcharts.com/stock/modules/exporting.js"></script>
<script type="text/javascript">
@matbor
matbor / functions.owntracks.py
Last active August 29, 2015 13:57
This will reverse Geo the gps data sent by owntracks and then send it thru mqttwarn to whatever target you specify, https://github.com/jpmens/mqttwarn
#add this first part to the top of the functions file
#for reversegeo
import time
#import logging
from urllib import urlencode
from urllib2 import urlopen
#this filter will reverse geo the address for you
def OwnTracksConvertWithAdd(data):
@matbor
matbor / 00readme.md
Last active August 29, 2015 13:57
Last Will and Testament Notification Function for mqttwarn. https://github.com/jpmens/mqttwarn

note; I have all my scripts setup so that the lwt (last will and testament) publishes 'offline' if the scripts die.

@matbor
matbor / 00readme.md
Last active August 29, 2015 13:57
HowFar2Home -- This is for mqttwarn https://github.com/jpmens/mqttwarn and Owntracks https://github.com/owntracks.

How Far 2 Home

This function was designed as a proof of concept and will return the estimated driving distance the device (using owntracks here) is from the GPS coordinates specified in the functions file

For example;

2014-03-24 15:45:00,484 INFO [log] matthew iphone is 38mins away from home

Requiements

@matbor
matbor / 00Readme.md
Last active January 14, 2025 11:04
mqtt/websocket html/js example
@matbor
matbor / index.php
Last active August 29, 2015 14:04
This is now working for me... thought i should post the code. highcharts example, for stackoverflow question. http://stackoverflow.com/questions/24911544/trying-to-load-flags-with-my-temperature-data-from-json-files
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Historical Temperature Data</title>
</head>
<style type="text/css">
#bubbles {
@matbor
matbor / pushalot.py
Created August 14, 2014 05:32
pushalot.com python test , replace xxxxxxxxxxxxxxx with your Authorization token(api). Modified from sickbeards pushalot notifier.
#!/usr/bin/python
from urllib import urlencode
from httplib import HTTPSConnection, HTTPException
from ssl import SSLError
pushalot_authorizationtoken = 'xxxxxxxxxxxxxxx'
pushalot_title = 'title'
pushalot_body = 'body'