New custom component: EdgeOS


#1

Created new custom component to integrate my HA with EdgeOS,
Integration is based (mostly) on WebSocket and few API calls.

It allows to monitor:

  • System CPU, Memory and uptime as sensors
  • Specific interface in to get tx/rx bps and total bytes (incoming and outgoing) as different sensors
  • Leased devices as sensor (in my network all devices connected to the network defined, so new leased devices should be treated as suspected)
  • Per monitored network device get tx/rx bps and total bytes (incoming and outgoing) as different sensors
  • Per monitored network device binary sensor with indication whether it’s connected or not (instead of pinging it)

Device tracker:
Ability to define a network device as tracking device.

If you would like to test it:

Project is running on my HA for the last 3 weeks.


Edgerouter X and HA
#2

Just tried to add this to my custom_components folder. Added the example lines to my configuration.yaml, changing the values to match my system but when restarting I get the following in my log

Setup failed for edgeos: Component not found

Along with another couple of similar lines about not being able to find the edgeos Component.

Inside my custom_components folder I created an edgeos folder and inside is the contents of the custom_components folder on the GitHub repo. Have I missed something, everything looks similar to the other custom_components I have working in HASS.

Any help appreciated, this Component sounds great.


#3

Realised that I needed to copy everything from the custom_components folder of the Github Repo straight to my custom_components folder. So it should contain the edgeos.py file and the device_tracker folder.

Looking at it now that was obvious, it’s late and confused me because the other custom components I have are under sensor or media_center folders.

The next issue I have is around the cert config line, I left it blank and threw an error, removed the whole line from my configuration.yaml and now I get:

Invalid config for [edgeos]: string value is None for dictionary value @ data['edgeos']['cert_file']. Got None. (See /config/configuration.yaml, line 404). Please check the docs at https://home-assistant.io/components/edgeos/

Do I have to use a certificate on my ERL-3, I said False to SSL in the config of this component. I think I may need to wait until some documentation is written, I’m obviously missing something.


#4

I tried this path for the cert file “/etc/lighttpd/server.pem” but keeps coming back with verify failed:

2019-02-08 10:31:23 ERROR (SyncWorker_15) [custom_components.edgeos] Failed to perform heartbeat, Error: HTTPSConnectionPool(host=‘192.168.1.1’, port=443): Max retries exceeded with url: /api/edge/heartbeat.json?t=1549593083 (Caused by SSLError(SSLError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)’),))
2019-02-08 10:31:23 ERROR (SyncWorker_15) [custom_components.edgeos] Failed to load static-devices, Error: HTTPSConnectionPool(host=‘192.168.1.1’, port=443): Max retries exceeded with url: /api/edge/get.json (Caused by SSLError(SSLError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)’),))


#5

I added configuration file with details about each settings, your configuration is missing path to the full chain certificate,
Later today i’ll change it to avoid checking the certificate, hopefully it will solve that issue,
Alternatively, you can create full chain certificate (combine cert with key to one file)


#6

Hi @grantc, the path you entered probably is just the certificate, as written in previous post - it requires the full chain


#7

Hi bar, thanks for the reply - any idea how to get that information? Thanks

openssl s_client -showcerts -connect 192.168.1.1:443

not sure what part of the output is the full chain :slight_smile:


#8

I’ll find later the article I used to create it, basically you create pem file consisted with the content of:

  1. Key
  2. Intermediate certificate
  3. Certificate

#9

Creating a .pem with the Private Key and Entire Trust Chain:
https://www.digicert.com/ssl-support/pem-ssl-creation.htm

-----BEGIN RSA PRIVATE KEY-----
(Your Private Key: your_domain_name.key)
-----END RSA PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
(Your Primary SSL certificate: your_domain_name.crt)
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
(Your Intermediate certificate: DigiCertCA.crt)
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
(Your Root certificate: TrustedRoot.crt)
-----END CERTIFICATE-----


#10

Updated the component, no SSL verification for HTTPS requests,
please try and let me know if now it works for you


#11

Confused now, so no .pem file path is required


#12

Sorry for that :slight_smile:

I updated it once again (removed the SSL verification from login request as well),
Now you don’t need to fill in the cert_file


#13

No longer getting complaint regarding the certificate, instead now get these 2 which are less friendly error messages.

error from callback <bound method EdgeOSWebSocket.on_error of <custom_components.edgeos.EdgeOSWebSocket object at 0x7fc82b824c18>>: on_error() takes 2 positional arguments but 3 were given
error from callback <bound method EdgeOSWebSocket.on_close of <custom_components.edgeos.EdgeOSWebSocket object at 0x7fc82b824c18>>: on_close() takes 1 positional argument but 2 were given

Thanks


#14

found out that it can be caused due to incompetible version of websocket-client,
just to be sure, can you run the following command and let me know which version installed in your system (if you are running python virtual environment, please run it from within it):
pip freeze | grep lxml

Mine is 0.54.0, according to forums, it can be caused when it lower than 0.53.0

thanks


#15

sorry, wrong past, should be:
pip freeze | grep websocket-client

Anyway, I pushed another fix, added the requirements of websocket-client,
If it’s not working, please post the version of your websocket-client

thanks


#16

Unfortunately still not working and I run hass.io, which is a docker container. pip isn’t installed, so can’t use that command to get the version.

I imagine lots of other people will have similar issues with more and more people using using hass.io now.

Any other idea who to check the version without pip?


#17

in both docker and hass.io pip installed, that’s the way it installs python packages,
you can create a command line sensor that you will get the value into its state:
sensor:

  • platform: command_line
    command: ‘pip freeze | grep websocket-client’

#18

@stevenhorner, any progress with the version / issue?

thanks


#19

Sorry away for the weekend, will try on Monday.
Thanks for the help.


#20

Hi bar,

Couple of errors in the log trying to get this up and running;

  1. 2019-02-11 08:44:13 ERROR (MainThread) [homeassistant.config] Invalid config for [edgeos]: string value is None for dictionary value @ data[‘edgeos’][‘cert_file’]. Got None. (See /home/homeassistant/.homeassistant/configuration.yaml, line 134). Please check the docs at https://home-assistant.io/components/edgeos/
    2019-02-11 08:44:13 ERROR (MainThread) [homeassistant.setup] Setup failed for edgeos: Invalid config.

I added the cert_file line back in (with no value) and then comment the line out still get the same error. I thought you removed this pre-req?

  1. 2019-02-11 08:44:15 ERROR (SyncWorker_13) [custom_components.device_tracker.edgeos] Failed to initialize EdgeOS Scanner, Error: ‘edgeos_ham’, Line: 37
    2019-02-11 08:44:15 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform edgeos

Thanks