Skip to content

Instantly share code, notes, and snippets.

@balloob
balloob / sensor_example.py
Last active Nov 23, 2021
Example platforms and automation component for Home Assistant
View sensor_example.py
"""
Copy this file to <config_dir>/example/sensor.py
Add to your configuration.yaml:
sensor:
platform: example
"""
from homeassistant.const import TEMP_CELSIUS
from homeassistant.helpers.entity import Entity
@balloob
balloob / panel-redirect.js
Created Jun 22, 2020
Add redirects to the Home Assistant sidebar to any place in Home Assistant
View panel-redirect.js
/*
Add a link to the sidebar to any path in Home Assistant
Put this file in <config>/www/panel-redirect.js
In configuration.yaml:
panel_custom:
- name: panel-redirect
# url_path needs to be unique for each panel_custom config
@balloob
balloob / config.h
Last active Nov 10, 2021
ESP8266 sketch to control a Whynter ARC-110WD portable air conditioner and monitor temperature using MQTT, infrared transmitter, DHT22. For a list of possible IR codes see https://docs.google.com/spreadsheets/d/1dsr4Jh-nzC6xvSKGpLlPBF0NRwvlpyw-ozg8eZU813w/edit#gid=0
View config.h
#define wifi_ssid "YOUR_WIFI_NAME"
#define wifi_password "YOUR_WIFI_PASSWORD"
#define mqtt_server "MQTT_SERVER"
#define mqtt_user "MQTT_USER"
#define mqtt_password "MQTT_PASS"
#define ac_topic "device/study_room/ac"
#define temperature_topic "device/study_room/temperature"
#define humidity_topic "device/study_room/humidity"
@balloob
balloob / pull-light-card.js
Created Nov 14, 2020
Custom card for Home Assistant that shows a pull Light Card. Video at https://twitter.com/balloob/status/1327745146633510912
View pull-light-card.js
/*
Created by @jh3yy
Adapted for Home Assistant by @balloob
Original: https://twitter.com/jh3yy/status/1327686213432717313
Only works on localhost because of restrictions MorphSVGPlugin3
Card config for usage in Home Assistant:
@balloob
balloob / balloob-battery-strategy.js
Created Apr 28, 2021
Lovelace strategy to show all batteries grouped by area.
View balloob-battery-strategy.js
/*
Battery strategy that shows your battery entities grouped by area.
To use:
- store this file in `<config>/www/balloob-battery-strategy.js`
- Add lovelace resource: `/local/balloob-battery-strategy.js`, type JavaScript Module
- Create a new Lovelace dashboard and set as content:
views:
- title: Batteries
@balloob
balloob / demo-strategy.js
Last active Apr 25, 2021
Demo Lovelace strategy for Home Assistant
View demo-strategy.js
/*
Demo strategy that shows each area as a tab. Each tab shows the area entities.
To use:
- store this file in `<config>/www/demo-strategy.js`
- Add lovelace resource: `/local/demo-strategy.js`, type JavaScript Module
- Create a new Lovelace dashboard and set as content:
strategy:
name: 'custom:balloob-demo'
@balloob
balloob / MQTT_ESP8266_temperature_humidity.ino
Created Jun 20, 2016
Sketch for the ESP8266 to publish temperature and humidity values received from a DHT22 to MQTT
View MQTT_ESP8266_temperature_humidity.ino
// Get ESP8266 going with Arduino IDE
// - https://github.com/esp8266/Arduino#installing-with-boards-manager
// Required libraries (sketch -> include library -> manage libraries)
// - PubSubClient by Nick ‘O Leary
// - DHT sensor library by Adafruit
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <DHT.h>
@balloob
balloob / example-card.js
Created Feb 20, 2021
Example custom card for Home Assistant. Created during Github Open Source Friday on Feb 19, 2021.
View example-card.js
/*
To use in Home Assistant, configure card:
type: 'custom:example-card'
entities:
- switch.wemo_insight
- light.bed_light
- light.ceiling_lights
- light.kitchen_lights
@balloob
balloob / demo.js
Created Aug 1, 2017
Example using home-assistant-js-websocket with Node
View demo.js
const WebSocket = require('ws');
global.WebSocket = WebSocket;
const HAWS = require("home-assistant-js-websocket");
const getWsUrl = haUrl => `ws://${haUrl}/api/websocket`;
HAWS.createConnection(getWsUrl('localhost:8123')).then(conn => {
HAWS.subscribeEntities(conn, logEntities);
});
@balloob
balloob / example-panel.js
Last active Aug 31, 2020
Example Panel for Home Assistant
View example-panel.js
/*
Example panel.
Put this file in <config>/www/example-panel.js
In configuration.yaml:
panel_custom:
- name: example-panel
# url_path needs to be unique for each panel_custom config