I must admit, I didn’t even realise there was an API available for freenas. I’ve added some information already such as CPU load, temperatures etc via SNMP but I like the idea of bringing in the alert messages into Home assistant.
Cool didnt know there was an API for FreeNAS. Been trying to do this with SNMP but had a lot of issues on the old 9.2 build so I stopped that project. Now I know there is an API I can monitor my NAS
2 volumes over here, so 2x api call, to get info about the volume.
@gremblin, maybe also add the scan_interval so it will check on regular times and not overflood the api? My NAS is just serving some non-important things so i’m calling both sensors only 1x an hour.
Thanks @Bramus. Ha, I didn’t even know about SNMP. I might look into that, just out of curiousity.
Good point on the scan_interval. You’re not pulling any information that gets updated all that often, so it doesn’t make since to pull every minute (the default). I had orginally hoped for the CPU, Memory, Network traffic information so I could track all of that in one place (HA), but the FreeNAS API doesn’t expose that information. The built in graphing is pretty good, and if it did publish that information, it would probably be a little bit of a performance hit I suppose. But I usually want to go back in time and see how it was performing after the fact…
I did get that information for my pfSense router… and basically I found out that those values don’t change all that often. Which is good. Just not all that interesting to look at.
Thank you for your YAML code!
But … I got an error in my Hass log, and also got the value ‘Unknown’ in the sensor.fn_nas0_report and sensor.fn_nas0_pct_used. The other values and sensors are OK.
The error in the log is, each minute:
empty reply found when expecting JSON data’
and
error parsing value: ‘value_json’ is undefined (value: , template: {{ value_json.status }})
What’s going wrong? The api information is visable when I call the api in my browser. And I copied your yaml code exacty (changed the ip adress of course). Should I rename ‘nas0’? What should it be?
‘trunk’ needs to be the name of your volume. I set it to ‘trunk’ because I think that’s the typical name set… but you could have set yours to anything.
This is great! I always wanted to pull volume health, alerts etc into my Grafana dashboard but Graphite and SNMP doesn’t provide it. It works great!
You can pull CPU, Memory, and Network using Graphite but that’s assuming you want to visualize it in Grafana. My knowledge is limited with pulling that information into Home Assistant.
@junior466 Can you give any information? What changed? You reboot FreeNAS? What does your FreeNAS UI say the alert level and message are? Have you tried pulling the API response from your browser to make sure the information is what you expect it to be? You mess with your HA Config at all? Are there log errors in HA? What troubleshooting steps have you done?
@gremblin I did reboot FreeNAS. My alert level and messages are clear/none. The API response is simply []. Home Assistant shows unknown for state for sensor.freenas_alert_level and sensor.freenas_alert_message (I changed my sensors name to freenas).
Nothing has changed in my configuration. It was working fine before rebooting FreeNAS.
You should be prompted for a username and password. Also, if you have non ssl connections disabled, it may give you issues. Do you connect to your freenas via http or https?
Your config looks good. It sounds like there is an issue on your FreeNAS side. Which version of FreeNAS are you running? They are doing some changes to the API for v11.2
The rewrite from the old API to the new middlewared continues. Once the API stabilizes and the rewrite is complete, api.freenas.org will be deprecated and replaced by the new API documentation. In the mean time, to see the API documentation for the new middleware, log into the new UI, click on the URL for the FreeNAS system in your browser’s location bar, and add /api/docs to the end of that URL. Blog Post
I’m running v11.1, v11.2 gave me issues with my Ubuntu VM.
@gremblin I have a feeling I know what could be wrong. In your example, you have an alert for an update so that is why the sensor works in your case. When I had a critical alert when I first tried your config, it worked fine for me as well. It displayed Critical for level and showed the message about one of my hard disk’s temperature.
Now that is empty (no alerts), it doesn’t show anything so the status is unknown. I bet if you cleared that alert you would have the same issue.
facepalm OH YEAH! Right! Yes. It will be empty when all is well. Atleast your message will be. I thought the level would still show though. Mine is currently showing Level: OK, Msg: There is a new update available! Apply it in System -> Update tab. But my FreeNAS train is pointed to 11.2 Stable currently, even though I’ve reverted back to 11.1
But didn’t you say that your volume sensors were empty as well?
Volume sensor shows just fine. I may had a typo on the config before.
So isn’t there a way to map this unknown status to display CLEAR or something more user friendly?
By the way, Homeassistant also doesn’t like the empty state:
Error parsing value: list object has no element 0 (value: [], template: {{ value_json[0].level }})