Skip to content

Instantly share code, notes, and snippets.

View agdamsbo's full-sized avatar

Andreas Gammelgaard Damsbo agdamsbo

View GitHub Profile
@agdamsbo
agdamsbo / check.packages.r
Last active June 28, 2023 12:13 — forked from smithdanielle/check.packages.r
Check if multiple R packages are installed. Install them if they are not,then load them into the R session.
# check.packages function: install and load multiple R packages.
# Check to see if packages are installed. Install them if they are not, then load them into the R session.
# Supplied repo to be used with RScript in terminal
check.packages <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE, repos=structure(c(CRAN="http://cloud.r-project.org/")))
sapply(pkg, require, character.only = TRUE)
}
@agdamsbo
agdamsbo / ESPhome switch SDTH blueprint
Last active August 24, 2023 03:23
Blueprint with different multi click actions based on text_sensor in ESPhome switch. Controls single, double and triple click as well as hold.
blueprint:
name: ESPhome switch SDTH
description: |
Different actions for different clicks.
Based on text_sensor in ESPhome switch.
ESPhome configuration example: https://gist.github.com/agdamsbo/819c27a5b986c38327d4b19057cbfb6d
## Inspiration ##
ESPhome decoupled approach: https://www.esphome-devices.com/devices/Shelly-1/
@agdamsbo
agdamsbo / ude-syd-shelly1-3.yaml
Last active June 5, 2023 05:54
Configuration example of ESPhome configuration for Shelly 1 switch with multi click functionality.
substitutions:
devicename: ude-syd-shelly1-3
channel_1: Hoveddør og parkering
ip: 192.168.1.107
ssid: !secret wifi_iot_ssid
wifi_pass: !secret wifi_iot_password
password: !secret esphome_api_password
dns1: 1.1.1.1
dns2: 1.0.0.1