Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SRM sensor #1

Open
i00 opened this issue May 6, 2020 · 71 comments
Open

SRM sensor #1

i00 opened this issue May 6, 2020 · 71 comments

Comments

@i00
Copy link
Owner

i00 commented May 6, 2020

Chatter for further information in:
home-assistant/core#31523 (comment)

@ghost
Copy link

ghost commented May 6, 2020

Can you write us how step by step add this integration and show code for card as you show on screen ?

@i00
Copy link
Owner Author

i00 commented May 6, 2020

@Pepeel Sure I will do this in two separate posts below for ease
image

@ghost
Copy link

ghost commented May 6, 2020

Ok i am waitng...
Thanks

ANd you are planing to implement SRM integration to official Home Assistant ? As official integration ?

@i00
Copy link
Owner Author

i00 commented May 6, 2020

Left Side

  • Setup your config.xaml with the synology_srm device tracker similar to below:
device_tracker:
  - platform: synology_srm
    host: SynologyRouter.local
    password: !secret SynologyRouter
    consider_home: 60 # default 180
    new_device_defaults:
      track_new_devices: true
  • Extract resources.zip to your config\www folder
  • In HA go to "Configuration > Lovelace Dashboards >Resources"
  • Add in the following resources as javascript modules:
    • /local/resources/auto-entities.js?v=16
    • /local/resources/card-mod.js?v=13
    • /local/resources/multiple-entity-row.js?v=3.1.1
  • Add a manual Lovelace card with the following content:
card:
  show_header_toggle: false
  title: Devices
  type: entities
