Advertisement
dykandDK

HA - Local date and time template sensor and card example

Oct 10th, 2020
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.56 KB | None | 0 0
  1. #################################################################
  2. # Sections below should be added to config.yaml file
  3. #################################################################
  4.  
  5. #----------------------------------------------------------
  6. # Local Date and time
  7. #----------------------------------------------------------
  8. sensor:
  9.   - platform: time_date
  10.     display_options:
  11.      - "time"
  12.       - "date"
  13.       - "date_time"
  14.       - "time_date"
  15.       - "time_utc"
  16.     scan_interval: 55 #once every 55 second
  17.  
  18.   - platform: template
  19.     sensors:
  20.      #Format time in local format
  21.       local_time:
  22.         value_template: "{{states('sensor.time') and as_timestamp(now()) | timestamp_custom('%H:%M')}}"
  23.       #Format date in local format
  24.       local_date:
  25.         value_template: "{{ states('sensor.date') and as_timestamp(now()) | timestamp_custom('%a %d.%m.%y') | replace('Mon','Man') | replace('Tue','Tir') | replace('Wed','Ons') | replace('Thu','Tor') | replace('Fri','Fre') | replace('Sat','Lør') | replace('Sun','Søn') }}"
  26.  
  27. #----------------------------------------------------------
  28. # Limit log entries
  29. # (e.g do not store history for date/time sensors)
  30. #----------------------------------------------------------
  31. recorder:
  32.   exclude:
  33.     entities:
  34.      - sensor.date
  35.       - sensor.time
  36.       - sensor.local_time
  37.       - sensor.date_time
  38.       - sensor.time
  39.       - sensor.time_date
  40.       - sensor.time_utc
  41.  
  42. #################################################################
  43. # Below must be added to your Lovelace file
  44. #################################################################
  45.  
  46.         #---------------------------------------------------------------
  47.         # Date and time
  48.         #---------------------------------------------------------------
  49.         - type: picture-elements
  50.           state_filter:
  51.            - null
  52.           image: /local/assets/blank.png
  53.           aspect_ratio: 14%
  54.           elements:
  55.             - type: state-label
  56.               entity: sensor.local_time
  57.               style:
  58.                 top: 50%
  59.                 left: 20%
  60.                 #height: 100px
  61.                 #width: 2.5%
  62.                 font-size: 2.8em
  63.                 color: rgba(202,217,235,1)
  64.             - type: state-label
  65.               entity: sensor.local_date
  66.               style:
  67.                 top: 50%
  68.                 left: 70%
  69.                 #width: 300px
  70.                 text-align: right
  71.                 font-size: 1.5em
  72.                 text-transform: uppercase
  73.                 color: rgba(202,217,235,.75)
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement