Skip to content

Instantly share code, notes, and snippets.

View Gnzlt's full-sized avatar

Gonzalo Toledano Gnzlt

View GitHub Profile
@Gnzlt
Gnzlt / echo-show-5-home-assistant-kiosk.md
Last active October 23, 2026 06:31
Echo Show 5 2nd gen (LineageOS 18.1) as a presence-aware Home Assistant kiosk

Echo Show 5 (2nd gen, "cronos") as a Home Assistant wall/desk kiosk: screen follows presence, CPU and memory tuning

A field guide for an Echo Show 5 (2021) running unofficial LineageOS 18.1 with the Home Assistant Companion app, used as an always-on dashboard that is on only while someone is in the room. Everything below was tested on one unit; where something is untested it says so.

What you get:

  • Real screen-off when the room is empty, screen-on (dashboard in front, no lock screen) when someone is there, driven entirely from Home Assistant.
  • An optional notification sound, and an optional "peek" (wake for 2 minutes) for important events.
  • A re-runnable ADB script that applies the kiosk settings, trims the system and installs a boot file with CPU/memory tuning.
  • The hardware findings (no proximity sensor, no camera, the one sensor it has) so you don't repeat the investigation.
@Gnzlt
Gnzlt / dynamic-light.yaml
Last active September 17, 2025 07:32
Home Assistant Blueprint - Dynamic Light Brightness
blueprint:
name: "Dynamic Light Brightness (Lux Based)"
description: >
This blueprint dynamically adjusts a light's brightness to complement the ambient light levels detected by an illuminance (lux) sensor.
It maps a defined range of lux values (from a minimum to a maximum) to a corresponding brightness range (e.g., 10 lux → 10% brightness, 500 lux → 100% brightness). The brightness is calculated using linear interpolation, ensuring smooth transitions as the ambient light changes.
The automation is only active when the target light is already turned on.
**Key Features:**
@Gnzlt
Gnzlt / InpsectionPermissionState.kt
Last active September 17, 2023 22:25
Jetpack Compose extension function to show Previews when using permission checks
package com.example
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalInspectionMode
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.google.accompanist.permissions.PermissionState
import com.google.accompanist.permissions.PermissionStatus
/**
* Wrapper for [com.google.accompanist.permissions.rememberPermissionState] to grant permissions when in Inspection mode
@Gnzlt
Gnzlt / CameraPreview.kt
Last active August 21, 2023 22:18
Android Jetpack Compose Camera Preview Composable
@Composable
fun CameraPreview(
modifier: Modifier = Modifier,
scaleType: PreviewView.ScaleType = PreviewView.ScaleType.FILL_CENTER,
cameraSelector: CameraSelector = CameraSelector.DEFAULT_FRONT_CAMERA
) {
val lifecycleOwner = LocalLifecycleOwner.current
AndroidView(
modifier = modifier,
factory = { context ->
@Gnzlt
Gnzlt / upload_video.py
Created August 20, 2023 09:43
Python 3 script that uploads a YouTube video using the YouTube Data API
#!/usr/bin/python
import http.client
import httplib2
import os
import random
import sys
import time
from apiclient.discovery import build
@Gnzlt
Gnzlt / NfcUtils.kt
Created January 17, 2022 20:00
Android NFC MIFARE Classic utils
package com.example
import android.content.Context
import android.nfc.tech.MifareClassic
object NfcUtils {
fun Context.isMifareClassicCompatible(): Boolean =
packageManager.systemAvailableFeatures.any { it.name == "com.nxp.mifare" }
@Gnzlt
Gnzlt / NfcTagLifecycleObserver.kt
Created January 15, 2022 23:17
Android NFC Tag Lifecycle Observer
package com.example
import android.app.Activity
import android.nfc.NfcAdapter
import android.nfc.Tag
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
class NfcTagLifecycleObserver(
private val activity: Activity,
@Gnzlt
Gnzlt / HashCompositeDisposable.kt
Last active January 4, 2022 12:26
RxJava Disposable that can hold onto multiple other Disposables and only keeps the last Disposable added with the same key.
package com.example
import io.reactivex.rxjava3.disposables.Disposable
import io.reactivex.rxjava3.exceptions.CompositeException
import io.reactivex.rxjava3.exceptions.Exceptions
import io.reactivex.rxjava3.internal.util.ExceptionHelper
/**
* A disposable that can hold onto multiple other Disposables
* and only keeps the last Disposable added with the same key.
@Gnzlt
Gnzlt / SuffixTextInputEditText.kt
Last active March 8, 2021 10:03
TextInputEditText with support for non editable suffix.
package com.example
import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Rect
import android.graphics.Typeface
import android.text.TextPaint
import android.util.AttributeSet
import com.google.android.material.textfield.TextInputEditText
@Gnzlt
Gnzlt / YuvImageDataFetcher.kt
Last active September 26, 2020 10:22
Custom Glide ModelLoader for Yuv Image [YUV_420_888]
import android.graphics.ImageFormat
import android.graphics.Rect
import android.graphics.YuvImage
import android.media.Image
import com.bumptech.glide.Priority
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.data.DataFetcher
import java.io.ByteArrayOutputStream
import java.nio.ByteBuffer