filter:
  include:
    - attributes:
        scanner: SynologySrmDeviceScanner
      entity_id: device_tracker.*
      options:
        entities:
          - attribute: mac
          - attribute: ip_addr
          - icon: 'mdi:ethernet'
          - icon: 'mdi:wifi-strength-1'
          - icon: 'mdi:wifi-strength-2'
          - icon: 'mdi:wifi-strength-4'
          - icon: 'mdi:gamepad-variant-outline'
          - icon: 'mdi:cellphone-android'
          - icon: 'mdi:television'
          - icon: 'mdi:dlna'
          - icon: 'mdi:desktop-tower'
          - icon: 'mdi:nas'
          - icon: 'mdi:laptop-chromebook'
          - icon: 'mdi:tablet-android'
          - icon: 'mdi:cctv'
          - icon: 'mdi:printer'
          - icon: 'mdi:router-wireless'
        icon: 'mdi:devices'
        secondary_info:
          attribute: band
        show_state: false
        style: >
          {% set lMAC = 1 %} {% set lIP = 2 %} {% set iEthernet = 3 %} {% set
          iWiFiBad = 4 %} {% set iWiFiOK = 5 %} {% set iWiFiGood = 6 %} {% set
          iGame = 7 %} {% set iPhone = 8 %} {% set iTV = 9 %} {% set iDLNA = 10
          %} {% set iDesktop = 11 %} {% set iNAS = 12 %} {% set iLaptop = 13 %}
          {% set iTablet = 14 %} {% set iCamera = 15 %} {% set iPrinter = 16 %}
          {% set iRouter = 17 %}
          div.entity:nth-child({{lMAC}}),div.entity:nth-child({{lIP}}) {
            margin-right:0;
          } div.entity:nth-child({% if state_attr(config.entity, 'ip_addr') ==
          '' %}{{lIP}}{% else %}{{lMAC}}{% endif %}) {
            display: none !important;
            visibility: hidden !important;
            position: absolute !important;
          } .secondary {
            padding-left:16px;
          } {% if state_attr(config.entity, 'is_wireless') == false %}
          .secondary {
            visibility: hidden;
          } .secondary:before {
            content: 'Ethernet';
            visibility: visible;
          } {% else %} .secondary:after {
            content: ' (Level {% if state_attr(config.entity, 'mesh_node_id') == 0 %}1{% elif state_attr(config.entity, 'mesh_node_id') == 4 %}3{% elif state_attr(config.entity, 'mesh_node_id') == 3 %}4{% else %}?{% endif %})';
          } {% endif %}


          div.entity:nth-child({{iEthernet}}),div.entity:nth-child({{iWiFiBad}}),div.entity:nth-child({{iWiFiOK}}),div.entity:nth-child({{iWiFiGood}})
          {
            --mdc-icon-size: 16px;
            position: absolute;
            top: 8px;
            left: 50px;
            visibility: hidden;
          } div.entity:nth-child({% if state_attr(config.entity, 'is_wireless')
          == false %}{{iEthernet}}{% elif state_attr(config.entity,
          'rate_quality') == 'low' %}{{iWiFiBad}}{% elif
          state_attr(config.entity, 'rate_quality') == 'middle' %}{{iWiFiOK}}{%
          elif state_attr(config.entity, 'rate_quality') == 'high'
          %}{{iWiFiGood}}{% endif %}) {
              visibility: visible;
          } :host>state-badge {
            {% if state_attr(config.entity, 'dev_type') != 'others' and state_attr(config.entity, 'dev_type') != 'default' %}
              visibility: hidden;
            {% endif %}
          } div.entity:nth-child(n+{{iGame}}{# << This is the first icon for the
          device type #}) {
            position: absolute;
            top: 0px;
            left: 8px;
            visibility: hidden;
          } div.entity:nth-child({% if state_attr(config.entity, 'dev_type') ==
          'gamebox' %}{{iGame}}{% elif state_attr(config.entity, 'dev_type') ==
          'phone' %}{{iPhone}}{% elif state_attr(config.entity, 'dev_type') ==
          'tv' %}{{iTV}}{% elif state_attr(config.entity, 'dev_type') == 'dlna'
          %}{{iDLNA}}{% elif state_attr(config.entity, 'dev_type') == 'computer'
          %}{{iDesktop}}{% elif state_attr(config.entity, 'dev_type') == 'nas'
          %}{{iNAS}}{% elif state_attr(config.entity, 'dev_type') == 'notebook'
          %}{{iLaptop}}{% elif state_attr(config.entity, 'dev_type') == 'tablet'
          %}{{iTablet}}{% elif state_attr(config.entity, 'dev_type') == 'ipcam'
          %}{{iCamera}}{% elif state_attr(config.entity, 'dev_type') ==
          'printer' %}{{iPrinter}}{% elif state_attr(config.entity, 'dev_type')
          == 'router' %}{{iRouter}}{% endif %}) {
              visibility: visible;
          }
        type: 'custom:multiple-entity-row'
      state: home
sort:
  ignore_case: true
  method: name
type: 'custom:auto-entities'
  • Note the (Level x) is what I call my mesh nodes - the lovelace xaml will need to be changed accordingly to suit your needs

@i00
Copy link
Owner Author

i00 commented May 6, 2020

ANd you are planing to implement SRM integration to official Home Assistant ? As official integration ?

Yes ... that is why there is a pull request for it ... it was ready months ago ... but in the meantime they decided to change their policy; which now prevents them from merging it ... I have holidays in a little over a month; so will try to update it then

@i00
Copy link
Owner Author

i00 commented May 6, 2020

Right Side

  • First of all extract synology_srm_router.zip to your config\custom_components folder (make sure you use this version ... I have updated it to work with the latest version of HA)
  • setup the sensors below in your config like follows for router info:
binary_sensor:
  - platform: ping
    host: 8.8.8.8
    name: Online
    count: 1
    scan_interval: 300
sensor:
  - platform: synology_srm_router
    host: SynologyRouter.local
    password: !secret SynologyRouter
    monitored_conditions:
      - core.list_ddns_extip
      - core.get_system_utilization
      - core.list_ddns_record
  - platform: scrape
    resource: https://www.whoismyisp.org
    select: ".isp"
    name: 'Internet Provider'
    scan_interval: 60 #1 mins
  - platform: template
    sensors:
      wan_download:
        value_template: "{% set i = namespace() %}{% set i.i = 0 %}{% for item in states.sensor.synology_srm.attributes.core_get_system_utilization.network if item.device|regex_match('^(usbnet|ppp)', ignorecase=true) %}{% set i.i = i.i + item.rx %}{% endfor %}{{ ((i.i / 1024 / 1024) * 8)|round(2) }}"
        friendly_name: Download
        unit_of_measurement: Mbit/s
        icon_template: 'mdi:download'
      wan_upload:
        value_template: "{% set i = namespace() %}{% set i.i = 0 %}{% for item in states.sensor.synology_srm.attributes.core_get_system_utilization.network if item.device|regex_match('^(usbnet|ppp)', ignorecase=true) %}{% set i.i = i.i + item.tx %}{% endfor %}{{ ((i.i / 1024 / 1024) * 8)|round(2) }}"
        friendly_name: Upload
        unit_of_measurement: Mbit/s
        icon_template: 'mdi:upload'
  • Extract resources.zip to your config\www folder (be aware this contains different resources to the left side; some components are the same; so you can either replace or skip the conflicts)
  • In HA go to "Configuration > Lovelace Dashboards >Resources"
  • Add in the following resources as javascript modules (skip any that you may have added in left side in italic):
    • /local/resources/card-mod.js?v=13
    • /local/resources/html-template-card.js?v=1.0.2
    • /local/resources/mini-graph-card-bundle.js?v=0.9.3
    • /local/resources/multiple-entity-row.js?v=3.1.1
    • /local/resources/template-entity-row.js?v=1.1.0
    • /local/resources/vertical-stack-in-card.js?v=0.1.3
  • Add a manual Lovelace card with the following content:
cards:
  - entities:
      - entity: binary_sensor.online
        icon: 'mdi:web'
        name: Status
        type: 'custom:multiple-entity-row'
      - entity: sensor.internet_provider
        icon: 'mdi:web'
        name: Provider
      - entity: sensor.pi_hole_ads_percentage_blocked_today
        name: Adverts Blocked (Last 24 Hours)
      - icon: 'mdi:server-network'
        name: Devices
        state: >
          {% set force_upadte = states.input_number.min_timer.state %} {% set i
          = namespace() %} {% set i.i = 0 %}{% for item in states.device_tracker
          if item.attributes.scanner == 'SynologySrmDeviceScanner' and
          item.state == 'home' %}{% set i.i = i.i + 1 %}{% endfor %}{{ i.i }}
        tap_action:
          action: navigate
          navigation_path: /lovelace/network
        type: 'custom:template-entity-row'
      - label: Routing Load
        type: section
      - icon: 'mdi:memory'
        name: CPU
        state: >
          {% set cpu =

          states.sensor.synology_srm.attributes.core_get_system_utilization.cpu
          -%}

          {{ cpu.other_load + cpu.system_load + cpu.user_load }} %
        type: 'custom:template-entity-row'
      - name: null
        secondary: Last 15 min average
        state: >
          {% set cpu =
          states.sensor.synology_srm.attributes.core_get_system_utilization.cpu
          -%}

          {% set cores = 2 -%}

          {{ (cpu['15min_load']/cores)|int }} %
        type: 'custom:template-entity-row'
      - icon: 'mdi:chip'
        name: Memory
        state: >
          {% set memory =
          states.sensor.synology_srm.attributes.core_get_system_utilization.memory
          -%} {{ memory.real_usage }} % ({{ (memory.memory_size / 1024 *
          memory.real_usage /100)|int }} / {{ (memory.memory_size / 1024)|int }}
          MB)
        type: 'custom:template-entity-row'
      - label: External Access
        type: section
    show_header_toggle: false
    style: |
      .card-content {
        padding-bottom: 0 !important;
      }
    title: Internet and Network
    type: entities
  - card:
      content: >-
        <table width=100%>

        {% set ddns_extip =
        states.sensor.synology_srm.attributes.core_list_ddns_extip -%}

        {% for item in ddns_extip -%}
          <tr><td valign=top>IP ({{ item.type }}):</td><td>{{ item.ip }}</td></tr>
          <tr><td valign=top>IPv6 ({{ item.type }}):</td><td>{{ item.ipv6 }}</td></tr>
        {% endfor -%}

        {% set ddns_extip =
        states.sensor.synology_srm.attributes.core_list_ddns_record -%}

        {% for item in ddns_extip.records %}
          {% set Preamble = "<b style='color: darkred;'>" if item.status != 'service_ddns_normal' else '' %}
          {% set Postamble = '<br>State: ' + item.status + '</b>' if item.status != 'service_ddns_normal' else '' %}
          <tr><td valign=top>{{ item.provider }}:</td><td>{{ Preamble }}{{ item.hostname }}{{ Postamble }}</td></tr>
        {% endfor -%}

        </table>
      ignore_line_breaks: true
      type: 'custom:html-template-card'
    style: |
      ha-card {
        padding-top: 0 !important;
        padding-left: 16px !important;
        padding-bottom: 0 !important;
      }
    type: 'custom:mod-card'
  - entities:
      - label: Traffic and Benchmarks (last 24 hours)
        type: section
    show_header_toggle: false
    style: |
      .card-content {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
      }
    type: entities
  - cards:
      - aggregate_func: ave
        entities:
          - entity: sensor.wan_download
            index: 0
            name: Traffic
          - color: '#0000FF44'
            entity: sensor.speedtest_download
            index: 1
            name: Speed Test
        font_size: 75
        group_by: hour
        height: 200
        hours_to_show: 24
        line_color: '#0000FF'
        lower_bound: 0
        name: Download
        show:
          icon: false
          labels: true
          points: hover
        style: |
          ha-card {
            padding-top: 0 !important;
            padding-right: 2px !important;
          }
          .header,
          .graph__legend {
            padding-bottom: 0 !important;
          }
          .info {
            display: none !important;
          }
          .label--max,
          .label--min {
            box-shadow: unset !important;
          }
        type: 'custom:mini-graph-card'
      - aggregate_func: ave
        entities:
          - entity: sensor.wan_upload
            index: 0
            name: Traffic
          - color: '#e74c3c44'
            entity: sensor.speedtest_upload
            index: 1
            name: Speed Test
        font_size: 75
        group_by: hour
        height: 200
        hours_to_show: 24
        line_color: '#e74c3c'
        lower_bound: 0
        name: Upload
        show:
          icon: false
          labels: true
          points: hover
        style: |
          ha-card {
            padding-top: 0 !important;
            padding-left: 1px !important;
            padding-right: 1px !important;
          }
          .header,
          .graph__legend {
            padding-bottom: 0 !important;
          }
          .info {
            display: none !important;
          }
          .label--max,
          .label--min {
            box-shadow: unset !important;
          }
        type: 'custom:mini-graph-card'
      - aggregate_func: ave
        entities:
          - entity: sensor.speedtest_ping
            index: 0
            name: Ping
          - color: '#0000FF44'
            entity: sensor.wan_download
            index: 1
            name: Download
            show_fill: false
            show_legend: false
            y_axis: secondary
          - color: '#e74c3c44'
            entity: sensor.wan_upload
            index: 2
            name: Upload
            show_fill: false
            show_legend: false
            y_axis: secondary
          - entity: sensor.speedtest_download
            index: 3
            show_fill: false
            show_legend: false
            show_line: false
            show_points: false
            y_axis: secondary
          - entity: sensor.speedtest_upload
            index: 4
            show_fill: false
            show_legend: false
            show_line: false
            show_points: false
            y_axis: secondary
        font_size: 75
        group_by: hour
        height: 200
        hours_to_show: 24
        line_color: var(--accent-color)
        lower_bound_secondary: 0
        show:
          icon_adaptive_color: false
          labels: true
          labels_secondary: false
          points: hover
        style: |
          ha-card {
            padding-top: 0 !important;
            padding-left: 1px !important;
            padding-right: 1px !important;
          }
          .header,
          .graph__legend {
            padding-bottom: 0 !important;
          }
          .info {
            display: none !important;
          }
          .label--max,
          .label--min {
            box-shadow: unset !important;
          }
        type: 'custom:mini-graph-card'
    type: horizontal-stack
type: 'custom:vertical-stack-in-card'

@ghost
Copy link

ghost commented May 6, 2020

ANd you are planing to implement SRM integration to official Home Assistant ? As official integration ?

Yes ... that is why there is a pull request for it ... it was ready months ago ... but in the meantime they decided to change their policy; which now prevents them from merging it ... I have holidays in a little over a month; so will try to update it then

But if you implement is to official integration we also do this config as you show or we can config it by WEBUI from Home Assistant ?

@i00
Copy link
Owner Author

i00 commented May 6, 2020

Web UI is now a requirement ... but that will only be for setup ... and for the right side
... also it will only replace this bit:

sensor:
  - platform: synology_srm_router
    host: SynologyRouter.local
    password: !secret SynologyRouter
    monitored_conditions:
      - core.list_ddns_extip
      - core.get_system_utilization
      - core.list_ddns_record

@ghost
Copy link

ghost commented May 6, 2020

But cards we will be must config as you show by manual ? And resources ....?

@i00
Copy link
Owner Author

i00 commented May 6, 2020

Yep Lovelace is largely manual; and cards that are for specific types of devices will not get integrated.

@i00
Copy link
Owner Author

i00 commented May 6, 2020

I personally also prefer the config.xaml file to the UI config.

@ghost
Copy link

ghost commented May 6, 2020

ok we are waiting for integration....

@i00
Copy link
Owner Author

i00 commented May 6, 2020

ok we are waiting for integration....

It really only saves a small part of the work above (one the easiest parts IMHO)
... finished the instructions btw :)

