-
Notifications
You must be signed in to change notification settings - Fork 0
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
Comments
Can you write us how step by step add this integration and show code for card as you show on screen ? |
@Pepeel Sure I will do this in two separate posts below for ease |
Ok i am waitng... ANd you are planing to implement SRM integration to official Home Assistant ? As official integration ? |
Left Side
device_tracker:
- platform: synology_srm
host: SynologyRouter.local
password: !secret SynologyRouter
consider_home: 60 # default 180
new_device_defaults:
track_new_devices: true
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'
|
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 |
Right Side
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'
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' |
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 ? |
Web UI is now a requirement ... but that will only be for setup ... and for the right side 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 |
But cards we will be must config as you show by manual ? And resources ....? |
Yep Lovelace is largely manual; and cards that are for specific types of devices will not get integrated. |
I personally also prefer the config.xaml file to the UI config. |
ok we are waiting for integration.... |
It really only saves a small part of the work above (one the easiest parts IMHO) |
@i00 thanks I'll try it later when I feel better. |
but this project was lost.... and no continiue by Synology. |
I tried your code but still no luck. the binary_sensor.online I made with ping is this the right way?
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. sensor.synology_srm.attributes.core_get_system_utilization.network gives me
|
@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 |
great thanks for your help, it works fine. Thanks again |
Can you go to developer tools and copy and paste in the output for your sensor.synology_srm? |
@i00 Here is my output
|
|
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. |
I connect over IPv4 Automatic so that will be the issue. 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 |
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 |
Just a minor correcting with the WAN upload and download sensor. 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. |
thank you very much for all your help and patience with me |
@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. |
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. You are correct, this is not the default one at the start of this post. `sensor:
Keep up the good work mate and will be following eagle eyed. |
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: |
Glad my work is appreciated :)
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 :)
The standard for this is to use the source_type attribute
Your welcome |
Icon fix ... all related to my fix above :)
To sort have a look here ... will be something like (untested): ....
sort:
method: attribute
reverse: true
attribute: current_rate
type: 'custom:auto-entities'
Again mentioned the fix for this in my previous post ;) |
Thanks for the quick response and fix, works great now. 👍
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. 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? |
Hi i00. When you plan add your integration to official HA or to HACS ? |
?? |
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). |
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 :) |
No i dont know. But please think about it.. i believe in you . Please many user wait for it. |
Yes, ill even buy you some beer/coffee to motivate you if necessary :) |
Will have a look at the documentation to implement the interface config this weekend. |
@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 :) |
@skynet01 ... works for me ... what does it look like for you? |
Multiple Entity Row got updated to v4.1.1 and the rows are now busted. I downgraded back to 3.5.1 for now. |
Will hopefully get around to looking at this in a few weeks :P |
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. |
@i00 is any chance to implement it to official integration in HA ? |
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. |
I created a manifest.json file in the synology_srm custom components directory with the following contents. It seems to have removed the error. { |
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
@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 😂 |
Hi |
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:
|
So any updates on this? Is it integrated already? |
I also wait for any integration but probably no plan for integration. |
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? |
Good will,be if someone can write integration for Home Assistant... official or for HACS |
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. Would rather use this integration than SNMP. |
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 :) |
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:
However, I now encounter the issue that the “Ethernet” is not being shown, it comes back as “undefined”: If I look to the following code, it should show “Ethernet” for non-wireless devices:
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? |
Chatter for further information in:
home-assistant/core#31523 (comment)
The text was updated successfully, but these errors were encountered: