Skip to content

Commit 203f90e

Browse files
Merge pull request #22 from TheRealFalseReality/copilot/update-notification-water-change
Reorder notification to show water change recommendation before overall assessment and condense output
2 parents b95e860 + fbd6f31 commit 203f90e

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

custom_components/aquarium_ai/__init__.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,13 @@ def _build_notification_message(notification_format, sensor_data, sensor_mapping
303303
icon = get_sensor_icon(info['name'])
304304
message_parts.append(f"{icon} {info['name']}: {info['value']}")
305305

306-
# Add overall analysis only
306+
# Add water change recommendation before overall analysis
307307
if response and "data" in response:
308308
ai_data = response["data"]
309+
if "water_change_recommendation" in ai_data:
310+
message_parts.append(f"\n💧 Water Change:\n{ai_data['water_change_recommendation']}")
311+
312+
# Add overall analysis
309313
if "overall_notification_analysis" in ai_data:
310314
message_parts.append(f"\n🎯 Overall Assessment:\n{ai_data['overall_notification_analysis']}")
311315
else:
@@ -340,6 +344,10 @@ def _build_notification_message(notification_format, sensor_data, sensor_mapping
340344
else:
341345
message_parts.append(f"\n{sensor_name}: {ai_data[analysis_key]}")
342346

347+
# Add water change recommendation before overall analysis
348+
if "water_change_recommendation" in ai_data:
349+
message_parts.append(f"\n💧 Water Change: {ai_data['water_change_recommendation']}")
350+
343351
# Add overall brief analysis (same as used for sensors)
344352
if "overall_analysis" in ai_data:
345353
message_parts.append(f"\n🎯 Overall Assessment: {ai_data['overall_analysis']}")
@@ -375,18 +383,16 @@ def _build_notification_message(notification_format, sensor_data, sensor_mapping
375383
else:
376384
message_parts.append(f"\n{sensor_name}:\n{ai_data[notification_key]}")
377385

386+
# Add water change recommendation before overall analysis
387+
if "water_change_recommendation" in ai_data:
388+
message_parts.append(f"\n💧 Water Change:\n{ai_data['water_change_recommendation']}")
389+
378390
# Add overall detailed analysis
379391
if "overall_notification_analysis" in ai_data:
380392
message_parts.append(f"\n🎯 Overall Assessment:\n{ai_data['overall_notification_analysis']}")
381393
else:
382394
message_parts.append("No analysis available")
383395

384-
# Add water change recommendation at the end for all formats
385-
if response and "data" in response:
386-
ai_data = response["data"]
387-
if "water_change_recommendation" in ai_data:
388-
message_parts.append(f"\n💧 Water Change Recommendation:\n{ai_data['water_change_recommendation']}")
389-
390396
return "\n".join(message_parts)
391397

392398

@@ -504,7 +510,7 @@ async def send_ai_aquarium_analysis(now):
504510
"selector": {"text": None}
505511
}
506512
analysis_structure_notification["water_change_recommendation"] = {
507-
"description": "Detailed water change recommendation considering current parameters, bioload from inhabitants, filtration capacity, and water change schedule. If recommended, suggest approximate percentage and timing. Consider the relationship between water quality, stocking levels, filtration, and maintenance schedule.",
513+
"description": "Concise water change recommendation. If recommended, state the percentage and timing (e.g., '30% within 2-3 days' or '25% this week'). If not needed, state when next scheduled change is due based on maintenance schedule. Do not include generic benefits or explanations about why water changes are important - focus only on whether it's needed and when.",
508514
"required": True,
509515
"selector": {"text": None}
510516
}
@@ -551,7 +557,7 @@ async def send_ai_aquarium_analysis(now):
551557
For overall_notification_analysis: Detailed but short paragraph assessment without character limits.
552558
553559
For water_change_recommended: Answer 'Yes' or 'No' with a brief reason considering all factors (under 150 characters).
554-
For water_change_recommendation: Provide detailed recommendation considering water quality, bioload from inhabitants, filtration capacity, water change schedule, and time since last water change if provided. If a water change is recommended, suggest approximate percentage and timing.
560+
For water_change_recommendation: Keep it concise. State whether a water change is needed, and if so, specify the percentage and when (e.g., '30% within 2-3 days'). If not needed now, mention when the next scheduled change is due. Do not include generic text about benefits like 'to replenish minerals', 'to maintain optimal conditions', or explanations about why water changes are important. Focus only on the specific need and timing based on current parameters, bioload, filtration, water change schedule, and time since last change.
555561
556562
Consider the relationships between different parameters
557563
Consider impact on aquarium health when the parameters are negative to the aquarium health

0 commit comments

Comments
 (0)