Skip to content

Instantly share code, notes, and snippets.

@c-kick
c-kick / hnl_hass_package.yaml
Last active April 11, 2024 10:22
Blueprint for Home Asssistant that manages basic smart home states (home, sleep & activity)
#Blueprint by Klaas Leussink / hnldesign.nl (c) 2024 - Part of hass_package - version 2.11.4.24
# REQUIRES this package: https://gist.github.com/c-kick/fa17b4e3ec474f4169dd8fa1e59e5d49
blueprint:
name: Manage smart home basics
source_url: https://gist.github.com/c-kick/2d252ec6faca02ec84a9e4a3c2e34f4f
description: |
Blueprint for Home Asssistant that manages basic smart home states (home, sleep & activity). REQUIRES this package: https://gist.github.com/c-kick/fa17b4e3ec474f4169dd8fa1e59e5d49
domain: automation
input:
input_night_schedule:
@c-kick
c-kick / hnl_hass_package.yaml
Last active April 11, 2024 10:19
This package is a required part of the HNL HASS pabkage blueprint: https://gist.github.com/c-kick/2d252ec6faca02ec84a9e4a3c2e34f4f
# This package is a required part of the HNL HASS package blueprint: https://gist.github.com/c-kick/2d252ec6faca02ec84a9e4a3c2e34f4f
input_boolean:
# -------------------------------------------- Primary states
primary_state_home:
name: "Thuis"
icon: mdi:home-account
primary_state_sleep:
name: "Slapen"
icon: mdi:bed
@c-kick
c-kick / _hnldesign-extend-bs-utils.scss
Last active January 25, 2024 10:33
Extends Bootstrap (padding, margin, gap, etc.) utilities with css variables
//
// Extends Bootstrap utilities defined in map '$add_css_variables_to' with css variables
// containing their respective units. Also adds additional values,
// if specified as 'name: variable' pairs in '$add_values'
//
// example:
// $add_css_variables_to: (
// padding-x
// )
// $add_values: (
@c-kick
c-kick / appliance-status-monitor.yaml
Last active January 25, 2024 10:09
Appliance Status Monitor - Blueprint for Home Assistant - Forked from (v2.1.1) leofabri's appliance status monitor (https://github.com/leofabri/hassio_appliance-status-monitor) with a few added features: job_planned state, power/standby state indicator, job complete indicator. See description inside blueprint for instructions and added features.
blueprint:
name: Monitor the state of an appliance - modded by hnldesign
source_url: https://gist.github.com/c-kick/31ffbdd3520c65833577648c2b96b289
description: "`- Version: 0.0.5 -`\n\nThis automation can detect and monitor the
state of your appliances by observing their power consumption.\nThis automation
blueprint is universal and very versatile. You can use it with anything that consumes
energy: a washing machine, a dishwasher, your fridge, the TV, etc. I refer to
the appliance's operations with the generic word job. A job could be anything
(washing, rinsing...).\n\nYou can pair this project with other automations and
services. I designed it with flexibility in mind. For instance, if you want to
@c-kick
c-kick / hnl.mobileConsole.js
Last active January 14, 2024 18:24
NOTE: V2 Released! Seehttps://github.com/c-kick/mobileConsole hnl.mobileConsole.js - extends JavaScript's console to display a visual console inside the webpage. Very usefull for debugging JS on mobile devices with no real console. Info and demo: http://www.hnldesign.nl/work/code/mobileconsole-javascript-console-for-mobile-devices/
/*!
*
* NEW VERSION AT https://github.com/c-kick/mobileConsole
*
* hnl.mobileConsole - javascript mobile console - v1.3.8 - 04/01/2021
* Adds html console to webpage. Especially useful for debugging JS on mobile devices.
* Supports 'log', 'trace', 'info', 'warn', 'error', 'group', 'groupEnd', 'table', 'assert', 'clear'
* Inspired by code by Jakub Fiala (https://gist.github.com/jakubfiala/8fe3461ab6508f46003d)
* Licensed under the MIT license
*
@c-kick
c-kick / zha_ikea_tradfri_4button_remote_color.yaml
Last active January 6, 2024 09:30 — forked from orcema/zha_ikea_tradfri_4button_remote_color.yaml
blueprint zha_ikea_tradfri_4button_remote_color
#Blueprint by Klaas Leussink / hnldesign.nl (c) 2022
blueprint:
name: ZHA - IKEA TRADFRI - 4 Button Remote - Color Lights
source_url: https://gist.github.com/c-kick/299999c9512c4260fe6de1cd843efdde
description: This automation simulates the use of the IKEA TRADFRI remote control
connected through ZHA. Original blueprint by orcema, modified by hnldesign/c-kick,
- added brightness and color control inputs (for usage with IKEA TRADFRI bulbs)
- more fine-grained dimming
- color_temp changing
domain: automation
@c-kick
c-kick / hnl.isVisible.mjs
Last active November 27, 2023 11:05
Check if an element is visible
/** isVisible
*
* Determines whether an element is visible within the (specified, or Window) viewport. Executes the callback based
* on that result. The callback is called with three parameters:
* - visible: a boolean that's true if ANY pixels of the element are visible
* - fullyVisible: a boolean that's true if the ENTIRE element fits the viewport, and thus is wholly visible
* - the element's bounding box, including 'pageY' and 'pageX' which contain the element's position as relative to
* the whole document. Useful for scrolling into view,
*
* The viewport can either be omitted, specified partially or completely.
@c-kick
c-kick / debouncer.mjs
Last active October 27, 2023 13:24
Rate-limiter/debouncer module for JavaScript. See https://code.hnldesign.nl/demo/hnl.debounce.html
/**
*
* debounceThis ES6 module v1.4 (10-2023)
* Debounces/rate-limits the provided function (callback)
*
* Provides a way to debounce or rate-limit a function, which can be useful in scenarios where events may be
* triggered frequently and rapidly, such as scrolling or resizing the window.
*
* Example usage:
*
@c-kick
c-kick / hnl.stickyStuck
Last active June 23, 2023 13:06
adds class 'stuck' to elements that are stuck. Uses Bootstraps' `position-sticky` class as a selector.
const stickes = document.body.querySelectorAll('.position-sticky');
window.addEventListener('scroll', function(){
stickes.forEach(function(el){
let stuck = false;
const rect = el.getBoundingClientRect();
if (window.getComputedStyle(el).bottom == 'auto') {
stuck = rect.top === parseInt(window.getComputedStyle(el).top, 10);
} else if (window.getComputedStyle(el).top == 'auto') {
stuck = rect.height + rect.top < window.innerHeight;
@c-kick
c-kick / doubleClickHandler.js
Last active May 12, 2023 12:03
doubleClickHandler - handles double-click events on elements
/**
* Handles the click event to detect single or double clicks.
* @param {MouseEvent} event - The click event object.
*/
function doubleClickHandler(event) {
const target = event.target;
if (new Date().getTime() - (target._lastTouch || 0) > 500) {
// Not a double click
target._lastTouch = new Date().getTime();