Template sensor creation

need some help with creation of template sensor, i want to retrieve the up time of my desktop using SNMP.

i created a sensor :

sensor:
  - platform: snmp
    name: PC Uptime
    host: 192.168.0.111
    baseoid: 1.3.6.1.2.1.1.3.0

the oid taken using this article :

Which output the entity below:

now i need help taking the math below and write it into the template sensor:

can some one help me with the creation ?

Use this as the value_template:

"{{ (float(states('sensor.pc_uptime')) / 8640000) | round(1) }}"

Change the value in round() to the number of decimal places you want to display.

1 Like

Thank you!, i managed thanks to your help retrieve from my desktop the correct data,
the desktop is really 3 days on! (Desktop OS 1903 )

the mini pc that i have is turned on more than 40 days, but for some reason it’s not working, maybe need to use different math ?

code below:

  - platform: template
    sensors:
      pc_uptimetest:
        friendly_name: "Desktop Uptime"
        unit_of_measurement: "Days"
        value_template: "{{ (float(states('sensor.pc_uptime')) / 8640000) | round(1) }}"
  - platform: template
    sensors:
      minipc_uptimetest:
        friendly_name: "Mini PC Uptime"
        unit_of_measurement: "Days"
        value_template: "{{ (float(states('sensor.mini_pc_uptime')) / 8640000) | round(1) }}"

system info from the machine, windows 10, build 1803:

any idea?

37472 / 8640000 = 0.004

0.004 rounded to one decimal place is 0.0

So you need to check what’s going on with the mini PC uptime sensor (not the template sensor). Not sure why it would report an incorrect value.

I found the correct oid , thank you!