Skip to content

Instantly share code, notes, and snippets.

@ayavilevich
ayavilevich / smoke.yaml
Created Oct 13, 2020
Home assistant configuration for integration with RF based smoke detectors. Full article is in my blog.
View smoke.yaml
binary_sensor:
- platform: mqtt
name: "Room1 Smoke Detector"
payload_on: "0x111111"
payload_off: "0x111111off"
device_class: smoke
state_topic: "tele/tasmota_rf/RESULT"
value_template: '{{ value_json.RfReceived.Data }}'
- platform: mqtt
name: "Room2 Smoke Detector"
@ayavilevich
ayavilevich / aws_ebs_leader.js
Created Feb 19, 2019
AWS Elastic Beanstalk "is leader instance" check for use with cron, etc (nodejs, async/await).
View aws_ebs_leader.js
// based on https://gist.github.com/tony-gutierrez/de5b304fd042f6140eb61a31d0ff92d5
async function isLeader() {
try {
// get APIs
var elasticbeanstalk = new AWS.ElasticBeanstalk();
var ec2 = new AWS.EC2();
var metadata = new AWS.MetadataService();
// get ec2 instance id
const request = new Promise( (resolve, reject) => { // MetadataService.request has no support for promise, make one ourselves
metadata.request('/latest/meta-data/instance-id', (err, InstanceId) => {