Files
kkelomatic_home/docs/redesign/fb_switch-analysis-summary.md
nearxos bf7bd56fe7 Initial commit: Home automation docs and CODESYS project
- Reorganized project: codesys/, docs/codesys|redesign|integration|reference/, scripts/
- CODESYS project and exports in codesys/
- Documentation index in docs/README.md
- Redesign and light naming configuration
- Water boiler control and safety design

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-07 21:52:46 +02:00

2.5 KiB

fb_switch Analysis Summary

Quick Assessment

Current Approach: ⚠️ Needs Improvement

Main Issue: Toggle-based control causes state desynchronization with Home Assistant.

Key Problems

1. State Desynchronization

  • Problem: HA sends ON/OFF commands, but CODESYS toggles
  • Result: HA thinks light is ON, sends ON again → CODESYS toggles it OFF
  • Impact: Lights don't match HA state

2. No Status Feedback

  • Problem: Status comes from toggle button, not actual relay
  • Result: Can't detect relay hardware failures
  • Impact: HA may show wrong status

3. Mixed Control Sources

  • Problem: HA and Zigbee both use same toggle mechanism
  • Result: Conflicting behaviors
  • Impact: Unpredictable control

What You Need

Control from Home Assistant (ON/OFF switches)
Control from Zigbee switches (toggle behavior)
Status feedback (actual relay state)

  • Separate ON/OFF commands for HA
  • Edge detection for Zigbee (toggle)
  • Read actual relay status from EtherCAT
  • Clear priority system

Pros: Clean, maintainable, extensible
Cons: Requires more changes

Option 2: Simplified Improvement

  • Add ON/OFF commands alongside toggle
  • Keep most existing structure
  • Add status feedback

Pros: Less changes, faster to implement
Cons: Less clean, still some complexity

Quick Fix (Minimal Changes)

If you need a quick fix while planning the redesign:

  1. In Node-RED: Convert HA ON/OFF to edge pulses

    // Only send toggle on state change
    if (currentState !== newState) {
        sendToggle = true;
    }
    
  2. Add status readback: Read actual EtherCAT output state

    lights.l_1_status := EtherCAT_Output_Channel_1;
    
  3. Update HA: Use state topic for status feedback

Decision Matrix

Approach Complexity Time Maintainability Recommended For
Full Redesign High 2-3 days Excellent Long-term solution
Simplified Medium 1 day Good Quick improvement
Quick Fix Low 2-4 hours Fair Temporary solution

My Recommendation

Start with Quick FixThen implement SimplifiedPlan Full Redesign

This gives you:

  1. Immediate working solution
  2. Better solution in short term
  3. Best solution for long term

See: Full Redesign Recommendation for detailed implementation.