Hi,
it is possible to add to the synologydsm sensor two new features:
- last boot
- uptime
Thank you
Hi,
it is possible to add to the synologydsm sensor two new features:
Thank you
This would be quite nice and hopefully not too hard to add
You can use SNMP to achive uptime. I use this code.
# synology.yaml
# Synology NAS
- platform: synologydsm
host: 192.168.1.20
username: !secret secret_nas1_username
password: !secret secret_nas1_password
monitored_conditions:
- cpu_total_load
- memory_real_usage
- network_up
- network_down
- volume_percentage_used
- volume_status
- disk_status
- platform: snmp
host: 192.168.1.20
community: public
name: Synology Uptime
baseoid: 1.3.6.1.2.1.25.1.1.0
value_template: >
{%- set time = value | int // 100 %}
{%- set minutes = ((time % 3600) // 60) %}
{%- set minutes = '{}min'.format(minutes) if minutes > 0 else '' %}
{%- set hours = ((time % 86400) // 3600) %}
{%- set hours = '{}hr '.format(hours) if hours > 0 else '' %}
{%- set days = (time // 86400) %}
{%- set days = '{}d '.format(days) if days > 0 else '' %}
{{ 'Less than 1 min' if time < 60 else days + hours + minutes }}
Well I can try it but how can I find baseoid for my NAS?
One way ist to use snmpwalk.
I use this string to my NAS.
snmpwalk -v1 -c public 192.168.1.20 | more
For more info, please see this URL https://www.comparitech.com/net-admin/snmpwalk-examples-windows-linux/
If someone still looking for uptime. I enabled last_boot entity which returns timestamp of last boot. Then I created template sensor like that:
sensor:
- platform: template
sensors:
synology_uptime_seconds:
value_template: "{{(as_timestamp(now()) - as_timestamp(states('sensor.YOUR_NAS_last_boot')))|int }}"
friendly_name: 'Synology Uptime Seconds'
icon_template: mdi:clock-outline
unit_of_measurement: "s"
which will give you uptime in seconds since last boot.
Hope it helps someone.