Custom component: EdgeOS

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?

Logs serms ok, I also encountered the same problem while using UNMS or with 2 HA that runs the component, could be that only one app can work with the websocket,
Didn’t invest too much effort to check it because I turned it off once I had the integration through HA,
I will check it again later this week

I turned it off a few hours ago, but it doesn’t seem to help. The router has also been updated from 1.10.8 to 1.10.9 and that also doesn’t change anything.
The user that I used for this component had operator access only, but changing it to admin access doesn’t help either.

Is there anything else that I could try or do to help find out what the issue is?

Can you change the log level of the component to debug and check if you are getting messages of export?
Not next to my PC, will send you later the exact term to look for if you can’t find it

EDIT: message you need to find is: “Handle export data”

I’ve changed the log to debug and copied some of the lines regarding the component.

2019-03-24 16:47:26 DEBUG (MainThread) [custom_components.edgeos] Handle export data
2019-03-24 16:47:26 DEBUG (MainThread) [custom_components.edgeos] export is empty
2019-03-24 16:47:27 DEBUG (SyncWorker_7) [custom_components.edgeos.device_tracker] Start scanning for new devices
2019-03-24 16:47:27 DEBUG (SyncWorker_7) [custom_components.edgeos.device_tracker] Following online devices found: []
2019-03-24 16:47:27 DEBUG (MainThread) [custom_components.edgeos] Handle interfaces data
2019-03-24 16:47:28 DEBUG (MainThread) [custom_components.edgeos] Handle system-stats data
2019-03-24 16:47:29 DEBUG (MainThread) [custom_components.edgeos] Handle interfaces data
2019-03-24 16:47:31 DEBUG (MainThread) [custom_components.edgeos] Handle export data
2019-03-24 16:47:31 DEBUG (MainThread) [custom_components.edgeos] export is empty
2019-03-24 16:47:31 DEBUG (MainThread) [custom_components.edgeos] Handle system-stats data
2019-03-24 16:47:31 DEBUG (MainThread) [custom_components.edgeos.web_socket] parse_message - Skipping message (Empty)

And for example I also have a line where it updated the state for a device:

2019-03-24 16:46:31 DEBUG (SyncWorker_6) [custom_components.edgeos.device_tracker] Start scanning for new devices
2019-03-24 16:46:31 DEBUG (SyncWorker_6) [custom_components.edgeos.device_tracker] Following online devices found: []
2019-03-24 16:46:32 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=binary_sensor.edgeos_device_printer, old_state=None, new_state=<state binary_sensor.edgeos_device_printer=off; device_class=connectivity, friendly_name=EdgeOS Device Printer, ip=10.0.1.3, mac=MAC_ADDRESS_HERE, time_changed=2019-03-24 16:46:32 @ 2019-03-24T16:46:32.221893+01:00>>

I hope there is something useful in there.

Probably that’s the reason, I need to read about it a bit, maybe in EdgeRouter Lite the message the component is expecting named not as in ER4.

I’m going to add a service that will allow logging all the data that comes from the WebSocket to be able to identify the right name, will run it a day and release it

1 Like

Thnx! I wish I had an ER4 :smiley:
If I can try anything, just let me know.