-
-
Notifications
You must be signed in to change notification settings - Fork 29k
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
Add Synology SRM sensor to get information from router #31523
Conversation
Update from Master
I signed the CLA ... I also added an example of how to get WAN Traffic (mainly what I use it for) |
@frenck ... sorry internet has been down since last weekend ... got hit by heavy storms and only got it back yesterday ... will do the documentation this weekend ... I may require some help later with the failing checks. Thanks |
I created the documentation and updated the pull request |
@i00 Removed the For the other build issues:
|
@frenck ... thanks will have a look at it this weekend :) |
Synology SRM - fixing up code and updating import
Um sorry ... does anyone have any ideas as to what this means?: Thanks |
Shameful bump.. |
Well, we can't see anymore, since the build logs are removed after some time. Please push an empty commit to re-trigger the build (or rebase the PR onto the latest |
@frenck ... sorry didn't realize that the logs got nuked ... just did the empty commit :) ... still failing though ... any ideas? Thanks a million 👍 |
You haven't updated the requirements. The message is pretty clear at the end:
|
Thanks @frenck ...
|
Yes, it needs to run from within the venv. |
Thanks for confirming that ... will do that next time :) |
@frenck .. sorry but any updates on this? |
Any update on what @i00? I don't believe you had a followup question? If you are pinging me for a review, I would really want to advise you not to ping people for that. There are a lot of PRs open for review, so please be patient. |
Ok thanks, just wasn't sure if this was forgotten about :) |
"live", | ||
] | ||
|
||
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We no longer accept additions or changes to the yaml config of integrations. See: https://github.com/home-assistant/architecture/blob/master/adr/0010-integration-configuration.md
This integration needs to be refactored to use a config flow and config entries.
https://developers.home-assistant.io/docs/config_entries_config_flow_handler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, should move this platform based copmponent to an integration based.
Will avoid double config for one device.
Hello, I’m a beginner, but if there’s going to be an Installable Beta, I’ll be happy to help with the test with a 2600AC and a 2200AC router. Thank you for your work. |
@ahkaroly, would be great; but at the moment the current version of it does not conform to the guidelines that were changed last week so the test would have to wait until I refactor it to accommodate this (will do when I take holidays next month). However; it will still work with the current release; so if you want it now so you can use the integration right away you can do so by using this: I get most of the following out of it: Kris |
Thank you very much. I see it works. I will test and I will if I find any problems. But I can't find one thing. Does your image show traffic and Benchmark, the total amount of data used per day? Where can I find this? Is this calculated by the home assistant, or can the sensor also transfer router statistics? |
No, it is the live traffic; see the Additional information in the OP that details how to create the wan_download & wan_upload sensors for this. I had to strip out the historical traffic as it is not supported in the current version in HA. |
Sorry, I watched the speedtest as day traffic. The current traffic is working perfectly :) Can't read monthly internet traffic with SNMP? |
Nope ... can basically read noting useful with SNMP with Synology SRM... Seems to be geared around general status rather than actual good routing information. |
Thanks for the great Job. Thanks for your help |
@AlwinHummels ; I take it you are talking about the device list on the left? device_tracker:
- platform: synology_srm
host: SynologyRouter.local
password: !secret SynologyRouter
consider_home: 60 # default 180
new_device_defaults:
track_new_devices: true In Lovelace I use this for the list of devices (bit messy but it does the job): 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: >
div.entity:nth-child(1),div.entity:nth-child(2) {
margin-right:0;
} div.entity:nth-child({% if state_attr(config.entity,
'ip_addr') == '' %}1{% else %}2{% 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') == 1 %}3{% elif state_attr(config.entity, 'mesh_node_id') == 3 %}4{% else %}?{% endif %})';
} {% endif %}
div.entity:nth-child(4),div.entity:nth-child(5),div.entity:nth-child(6),div.entity:nth-child(7)
{
--iron-icon-height: 16px;
position: absolute;
top: 8px;
left: 50px;
visibility: hidden;
} div.entity:nth-child({% if state_attr(config.entity,
'is_wireless') == false %}4{% elif state_attr(config.entity,
'rate_quality') == 'low' %}5{% elif state_attr(config.entity,
'rate_quality') == 'middle' %}6{% elif
state_attr(config.entity, 'rate_quality') == 'high' %}7{%
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+8) {
position: absolute;
top: 0px;
left: 8px;
visibility: hidden;
} div.entity:nth-child({% if state_attr(config.entity,
'dev_type') == 'gamebox' %}8{% elif state_attr(config.entity,
'dev_type') == 'phone' %}9{% elif state_attr(config.entity,
'dev_type') == 'tv' %}10{% elif state_attr(config.entity,
'dev_type') == 'dlna' %}11{% elif state_attr(config.entity,
'dev_type') == 'computer' %}12{% elif
state_attr(config.entity, 'dev_type') == 'nas' %}13{% elif
state_attr(config.entity, 'dev_type') == 'notebook' %}14{%
elif state_attr(config.entity, 'dev_type') == 'tablet' %}15{%
elif state_attr(config.entity, 'dev_type') == 'ipcam' %}16{%
elif state_attr(config.entity, 'dev_type') == 'printer' %}17{%
elif state_attr(config.entity, 'dev_type') == 'router' %}18{%
endif %}) {
visibility: visible;
}
type: 'custom:multiple-entity-row'
state: home
sort:
ignore_case: true
method: name
type: 'custom:auto-entities' The Lovelace stuff requires the following: Note that I have hard-coded the mesh IDs to the name (Level 1,3,4) ... so you may need to fiddle with that ... search for Level in my Lovelace config. Hope that helps, EDIT: Also I am not sure if the version that I have here is compatible with the current srm version that I had merged in to the current version of HA ... if there are issues let me know ... I have a version that works with it. |
Hi Are you planing to add it to official integration of Home Assistant ? |
@i00 Thanks a lot for your help, can you please share the code for the other cards too. |
@Pepeel @AlwinHummels ... I feel this is a little off-topic ... so I have started a chatter thread here ... feel free to leave any questions there. Also I have time off coming up from the 8th of June ... so will probably finish this push off then. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should focus on #35412 first.
Then update this PR accordingly.
), | ||
vol.Optional( | ||
CONF_MONITORED_CONDITIONS, default=DEFAULT_MONITORED_CONDITIONS | ||
): vol.All(cv.ensure_list, [vol.In(POSSIBLE_MONITORED_CONDITIONS)]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid monitored_contitions
from https://github.com/home-assistant/architecture/blob/master/adr/0003-monitor-condition-and-data-selectors.md
Is your different conditions are making a specific fetch ?
Or maybe you can use entity_registry_enabled_default
https://developers.home-assistant.io/docs/core/entity#advanced-properties
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes ... they make separate requests ... so I think this should remain.
|
||
def setup_platform(hass, config, add_devices, discovery_info=None): | ||
"""Set up the Synology SRM Sensor.""" | ||
add_devices([SynologySrm(config)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a device tracker; this is to obtain information from the router; the existing SRM integration can be used for device tracking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is not a device_tracker, but the behavior is the same.
You can actually see it in icloud/sensor
.
But since when you have a new device connected to your router, you have to create a sensor, this should work like this.
"live", | ||
] | ||
|
||
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, should move this platform based copmponent to an integration based.
Will avoid double config for one device.
Just reviewed #35412 |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
Can anyone help with the download/upload speed sensors config? value_template: "{% set i = namespace() %}{% set i.i = 0 %}{% for item in states.sensor.synology_srm.attributes.core_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) }}" From my sensor.synology_srm respond i see the WAN load load under "device: lbr0". How can i get it separately from other numbers? core_get_system_utilization:
|
Please open an issue if you suspect a bug. If you need help please use our help channels: PRs should not be used for support or bug reports. Thanks! |
Proposed change
The current SRM integration is used for obtaining devices for tracking only ...
This adds sensor support so that additional information can be obtained from the router (that is not contained in SNMP).
Type of change
Example entry for
configuration.yaml
:Additional information
Information is returned in attributes, the state is the external IP address.
Here is an example of how to use this to implement entities for current WAN traffic:
Also ... I am not sure how to submit corresponding documentation along with this as it appears to be in another repo.
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
Will do this up on the week end
If the code communicates with devices, web services, or third-party tools:
Does not communicates with devices, web services, or third-party tools
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
How do we get this scored? It isn't apparent in the docs