Skip to content

Instantly share code, notes, and snippets.

@thomasloven
thomasloven / fixdailylinks.js
Last active April 25, 2024 08:59
Obsidian.md templater script to update the link chain of Daily Notes
@thomasloven
thomasloven / fix_output_filenames.py
Last active April 12, 2024 11:25
Shorten PrusaSlicer output filenames for all default printers
""" Shortens output filenames for all printers in prusa config folder.
Will turn filename into: {input_filename_base}_{nozzle_size}_{printing_filament_types}_{print_time}.gcode
Place this file in your PrusaSlicer config folder (Help->Show Configuration Folder) and run it with python.
Make a backup first.
/ Thomas Lovén 2024
"""
import glob
import configparser
@thomasloven
thomasloven / customelement-test.ts
Last active August 15, 2023 06:09
How to use ha elements when using ScopedRegistry
import { LitElement, html } from "lit";
import { customElement, property } from "lit/decorators.js";
import { ScopedRegistryHost } from "@lit-labs/scoped-registry-mixin";
@customElement("customelement-test")
class CustomElementTest extends ScopedRegistryHost(LitElement) {
@property() hass;
static elementDefinitions = {
"ha-card": customElements.get("ha-card"), // This works because ha-card is ALWAYS loaded before custom cards (for now)
@thomasloven
thomasloven / valetudo_room_clean.yaml
Last active February 9, 2021 15:28
Valetudo room cleaning
blueprint:
name: Xiaomi vacuum- clean rooms
description: |
## Clean the specified rooms
This works for Xiaomi vacuum cleaners - with Valetudo RE - which have room recognition and cleaning.
Vacuum specific rooms based on the state of a number of [Toggle Helper entities](/config/helpers) (`input_boolean`).
**This automation does not have any own triggers, but must be triggered manually or by an
`automation.trigger` service call.**
@thomasloven
thomasloven / xiaomi_room_clean.yaml
Last active January 29, 2023 23:11
Make Xiaomi vacuum cleaner vacuum certain rooms by input_boolean state. Requires Home Assistant 2021.2.0 or later.
blueprint:
name: Xiaomi vacuum- clean rooms
description: |
## Clean the specified rooms
This works for Xiaomi vacuum cleaners which have room recognition and cleaning.
Vacuum specific rooms based on the state of a number of [Toggle Helper entities](/config/helpers) (`input_boolean`).
**This automation does not have any own triggers, but must be triggered manually or by an
`automation.trigger` service call.**
alias: CTRL - Radiokub
description: ''
trigger:
- device_id: df4038b233b4449f8b17b5b1925927ba
domain: deconz
platform: device
type: remote_moved_any_side
subtype: ''
- device_id: df4038b233b4449f8b17b5b1925927ba
domain: deconz
alias: Aurora Borealis
sequence:
- variables:
light: {{light | default(light.default_lamp) }}
start_time: '{{ now() | as_timestamp }}'
hue_lim:
- 120
- 290
wavelength: 30
amplitude: '{{(hue_lim[1] - hue_lim[0])/2}}'
@thomasloven
thomasloven / random_color.yaml
Created September 28, 2020 12:32
Turn light on to random color name
- variables:
color: >-
{{["aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
"bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
"burlywood", "cadetblue", "chartreuse", "chocolate", "coral",
"cornflowerblue", "cornsilk", "crimson", "cyan", "darkblue", "darkcyan",
"darkgoldenrod", "darkgray", "darkgreen", "darkgrey", "darkkhaki",
"darkmagenta", "darkolivegreen", "darkorange", "darkorchid", "darkred",
"darksalmon", "darkseagreen", "darkslateblue", "darkslategray",
"darkslategrey", "darkturquoise", "darkviolet", "deeppink", "deepskyblue",
@thomasloven
thomasloven / clean_rooms.py
Last active June 30, 2020 15:09
Select rooms to clean with xiaomi
# In <config>/python_scripts/
vacuum = "vacuum.xiaomi_vacuum_cleaner"
zones = {
"hallen": 24,
"koket": 22,
"vardagsrummet": 23,
"sovrum": 17,
"kontoret": 16,
"barnrum": 1,
}
homeassistant:
customize:
package.node_anchors:
coffee_switch: &cfe_switch switch.kaffebryggare
coffee_remote: &cfe_remote switch.kaffekontroll
common: &common
package: 'devices/coffeemaker'
input_boolean.cfe_on: