Skip to content

Instantly share code, notes, and snippets.

View inakianduaga's full-sized avatar

Inaki Anduaga inakianduaga

View GitHub Profile
@inakianduaga
inakianduaga / huetap_native.yaml
Last active March 15, 2025 14:26
Update implementation
blueprint:
name: Philips Hue Tap Controller (Optimized)
description: Automate actions for each button on a Philips Hue Tap device.
domain: automation
input:
tap_device:
name: Philips Hue Tap Device
description: Select the Hue Tap device
selector:
device:
@inakianduaga
inakianduaga / link_multiple_devices.yaml
Last active February 15, 2025 11:49 — forked from aderusha/link_multiple_devices.yaml
Split conditions to handle color_mode properly
@inakianduaga
inakianduaga / hue-remote-dimmer-december-2021.yaml
Last active November 10, 2024 13:35 — forked from codycodes/hue-remote-dimmer-december-2021.yaml
Update to support brightness down properly
blueprint:
name: Hue Dimmer Remote Inaki Custom
description: |
(Dec 2021 Update) Using a Hue bridge with which a dimmer remote is paired, allows you to configure actions based on said Hue Dimmer Remote.
NOTE: tested with RWL020 and RWL022, but community says it also works with RWL021!
- Cover entity is optional
- Long off-press turns brightness to 1%
- Long On-press turn brightness up by 33%
domain: automation
source_url: https://gist.github.com/codycodes/f051781c35cfdfee15162ff680c9cbd8
@inakianduaga
inakianduaga / strictCustomEvent.ts
Created October 2, 2018 16:15
Typesafe CustomEvents on your Frontend - StrictCustomEvent proxy
export const strictCustomEvent = <
T extends keyof Omit<DocumentEventMap, defaultDocumentEventNames>,
D extends UnpackCustomEventPayload<DocumentEventMap[T]>
>(
name: T,
payload: Omit<CustomEventInit<D>, "detail"> & {
detail: D
}
): CustomEvent<D> => new CustomEvent(name, payload)
@inakianduaga
inakianduaga / lib.dom.d.ts
Last active October 4, 2018 06:33
Typesafe CustomEvents on your Frontend - Standard lib CustomEvent constructor
// https://github.com/Microsoft/TypeScript/blob/master/lib/lib.dom.d.ts#L3307
declare var CustomEvent: {
prototype: CustomEvent;
new <T>(typeArg: string, eventInitDict?: CustomEventInit<T>): CustomEvent<T>;
};
@inakianduaga
inakianduaga / globalAugmentationExample.ts
Created October 2, 2018 16:07
Typesafe CustomEvents on your Frontend - CustomEvent global augmentation example
export const ClassifiedListFilterUpdate = "CL_FILTER_UPDATE";
export type ClassifiedListFilterUpdate = {
searchUrls: {
/**
* Search url with legacy parameters
*/
legacy: string;
/**
* Search url with newer `mmm` parameters
*/
@inakianduaga
inakianduaga / lib.dom.d.ts
Last active October 4, 2018 06:33
Typesafe CustomEvents on your Frontend - standard library section
// lib.dom.d.ts section
// https://github.com/Microsoft/TypeScript/blob/master/lib/lib.dom.d.ts#L4450
addEventListener<K extends keyof DocumentEventMap>(
type: K,
listener: (this: Document, ev: DocumentEventMap[K]) => any,
options?: boolean | AddEventListenerOptions
): void;
@inakianduaga
inakianduaga / producingExample.ts
Created October 2, 2018 15:51
Typesafe CustomEvents on your Frontend - Production Example
// somewhere in another app...
import { ListPage, strictCustomEvent } from "@autoscout24/custom-events";
document.dispatchEvent(
strictCustomEvent(ListPage.ClassifiedListTotalCountUpdate, {
detail: {
totalCount: 42
}
})
);
@inakianduaga
inakianduaga / listeningExample.ts
Last active October 2, 2018 15:49
Typesafe CustomEvents on your Frontend - Listening Example
// somewhere in your app...
import { ListPage } from "@autoscout24/custom-events";
document.addEventListener(ListPage.ClassifiedListFilterUpdate, e =>
console.log(e.detail.searchUrls.standard)
);
@inakianduaga
inakianduaga / middleware.ts
Last active August 16, 2018 16:54
Redux for vanillaJS Medium.com article - Redux gallery middleware
import * as Redux from "redux";
import Config from "./config"; // some config
import { State } from "../../store/rootReducer";
import * as actions from "./actions";
import { listeners as domListeners, mutations as domMutations } from "./dom";
/**
* Middleware to schedule dom mutations based on redux actions / state changes
*/
export const middleware = (_: Config) => (