Hi,
I can help you with this one.
First of all let me tell you how you can test your script without restarting HA and getting all the errors.
Install the ssh add-on from the library and then access the add-on page and type the command like this: python3 /config/python_scripts/nsa542_get_info.py $IP $USERNAME $PASSWORD
Then try to change the script and print the request output by adding print(response_login.text) on line 13 and print(response.text)
on line 16.
If the login is OK the print will display 9.
The second print should print the JSON that you get from the inspect page.
If yes(letter 9 is printed and the JSON also) then remove the print(response_login.text) and print(response.text) and we can analyze the output and adjust the parsing logic.
If no, please tell me what is the output that you get.
Hello.
I want to ask for help. I do not speak English well.
I have a Zyxel NSA 325v2 NAS that I would like to monitor in HA.
With this: http://192.168.65.11/r51009,/adv,/cgi-bin/zysh-cgi?c0=show cpu temperature&write=0&c1=show mem status&c2=storage showIVolumeInfo&c3=show cpu status I can retrieve some data. I get this back: ({
zyshdata0: [
{’_CPU_temperature’:’+46.00 C’}
],
errno0:0,
errmsg0:‘OK’,
zyshdata1: [
{’_memory_size’:‘498MB’,’_memory_used’:‘68MB’,’_memory_usage’:‘13%’}
],
errno1:0,
errmsg1:‘OK’,
zyshdata2: [
{’_VolName’:‘Disk’,’_Devnode’:’/dev/md0’,’_VolType’:‘raid1’,’_VolState’:‘healthy’,’_TotalSpace’:‘960925088’,’_Unit’:‘KB ‘,’_UsedSpace’:‘357700056’,’_Unit’:‘KB’,’_FilesystemType’:‘ext4’,’_DiskNames’:‘disk1 disk2’,’_Mountpath’:’/i-data/5ef68e83’}
],
errno2:0,
errmsg2:‘OK’,
zyshdata3: [
{’_CPU_utilization’:‘0 %’}
],
errno3:0,
errmsg3:‘OK’
}) Unfortunately, the sensors are still in an unknown state.
How should it work?
Hello,
I can use some help too, I can’t get sensors for NSA310 working.
In ssh I figured out that the import requests wasn’t working and am not able to do the pip install for it is not allowed as root.
I have tried to run the NSA310 python script and can see the the values of my NSA310.
I am also struggling with the command_line options since recent changes.
So I have now:
/config/python_scripts/nsa542_get_info.py as described
a command_line.yaml with:
sensor:
name: nsa310
json_attributes:
- cpu_usage
- cpu_temp
- mem_usage
- hdd_usage
- hdd_health
command: python3 /config/python_scripts/nsa310_get_info.py 192.168… user password
value_template: ‘{{ value_json.cpu_usage }}’
unit_of_measurement: “%”
scan_interval: 60
and in /config/configuration.yaml command_line: !include command_line.yaml
Error is: No module named ‘requests’.
Don’t know type of installation you using, but ‘import requests’ not working because module not installed in python.
Thanks for your patience and reply but i have little knowledge of python and the only thing i understand is to create the package folder and to put the nsa310 py script into it. The rest is a mystery for me.
I finaly managed to get it working.
The copied Yaml code didn’t work but with try and error and some modification it suddenly worked.
Thanks for the reply !
Hi, on my 540 with Firmware V5.21(AATB.11) (r51266) none of the cgi´s (show_sysinfo/zysh-cgi) works for me. Has someone a solution? or can someone describe how to discover the right cgi-string ?
OK Thanks, for your answer, the CGI via Browser ist now working but the sensors gettting no data, what i see is this: [core-ssh homeassistant]$ cat home-assistant.log | grep 540 2024-03-01 09:39:43.692 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: ‘None’ has no attribute ‘attributes’ when rendering ‘{{ states.sensor.nas540.attributes.cpu_temp }}’