Advertisement
fablav

sensore pretty_date

Sep 8th, 2024
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 0.86 KB | Software | 0 0
  1. # Sensori
  2. sensor:
  3.   - platform: template
  4.     sensors:
  5.       pretty_date:
  6.         friendly_name: Data di oggi
  7.         value_template: >-
  8.           {% set today = states("sensor.date") %}
  9.           {% set arr_week_days = ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato"] %}
  10.           {% set arr_months = ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"] %}
  11.           {% set week_day = as_timestamp(today) | timestamp_custom('%w') | int %}
  12.           {% set day = as_timestamp(today) | timestamp_custom('%d') %}
  13.           {% set month = as_timestamp(today) | timestamp_custom('%m') | int %}
  14.           {% set year = as_timestamp(today) | timestamp_custom('%Y') | int %}
  15.           {{ arr_week_days[week_day] }}, {{ day }} {{ arr_months[month-1] }} {{ year }}
  16.  
Tags: ha
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement