# Redesign Implementation Roadmap ## Overview This document provides a step-by-step roadmap for implementing the redesigned structure based on the light naming configuration. ## Phase 1: Configuration & Planning ### Step 1.1: Review Light Naming Configuration - [ ] Review `light-naming-configuration.md` - [ ] Modify light names per room based on actual installation - [ ] Remove unused lights from structure - [ ] Add any missing lights - [ ] Document relay-to-light mapping ### Step 1.2: Map Relays to Lights - [ ] Create mapping table: Relay # → Room → Light Name - [ ] Document in `relay-mapping.md` - [ ] Verify all relays are accounted for **Example Mapping**: ``` Relay 1 → kitchen → main Relay 2 → kitchen → under_cabinet Relay 3 → kitchen → island Relay 4 → master_bedroom → main Relay 5 → master_bedroom → bedside_left ... ``` ### Step 1.3: Water Boiler Configuration - [ ] Review water boiler safety requirements - [ ] Configure temperature limits - [ ] Configure time limits (max ON, min OFF) - [ ] Identify sensor inputs (temperature, flow, pressure) - [ ] Map boiler relay output --- ## Phase 2: CODESYS Structure Implementation ### Step 2.1: Create New Data Structures - [ ] Create `struct_light_control` type - [ ] Create `struct_water_boiler` type - [ ] Create room-specific structures - [ ] Create global `rooms` structure ### Step 2.2: Create Function Blocks - [ ] Create `fb_lightControl` function block - [ ] Create `fb_waterBoiler` function block - [ ] Test function blocks in simulation ### Step 2.3: Update Network Variables - [ ] Update `NVL_Sender` with new structure - [ ] Update `NVL_Receiver` with new structure - [ ] Add water boiler network variables - [ ] Configure network variable properties ### Step 2.4: Implement Control Logic - [ ] Replace `fb_switch` with new structure - [ ] Implement light control per room - [ ] Implement water boiler control - [ ] Add relay output mapping - [ ] Add relay status readback ### Step 2.5: Testing - [ ] Test in simulation - [ ] Test individual light control - [ ] Test water boiler control - [ ] Test safety measures - [ ] Verify network variable transmission --- ## Phase 3: Node-RED Integration ### Step 3.1: Update Network Variable Nodes - [ ] Update CODESYS network variable nodes - [ ] Configure new variable structure - [ ] Test bidirectional communication ### Step 3.2: Create Transformation Functions - [ ] Create function to flatten room structure for HA - [ ] Create function to convert HA commands to CODESYS format - [ ] Create function for Zigbee edge detection - [ ] Test transformations ### Step 3.3: Update MQTT Flows - [ ] Update MQTT topics to new naming convention - [ ] Configure Home Assistant auto-discovery - [ ] Update Zigbee switch flows - [ ] Add water boiler MQTT flows ### Step 3.4: Testing - [ ] Test HA → CODESYS commands - [ ] Test Zigbee → CODESYS commands - [ ] Test CODESYS → HA status updates - [ ] Test water boiler control - [ ] Verify MQTT message flow --- ## Phase 4: Home Assistant Configuration ### Step 4.1: Entity Configuration - [ ] Create light entities for all lights - [ ] Configure entity names and icons - [ ] Set up areas/rooms in HA - [ ] Create water boiler entity ### Step 4.2: Dashboard Setup - [ ] Create lighting dashboard - [ ] Group lights by room - [ ] Add water boiler control - [ ] Add status indicators ### Step 4.3: Automations - [ ] Update existing automations - [ ] Create new automations if needed - [ ] Test automations --- ## Phase 5: Migration & Deployment ### Step 5.1: Backup Current System - [ ] Backup CODESYS project - [ ] Export Node-RED flows - [ ] Backup Home Assistant configuration - [ ] Document current state ### Step 5.2: Parallel Testing - [ ] Deploy new structure in test mode - [ ] Run parallel with old system - [ ] Compare behavior - [ ] Fix any issues ### Step 5.3: Gradual Migration - [ ] Migrate one room at a time - [ ] Test each room thoroughly - [ ] Migrate water boiler - [ ] Complete migration ### Step 5.4: Validation - [ ] Test all lights from HA - [ ] Test all lights from Zigbee switches - [ ] Verify status feedback - [ ] Test water boiler control - [ ] Test all safety measures - [ ] Verify no regressions --- ## Implementation Checklist ### CODESYS - [ ] New data structures defined - [ ] Function blocks created and tested - [ ] Network variables updated - [ ] Control logic implemented - [ ] Relay mapping configured - [ ] Status readback implemented - [ ] Water boiler safety measures implemented - [ ] Code tested in simulation ### Node-RED - [ ] Network variable nodes updated - [ ] Transformation functions created - [ ] MQTT flows updated - [ ] HA auto-discovery configured - [ ] Zigbee integration updated - [ ] Water boiler flows added - [ ] All flows tested ### Home Assistant - [ ] All light entities created - [ ] Water boiler entity created - [ ] Areas/rooms configured - [ ] Dashboard updated - [ ] Automations updated - [ ] All entities tested ### Documentation - [ ] Light naming configuration finalized - [ ] Relay mapping documented - [ ] Network variable structure documented - [ ] MQTT topics documented - [ ] Safety measures documented - [ ] Troubleshooting guide updated --- ## Key Files Reference 1. **Light Configuration**: `light-naming-configuration.md` 2. **Structure Analysis**: `structure-redesign-analysis.md` 3. **Visual Comparison**: `structure-comparison-visual.md` 4. **Function Block Redesign**: `fb_switch-redesign-recommendation.md` 5. **This Roadmap**: `redesign-implementation-roadmap.md` --- ## Estimated Timeline - **Phase 1** (Planning): 1-2 days - **Phase 2** (CODESYS): 2-3 days - **Phase 3** (Node-RED): 1-2 days - **Phase 4** (Home Assistant): 1 day - **Phase 5** (Migration): 2-3 days **Total**: ~7-11 days (depending on complexity and testing) --- ## Risk Mitigation ### Risks 1. **Network Variable Changes**: May break existing Node-RED flows - **Mitigation**: Test thoroughly, have rollback plan 2. **State Synchronization**: During migration, states may be inconsistent - **Mitigation**: Migrate during low-usage period, verify all states 3. **Water Boiler Safety**: Critical system, must work correctly - **Mitigation**: Extensive testing, manual override available 4. **Home Assistant Entities**: May need to recreate entities - **Mitigation**: Use unique_id to preserve entity history ### Rollback Plan - Keep old CODESYS project as backup - Keep old Node-RED flows as backup - Document rollback procedure - Test rollback procedure --- **Status**: Planning Phase **Next Step**: Review and modify `light-naming-configuration.md` with actual light configuration