Skip to content

Instantly share code, notes, and snippets.

@paoloantinori
paoloantinori / 80-mount-usb-to-media-by-label.rules
Created December 21, 2020 16:19 — forked from eklex/80-mount-usb-to-media-by-label.rules
udev rule for Home Assistant OS (hassio) to mount USB drives into the Supervisor Media directory
#
# udev rule
# Mount USB drive to the media directory using the partition name as mount point
#
# Description:
# Created for Home Assistant OS, this rule mounts any USB drives
# into the Hassio media directory (/mnt/data/supervisor/media).
# When a USB drive is connected to the board, the rule creates one directory
# per partition under the media directory. The newly created partition is named
# as the partition name. If the partition does not have a name, then the following
@paoloantinori
paoloantinori / tempo_relativo.jinja2
Created June 5, 2021 08:38
Funzione helper da usarsi nei templates di Home Assistant per convertire le informazioni temporali relative dall'inglese all'italiano
{# Per testare basta copiare tutto questo nel tab Template dei Developer Tools#}
{# funzione helper per tradurre una data in tempo relativo #}
{%- macro trauduci_tempo(tempo) %}
{%- set testo = relative_time(tempo) %}
{{ relative_time(testo) | replace('seconds', 'secondi') | regex_replace('second\\b', 'secondo') | replace('minutes', 'minuti') | replace('minute', 'minuto') | replace('hours', 'ore') | replace('hour', 'ora') | replace('days', 'giorni')| replace('day', 'giorno') | replace('months', 'mesi') | replace('month', 'mese')}}
{%- endmacro %}
{# esempio di utilizzo #}
{{ trauduci_tempo(states.sensor.time.last_changed) }} fa.