aaronk6 / dsl-monitoring

This is a collection of monitoring scripts for DSL monitoring.
8 stars 1 forks source link

Possible to save the decrypted Status.json to a file? #1

Closed DFS-90 closed 1 year ago

DFS-90 commented 1 year ago

Hi,

thanks for your great work concerning the Speedport Smart 4 script!

I'm trying to monitor my Speedport Smart 4 with my HomeAssistant Server; therefore I'd like to access its (decrypted) Status.json page. I realized that your script is able to decrypt the router's Status.json page; I was also able to get it working with my Speedport Smart 4 (FW 010139.3.1.001.0) in router mode.

I'm trying to save the decrypted Status.json to a new file in order to parse it with Home Assistant. As I'm unable to do programming in Python, I have no idea if there is any possibility to achieve this with your script.

Is there a function that saves the decrypted Status.json to a new file so that it can be used further?

Thanks in advance and best regards, David

aaronk6 commented 1 year ago

Hi David,

Happy to hear that someone besides me is using this! 🙂 Currently, there’s no function to save the decrypted Status.json, but I’m happy to add something like this. Can’t give you an ETA, but I’ll add it to my list and report back once there’s progress.

DFS-90 commented 1 year ago

Sounds perfect - thanks in advance for your support! 🙂

aaronk6 commented 1 year ago

Done! The updated script supports a new --format parameter to specify either json or influxdb. It defaults to json. Let me know if it works for you.

DFS-90 commented 1 year ago

This is great work - thank you so much! 🙂

Only by curiosity: Are there any other parameters that can be read from the decrypted Status.json?

Background: I also own a "Telekom 5G-Empfänger" that delivers several parameters via /data/Status.json (but unencrypted): [ {"vartype":"page_title","varid":"title","varvalue":"5G-Empfänger Konfigurationsprogramm"}, {"vartype":"value","varid":"device_name","varvalue":"5G-Empfänger"}, {"vartype":"value","varid":"save_fails","varvalue":"0"}, {"vartype":"value","varid":"datetime","varvalue":"2023-04-11 16:55:22"}, {"vartype":"value","varid":"device_type","varvalue":"SE"}, {"vartype":"value","varid":"firmware_version","varvalue":"010149.1.0.006.0"}, {"vartype":"value","varid":"firmware_date","varvalue":"2022-11-22"}, {"vartype":"value","varid":"modem_version","varvalue":"RG520NEUDBR01A04M8GA_OCPU_ACY_BETA_20221115C"}, {"vartype":"value","varid":"hardware_revision","varvalue":"01"}, {"vartype":"value","varid":"serial_number","varvalue":"xxxxxxxxxx"}, {"vartype":"value","varid":"fw_version_standby","varvalue":"010100.1.0.004.2"}, {"vartype":"value","varid":"hardware_state","varvalue":"0"}, {"vartype":"value","varid":"link_status","varvalue":"2500"}, {"vartype":"value","varid":"link_up","varvalue":"707"}, {"vartype":"value","varid":"rxbip_crc","varvalue":"64375"}, {"vartype":"value","varid":"fw_success","varvalue":"1"}, {"vartype":"value","varid":"autofw_active","varvalue":"1"}, {"vartype":"value","varid":"lte_status","varvalue":"32"}, {"vartype":"value","varid":"dsl_tunnel","varvalue":"0"}, {"vartype":"value","varid":"lte_tunnel","varvalue":"1"}, {"vartype":"value","varid":"hybrid_tunnel","varvalue":"0"}, {"vartype":"value","varid":"public_ip_v6_full","varvalue":"---"}, {"vartype":"value","varid":"ex5g_uptime","varvalue":"--"}, {"vartype":"value","varid":"ex5g_type","varvalue":"H-Com 4000 XT"}, {"vartype":"value","varid":"ex5g_fw_version","varvalue":"21.260.00.00.000"}, {"vartype":"value","varid":"ex5g_imei","varvalue":"xxxxxxxx"}, {"vartype":"value","varid":"ex5g_cardnr","varvalue":""}, {"vartype":"value","varid":"ex5g_imsi","varvalue":""}, {"vartype":"value","varid":"ex5g_signal_5g","varvalue":"--"}, {"vartype":"value","varid":"ex5g_freq_5g","varvalue":"0"}, {"vartype":"value","varid":"ex5g_signal_lte","varvalue":"--"}, {"vartype":"value","varid":"ex5g_freq_lte","varvalue":"0"}, {"vartype":"value","varid":"ui_version","varvalue":"2.21.205"}, {"vartype":"status","varid":"loginstate","varvalue":"0"}]

My idea is to save the "raw" but decrypted Status.json that contains all values like in the exampe above. Afterwards, I'd try to read those variables into HomeAssistant.

Thanks and best regards, David

aaronk6 commented 1 year ago

Oh, yeah, that makes sense. I’ll add a --raw parameter that simply returns the decoded data as is. One caveat is that the Speedport returns number values as strings (this can also be seen in the output you posted above). Depending on what you plan to do with the data, you might need to cast those values to integers in Home Assistant.

aaronk6 commented 1 year ago

I’ve added a raw as an output format:

$ ./smart4-vdsl --format raw 
[{"vartype": "value", "varid": "device_name", "varvalue": "Speedport Smart 4"}, {"vartype": "value", "varid": "factorydefault", "varvalue": "1"}, {"vartype": "value", "varid": "rebooting", "varvalue": "0"}, {"vartype": "status", "varid": "loginstate", "varvalue": "0"}, {"vartype": "value", "varid": "router_state", "varvalue": "MODEM"}, …
DFS-90 commented 1 year ago

This is awesome and exactly what I was looking for - thank you very much for your efforts!

Your new version works perfectly - I was just able to do a quick test with my Speedport Smart 4 in Router mode. There are so many parameters that can be read - it also reports the status of the external 5G receiver ("Telekom 5G-Empfänger") as well as the status of hybrid bonding (which I will be able to test next month)!

I can now use a cronjob in order to write its "raw" output to an smb share and read its values to several HomeAssistant JSON sensors. Monitoring my 5G system will be so much easier - thanks again! 🙂

DFS-90 commented 1 year ago

Just in case you're also interested in Home Assistant: Speedport Smart 4 - Sensors for HomeAssistant.

aaronk6 commented 1 year ago

Cool, thanks for sharing! I’m actually using Home Assistant and I’m a big fan! I also have my DSL stats in Home Assistant, but through InfluxDB as I avoid calling the command-line directly from Home Assistant to keep things separated. Instead, I run telegraf on a different host that runs the smart4-vdsl script and feeds the output into InfluxDB. Home Assistant then pulls the values from InfluxDB. It’s a bit more complex but allows me to monitor my stats in Grafana which is quite nice!