Goal: Connect your smart laser printer (Brother MFC-L2710DW) via IPP and SNMP to track diagnostic stats (toner levels, drum life, fuser health, page counters).
Before jumping into the script code, it is important to understand why command-line scripts are extremely useful for modern smart homes. Beyond convenience for terminal users, these CLI scripts act as a programmatic interface (API bridge) for agentic AI assistants like Antigravity (agy).
By exposing Home Assistant states through standard shell scripts, an AI agent running in your workspace can query, check, and verify live IoT metrics or network states autonomously. This enables the agent to check if the network is healthy, read environment levels, or verify configurations without having to scrape web-based dashboards or utilize complex browser interfaces. It bridges human developer terminal workflows with agentic automation.
Step-by-Step Configuration
1. Network Setup & IPP Auto-Discovery
Home Assistant Core discovers IPP network printers automatically via mDNS on your local network:
- Ensure your Brother printer is powered on and connected to the same subnet (e.g., static IP
192.168.1.204). - In Home Assistant UI, navigate to Settings -> Devices & Services.
- You will see Brother MFC-L2710DW series in the discovered list. Click Configure.
- Confirm the IP address and submit. This creates the IPP printer entity.
2. Configure Advanced SNMP Metrics
To extract advanced hardware indicators (toner remaining, fuser life, fuser counters), configure the native Brother integration:
- Navigate to Settings -> Devices & Services -> Add Integration.
- Search and select Brother.
- Enter the printer’s static IP address (
192.168.1.204). - Select your printer model. The integration will query the printer over SNMP (Port 161) to import remaining toner sensors.
3. Querying Printer Diagnostics via CLI
Once configured, all status sensors will populate. You can query pages printed or toner remaining using your CLI bridge:
# Check how much black toner is remaining
$ /home/gvoina/scripts/get_ha_sensor.sh sensor.mfc_l2710dw_black_toner_remaining
MFC-L2710DW Black Toner Remaining: 80 %
# Check the fuser page counter (total prints)
$ /home/gvoina/scripts/get_ha_sensor.sh sensor.mfc_l2710dw_page_counter
MFC-L2710DW Page Counter: 12540 pages
# Check drum life expectancy
$ /home/gvoina/scripts/get_ha_sensor.sh sensor.mfc_l2710dw_drum_remaining_lifetime
MFC-L2710DW Drum Remaining Lifetime: 92 %
# Check if the printer is printing or sleeping
$ /home/gvoina/scripts/get_ha_sensor.sh sensor.mfc_l2710dw_status
MFC-L2710DW Status: sleep
Now you can set up automations to send you a notification when toner drops below 10%!
