Format last_boot

I would like to format the last_boot sensor to display just date, without time.
How could I do this?
Here is my corresponding part of my sensor.yaml:

####################################################
# Raspberry PI system Monitoring                   #
####################################################
  - platform: systemmonitor
    resources:
      - type: processor_use
      - type: memory_use_percent
      - type: memory_free
      - type: disk_use_percent
        arg: /home
      - type: disk_free
        arg: /home

  - platform: systemmonitor
    resources:
      - type: last_boot

#  - platform: cpuspeed      #  Does not show anything?!

  - platform: command_line
    name: CPU Temperature
    command: "cat /sys/class/thermal/thermal_zone0/temp"
    # If errors occur, remove degree symbol below
    unit_of_measurement: "Ā°C"
    value_template: '{{ value | multiply(0.001) | round(1) }}'
1 Like

Use a template sensor.

- platform: template
  sensors:
    date_last_boot:
    friendly_name: "Last Boot"
    value_template: '{{ states.sensor.last_boot.state.split("T")[0] }}'
1 Like

In customize.yaml:

sensor.last_boot:
  friendly_name: Last Boot
  device_class: timestamp
  icon: mdi:clock

Then in lovelace:

              - entity: sensor.last_boot
                format: datetime

The supported formats are : relative, total, date, time, datetime so in your case use date

2 Likes

Iā€™m not with lovelace yet :thinking:

I need to have the normal last_boot sensor, too. Otherwise the nice one shows unknown?

  - platform: systemmonitor
    resources:
      - type: last_boot
        #hidden: true
      
  - platform: template
    sensors:
      date_last_boot:
        friendly_name: "Nice last boot"
        value_template: '{{ states.sensor.last_boot.state.split("T")[0] }}'

And even just setting hidden to true, I get an unknown in the nice one :roll_eyes:

Not sure, it works on my system

Template sensor:
sensor

front end display:
last_boot

systemmonitor:
system

Looks niceā€¦ Is there a trick to have the sensors in a row and not in single lines?

Works for me, too. BUT: Additionally I have the Last Boot Sensor (circle in the row with all sensors not grouped).
Screenshot

Iā€™m using lovelace as my frontend. Iā€™m not doing all the crazy things that you see people doing. Mine still looks like stock with the exception of a few groups that are grouped horizontally like above.

I have to ask, how did you find the supported formats ā€œrelative, total, date, time, datetimeā€? I looked into the component on github and didnt find anything.

I found it documented in a PR at some point. Its to do with the device_class

1 Like

Thank you. I appreciate you sharing your knowledge here. Read your name in the forums so often and you helped me with many of my problems.

1 Like

I have just tried to do the same, but it still shows like this:

image

image

from customize.yaml:

sensor.last_boot:
  friendly_name: Last Boot
  device_class: timestamp
  icon: mdi:clock

and my card:

      - type: glance
        title: Pi system
        columns: 5
        entities:
          - entity: sensor.cpu_temp
            name: 
          - entity: sensor.disk_use_percent
            name: 
          - entity: sensor.memory_use_pimb
            name: 
          - entity: sensor.memory_use_percent
            name: 
          - entity: sensor.processor_use
            name: 
          - entity: sensor.last_boot
            format: datetime
            name:   

surely if it knows last boot was 12 mins ago it shouldnt show 6/3/2020?

for me it does not work with this configuration

- platform: systemmonitor
  resources:
     - type: last_boot
       hidden: true

is giving me such an error: Invalid config for [sensor.systemmonitor]: [hidden] is an invalid option for [sensor.systemmonitor]. Check: sensor.systemmonitor->resources->7->hidden. (See ?, line ?).

Delete this, hidden is not a valid option.