@ghost
Copy link

ghost commented May 6, 2020

ok thanks.
BTW i am waitng when Synology release new version SRM 1.2.4....
In 2017 start project create new software NSM but Synology stop project.... But it looks better than SRM. More professional.... Looks it is creenshot from NSM and new device SG1000 which also plan release but also lost....
NSM_01

NSM_02

NSM_03

@HummelsTech
Copy link

HummelsTech commented May 6, 2020

@i00 thanks I'll try it later when I feel better.

@ghost
Copy link

ghost commented May 6, 2020

but this project was lost.... and no continiue by Synology.

@HummelsTech
Copy link

HummelsTech commented May 7, 2020

I tried your code but still no luck.
- entities: - entity: binary_sensor.online - entity: sensor.internet_provider
are missing in my setup how did you create them?

the binary_sensor.online I made with ping is this the right way?

- platform: template sensors: wan_download: value_template: "{% set i = namespace() %}{% set i.i = 0 %}{% for item in states.sensor.synology_srm.attributes.core_get_system_utilization.network if item.device|regex_match('^(usbnet|ppp)', ignorecase=true) %}{% set i.i = i.i + item.rx %}{% endfor %}{{ ((i.i / 1024 / 1024) * 8)|round(2) }}" friendly_name: Download unit_of_measurement: Mbit/s icon_template: 'mdi:download' wan_upload: value_template: "{% set i = namespace() %}{% set i.i = 0 %}{% for item in states.sensor.synology_srm.attributes.core_get_system_utilization.network if item.device|regex_match('^(usbnet|ppp)', ignorecase=true) %}{% set i.i = i.i + item.tx %}{% endfor %}{{ ((i.i / 1024 / 1024) * 8)|round(2) }}" friendly_name: Upload unit_of_measurement: Mbit/s icon_template: 'mdi:upload'
Gives me only 0.0
is (usbnet|ppp) correct?

