i00 / Chatter

1 stars 0 forks source link

SRM sensor #1

Open i00 opened 4 years ago

i00 commented 4 years ago

Chatter for further information in: https://github.com/home-assistant/core/pull/31523#issuecomment-623335873

ghost commented 4 years ago

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

i00 commented 4 years ago

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

ghost commented 4 years ago

Ok i am waitng... Thanks

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

i00 commented 4 years ago

Left Side

i00 commented 4 years ago

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 commented 4 years ago

Right Side

ghost commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

i00 commented 4 years ago

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

i00 commented 4 years ago

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

ghost commented 4 years ago

ok we are waiting for integration....

i00 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

ghost commented 4 years ago

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

HummelsTech commented 4 years ago

I tried your code but still no luck. ` - entities:

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:

i00 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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

HummelsTech commented 4 years ago

@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 commented 4 years ago
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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago
  - 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.synologysrmrouter.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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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:

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

i00 commented 4 years ago

I updated the icon size change to work with 0.110+ in the Left Side example... Basically change:

--iron-icon-height: 16px;

to:

--mdc-icon-size: 16px;
HummelsTech commented 4 years ago

thanks again for the update

HummelsTech commented 4 years ago

Is there any progress to get this sensor as an official integration? Or do you have a updated version? I really like your solution but it seems not working anymore on my setup.

ghost commented 4 years ago

Also ask about any progress :) to add it to integration official?

HummelsTech commented 4 years ago

Or add it through hacs

ghost commented 4 years ago

But finally better Will be to add in official integration

i00 commented 4 years ago

I made a pull request that has been merged into HA for some time now with the device tracker...

As for the router info I did ... but it got declined; as it now requires setup through the integrations screen... even though I made the pull request months before this was required!

Pull request is here: https://github.com/home-assistant/core/pull/31523

HummelsTech commented 4 years ago

ok thanks for reaction but maybe you can add this as a custom component with Hacs

ghost commented 4 years ago

But you can not also add this to setup it by integration screen ?

i00 commented 4 years ago

I haven't looked at how that all works yet; so I have not ... that is why the pull request got rejected in the end. I do plan to visit that again sometime.

ghost commented 3 years ago

Please try do it because we wait for it.... please

skynet01 commented 3 years ago

@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.

It was a breath to setup and follow your directions. I had to change my adapters from ppp to lbr0 (and eth2 i think.. for failover that's on my first lan port) as per my config. 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

...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

Again thank you sooo much for this!!

skynet01 commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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 commented 3 years ago

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 _currentrate 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 commented 3 years ago

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

pepsonEL commented 3 years ago

??

i00 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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