Hands-on with Augment Code(3 min read)

Augment Code, one of the new AI-powered coding assistants, promises to make software development faster and more intuitive. But does it hold up in real-world scenarios, beyond demo apps and sample code?

Open source software provides a great opportunity to learn these tools with real code, solving real problems. Plus you get to contribute back to the community.

I decided to put Augment Code through its paces by solving a practical improvement I wanted to make to the pysunspec2 project, involving home IoT devices and solar energy controllers.

Tackling Real-World Complexity

I chose to test Augment Code on the pysunspec2 library, used by the Home Assistant SunSpec plugin. This library is used to communicate to local solar systems and provide real time data via Sunspec over TCP.

While configuring for my local SolarEdge controllers, I encountered issues configuring multiple controllers with the same IP but different Unit IDs. HA-Sunspec allows multiple configurations with the same IP address but different Unit IDs, but it wasn't working.

I tracked the issue down to the SolarEdge Sunspec technical documentation that states:

"Only a single connection and session are supported." (p. 13)

The HA-Sunspec component used different connections for each configuration, i.e. it used a separate connection even though the Unit ID is just a parameter passed in the protocol. To fix this I need to change the library, and then HA-Sunspec, to support multiple units on the one TCP connection.

My current work around is to just configure one unit, and then double the value, as the two units are similar. Making the change was a great opportunity to test out Augment Code on a real problem, while also providing something practical I could use.

Integrating Augment Code

To address this, my idea was to enhance HA-SunSpec's underlying Python library, pysunspec2, to manage multiple Unit IDs through a single connection. Augment Code seamlessly integrated into VS Code as a local agent, providing interactive feedback as it worked through my requirements.

Initially, I thought it would be straightforward—just replacing read() and write() functions with variants accepting unit parameters.

Augment Code executed these modifications swiftly, complete with unit tests and documentation updates.

Refining the Solution

However, deeper investigation revealed that a higher-level API with dynamic scanning capabilities (scan()) existed, making direct changes less practical. Instead, a structured object model was needed.

Augment Code required more guidance here, but eventually, it helped implement a cleaner solution:

d = client.SunSpecModbusClientDeviceTCP(unit_id=1, ipaddr='192.168.1.100', ipport=502)
d.connect()
d.scan_units([1, 2])
# Old API - implied unit_id=1
print(f"{d.common[0].Mn.value}")
# New API
print(f"{d.Units[2].common[0].Mn.value}")

This structure allowed scanning multiple Unit IDs simultaneously and provided backward compatibility.

The pull request has about 500 new lines — across code, tests, and documentation — and 50 changed lines.

The Value of AI Collaboration

Although guiding Augment Code through this advanced pattern took a bit more time — around a day compared to a couple of hours for the simpler initial fix — it significantly accelerated development compared to my solo effort, particularly given my limited Python experience.

Using an agent was particularly good for some routine work like updating tests and generating documentation, and it is intesting watching the agent work through cyckles of change, run tests, check results, fix.

Next Steps

If you want to get started using AI agents, demo apps and sample code are not enough — instead pick an open source project in domain you like, or heavily use, and start using AI.

This doesn't have to be just coding, as many open source projects also need testing and documentation.

You can learn so much more by using the tools in anger on real problems, so get started now!

Have you used AI tools like Augment Code to tackle real-world coding challenges? Share your experiences below!

Leave a Reply

Your email address will not be published. Required fields are marked *