At my sytem I saw: .core_list_ddns_record instead off .core_ddns_record so I replaced this in the code

So any help is welcome.
I use Home Assistant on my Synology NAS and have a RT2600AC and two MR2200AC

sensor.synology_srm.attributes.core_get_system_utilization.network gives me
`network:

  • device: total
    rx: 86081
    tx: 91343
  • device: bwlan0
    rx: 0
    tx: 0
  • device: bwlan1
    rx: 0
    tx: 0
  • device: eth0
    rx: 27204
    tx: 52711
  • device: lbr0
    rx: 58877
    tx: 38632`

@i00
Copy link
Owner Author

i00 commented May 8, 2020

@AlwinHummels ... ahh sorry missed those :) :

binary_sensor:
  - platform: ping
    host: 8.8.8.8
    name: Online
    count: 1
    scan_interval: 300
sensor:
  - platform: scrape
    resource: https://www.whoismyisp.org
    select: ".isp"
    name: 'Internet Provider'
    scan_interval: 60 #1 mins

@HummelsTech
Copy link

HummelsTech commented May 8, 2020

great thanks for your help, it works fine.
but the wan_upload and wan_download sensors still gives me a value of 0.0
Can you explain the code so I can fix it.

Thanks again

@i00
Copy link
Owner Author

i00 commented May 8, 2020

Can you go to developer tools and copy and paste in the output for your sensor.synology_srm?
Thanks

@HummelsTech
Copy link

HummelsTech commented May 8, 2020

@i00 Here is my output

core_list_ddns_extip:
  - ip: 12.34.56.78
    ipv6: '0:0:0:0:0:0:0:0'
    type: WAN
core_get_system_utilization:
  cpu:
    15min_load: 57
    1min_load: 34
    5min_load: 35
    device: System
    other_load: 1
    system_load: 10
    user_load: 5
  disk:
    disk:
      - device: sdr
        display_name: USB Disk 1
        read_access: 0
        read_byte: 0
        type: usb
        utilization: 0
        write_access: 0
        write_byte: 0
    total:
      device: total
      read_access: 0
      read_byte: 0
      utilization: 0
      write_access: 0
      write_byte: 0
  memory:
    avail_real: 90552
    avail_swap: 1256352
    buffer: 10636
    cached: 162112
    device: Memory
    memory_size: 524288
    real_usage: 44
    si_disk: 0
    so_disk: 0
    swap_usage: 4
    total_real: 477388
    total_swap: 1310712
  network:
    - device: total
      rx: 159245
      tx: 156825
    - device: bwlan0
      rx: 0
      tx: 0
    - device: bwlan1
      rx: 0
      tx: 0
    - device: eth0
      rx: 96493
      tx: 56797
    - device: lbr0
      rx: 62752
      tx: 100028
  space:
    lun: []
    total:
      device: total
      read_access: 0
      read_byte: 0
      utilization: 0
      write_access: 0
      write_byte: 0
    volume:
      - device: mmcblk0p6
        display_name: volume1
        read_access: 0
        read_byte: 0
        utilization: 0
        write_access: 0
        write_byte: 0
  time: 1588936034
core_list_ddns_record:
  next_update_time: '2020-05-09 12:32'
  records:
    - enable: true
      heartbeat: true
      hostname: xxxxxx.synology.me
      id: Synology
      ip: 12.34.56.78
      ipv6: '0:0:0:0:0:0:0:0'
      lastupdated: '2020-05-08 12:32'
      net: DEFAULT
      provider: Synology
      status: service_ddns_normal
      username: xxxxx@xxxxx.nl
friendly_name: synology_srm
icon: 'mdi:router-wireless'

@HummelsTech
Copy link

Logboekdetails (ERROR)
Logger: homeassistant.components.template.sensor
Source: components/template/sensor.py:237
Integration: template (documentation, issues)
First occurred: 13:41:46 (2 occurrences)
Last logged: 13:41:46

Could not render template Download: UndefinedError: 'mappingproxy object' has no attribute 'core_get_system_utilization'
Could not render template Upload: UndefinedError: 'mappingproxy object' has no attribute 'core_get_system_utilization'

@i00
Copy link
Owner Author

i00 commented May 9, 2020

How are you connecting to the internet? ... my script only supports logging from usbnet (4g dongle) and ppp (PPPoE)

Also I imagine that the errors in the log are just because the sensor hadn't hit the router yet to build the attributes at startup.

@HummelsTech
Copy link

HummelsTech commented May 9, 2020

I connect over IPv4 Automatic so that will be the issue.
I have a connectbox from Ziggo (My Provider in the Netherlands) this is in Bridge mode and my RT2600ac is connectet to that box for internet.
I don't have a 4g dongle but it's on my wishlist ;-) any recommendations?

Is it rigth when I replace theregex_match('^(usbnet|ppp)' by regex_match('^(lbr|eth)' or just only regex_match('^(total)'

BTW No idea what lbr and the bwlan stands for

@i00
Copy link
Owner Author

i00 commented May 9, 2020

You can still get the WAN up / down ... you can actually get the bandwidth on each of the ports too (but generally not that useful for this purpose)... try adding the the lbr one to the regex and see if it looks right

@clicky73
Copy link

clicky73 commented May 9, 2020

  - platform: template
    sensors:
      wan_download:
        value_template: "{% set i = namespace() %}{% set i.i = 0 %}{% for item in states.sensor.synology_srm.attributes.core_get_system_utilization.network if item.device|regex_match('^(usbnet|ppp)', ignorecase=true) %}{% set i.i = i.i + item.rx %}{% endfor %}{{ ((i.i / 1024 / 1024) * 8)|round(2) }}"
        friendly_name: Download
        unit_of_measurement: Mbit/s
        icon_template: 'mdi:download'
      wan_upload:
        value_template: "{% set i = namespace() %}{% set i.i = 0 %}{% for item in states.sensor.synology_srm.attributes.core_get_system_utilization.network if item.device|regex_match('^(usbnet|ppp)', ignorecase=true) %}{% set i.i = i.i + item.tx %}{% endfor %}{{ ((i.i / 1024 / 1024) * 8)|round(2) }}"
        friendly_name: Upload
        unit_of_measurement: Mbit/s
        icon_template: 'mdi:upload'

Just a minor correcting with the WAN upload and download sensor.
- platform: template sensors: wan_download: value_template: "{% set i = namespace() %}{% set i.i = 0 %}{% for item in states.sensor.synology_srm_router.attributes.core_get_system_utilization.network if item.device|regex_match('^(usbnet|ppp)', ignorecase=true) %}{% set i.i = i.i + item.rx %}{% endfor %}{{ ((i.i / 1024 / 1024) * 8)|round(2) }}" friendly_name: SRM Download unit_of_measurement: Mbit/s icon_template: 'mdi:download' wan_upload: value_template: "{% set i = namespace() %}{% set i.i = 0 %}{% for item in states.sensor.synology_srm_router.attributes.core_get_system_utilization.network if item.device|regex_match('^(usbnet|ppp)', ignorecase=true) %}{% set i.i = i.i + item.tx %}{% endfor %}{{ ((i.i / 1024 / 1024) * 8)|round(2) }}" friendly_name: SRM Upload unit_of_measurement: Mbit/s icon_template: 'mdi:upload'

Make sure it is "states.sensor.synology_srm_router.attributes.core_get_system_utilization.network"

The _router part was missing and failing to get network.

Apart from that, excellent work again Kris.
Looking forward to this being integrated.

@HummelsTech
Copy link

You can still get the WAN up / down ... you can actually get the bandwidth on each of the ports too (but generally not that useful for this purpose)... try adding the the lbr one to the regex and see if it looks right

thank you very much for all your help and patience with me

@i00
Copy link
Owner Author

i00 commented May 9, 2020

@clicky73 ... it shouldn't be synology_srm_router unless it has been changed.. the name by default is synology_srm ... you can change the name in the config with the name attribute; or rename it via the interface.

@clicky73
Copy link

Hey Kirs (@i00)

I am going from your post 4 days ago with the code to enable it to work on the latest version of HA and pull the WAN download and upload data.
https://github.com/i00/Chatter/issues/1#issuecomment-624612428
The platform is synology_srm_router and you need to add the _router in the template as previously mentioned to pull the attributes.

You are correct, this is not the default one at the start of this post.

`sensor:

  • platform: synology_srm_router
    host: SynologyRouter.local
    password: !secret SynologyRouter
    monitored_conditions:
    • core.list_ddns_extip
    • core.get_system_utilization
    • core.list_ddns_record`

Keep up the good work mate and will be following eagle eyed.

@skynet01
Copy link

skynet01 commented Oct 13, 2020

Kris, (@i00) I tried figuring out how you created that auto-entities syntax.. but it's way over my head when you started messing with nth-child etc. You sir are a wizard. Can you post your latest syntax for the list card? Maybe some Lovelace cards got updated?

I was able to switch out so IP addresses show up instead of MACs but I still get the Ethernet icon to the right and get a wifi icon next to "Ethernet" text.

Also, any chance of sorting them by connection speed instead of name? That way ethernet will be at the top followed by actual connection speed sorting... Just a thought :)

When I copy and paste your list mine looks like this:

image

@i00
Copy link
Owner Author

i00 commented Oct 13, 2020

@i00 thank you so much for this integration modification, I just followed your guide and everything worked out of the box with the latest SRM update (1.2.4.8xxx Update 1) even today. Now I have your awesomely designed Lovelace cards, you saved me days in setting them up myself from scratch.

Glad my work is appreciated :)

Also, it looks like some of the icons were not mapping correctly adding - icon: 'mdi:wifi-strength-3' to the list at the top solved it. But for some reason, I have MAC address followed by an Ethernet icon show up for all my devices instead of just IP addresses like in yours. I think I can probably figure out the tweaks there on my own unless it's already fixed in your new build

Already fixed myself ... this is due to changes in updates to multiple-entity-row since I wrote this up; I have updated the yaml under "Left Side" where you copied it from originally :)

...Anyway
My only minor request that would make this integration easier to use (other than adding this to HACS) is can you add an option for entity prefix for device_tracker entities?
I want to keep my actual device trackers separate from the router ones.

This way I can easily see which device trackers come from a router, so it would be device_tracker.srm_XXXXX

The standard for this is to use the source_type attribute

Again thank you sooo much for this!!

Your welcome

@i00
Copy link
Owner Author

i00 commented Oct 13, 2020

Kris, (@i00) I tried figuring out how you created that auto-entities syntax.. but it's way over my head when you started messing with nth-child etc. You sir are a wizard. Can you post your latest syntax for the list card? Maybe some Lovelace cards got updated?

I was able to switch out so IP addresses show up instead of MACs but I still get the Ethernet icon to the right and get a wifi icon next to "Ethernet" text.

Icon fix ... all related to my fix above :)

Also, any chance of sorting them by connection speed instead of name? That way ethernet will be at the top followed by actual connection speed sorting... Just a thought :)

To sort have a look here ... will be something like (untested):

....
sort:
  method: attribute
  reverse: true
  attribute: current_rate
type: 'custom:auto-entities'

When I copy and paste your list mine looks like this:

Again mentioned the fix for this in my previous post ;)

@skynet01
Copy link

skynet01 commented Oct 13, 2020

Thanks for the quick response and fix, works great now. 👍

The standard for this is to use the source_type attribute

Yeah, I saw that in your template, this was more so it's easier to tell apart on the entities list screen or do global customizations/filtering using wildcards for places that don't support attribute filtering.

Your sorting works great! For the record current_rate was too crazy since it kept updating and jumping around for me. I found that "attribute: band" worked better. Thanks for the tip.
Again super impressed with your template hacking of how you are hiding icons that you don't need using div tags :)

On another note, I noticed that not all attribute: dev_type devices are shown. For example on the router I have my Alexas marked as Alexas device type but it shows up as "default" device type. I take it this an issue with synolory_srm or issue with the router API?

@pepsonEL
Copy link

Hi i00. When you plan add your integration to official HA or to HACS ?

@pepsonEL
Copy link

??

@i00
Copy link
Owner Author

i00 commented Oct 23, 2020

On another note, I noticed that not all attribute: dev_type devices are shown. For example on the router I have my Alexas marked as Alexas device type but it shows up as "default" device type. I take it this an issue with synolory_srm or issue with the router API?

Yep not all device types are listed ... it just defaults to other if the API does not know it ... i imagine that this will be the srm python lib that doesn't support these; since it just uses the routers undocumented API (that does support it obviously).

@i00
Copy link
Owner Author

i00 commented Oct 23, 2020

Hi i00. When you plan add your integration to official HA or to HACS ?

I did submit this; but then they changed their policy several months later to not allow config setups; and so they won't merge it.

I have not looked at implementing it into the integrations interface... if you know how to do this let me know :)

@pepsonEL
Copy link

No i dont know. But please think about it.. i believe in you . Please many user wait for it.

@skynet01
Copy link

Yes, ill even buy you some beer/coffee to motivate you if necessary :)

@i00
Copy link
Owner Author

i00 commented Nov 2, 2020

Will have a look at the documentation to implement the interface config this weekend.

@skynet01
Copy link

@i00 Kris, do you by any chance have any updates on your latest Lovelace config? It looks like the latest version of Multiple Entity Row broke the config again :)

@i00
Copy link
Owner Author

i00 commented Jan 5, 2021

@skynet01 ... works for me ... what does it look like for you?

@skynet01
Copy link

skynet01 commented Jan 5, 2021

Multiple Entity Row got updated to v4.1.1 and the rows are now busted. I downgraded back to 3.5.1 for now.

@i00
Copy link
Owner Author

i00 commented Jan 14, 2021

Will hopefully get around to looking at this in a few weeks :P

@genesispc
Copy link

Hey I've been seeing "2021-05-09 20:52:32 ERROR (MainThread) [homeassistant.loader] No 'version' key in the manifest file for custom integration 'synology_srm_router'. As of Home Assistant 2021.6, this integration will no longer be loaded. Please report this to the maintainer of 'synology_srm_router'" lately, have you had a chance to work on this. Can I help I really like the extra details provided.

