# Uniform lighting naming rules

This project uses one canonical naming strategy for CODESYS, Node-RED, and Home Assistant.

## 1) Canonical token format

- All tokens are `snake_case`.
- Allowed chars: `a-z`, `0-9`, `_`.
- Normalize free text by:
  - lowercasing
  - trimming spaces
  - replacing spaces and dashes with `_`
  - collapsing repeated `_`
  - applying typo fixes (`ktchen -> kitchen`, `guiest -> guest`, `wachine -> laundry`)

## 2) Canonical data columns

Source of truth is `lights_zones_canonical.csv` with:

- `circuit_no`
- `zone`
- `area`
- `room`
- `light_type`
- `index` (duplicate counter for same area+room+light_type)
- `light_no` (PLC light channel inside room, 1..6)
- `codesys_in_key`
- `codesys_out_key`
- `nodered_room_key`
- `ha_entity_id`

## 3) ID generation formulas

- `codesys_in_key` = `<area>_<room>`
- `codesys_out_key` = `l_<area>_<room>`
- `nodered_room_key` = `<area>_<room>`
- `ha_entity_id` = `input_boolean.<area>_<room>_<light_type>_<index>`

Examples:

- `input_boolean.open_plan_living_room_main_1`
- `open_plan_guest_wc`
- `l_master_bedroom_suite`

## 4) PLC mapping rule

- `light_no` maps to CODESYS `l_<N>` and Node-RED `light`:
  - `light_no = 1` -> `l_1`
  - `light_no = 2` -> `l_2`
  - ...
  - `light_no = 6` -> `l_6`

## 5) Reserved room keys used in this migration

- `open_plan_living_room`
- `open_plan_dining_room`
- `open_plan_entrance`
- `open_plan_guest_wc`
- `kitchen_kitchen`
- `kitchen_pantry`
- `bedrooms_office`
- `bedrooms_hallway`
- `bedrooms_laundry`
- `bedrooms_shower`
- `bedrooms_bedroom`
- `master_bedroom_suite`
- `master_bedroom_bathroom`
- `exterior_veranda`
- `exterior_entrance`
- `exterior_yard`
