Custom component: EdgeOS

Not yet, hopefully will get to it tomorrow

Okay, new version running, I had this issue where I tried to exclude sensor.edgeos_system_uptime
from history (loading up the history took a really long time) but I guess it was either the data that had already been logged to yesterday or it had something to do with the browser cache, because now mem and cpu are gone from the history. However I can still see the uptime itself in history climbing today, even after the change of date in history page.

Other thoughts:

  • Mbps is still shown like this: MBps (Received) 1188036608 so the conversion isn’t working correctly (I don’t have this fast connection :wink: )
  • Now that the most of the interface data is in one sensor, it’s not possible to create a history graph for most of the data in the sensor. I can see the current data of bytes received, bps etc. but the only thing that is recorded is the state of eth0 connection
    image

Owch. I just tried it with hassio and I lost access to the frontend. Fortunately SAMBA and SSH were still working so I removed the config and files and restarted. One browser refresh later and all is well again.

I had moved the required files to the required locations and added this to my configuration.yaml file:

edgeos:
  host: !secret edge_os_host
  ssl: false
  username: !secret edge_os_username
  password: !secret edge_os_password
  monitored_interfaces: 				
    - eth0
  unit: 'M'

Secrets were also defined appropriately.

I merged all data related to a device / interface under one sensor with all the attributes that represents the data that was previously in different sensor,
same for the system sensor, this time it represents the uptime with attributes of memory and CPU.

on top of those changes, I change the flow to update the sensor upon update request (time based by default 60 seconds, can be updated as all other sensors available by changing the scan_interval configuration).

the reason why I’ve done it is to reduce the number of items it creates until I will add the ability to define which parameters the user would like to get (from a list of predefined values).

As for the calculation, I will check it, when did you take the latest from GitHub?

Thanks

Do you have any logs that will redirect me to the issue?

thanks

Unfortunately not any more. I’ve restarted many times since then implementing an SNMP method.

New version in GitHub:

  • Added services for stop and restart WebSocket connection
  • Fix calculation of bits to any other configured unit
  • Format the last change date and time

I’m using the SNMP approach in Grafana’s dashboard, it works really great, the reason why I’ve done that was to compare the results

I just took took the latest version, and it looks like this:
image

This could be a very stupid question, but shouldn’t you divide bytes with 1024 to get kilobytes and kilobytes with 1024 to get megabytes, not multiply them? :wink:

I will check it, seems weird to me too…

Checked it and I multiplied instead dividing,
I worked on additional fix for the websocket thread termination (probably what causes to get med after few disconnects), waiting to see how it behaves tonight

Will try to have both fixes released tomorrow’s morning

Fixed the calculation

1 Like

Just a question as to why the eth3 interface would be showing connected after I removed the connection as a test. Duplex dropped from Full to Half, Speed from 1000 to 10, MBps (sent and received are at 0) immediately, but not the status. I assume it will check for a connection at a certain interval? Just wondering…

I creadted new service part of the version from 5 days ago, its purpose is to store the state to json file,
Can you run that service just to check what is the state of the interface (should be under interference, eth3, link)?
Please don’t post it, it contains all the info of the network.

In addition, did you restart the home assistant afterward to check whether it updates or not?

Thanks

Hi, happy to run the service, but having problems trying to work out exactly where it is from your description. This is all I found in the services
image

To the config folder

EdgeOS component new version with the following available in GitHub:

  • Aligned compatibility to HA v91.0 (according to warnings)
  • Switched websockets to aiohttp websocket
  • Separated classes to different files
  • Logs contains line number to find error cause faster
  • Better parsing of messages (reduced the number of unprocessed messages)
  • Better connection disconnection handling
  • Improved threads handling (removed threading definitions, using HA async)

If you are using the previous version, please remove:
custom_components/edgeos.py
custom_components/device_tracker/edgeos.py

Entire component is now according to the new HA standards - domain folder with all its classes

Please let me know if you encountered any issues

Thanks

1 Like

I just added this component and it looks great. The stats for the interface seem correct, but if I add a monitored_device I do get a binary_sensor for it, but the state is always disconnected. There is also no device_tracker being created for the device. (I did add both the edgeos component and the device_tracker for edgeos)
I’ve also tried to add my access point since that should always be available, but that also shows up as disconnected.
Am I doing something wrong or do other people have the same issue? I’m running HassOS 0.89.2.

edit:
I see now that “time_changed” doesn’t update.

the data that the component displays is based on the events from the router, it works like UNMS server while the UI is the HA,
If you will install that server, you probably get the same behavior - Access Point (as well as other networking devices) are not being reported (RX/TX rate), as result of that binary sensor of those devices cannot be handled with the EdgeOS component (frustrating me as well),
about the time_changed that was not changed, did you add more devices to be monitored?

In case those devices are not being updated, please attach the log of all the edgeos messages (warning and above should be enough).

I’ll try to find a solution, but that probably will take time…

I’ve added some more devices. Just like my phone they show up nicely as a binary sensor. IP and MAC address are correct. Time_changed is set to when Home Assistant restarted and doesn’t update.

I’ve copied the log with only my phone as a monitored device:

2019-03-23 16:41:04 WARNING (MainThread) [homeassistant.loader] You are using a custom component for edgeos which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-03-23 16:41:11 INFO (MainThread) [homeassistant.setup] Setting up edgeos
2019-03-23 16:41:11 INFO (MainThread) [homeassistant.loader] Loaded edgeos.device_tracker from custom_components.edgeos.device_tracker
2019-03-23 16:41:11 WARNING (MainThread) [homeassistant.loader] You are using a custom component for edgeos.device_tracker which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-03-23 16:41:15 INFO (MainThread) [homeassistant.setup] Setup of domain edgeos took 4.1 seconds.
2019-03-23 16:41:15 INFO (MainThread) [homeassistant.components.device_tracker] Setting up device_tracker.edgeos
2019-03-23 16:41:15 INFO (SyncWorker_15) [custom_components.edgeos.device_tracker] Getting EdgeOS Scanner, Configuration: OrderedDict([('platform', 'edgeos'), ('hosts', ['Bart-Phone']), ('consider_home', datetime.timedelta(seconds=180)), ('new_device_defaults', {'hide_if_away': False, 'track_new_devices': True})])
2019-03-23 16:41:15 INFO (SyncWorker_15) [custom_components.edgeos.device_tracker] Initializing EdgeOS Scanner, Looking for: ['Bart-Phone']
2019-03-23 16:41:26 INFO (MainThread) [custom_components.edgeos] initialize_edgeos_connection - Initialization #0 begun at <Event homeassistant_start[L]>
2019-03-23 16:41:38 INFO (MainThread) [custom_components.edgeos.web_socket] start_listen - Start
2019-03-23 16:41:38 INFO (MainThread) [custom_components.edgeos.web_socket] get_subscription_data - Subscription data: 164 {"SUBSCRIBE":[{"name":"export"},{"name":"interfaces"},{"name":"system-stats"},{"name":"discover"}],"UNSUBSCRIBE":[],"SESSION_ID":"---"}
2019-03-23 16:41:40 INFO (MainThread) [custom_components.edgeos.web_socket] Connection connected, Subscribing to: 164 {"SUBSCRIBE":[{"name":"export"},{"name":"interfaces"},{"name":"system-stats"},{"name":"discover"}],"UNSUBSCRIBE":[],"SESSION_ID":"---"}
2019-03-23 16:41:40 INFO (MainThread) [custom_components.edgeos.web_socket] Subscribed
2019-03-23 16:42:16 INFO (MainThread) [custom_components.edgeos] Refresh EdgeOS components (2019-03-23 15:42:16.003085+00:00)
2019-03-23 16:43:17 INFO (MainThread) [custom_components.edgeos] Refresh EdgeOS components (2019-03-23 15:43:17.005617+00:00)
2019-03-23 16:44:18 INFO (MainThread) [custom_components.edgeos] Refresh EdgeOS components (2019-03-23 15:44:18.003437+00:00)

My Edgerouter Lite is connected to UNMS. Does that matter?