@pepsonEL
Copy link

@i00 is any chance to implement it to official integration in HA ?

@pepsonEL
Copy link

but this project was lost.... and no continiue by Synology.

I also think that NSM looks better than SRM , i dont know why Synology lost this project. Now good news will be if Synology implement functionsality NSM to new SRM 1.3.0 which will be release in newar future. But i dont know if it implement any feature in new SRM.

@genesispc
Copy link

I created a manifest.json file in the synology_srm custom components directory with the following contents. It seems to have removed the error.

{
"domain": "synology_srm_router",
"name": "Synology SRM integration",
"version": "1.0.0",
"documentation": "",
"dependencies": [],
"codeowners": [],
"issue_tracker": "",
"requirements": [],
"config_flow": false
}

@pepsonEL
Copy link

Ok but how use it in HA ?

@skynet01
Copy link

Ok but how use it in HA ?

Go to custom_components\synology_srm_router open file manifest.json (or create it if its not there) and paste

{
"domain": "synology_srm_router",
"name": "Synology SRM integration",
"version": "1.0.0",
"documentation": "",
"dependencies": [],
"codeowners": [],
"issue_tracker": "",
"requirements": [],
"config_flow": false
}

@i00 Kris any chance you have updated config for the Multiple Entity Row 4.2.0? I tried poking around it myself but your templating skillz are beyond me 😂

@pepsonEL
Copy link

pepsonEL commented Sep 3, 2021

@Pepeel Sure I will do this in two separate posts below for ease
image

Hi
I configure as you show and i have a problem with icons as show on image:
icons

@skynet01
Copy link

skynet01 commented Sep 5, 2021

I had the same issue as you, i think its cause the Multile Entieties rows got updated. I switched to using Flex-table-card. You can get in on HACS. It's much easier to use, displays data in a cleaner way and uses much less resources: Here is my example:

type: custom:stack-in-card
title: Ethernet Devices
cards:
  - type: custom:auto-entities
    filter:
      exclude:
        - state: not_home
      include:
        - attributes:
            scanner: SynologySrmDeviceScanner
            connection: ethernet
    card:
      type: custom:flex-table-card
      sort_by: hostname
      clickable: true
      columns:
        - data: hostname
          name: Name
        - data: ip_addr
          name: IP
  - type: custom:flex-table-card
    entities:
      include: device_tracker.*
    title: Wireless Devices
    sort_by: hostname+
    strict: true
    clickable: true
    columns:
      - data: hostname
        name: Name
      - data: band,current_rate
        name: Band
        multi_delimiter: ' - '
        suffix: Mbps
      - data: ip_addr
        name: IP
      - data: band
        name: Name
        hidden: true

image

@advorsky73
Copy link

So any updates on this? Is it integrated already?

@pepsonEL
Copy link

I also wait for any integration but probably no plan for integration.

@skynet01
Copy link

The SRM sensor stopped working for me, or more accurately the attributes no longer show up under the sensor. Anyway to get it to work again?

@pepsonEL
Copy link

Good will,be if someone can write integration for Home Assistant... official or for HACS

@clicky73
Copy link

clicky73 commented Apr 14, 2022

Broke for me also after going to 2022.4.3.

As I need the network traffic, I changed to using SNMP in the link below, until this is fixed.
https://www.reddit.com/r/homeassistant/comments/njxon2/making_a_bandwidth_monitor_for_synology_rt2600ac/

Would rather use this integration than SNMP.

@skynet01
Copy link

You were able to get the network traffic with this integration as it was one of the attributes you just had to convert the units using a template sensor. ... but yeah it no longer works now. Thank you for the link to the SNMP thing, I'll be switching to that if there is no update :)

@dries83
Copy link

dries83 commented Jun 5, 2024

Still struggling to get the monitor back work. I was able to get the correct overview, but I miss the "Ethernet" status.

I am a bit further, by adding the card_mod in front of style, it shows again the correct lay-out:

show_state: true
card_mod:
  style: >

However, I now encounter the issue that the “Ethernet” is not being shown, it comes back as “undefined”:

image

If I look to the following code, it should show “Ethernet” for non-wireless devices:

    } {% if state_attr(config.entity, 'is_wireless') == false %} .secondary {
      visibility: visible;
      display: block;
    } {% else %} .secondary:after {
      content: ' (Level {% if state_attr(config.entity, 'mesh_node_id') == 0 %}1{% elif state_attr(config.entity, 'mesh_node_id') == 4 %}3{% elif state_attr(config.entity, 'mesh_node_id') == 3 %}4{% else %}?{% endif %})';
    } {% endif %}

However, it doesn’t. I tried to debug and alter the code, but so far without success. Also ChatGPT was not able to help me further. Any ideas from your side?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants