System Monitoring - How does yours look?

@cwhits what is the yaml code for locking the service on the right side of your card?

@ghvader
Allow me…
It is the toggle-lock-entity-row - GitHub - thomasloven/lovelace-toggle-lock-entity-row
Look at some of @thomasloven other cards, they are all excellent.

It’s a pleasure, I wish I could say it was my idea… I forget now who I got that from.

1 Like

Can you share the sensors as well :slight_smile:?
Also, where do you save the Rpi and HA uptime?

1 Like

@Yoinkz

#============
#=== Sensors
#============
sensor:

  #===========================================
  #=== Latest Sonoff Tasmota firmware version
  #===========================================
  - platform: command_line
    name: Tasmota Current Version
    command: "curl -s https://github.com/arendst/Sonoff-Tasmota/releases/latest | cut -d'\"' -f2 | rev | cut -d'/' -f1 | rev"
    scan_interval: 86400

  #==============================
  #=== Installed hass.io version
  #==============================
  - platform: version
    name: Installed Version
    source: local


  #================================
  #=== Latest Available HA Version
  #================================
  - platform: version
    name: Latest Available Version
    beta: false
    image: raspberrypi3
    source: hassio


  #=======================
  #=== Raspberry Pi Power
  #=======================
  - platform: rpi_power
    text_state: True


  #=============================================
  #=== Last boot time, Disk, memory & CPU usage
  #=============================================
  - platform: systemmonitor
    resources:
      - type: last_boot
      - type: disk_use_percent
        arg: /
      - type: memory_use_percent
      - type: processor_use

  
  #====================
  #=== CPU Temperature
  #====================
  - platform: command_line
    name: CPU Temp
    command: "cat /sys/class/thermal/thermal_zone0/temp"
    unit_of_measurement: "°C"
    value_template: '{{ value | multiply(0.001) | round(0) }}'


  #===================
  #=== System Up Time
  #===================
  - platform: uptime


  - platform: template
    sensors:

      #==========================
      #=== Home Assistant uptime
      #==========================
      ha_uptime:
        friendly_name: HA Uptime
        value_template: >
          {% if states('sensor.uptime') == '0.0' %} 
            Just restarted...
          {% else %}
            {% macro phrase(value, name) %}
            {%- set value = value | int %}
            {%- set end = 's' if value > 1 else '' %}
            {{- '{} {}{}'.format(value, name, end) if value | int > 0 else '' }}
            {%- endmacro %}
            
            {% set weeks = (states('sensor.uptime') | int / 7) | int %}
            {% set days = (states('sensor.uptime') | int) - (weeks * 7) %}
            {% set hours = (states('sensor.uptime') | float - states('sensor.uptime') | int) * 24 %}
            {% set minutes = (hours - hours | int) * 60 %}

            {{ [ phrase(weeks, 'week'), phrase(days, 'day'), phrase(hours, 'hr'), phrase(minutes, 'min') ] | select('!=','') | list | join(', ') }}
          {% endif %}


      #=========================================
      #=== Raspberry Pi last boot date and time
      #=========================================
      last_boot_date_time:
        friendly_name: Last Boot
        value_template: >
          {% set date = as_timestamp(states('sensor.last_boot')) | timestamp_custom('%d') %}
          {% set date = '{:01}'.format(date | int) %}
          {% if date in ('1', '21', '31') %}
            {% set date = date ~ 'st' %}
          {% elif date in ('2', '22') %}
            {% set date = date ~ 'nd' %}
          {% elif date in ('3', '23') %}
            {% set date = date ~ 'rd' %}
          {% else %}
            {% set date = date ~ 'th' %}
          {% endif %}

          {{ as_timestamp(states('sensor.last_boot')) | timestamp_custom('%H:%M on %a') }} {{ date }} {{ as_timestamp(states('sensor.last_boot')) | timestamp_custom('%b %Y') }}


      #=========================
      #=== Raspberry Pi Up Time
      #=========================
      rpi_uptime:
        friendly_name: RPi Uptime
        entity_id: sensor.time
        value_template: >
          {% set up_time = as_timestamp(now()) - as_timestamp(states('sensor.last_boot')) %}

          {% set minutes = (up_time // 60) | int %}
          {% set hours = (minutes // 60) %}
          {% set days = (hours // 24) %}
          {% set weeks = (days // 7) %}

          {% set minutes = (minutes % 60) %}
          {% set hours =  (hours % 24) %}
          {% set days = (days % 7) %}

          {% macro phrase(value, name) %}
                    {%- set value = value %}
                    {%- set end = 's' if value > 1 else '' %}
                    {{- '{} {}{}'.format(value, name, end) if value | int > 0 else '' }}
          {%- endmacro %}
                    
          {% set text = [ phrase(weeks, 'week'), phrase(days, 'day'), phrase(hours, 'hr'), phrase(minutes, 'min') ] | select('!=','') | list | join(', ') %}
          {% set last_comma = text.rfind(',') %}
          {% if last_comma != -1 %}
            {% set text = text[:last_comma] + ' and' + text[last_comma + 1:] %}
          {% endif %}
          
          {{ text }}
18 Likes

How did you do your component count? Thats a great idea

EDIT: A much better way, courtesy of @petro is further down this thread.
Here --> System Monitoring - How does your look?


#====================================
#=== Home Assistant Component counts
#====================================
sensor:
  - platform: template
    sensors:

    #----- Count Automations
      count_automations:
        entity_id: sensor.date
        value_template: >
          {%- set domains = ['automation'] -%}
          {%- for domain in domains -%}
            {%- for item in states[domain] -%}
              {% if loop.first %}
                {{loop.length}}
              {% endif %}
            {%- endfor -%}
          {%- endfor -%}

    #----- Count Scripts
      count_scripts:
        entity_id: sensor.date
        value_template: >
          {%- set domains = ['script'] -%}
          {%- for domain in domains -%}
            {%- for item in states[domain] -%}
              {% if loop.first %}
                {{loop.length}}
              {% endif %}
            {%- endfor -%}
          {%- endfor -%}

    #----- Count Device Trackers
      count_device_trackers:
        entity_id: sensor.date
        value_template: >
          {%- set domains = ['device_tracker'] -%}
          {%- for domain in domains -%}
            {%- for item in states[domain] -%}
              {% if loop.first %}
                {{loop.length}}
              {% endif %}
            {%- endfor -%}
          {%- endfor -%}        

    #----- Count Binary Sensors
      count_binary_sensors:
        entity_id: sensor.date
        value_template: >
          {%- set domains = ['binary_sensor'] -%}
          {%- for domain in domains -%}
            {%- for item in states[domain] -%}
              {% if loop.first %}
                {{loop.length}}
              {% endif %}
            {%- endfor -%}
          {%- endfor -%}

    #----- Count Sensors
      count_sensors:
        entity_id: sensor.date
        value_template: >
          {%- set domains = ['sensor'] -%}
          {%- for domain in domains -%}
            {%- for item in states[domain] -%}
              {% if loop.first %}
                {{loop.length}}
              {% endif %}
            {%- endfor -%}
          {%- endfor -%}

    #----- Count Switches
      count_switches:
        entity_id: sensor.date
        value_template: >
          {%- set domains = ['switch'] -%}
          {%- for domain in domains -%}
            {%- for item in states[domain] -%}
              {% if loop.first %}
                {{loop.length}}
              {% endif %}
            {%- endfor -%}
          {%- endfor -%}

    #----- Count Zones
      count_zones:
        entity_id: sensor.date
        value_template: >
          {%- set domains = ['zone'] -%}
          {%- for domain in domains -%}
            {%- for item in states[domain] -%}
              {% if loop.first %}
                {{loop.length}}
              {% endif %}
            {%- endfor -%}
          {%- endfor -%}

    #----- Input Booleans
      count_input_booleans:
        entity_id: sensor.date
        value_template: >
          {%- set domains = ['input_boolean'] -%}
          {%- for domain in domains -%}
            {%- for item in states[domain] -%}
              {% if loop.first %}
                {{loop.length}}
              {% endif %}
            {%- endfor -%}
          {%- endfor -%}

    #----- Input Numbers
      count_input_numbers:
        entity_id: sensor.date
        value_template: >
          {%- set domains = ['input_number'] -%}
          {%- for domain in domains -%}
            {%- for item in states[domain] -%}
              {% if loop.first %}
                {{loop.length}}
              {% endif %}
            {%- endfor -%}
          {%- endfor -%}

    #----- Input Texts
      count_input_texts:
        entity_id: sensor.date
        value_template: >
          {%- set domains = ['input_text'] -%}
          {%- for domain in domains -%}
            {%- for item in states[domain] -%}
              {% if loop.first %}
                {{loop.length}}
              {% endif %}
            {%- endfor -%}
          {%- endfor -%}

    #----- Input Selects
      count_input_selects:
        entity_id: sensor.date
        value_template: >
          {%- set domains = ['input_select'] -%}
          {%- for domain in domains -%}
            {%- for item in states[domain] -%}
              {% if loop.first %}
                {{loop.length}}
              {% endif %}
            {%- endfor -%}
          {%- endfor -%}

    #----- Input Date Times
      count_input_datetimes:
        entity_id: sensor.date
        value_template: >
          {%- set domains = ['input_datetime'] -%}
          {%- for domain in domains -%}
            {%- for item in states[domain] -%}
              {% if loop.first %}
                {{loop.length}}
              {% endif %}
            {%- endfor -%}
          {%- endfor -%}
17 Likes

Your memory usage if quite low compared to mine, are you using the free command to get memory usage or some other way?

@klogg

Thanks - much appreciated !

1 Like

No, not as far as I know! I am running hassio on an RPi3 so even if I new Linux I wouldn’t be able to run any native commands.

Gives me this error:

Platform not found: sensor.rpi_power

you’ll have to install the component manually

4 Likes

:wink: Thanks!

What about your icons (customize.yaml)?

I think they are all set in Lovelace… which ones are you missing?

Take a look:

image

But maybe the icons actually suits pretty well.

hello I tried to implement this sensor unfortunately I get a felhlermeldung. can you help me maybe? “Platform not found: sensor.rpi_power”

@Yoinkz Look in my Lovelace code posted higher up. For example

          - entity: sensor.installed_version
            name: Hassio Installed Version
            icon: mdi:home-assistant
1 Like

@Yoda Did you follow the install instructions properly?
Following the ‘Great Migration’ things changed a bit.

 rename it to sensor.py 

Also it does say something about getting an error the first time after installing it. Maybe restart HA again?

1 Like

@klogg

Are you still using the “old” lovelace or do you edit your ui in the web-editor?

I still maintain my own yaml file for Lovelace, yes.