This document provides a comprehensive overview of the architecture of the eebus-go library, which implements the EEBUS protocol stack for energy management systems in Go.
The eebus-go library is a Go implementation of the EEBUS standard, providing a foundation for implementing energy management use cases. It builds upon two core protocol implementations:
- SHIP (Smart Home IP) - Communication protocol layer
- SPINE (Smart Premises Interoperable Network-Neutral) - Application protocol layer
The architecture follows a layered approach from low-level networking to high-level use cases:
┌─────────────────────────────────────────┐
│ Use Cases Layer │
│ (CEM, CS, EG, MA actors with │
│ specific use case implementations) │
├─────────────────────────────────────────┤
│ Features Layer │
│ (Client/Server feature helpers for │
│ common SPINE feature operations) │
├─────────────────────────────────────────┤
│ Service Layer │
│ (Central orchestration, device │
│ management, event coordination) │
├─────────────────────────────────────────┤
│ SPINE Layer │
│ (Application protocol, entities, │
│ features, data models) │
├─────────────────────────────────────────┤
│ SHIP Layer │
│ (Transport protocol, websockets, │
│ mDNS, pairing, security) │
└─────────────────────────────────────────┘
The central orchestration component that manages all aspects of the EEBUS service.
Key Components:
Service: Main service implementation that coordinates all subsystemsServiceInterface: Defines the contract for service operationsServiceReaderInterface: Callback interface for service events
Responsibilities:
- Initialize and manage SHIP and SPINE layers
- Handle device connections and disconnections
- Coordinate use case implementations
- Manage mDNS service discovery
- Handle websocket connections
- Certificate and security management
Key Methods:
Setup(): Initialize the service componentsStart(): Begin service operationsAddUseCase(): Register use case implementationsRegisterRemoteSKI(): Register a remote device for connection
Defines the service configuration parameters required for EEBUS operation.
Key Parameters:
- Device identification (brand, model, serial number, vendor code)
- Network configuration (port, interfaces, certificates)
- SPINE device and entity types
- mDNS service parameters
- Feature set definitions
Provides high-level abstractions for SPINE features with client/server role implementations.
Features where the local entity acts as a client (consumer) of remote server features:
DeviceClassification: Request device manufacturer informationDeviceConfiguration: Read/write device configuration parametersElectricalConnection: Access electrical connection parametersLoadControl: Interact with load control functionalityMeasurement: Request measurement dataTimeSeries: Access time series data
Features where the local entity acts as a server (provider) of feature functionality:
DeviceConfiguration: Provide device configuration dataDeviceDiagnosis: Report device state and diagnosticsLoadControl: Accept and manage load control commandsMeasurement: Provide measurement data
Common functionality shared between client and server implementations.
Actor-based implementations of specific EEBUS use cases following the EEBUS specification.
Customer Energy Management (CEM) — usecases/cem/:
cevc: Coordinated EV Chargingevcc: EV Commissioning and Configurationevcem: EV Charging Electricity Measurementevsecc: EVSE Commissioning and Configurationevsoc: EV State Of Chargeopev: Overload Protection by EV Charging Current Curtailmentoscev: Optimization of Self-Consumption During EV Chargingvabd: Visualization of Aggregated Battery Datavapd: Visualization of Aggregated Photovoltaic Data
Controllable System (CS) — usecases/cs/:
lpc: Limitation of Power Consumptionlpp: Limitation of Power Production
Energy Guard (EG) — usecases/eg/:
lpc: Limitation of Power Consumptionlpp: Limitation of Power Production
Monitoring Appliance (MA) — usecases/ma/:
mpc: Monitoring of Power Consumptionmgcp: Monitoring of Grid Connection Point
Provides common functionality for all use case implementations:
UseCaseBase:
- Entity and actor type validation
- Scenario management
- Feature registration
- Event handling coordination
- Remote device compatibility checking
-
Service Initialization:
Configuration → Service.Setup() → SPINE Device Creation → mDNS Setup → SHIP Hub Setup -
Remote Device Discovery:
mDNS Discovery → Service Registry → Connection Attempt → SHIP Handshake → Device Registration -
Entity and Feature Discovery:
SPINE Discovery → Entity Registration → Feature Registration → Use Case Matching
-
SHIP Layer Events:
- Connection/disconnection events
- Pairing state updates
- Service discovery updates
-
SPINE Layer Events:
- Device/entity changes
- Feature data updates
- Binding and subscription changes
-
Use Case Events:
- Use case specific data updates
- State changes
- Error conditions
Application Layer (Use Cases)
↕
Feature Layer (Client/Server Helpers)
↕
Service Layer (Event Coordination)
↕
SPINE Layer (Application Protocol)
↕
SHIP Layer (Transport Protocol)
↕
Network Layer (WebSocket/TCP)
The service implements the HubReaderInterface to handle SHIP-level events:
RemoteSKIConnected(): Handle successful remote connectionsRemoteSKIDisconnected(): Handle connection terminationsSetupRemoteDevice(): Configure remote device communicationVisibleRemoteServicesUpdated(): Process service discovery updates
Use cases integrate with the service through:
- Feature Registration: Use cases register required SPINE features
- Event Callbacks: Use cases receive relevant SPINE events
- Data Access: Use cases access remote device data through feature helpers
- State Management: Use cases maintain scenario-specific state
Features provide abstraction over SPINE functionality:
- Subscription Management: Automatic subscription to remote feature updates
- Data Requests: Simplified methods for requesting remote data
- Write Operations: Safe write operations with proper validation
- Event Filtering: Automatic filtering of relevant events
- X.509 certificate handling for device authentication
- Certificate validation and trust establishment
- Secure key exchange during pairing
- Discovery: mDNS-based service discovery
- Initial Contact: SHIP handshake initiation
- Authentication: Certificate exchange and validation
- Trust Establishment: User approval/automatic acceptance
- Secure Communication: Encrypted message exchange
- SKI (Subject Key Identifier) based device identification
- Configurable auto-accept policies
- User interaction callbacks for pairing approval
configuration := api.NewConfiguration(
vendorCode, brand, model, serial,
deviceCategories, deviceType, entityTypes,
port, certificate, heartbeatTimeout
)service.AddUseCase(NewEVCC(service, localEntity, eventCallback))func (h *Handler) HandleEvent(payload spineapi.EventPayload) {
// Process use case specific events
}- Implement
UseCaseInterface - Extend
UseCaseBasefor common functionality - Register with service using
AddUseCase()
- Implement feature client/server interfaces
- Use internal feature helpers for common operations
- Register features with local entities
- Implement
EntityEventCallbackfor use case events - Implement
ServiceReaderInterfacefor service events - Process events through the established event flow
The architecture supports comprehensive testing through:
- Mock interfaces for all major components
- Test helpers for setting up device scenarios
- Integration test framework for end-to-end testing
- Feature-specific test suites
github.com/enbility/ship-go: SHIP protocol implementationgithub.com/enbility/spine-go: SPINE protocol implementation
- Clear separation of concerns between layers
- Interface-based design for testability
- Event-driven architecture for loose coupling
This architecture provides a robust, extensible foundation for implementing EEBUS-based energy management solutions while maintaining clear separation between protocol layers and business logic.