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
prediction: | |
friendly_name: "Weather prediction" | |
value_template: >- | |
{%- set state = states('weather.smhi_home') -%} | |
{% if state == 'clear-night' %} klart, natt | |
{% elif state == 'cloudy' %} molnigt | |
{% elif state == 'exceptional' %} exceptionellt | |
{% elif state == 'fog' %} dimma | |
{% elif state == 'hail' %} hagel | |
{% elif state == 'lightning' %} åska |
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
{% set hour_when = as_timestamp(state_attr('binary_sensor.nordpool_planner_time_when_low_electricity_price', 'starts_at'))|int%} | |
{% set real_hour = (state_attr('binary_sensor.nordpool_planner_time_when_low_electricity_price', 'starts_at')) %} | |
Electricity is cheap at: {{ real_hour }} | |
{% set time_now = as_timestamp(now())|int%} | |
{% set hour_now = time_now|timestamp_custom('%H') %} | |
{% set hours_until = -((time_now - hour_when)|int/3600)|int %} | |
Hours left until cheap electricity: {{ hours_until }} |
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
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
} | |
} | |
############## | |
class PersonAdapter( |
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
# Code inspired by https://projects.raspberrypi.org/en/projects/physical-computing/11 | |
from gpiozero import MotionSensor | |
import paho.mqtt.client as paho | |
import json | |
pir = MotionSensor(22) | |
mqtt_pir_topic = "magicmirror/pir" | |
broker="192.168.1.190" | |
client= paho.Client("MagicMirrorSensors") |
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/python | |
# Script that reads various I2C sensors. | |
# CCS811, BH1750, HTU21. (Air quality, light, temp & humidity). | |
# CCS811. "This part will measure eCO2 (equivalent calculated carbon-dioxide) concentration | |
# within a range of 400 to 8192 parts per million (ppm), and TVOC (Total Volatile Organic | |
# Compound) concentration within a range of 0 to 1187 parts per billion (ppb)." | |
# "The BH1750 provides 16-bit light measurements in lux" |
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
<!DOCTYPE html> | |
<head> | |
<title>Javascript MQTT test</title> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.1/mqttws31.min.js"></script> | |
</head> | |
<body> | |
<script> | |
// Connection settings | |
var broker = new Object(); | |
broker.hostname = '192.168.1.190'; |
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
import sys | |
import paho.mqtt.publish as publish | |
publish.single("mqttjs", "Hello from mqttjs", hostname="192.168.1.190") | |
// If using web sockets: | |
publish.single("mqttjs", "Hello from mqttjs", hostname="192.168.1.190", port=9001, transport='websockets') |
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 python | |
''' | |
getVlcData.py | |
This script fetches information from the VLC media player. | |
For this to work VLC has to be started with it's http-server activated. | |
This can be done with a command line like this: | |
vlc --aout=alsa --alsa-audio-device="hw:0,0" --daemon --syslog -I http --http-port 8080 --http-password <password> |
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 python | |
''' | |
Send a Mqtt message if system is playing sound, another if it's stopped | |
Put Mqtt server password in a separate file named "mqttpass.txt". | |
''' | |
import os, time, json, sys | |
import paho.mqtt.client as mqtt | |
MQTT_HOST = '192.168.1.79' | |
MQTT_PORT = 1883 |
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
# Started by a Systemd script called 'waitformqtt.service': | |
# | |
# [Unit] | |
# Description=Checks if Mosquitto is running | |
# After=network-online.target | |
# [Service] | |
# User=rock64 | |
# Type=oneshot | |
# ExecStart=/home/rock64/waitForMosquitto |
NewerOlder