Strands SDK is an open-source Python SDK for implementing AI agents. It manages the agent loop: reasoning across steps, executing tools, and maintaining context. A tool is a function the agent can call to obtain data or interact with another system; it is not just another prompt. section 8.4.3
For home climate control, an agent can combine current solar output, a weather forecast, and indoor conditions before deciding whether to run the HVAC system. The @tool decorator exposes a Python function to the agent. Its documentation should specify when to call it, its inputs, and its returned data. section 8.4.3
Listing 8.10 Tool to query Fronius Symo inverter power data
from strands import tool
@tool #1
def get_realtime_solar_data(scope: str = "System") -> Dict[str, Any]:
""" #2
Fetches real-time solar production metrics from the local Fronius
inverter.
Use this tool when you need to know the current solar output (PAC) or
the total energy produced today (DAY_ENERGY).
Args:
scope: The data scope to query. Defaults to "System".
Returns:
Dict[str, Any]: A dictionary containing:
- current_power_w: Current AC power output in Watts.
- day_energy_wh: Total energy produced today in Watt-hours.
- timestamp: The time of the reading.
"""
url = "http://192.168.1.180/solar_api/v1/GetInverterRealtimeData.cgi" #3
try:
response = requests.get(url, params={"Scope": scope}, timeout=5)
response.raise_for_status()
data = response.json()
realtime_data = data.get("Body", {}).get("Data", {})
pac_value = realtime_data.get("PAC", {}).get("Values", {}).
get("1", 0)
day_energy = realtime_data.get("DAY_ENERGY", {}).get("Values",
{}).get("1", 0)
return {
"current_power_w": pac_value,
"day_energy_wh": day_energy,
"timestamp": data.get("Head", {}).get("Timestamp"),
"status": "success",
}
except requests.RequestException as e:
return {
"status": "error",
"message": f"Failed to connect to inverter: {str(e)}",
}
The inverter tool shows a documented @tool function that requests live solar data and returns current power, daily energy, and a timestamp. section 8.4.3
Listing 8.11 Agent with Strands SDK for home climate control
import datetime
from strands import Agent
current_time_str = datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ")
system_prompt = f""" #1
### ROLE
Climate Control Agent. Current Time: {current_time_str}.
### CONSTANTS
- **Target Temp:** 21°C–24°C
- **AC Load:** 1500W
- **Baseload:** 1000W (08:00–16:00); 200W (otherwise).
### CONTROL POLICY
1. **Fetch Data:** Get current solar ($P_{{solar}}$), forecast,
and indoor temp ($T_{{room}}$ (last 24 hours).
2. **Calculate Excess:** $P_{{excess}} = P_{{solar}} - \\text{{Baseload}}$.
3. **Evaluate State:**
- **COOLING NEEDED** if $T_{{room}} > 24°C$.
- **OPPORTUNISTIC COOLING** if $P_{{excess}} > 1500W$ AND $T_{{room}} >
21°C$ (Priority: Solar).
- **IDLE** otherwise.
4. **Safety:** Apply hysteresis (don't cycle AC if state changed
<15 mins ago).
5. **Priorities:** Always prioritize minimizing grid consumption
over comfort.
### OUTPUT INSTRUCTION
Output a concise reasoning step (e.g., "Excess solar 1600W > AC Load;
engaging cooling."), then call `set_aircon_state` if a change is needed.
"""
agent = Agent( #2
name="ClimateAgent",
system_prompt=system_prompt,
tools=[
get_realtime_solar_data,
get_weather_forecast,
get_space_climate_history,
set_aircon_state,
],
)
The agent prompt turns the retrieved data into a control policy: calculate excess solar power, check temperature thresholds, and avoid rapid AC cycling. section 8.4.3
