This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import paho.mqtt.client as mqtt | |
import datetime | |
import time | |
from influxdb import InfluxDBClient | |
def on_connect(client, userdata, rc): | |
print("Connected with result code "+str(rc)) | |
client.subscribe("Home/#") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// This is an example on MQTT publish from an ESP8266 board | |
// to an MQTT broker (I have used a local Mosquitto running on a Raspberry Pi) | |
// This example uses the PubSub client library (https://github.com/knolleary/pubsubclient) | |
// Install it in the Arduino IDE before compiling the sketch | |
// Sensor values are fetched from an indoor DHT22 sensor and an outdoor DHT22 sensor | |
#include <ESP8266WiFi.h> | |
#include <PubSubClient.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import paho.mqtt.client as mqtt | |
import datetime | |
import time | |
from Adafruit_IO import MQTTClient | |
from adafruit_credentials import ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY | |
from mylogger import logger | |
# | |
# Subscribes to messages via a local MQTT broker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
automation: | |
- alias: Turn on window lights when Lars gets home | |
trigger: | |
platform: zone | |
entity_id: device_tracker.my_iphone | |
zone: zone.home | |
event: enter | |
action: | |
service: switch.turn_on | |
entity_id: group.window_lights |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zone 1: | |
name: Work (Lars) | |
latitude: 61.422185 | |
longitude: 18.560426 | |
radius: 100 | |
icon: mdi:worker | |
zone 2: | |
name: School | |
latitude: 61.494772 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import paho.mqtt.publish as publish | |
from subprocess import check_output | |
from re import findall | |
import psutil | |
import sys | |
def get_temp(): | |
temp = check_output(["vcgencmd","measure_temp"]).decode("UTF-8") | |
return(findall("\d+\.\d+",temp)[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import paho.mqtt.client as mqtt | |
import datetime | |
import time | |
from influxdb import InfluxDBClient | |
def on_connect(client, userdata, flags, rc): | |
print("Connected with result code "+str(rc)) | |
client.subscribe("Home/#") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ influx -precision rfc3339 // starts the InfluxDB shell and shows time in rfc3339 format | |
Connected to http://localhost:8086 version 1.2.0 | |
InfluxDB shell version: 1.2.0 | |
> create database demo // Creates a new database | |
> use demo | |
Using database demo | |
> insert mysensor1 value=0.51 // Insert new datapoints | |
> insert mysensor1 value=0.53 // for the measurement | |
> insert mysensor1 value=0.45 // "mysensor1" | |
> select * from mysensor1 // Get the whole time series |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
group: | |
indoor_lights: | |
name: Indoor lights | |
entities: | |
- switch.window_lights_downstairs | |
- switch.wall_lights_downstairs | |
- switch.window_lights_upstairs | |
- switch.floor_light_upstairs | |
automation: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
automation: | |
- alias: Turn on garden lights when sun sets | |
trigger: | |
platform: sun | |
event: sunset | |
action: | |
service: switch.turn_on | |
entity_id: switch.garden_lights | |
- alias: Turn off garden lights when sun rises |