Advertisement
Guest User

Untitled

a guest
Jan 17th, 2022
493
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None
  1. ##System Monitor
  2. - platform: systemmonitor
  3. resources:
  4. - type: disk_use_percent
  5. - type: disk_use
  6. - type: disk_free
  7. - type: memory_use_percent
  8. - type: memory_free
  9. - type: memory_use
  10. - type: swap_use
  11. - type: processor_use
  12. - type: processor_temperature
  13. - platform: version
  14. source: local
  15. name: HomeAssistant Version
  16. - platform: uptime
  17. name: "uptime"
  18. - platform: template
  19. sensors:
  20. disk_total:
  21. value_template: "{{ ( states('sensor.disk_use')|float + states('sensor.disk_free')|float )| round (1) }}"
  22. homeassistant_uptime:
  23. friendly_name: "Home Assistant uptime"
  24. value_template: >-
  25. {% set up_time = as_timestamp(now()) - as_timestamp(states('sensor.uptime')) %}
  26.  
  27. {% if up_time == 0 %}
  28. Just restarted...
  29. {% else %}
  30. {% set minutes = (up_time // 60) | int %}
  31. {% set hours = (minutes // 60) %}
  32. {% set days = (hours // 24) %}
  33. {% set weeks = (days // 7) %}
  34.  
  35. {% set minutes = (minutes % 60) %}
  36. {% set hours = (hours % 24) %}
  37. {% set days = (days % 7) %}
  38.  
  39. {% macro phrase(value, name) %}
  40. {%- set value = value %}
  41. {%- set end = 's' if value > 1 else '' %}
  42. {{- '{} {}{}'.format(value, name, end) if value | int > 0 else '' }}
  43. {%- endmacro %}
  44.  
  45. {% set text = [ phrase(weeks, 'week'), phrase(days, 'day'), phrase(hours, 'hr'), phrase(minutes, 'min') ] | select('!=','') | list | join(', ') %}
  46. {% set last_comma = text.rfind(',') %}
  47. {% if last_comma != -1 %}
  48. {% set text = text[:last_comma] + ' and' + text[last_comma + 1:] %}
  49. {% endif %}
  50.  
  51. {{ text }}
  52.  
  53. {% endif %}
Advertisement
RAW Paste Data Copied
Advertisement