Introduction
Network monitoring provides insights into system connectivity and resource usage. The ha_netstat-overview-card is a custom card for Home Assistant that visualizes network statistics in a structured format.
Why Use a Network Statistics Overview Card?
Monitoring network statistics allows users to track device connections, bandwidth usage, and overall network health. This card provides:
- Real-time visualization of network activity
- Clear differentiation between active and inactive connections
- Tracking of bandwidth consumption and performance metrics
Warning
Build this on a Fedora Linux host, I am not sure how netstat behaves on other OSes. Please add your solution in this blog based on your OS.
Features of ha_netstat-overview-card
This custom card provides:
- Network statistics visualization
- Integration with Home Assistant
- Real-time updates
- Customizable appearance
- Support for multiple network data sources
How to Install
To set up this custom card in Home Assistant:
-
Download the Card
Clone or download the repository from GitHub:git clone https://github.com/RoyOltmans/ha_netstat-overview-card
-
Add the Card to Home Assistant
Copy theha_netstat-overview-card
folder into thewww/community/
directory within your Home Assistant configuration. -
Include the Resource in Lovelace
Add the following toui-lovelace.yaml
:resources: - url: /local/community/ha_netstat-overview-card/ha_netstat-overview-card.js type: module
-
Sensor
Here’s the expected format and sensor.network_connections (Viewable in Developer Tools → States):
command_line:
- sensor:
name: Network Connections
command: "netstat -ntu | awk '{if (NR>2) print $4, $5}' | awk -F'[: ]+' '{print $(NF-3), $(NF-2), $(NF-1), $(NF)}' | grep -E '^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+ [0-9]+ [0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+ [0-9]+$' | jq -c -R '[inputs | capture(\"(?<source>[0-9.]+) (?<sport>[0-9]+) (?<target>[0-9.]+) (?<port>[0-9]+)\") | {source, sport: ( .sport | tonumber ), target, port: ( .port | tonumber )}] | {connections: .}'"
value_template: "{{ value_json.connections | length }}"
json_attributes:
- connections
scan_interval: 60
- Card Configuration
Place this in an single card panel
type: custom:netstat-overview-card
title: Netstat Overview
Considerations
This custom card displays network data but requires properly configured network monitoring sensors within Home Assistant. Users should ensure their system has the necessary data sources for accurate representation.
For more information or contributions, visit the project repository: ha_netstat-overview-card.