-
Notifications
You must be signed in to change notification settings - Fork 6
Conditional Entity System
The Monitor My Solar integration features an advanced conditional entity system that dynamically enables and disables entity settings based on configuration dependencies. This system ensures users can only configure settings that are valid for their current inverter configuration, preventing invalid configurations and providing clear visual feedback.
The conditional entity system automatically detects your inverter type and applies the appropriate logic:
- SmartLoad Enable/Disable: Controls which SmartLoads are active
- SOC/Volt vs Time Mode: Determines whether SmartLoads use SOC/Voltage or time-based settings
- Charge Control: Controls whether charge settings use Voltage or SOC mode
- Discharge Control: Controls whether discharge settings use Voltage or SOC mode
When entities are unavailable due to configuration dependencies:
- Always Visible: Entities remain visible in Home Assistant at all times
- Helpful Error Messages: When you try to interact with conditionally unavailable entities, you see clear error messages explaining why the entity is unavailable
- Dynamic Updates: Error messages automatically update when you change control settings
- HomeAssistantError Pattern: Uses Home Assistant's recommended pattern for conditional entities
When a SmartLoad is disabled, all related settings show error messages when used except the enable/disable switch itself.
Example: If SmartLoad3_Enable is false:
- ❌ All SmartLoad3 settings show error messages when used: "Smart Port 3 is set to 'Does Not Operate'"
- ✅ Only the
SmartLoad3_Enableswitch works normally
Each SmartLoad can operate in two modes:
Working Settings (can be used normally):
-
StartSOC,EndSOC- SOC-based start/end points -
StartVolt,EndVolt- Voltage-based start/end points -
SheddingStartSOC,SheddingEndSOC- SOC-based shedding -
SheddingStartVolt,SheddingEndVolt- Voltage-based shedding
Error Settings (show error messages when used):
- All time-based settings (
Start0,End0,Start1,End1, etc.) - Error: "Smart Port X is in SOC/Volt mode - Time settings not available"
Working Settings (can be used normally):
-
Start0,End0- First time period -
Start1,End1- Second time period -
Start2,End2- Third time period
Error Settings (show error messages when used):
- All SOC/Voltage-based settings - Error: "Smart Port X is in Time mode - SOC/Volt settings not available"
{
"SmartLoad": {
"Bits": {
"SmartLoad1_Enable": true,
"SmartLoad2_Enable": true,
"SmartLoad3_Enable": false,
"SmartLoad4_Enable": false
}
},
"SmartSOCVoltBits": {
"SmartLoad1_SOC_Volt": true,
"SmartLoad2_SOC_Volt": false,
"SmartLoad3_SOC_Volt": true,
"SmartLoad4_SOC_Volt": false
}
}Result:
- SmartLoad1: ✅ Enabled + SOC/Volt mode → SOC/Volt entities work normally, Time entities show error messages
- SmartLoad2: ✅ Enabled + Time mode → Time entities work normally, SOC/Volt entities show error messages
- SmartLoad3: ❌ Disabled → All entities show error messages (except Enable switch)
- SmartLoad4: ❌ Disabled → All entities show error messages (except Enable switch)
The charge control system has two main settings that determine which entities are available:
- "Voltage": Enables voltage-based charge settings
- "SOC": Enables SOC-based charge settings
- "Time According To": Enables time-based charge settings
- "SOC/Volt According To": Enables SOC/Voltage-based charge settings
- "Time and SOC/Volt According To": Enables both time and SOC/Voltage-based settings
Working (can be used normally):
-
ACChgStartVolt- AC Charge Start (Voltage) -
ACChgEndVolt- AC Charge End (Voltage)
Error (show error messages when used):
- All SOC-based charge settings - Error: "Charge control is set to 'Voltage' - SOC settings not available"
- All time-based charge settings - Error: "Charge type is set to 'SOC/Volt According To' - Time settings not available"
Working (can be used normally):
-
ACChgStartSOC- AC Charge Start (SOC) -
ACChgEndSOC- AC Charge End (SOC)
Error (show error messages when used):
- All voltage-based charge settings - Error: "Charge control is set to 'SOC' - Voltage settings not available"
- All time-based charge settings - Error: "Charge type is set to 'SOC/Volt According To' - Time settings not available"
Working (can be used normally):
- All time-based settings (
Time0throughTime47) - Time period settings (
ACChgStart,ACChgEnd, etc.)
Error (show error messages when used):
- All SOC/Voltage-based charge settings - Error: "Charge type is set to 'Time According To' - SOC/Volt settings not available"
Working (can be used normally):
- All time-based settings
- SOC/Voltage-based settings (based on
ubBatChgcontrolsetting)
Error (show error messages when used):
- None (all charge entities work normally)
- "Voltage": Enables voltage-based discharge settings
- "SOC": Enables SOC-based discharge settings
Working (can be used normally):
-
ForceDichgEndVolt- Stop Discharge (Voltage)
Error (shows error message when used):
-
ForcedDischgSOCLimit- Force Discharge SOC Limit - Error: "Discharge control is set to 'Voltage' - SOC settings not available"
Working (can be used normally):
-
ForcedDischgSOCLimit- Force Discharge SOC Limit
Error (shows error message when used):
-
ForceDichgEndVolt- Stop Discharge (Voltage) - Error: "Discharge control is set to 'SOC' - Voltage settings not available"
- You have
SmartLoad1enabled in SOC/Volt mode - You change
SmartLoad1_SOC_Volttofalse(Time mode) - Immediately: SOC/Volt entities show error messages when used: "Smart Port 1 is in Time mode - SOC/Volt settings not available"
- Immediately: Time entities work normally
- No restart or refresh needed
- You have
SmartLoad2configured with various settings - You set
SmartLoad2_Enabletofalse - Immediately: All SmartLoad2 settings show error messages when used: "Smart Port 2 is set to 'Does Not Operate'"
-
Immediately: Only the
SmartLoad2_Enableswitch works normally
- You set
ubBatChgcontrolto "Voltage" - You set
ACChargeTypeto "SOC/Volt According To" -
Working:
ACChgStartVolt,ACChgEndVolt(can be used normally) - Error: All SOC and time-based charge settings show error messages when used
- Prevents Invalid Configurations: You cannot set conflicting settings
- Clear Error Messages: You see helpful error messages explaining why entities are unavailable
- Always Visible: Entities remain visible at all times, making the interface more predictable
- Dynamic Behavior: Error messages automatically update when dependencies change
- Immediate Response: Changes to control settings trigger instant availability updates
- Unified System: Same conditional logic works for both GridBoss and standard units
- No Breaking Changes: Existing functionality remains intact
- Automatic Detection: System automatically detects unit type and applies appropriate logic
- Home Assistant Best Practice: Uses the recommended HomeAssistantError pattern
- The system uses Home Assistant's recommended
HomeAssistantErrorpattern - Entities remain available at all times but show error messages when used inappropriately
- Entity availability updates are triggered asynchronously
- The system gracefully handles missing or incomplete configuration data
- All changes are backward compatible
- Control setting changes trigger instant availability updates via MQTT processing
- Detailed error messages explain exactly why entities are unavailable
If entities don't update when you change control settings:
- Check that your dongle is connected and communicating
- Verify the control setting change was successful
- Wait a few seconds for the update to propagate
- Check the Home Assistant logs for any error messages
If all entities show error messages when used:
- Check your dongle connection status
- Verify the inverter is responding to MQTT messages
- Check that the coordinator is receiving updates successfully
If entities show the wrong error messages for your configuration:
- Verify your control settings are set correctly
- Check that your inverter type is detected properly
- Review the entity classification in the logs
The conditional entity system is designed to be extensible. Future enhancements may include:
- Additional conditional settings for more complex configurations
- Visual indicators in the configuration flow
- Automation support for entity availability
- Cross-unit dependencies for multi-inverter setups