This document outlines the comprehensive integration of Homey Web API into NSPanelManager to enable control of Homey devices (lights, switches, buttons, thermostats) and scenes (Flows and Moods). This integration follows the same architecture pattern as existing Home Assistant and OpenHAB integrations.
- Lights: Devices with capabilities
onoff,dim,light_hue,light_saturation,light_temperature,light_mode - Switches: Devices with capability
onoff - Buttons: Devices with capability
onoff - Thermostats: Devices with capabilities
target_temperature,measure_temperature,thermostat_mode - Scenes: Homey Flows (prefixed with
[F]) and Moods (prefixed with[M])
- Homey IP address or mDNS name (e.g.,
homey.local) - Homey API key (generated in Homey app)
- Settings stored in NSPanelManager database
- WebSocket connection for real-time device state synchronization
- Event-driven architecture similar to Home Assistant integration
- Homey as third integration option alongside HA and OpenHAB
- Settings configuration page for Homey credentials
- Entity selection and filtering by capability
- Scene naming with [F] and [M] prefixes
┌─────────────────────────────────┐
│ Web Interface (Python) │
├─────────────────────────────────┤
│ • homey_api.py (HTTP requests) │
│ • api.py (extend entity fetching)│
│ • htmx.py (UI integration) │
└──────────────┬──────────────────┘
│
┌──────┴──────────┐
│ │
┌────▼─────┐ ┌──────▼──────────┐
│ SQLite │ │ Homey API │
│ Database │ │ (HTTP/REST) │
└──────────┘ └──────┬──────────┘
│
┌─────────────────────────┴───────────────────────┐
│ MQTTManager (C++) │
├─────────────────────────────────────────────────┤
│ • HomeyManager (WebSocket) │
│ • HomeyLight / HomeySwitch / HomeyThermostat │
│ • HomeyButton / HomeyScene │
│ • EntityManager (instantiation logic) │
└─────────────────────────────────────────────────┘
Status: ✅ COMPLETED
- Add
homey_addresssetting to database - Add
homey_tokensetting to database - Create settings UI in web interface (
templates/settings.html) - Add Homey section to initial setup wizard (
templates/modals/initial_setup/homey.html) - Implement settings persistence (with token masking and clear functionality)
- Create API key generation guide
- Document Homey IP address configuration
- Document settings validation
Deliverables:
- ✅ Python homey_api.py module created with device/flow/mood discovery
- ✅ Settings stored in web_settings table
- ✅ UI form for Homey configuration in templates/settings.html (complete with token masking)
- ✅ Initial setup step for Homey in templates/modals/initial_setup/homey.html
- ✅ Settings persistence with secure token handling
Status: ✅ COMPLETED
- Create
docker/web/nspanelmanager/web/homey_api.py - Implement
get_all_homey_devices() - Implement capability filtering logic
- Implement
get_all_homey_flows() - Implement
get_all_homey_moods() - Implement error handling and logging
- Add Homey to
get_all_available_entities()inapi.py - Filter devices by supported capabilities
- Add [F] prefix to Flow names
- Add [M] prefix to Mood names
- Return standardized entity format
- Extend entity source selection in
htmx.py - Add Homey option to
partial_add_entity_to_entities_page_select_entity_source() - Add Homey to supported entity types lists (all 5 types supported!)
- Implement entity-specific configuration screens
Deliverables:
- ✅
homey_api.pymodule with device discovery - ✅ Integration with
get_all_available_entities()in api.py - ✅ Complete UI integration in htmx.py for all entity types
Status: ✅ COMPLETED
- Extend
partial_entity_add_light_entity()for Homey - Extend
partial_entity_edit_light_entity()for Homey - Extend
create_or_update_light_entity()for Homey - Store Homey device ID in entity_data JSON
- Store capability list in entity_data JSON
- Map light properties (can_dim, can_color_temperature, can_rgb)
- Extend
partial_entity_add_switch_entity()for Homey - Extend
partial_entity_edit_switch_entity()for Homey - Extend
create_or_update_switch_entity()for Homey - Store Homey device ID in entity_data JSON
- Extend
partial_entity_add_button_entity()for Homey - Extend
partial_entity_edit_button_entity()for Homey - Extend
create_or_update_button_entity()for Homey - Store Homey device ID in entity_data JSON
- Template exists:
templates/partial/select_entity/entity_add_or_edit_thermostat_to_room.html - Extend
partial_entity_add_thermostat_entity()for Homey (with capability filtering!) - Extend
partial_entity_edit_thermostat_entity()for Homey (with capability filtering!) - Extend
create_or_update_thermostat_entity()for Homey - Store Homey device ID in entity_data JSON
- Extend
partial_entity_add_scene_entity()for Homey (Flows & Moods) - Extend
create_or_update_scene_entity()for Homey - Store Homey flow/mood ID in backend_name
- Support for both Flows and Moods
Entity Data JSON Structures:
Light:
{
"controller": "homey",
"homey_device_id": "device-uuid",
"can_dim": true,
"can_color_temperature": true,
"can_rgb": true,
"capabilities": ["onoff", "dim", "light_temperature", "light_hue", "light_saturation"]
}Switch:
{
"controller": "homey",
"homey_device_id": "device-uuid",
"capabilities": ["onoff"]
}Button:
{
"controller": "homey",
"homey_device_id": "device-uuid",
"capabilities": ["onoff"]
}Thermostat:
{
"controller": "homey",
"homey_device_id": "device-uuid",
"capabilities": ["target_temperature", "measure_temperature", "thermostat_mode"]
}Scene:
{
"controller": "homey",
"homey_id": "flow-or-mood-uuid",
"homey_type": "flow" // or "mood"
}Deliverables:
- ✅ Entity creation UI for all Homey entity types (Light, Switch, Button, Thermostat, Scene)
- ✅ Entity edit UI for all Homey entity types
- ✅ Proper storage of Homey-specific data (device IDs, capabilities)
- ✅ Database records with correct controller type
- ✅ Special thermostat filtering for devices with temperature capabilities
Status: ✅ COMPLETED
- Create
docker/MQTTManager/include/homey_manager/homey_manager.hpp - Define class structure (static methods, WebSocket, events)
- Define configuration struct
- Define observer/signal pattern
- Implement
init()- Start thread and WebSocket - Implement
connect()- Connect to Homey WebSocket - Implement
reload_config()- Reload from database - Implement authentication with API key
- Implement WebSocket message handling
- Implement device event processing
- Implement observer pattern for entity updates
- Implement disconnect/reconnect logic
- Add comprehensive logging
- Load homey_address from settings
- Load homey_token from settings
- Handle configuration changes
- Validate credentials
Deliverables:
- ✅ Functional HomeyManager with WebSocket connection
- ✅ Real-time device event handling
- ✅ Observer pattern for entity state changes
Status: ✅ COMPLETED (including thermostat!)
- Create
docker/MQTTManager/include/light/homey_light.hpp - Create
docker/MQTTManager/include/light/homey_light.cpp - Extend Light base class
- Implement state synchronization
- Implement brightness control
- Implement color temperature control
- Implement RGB color control
- Implement hue/saturation control
- Handle device events from HomeyManager
- Implement
send_state_update_to_controller()
- Create
docker/MQTTManager/include/switch/homey_switch.hpp - Create
docker/MQTTManager/include/switch/homey_switch.cpp - Extend SwitchEntity base class
- Implement on/off control
- Handle device events
- Implement
send_state_update_to_controller()
- Create
docker/MQTTManager/include/button/homey_button.hpp - Create
docker/MQTTManager/include/button/homey_button.cpp - Extend ButtonEntity base class
- Implement button press triggering
- Handle device events
- Implement
send_state_update_to_controller()
- Create
docker/MQTTManager/include/scenes/homey_scene.hpp - Create
docker/MQTTManager/include/scenes/homey_scene.cpp - Extend Scene base class
- Support both Flows and Moods
- Implement scene activation
- Store and detect scene type (flow/mood)
- Create
docker/MQTTManager/include/thermostat/homey_thermostat.hpp - Create
docker/MQTTManager/include/thermostat/homey_thermostat.cpp - Extend ThermostatEntity base class
- Implement temperature control
- Handle device events
- Implement
send_state_update_to_controller()
Deliverables:
- ✅ All five entity types implemented (Light, Switch, Button, Scene, Thermostat)
- ✅ Full control capabilities
- ✅ Proper state synchronization
Status: ✅ COMPLETED
- Modify
load_lights()- Add Homey light instantiation - Modify
load_switches()- Add Homey switch instantiation - Modify
load_buttons()- Add Homey button instantiation - Modify
load_scenes()- Add Homey scene instantiation - Modify
load_thermostats()- Add Homey thermostat instantiation - Add includes for new Homey entity headers
- Add HomeyManager to CMakeLists.txt
- Add Homey source files for Light to CMakeLists.txt
- Add Homey source files for Switch to CMakeLists.txt
- Add Homey source files for Button to CMakeLists.txt
- Add Homey source files for Scene to CMakeLists.txt
- Add Homey source files for Thermostat to CMakeLists.txt
- Ensure compilation of new modules
- Verify dependency linking
- Initialize HomeyManager in application startup
- Ensure proper thread management
- Handle shutdown gracefully
Deliverables:
- ✅ EntityManager properly instantiates all Homey entity types
- ✅ Project compiles with all new files
- ✅ HomeyManager starts on application launch
Status: ⬜ NOT STARTED
- Test Homey API connectivity
- Test capability filtering
- Test entity data storage/retrieval
- Test WebSocket connection handling
- Test device state synchronization
- Test thermostat functionality
- Test light control (on/off, brightness, color)
- Test switch control
- Test button triggering
- Test scene activation
- Test thermostat control
- Test real-time updates
- Test reconnection logic
- Test configuration changes
- Verify database records
- Check WebSocket logs
- Monitor entity state changes
- Test error scenarios
- Validate API compatibility
Deliverables:
- Comprehensive test coverage
- Bug fixes and refinements
- Performance validation
Status: ⬜ NOT STARTED
- Create Homey setup guide
- Document API key generation
- Document supported device types
- Create troubleshooting guide
- Add thermostat documentation
- Document HomeyManager API
- Document entity classes
- Add code comments for complex logic
- Create architecture diagrams
- Improve error messages
- Add connection status indicators
- Enhance entity filtering UI
- Add validation feedback
- Polish entity creation workflows
Deliverables:
- Complete user documentation
- Code documentation
- Polished UI/UX
docker/web/nspanelmanager/web/
├── homey_api.py ✅ CREATED
docker/web/nspanelmanager/web/templates/modals/initial_setup/
├── homey.html ✅ CREATED
docker/web/nspanelmanager/web/templates/partial/select_entity/
├── entity_add_or_edit_thermostat_to_room.html ✅ EXISTS
docker/MQTTManager/include/
├── homey_manager/
│ ├── homey_manager.hpp ✅ CREATED
│ └── homey_manager.cpp ✅ CREATED
├── light/
│ ├── homey_light.hpp ✅ CREATED
│ └── homey_light.cpp ✅ CREATED
├── switch/
│ ├── homey_switch.hpp ✅ CREATED
│ └── homey_switch.cpp ✅ CREATED
├── button/
│ ├── homey_button.hpp ✅ CREATED
│ └── homey_button.cpp ✅ CREATED
├── thermostat/
│ ├── homey_thermostat.hpp ✅ CREATED
│ └── homey_thermostat.cpp ✅ CREATED
└── scenes/
├── homey_scene.hpp ✅ CREATED
└── homey_scene.cpp ✅ CREATED
docker/web/nspanelmanager/web/
├── api.py ✅ MODIFIED (Homey integration)
├── htmx.py ✅ MODIFIED (Complete Homey support for all entities)
├── templates/settings.html ✅ MODIFIED (Homey settings section)
docker/MQTTManager/
├── CMakeLists.txt ✅ MODIFIED (All Homey components)
├── include/entity_manager/
│ ├── entity_manager.hpp ✅ MODIFIED (Homey includes)
│ └── entity_manager.cpp ✅ MODIFIED (Homey entity loading)
GET http://{homey_address}/api/manager/devices/device
Headers: Authorization: Bearer {api_key}
Response includes device data with capabilities.
GET http://{homey_address}/api/manager/flow/flow
Headers: Authorization: Bearer {api_key}
Access via devices or dedicated mood endpoints.
GET http://{homey_address}/api/manager/moods/mood
Headers: Authorization: Bearer {api_key}
PUT http://{homey_address}/api/manager/devices/device/{device_id}/capability/{capability_id}
Headers: Authorization: Bearer {api_key}
Body: { "value": <capability_value> }
POST http://{homey_address}/api/manager/flow/flow/{flow_id}/trigger
Headers: Authorization: Bearer {api_key}
POST http://{homey_address}/api/manager/moods/mood/{mood_id}/set
Headers: Authorization: Bearer {api_key}
ws://{homey_address}/api/manager/devices/device?token={api_key}
{
"type": "device.update",
"device": {
"id": "device-uuid",
"capabilities": {
"onoff": { "value": true },
"dim": { "value": 0.85 },
"light_temperature": { "value": 4000 }
}
}
}| Homey Capability | NSPanel Feature | Data Type | Range |
|---|---|---|---|
onoff |
On/Off toggle | Boolean | true/false |
dim |
Brightness | Float (decimal) | 0.0 - 1.0 → 0-100% |
light_hue |
Hue | Float | 0.0 - 1.0 → 0-360° |
light_saturation |
Saturation | Float | 0.0 - 1.0 → 0-100% |
light_temperature |
Color Temp | Integer | 0.0 - 1.0 → Kelvin (1000-10000) |
light_mode |
Light Mode | String | (mode-specific) |
button |
Button Press | (trigger) | (event-based) |
target_temperature |
Target Temp | Float | (°C) |
measure_temperature |
Current Temp | Float | (°C) |
thermostat_mode |
Thermostat Mode | String | (heat/cool/auto) |
Uses existing Entity and Scene tables with controller field in entity_data JSON.
Light Entity:
{
"controller": "homey",
"homey_device_id": "<uuid>",
"homey_device_name": "<name>",
"can_dim": true,
"can_color_temperature": true,
"can_rgb": true,
"capabilities": ["onoff", "dim", "light_temperature", "light_hue", "light_saturation"],
"controlled_by_nspanel_main_page": true,
"is_ceiling_light": false
}Switch Entity:
{
"controller": "homey",
"homey_device_id": "<uuid>",
"homey_device_name": "<name>",
"capabilities": ["onoff"]
}Button Entity:
{
"controller": "homey",
"homey_device_id": "<uuid>",
"homey_device_name": "<name>",
"capabilities": ["onoff"]
}Thermostat Entity:
{
"controller": "homey",
"homey_device_id": "<uuid>",
"homey_device_name": "<name>",
"capabilities": ["target_temperature", "measure_temperature", "thermostat_mode"]
}Scene (Backend Name):
homey_flow_<uuid> (for Flows)
homey_mood_<uuid> (for Moods)
- ✅ Phase 1: Foundation & Settings (Complete with UI, persistence, token masking)
- ✅ Phase 2: Python Web Interface (API client + full UI integration in htmx.py)
- ✅ Phase 3: Entity Creation & Storage (All 5 entity types with create/edit UI)
- ✅ Phase 4: C++ Backend - Homey Manager (WebSocket connection & observer pattern)
- ✅ Phase 5: C++ Backend - Entity Types (All 5: Light, Switch, Button, Scene, Thermostat)
- ✅ Phase 6: Integration with EntityManager (Complete integration + CMake)
- ✅ Phase 8: Documentation (THIS document - comprehensive implementation guide)
- 🟨 Phase 7: Testing & Debugging (Awaiting real-world testing)
- ✅ Complete UI Integration: All entity types can be added/edited through web interface
- ✅ Settings Management: Full settings UI in main settings page AND initial setup wizard
- ✅ Entity Support: Light, Switch, Button, Thermostat, Scene (Flows & Moods)
- ✅ Smart Filtering: Thermostat devices filtered by temperature capabilities
- ✅ Full Backend: C++ entities with WebSocket state synchronization
- ✅ Database Integration: Proper entity_data storage with controller field
- ✅ Build System: All Homey components in CMakeLists.txt
- ✅ Created HomeyManager with WebSocket connection
- ✅ Implemented all 5 HomeyEntity types (Light, Switch, Button, Scene, Thermostat)
- ✅ Full EntityManager integration for all entity types
- ✅ Complete htmx.py integration for all entity types (add & edit)
- ✅ NEW: Thermostat support added (not in original plan!)
- ✅ Initial setup wizard + main settings page for Homey
- ✅ Smart thermostat filtering by capability in UI
Estimated Effort: Medium (2-3 days)
-
Functional Testing:
- Test Homey connection and authentication
- Test entity discovery and listing
- Test entity creation for all types
- Test real-time state updates via WebSocket
- Test device control (lights, switches, buttons, thermostats, scenes)
-
Error Handling:
- Test connection failures
- Test invalid credentials
- Test device not found scenarios
- Test capability mismatches
-
Performance Testing:
- Test WebSocket reconnection
- Test multiple device state updates
- Monitor memory usage
Estimated Effort: Low (1-2 days)
-
User Documentation:
- Create step-by-step Homey setup guide
- Document how to generate Homey API keys
- Add troubleshooting section
- Document supported capabilities
- Add thermostat-specific documentation
-
Developer Documentation:
- Add code comments to HomeyManager
- Document entity class implementations
- Update README with Homey integration info
- Abstract interface for easier integration of new controllers
- Homey device discovery via mDNS
- API rate limiting and caching
- Homey webhook support for even faster updates
- Multi-Homey support
- Advanced thermostat features (schedules, presets)
- Initially single Homey instance (can be extended later)
- Button entity only supports basic press (not long press/double press initially)
- Moods treated as scenes (same behavior as Flows)
- None additional (all libraries already in project)
- Python: requests (existing)
- C++: ixwebsocket (existing), nlohmann/json (existing)
- Home Assistant integration:
docker/MQTTManager/include/home_assistant_manager/ - OpenHAB integration:
docker/MQTTManager/include/openhab_manager/