Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
ed45737
Merge tag 'v0.7.0' into dev
DerAndereAndi Sep 21, 2024
b87c872
Update README badges
DerAndereAndi Sep 21, 2024
b926b0c
Add missing mock changes
DerAndereAndi Oct 7, 2024
30ee8bc
Update SHIP to latest dev version
DerAndereAndi Oct 7, 2024
9f07e2a
Fix invalid HVAC data type to function assignment
DerAndereAndi Oct 11, 2024
272b8f9
Fix send request caching not fully working
DerAndereAndi Oct 11, 2024
06d9bf0
Fix invalid HVAC data type to function assignment
DerAndereAndi Oct 12, 2024
d5f89c7
Fix: Correct Data Types for Setpoint Description, Selector, and HVAC
daviddsapir Oct 22, 2024
8cfa9c8
Fix possible race condition in events handler
AhmedMagdyCoretech Oct 23, 2024
f5aacd9
Fix possible race condition in events handler (#39)
DerAndereAndi Oct 23, 2024
f75c7fe
Add eebus:"key" for foreign identifiers in SetpointDescriptionDataTyp…
daviddsapir Oct 23, 2024
0b14938
Fix: Correct Data Types for Setpoint Description, Selector, and HVAC …
DerAndereAndi Oct 23, 2024
8d0bef9
Fix TimePeriodType EndTime getting negative values
DerAndereAndi Oct 29, 2024
96e3b58
Fix TimePeriodType EndTime getting negative values (#40)
DerAndereAndi Oct 30, 2024
a6cb072
Fix Data Types in HVAC System Functions
Nov 4, 2024
36f6883
Update EntityLocalInterface for UseCase handling
DerAndereAndi Nov 4, 2024
76eefff
Fix: Data Types in HVAC System Functions (#41)
DerAndereAndi Nov 4, 2024
4f986b1
Fix: HVAC System Function Operation Mode Selector
Nov 6, 2024
7ae756c
Update EntityLocalInterface for UseCase handling (#42)
DerAndereAndi Nov 8, 2024
c2d2b16
Fix: HVAC System Function Operation Mode Selector (#43)
DerAndereAndi Nov 8, 2024
8aa7206
Add JSON Marshalling support to device and entity
DerAndereAndi Nov 8, 2024
fb7dc01
Add JSON Marshalling support to device and entity (#45)
DerAndereAndi Nov 11, 2024
b7ea017
Update UseCaseFilter type and mocks
DerAndereAndi Nov 18, 2024
14df088
Fix gosec warning
DerAndereAndi Nov 18, 2024
4690d88
Add Code of Conduct and Contributing
DerAndereAndi Nov 18, 2024
0589320
Various maintenance updates (#46)
DerAndereAndi Nov 18, 2024
51d686b
Fix data type of SPINE model ScaleType
DerAndereAndi Dec 9, 2024
5d63cf6
Improve disconnect event handling
DerAndereAndi Dec 9, 2024
1aed917
Maintenance updates (#48)
DerAndereAndi Dec 9, 2024
dd5ea2c
fix: possible concurrent map access (#49)
kirollosnct Jan 23, 2025
3e9b843
Various maintenance tasks
DerAndereAndi Jan 23, 2025
5fb9ea1
Possible concurrent map access (#49) (#50)
DerAndereAndi Jan 23, 2025
97dcc80
Update liecense
DerAndereAndi Jan 24, 2025
89e9a5f
Remove not needed variable
DerAndereAndi Jan 29, 2025
ba5c933
Update handling of detaileddiscovery updates
DerAndereAndi Jan 29, 2025
75af90f
Some code simplifications
DerAndereAndi Jan 30, 2025
3b3848a
Improve binding and subscription manager
DerAndereAndi Feb 1, 2025
a2701bf
Also check device when removing entity binding
DerAndereAndi Feb 2, 2025
cd41007
Improve binding and subscription manager (#55)
DerAndereAndi Feb 3, 2025
174299d
Fixes for bindings & subscriptions
DerAndereAndi Feb 7, 2025
dd9e56d
Reactor bindings and subscriptions
DerAndereAndi Feb 18, 2025
ef3d886
Fix failing integration test
DerAndereAndi Feb 18, 2025
4183888
Apply suggestions from code review
DerAndereAndi Feb 19, 2025
dab7ace
Apply suggestions from code review
DerAndereAndi Feb 21, 2025
cb6d157
Fix code formatting
DerAndereAndi Feb 21, 2025
130494a
Fix logic checking for address match
DerAndereAndi Feb 21, 2025
114e2d0
Refactor bindings and subscriptions (#58)
DerAndereAndi Feb 21, 2025
e08be90
Merge branch 'dev' into feature/maintenance
DerAndereAndi Feb 21, 2025
93ce930
Update dependencies
DerAndereAndi Feb 21, 2025
f4c752d
Improve device change handling
DerAndereAndi Feb 22, 2025
21e14a1
Move ISO-8601 support to updated library
DerAndereAndi Mar 25, 2025
91479d4
Update dependencies
DerAndereAndi Mar 25, 2025
896e3ae
Update to go 1.23, ship-go and other dependencies
DerAndereAndi Jul 3, 2025
76469d2
Add binding test cases
DerAndereAndi Jul 3, 2025
be7bc5a
Add architecture documentation
DerAndereAndi Jul 3, 2025
90e90e6
More dependency updates
DerAndereAndi Jul 3, 2025
e03205e
Add DeepWiki link to readme
DerAndereAndi Jul 3, 2025
31bf060
Various maintenance tasks (#51)
DerAndereAndi Jul 3, 2025
a73a537
Add comprehensive SPINE implementation analysis documentation
DerAndereAndi Jul 3, 2025
d358cc4
Add comprehensive SPINE implementation analysis documentation (#61)
DerAndereAndi Jul 3, 2025
5468324
Update mocks
DerAndereAndi Jul 3, 2025
690c65f
✨ feat: implement calendar-aware ISO 8601 duration formatting
DerAndereAndi Jul 3, 2025
4f97bdb
✅ test: add comprehensive test coverage for calendar-aware duration f…
DerAndereAndi Jul 3, 2025
e8c48ff
✨ feat: implement calendar-aware ISO 8601 duration formatting (#62)
DerAndereAndi Jul 4, 2025
b95fc69
✅ test: add comprehensive msgCounter verification tests
DerAndereAndi Jul 4, 2025
5e8fbc9
📝 docs: add XSD restriction analysis and decision documentation
DerAndereAndi Jul 4, 2025
c3d1294
✨ feat: implement XSD-compliant factory function for NodeManagement e…
DerAndereAndi Jul 4, 2025
656fd68
✨ feat: implement XSD-compliant factory function for NodeManagement e…
DerAndereAndi Jul 4, 2025
823f6ca
✅ test: add comprehensive test coverage for partial filter reply beha…
DerAndereAndi Jul 4, 2025
d7a676b
✅ test: add comprehensive test coverage for partial filter reply beha…
DerAndereAndi Jul 4, 2025
1184ed2
fix: ensure error code 6 for unknown functions per SPINE spec
DerAndereAndi Jul 5, 2025
ed1a1ac
📝 docs: convert analysis docs from version numbers to date-based vers…
DerAndereAndi Jul 5, 2025
eb5b6bc
📝 docs: fix numbering and update entity depth limit analysis in SPEC_…
DerAndereAndi Jul 5, 2025
2aed843
📝 docs: clarify timeout handling is spec-compliant and add comprehens…
DerAndereAndi Jul 5, 2025
dbd4eea
📝 docs: correct architectural understanding of SPINE vs transport lay…
DerAndereAndi Jul 5, 2025
6709af9
📝 docs: add document history sections to analysis documents
DerAndereAndi Jul 5, 2025
42f8d7f
📝 docs: update loop detection analysis and clean up documentation
DerAndereAndi Jul 5, 2025
7bff174
✨ feat: implement smart list update filtering to prevent duplicate en…
DerAndereAndi Jul 13, 2025
7248a16
✅ test: add comprehensive unit test coverage for eebus_tags.go and up…
DerAndereAndi Jul 13, 2025
fdbfaf6
📝 docs: add comprehensive documentation and examples for SPINE update…
DerAndereAndi Jul 13, 2025
425c6d7
🐛 fix: add cmdFunction parameter to FilterType.Data() for partial fil…
DerAndereAndi Aug 14, 2025
5af7d83
Fix build errors
DerAndereAndi Aug 14, 2025
7e6551c
✅ test: improve test coverage for validation and update functions
DerAndereAndi Aug 14, 2025
c4ae675
✨ feat: implement smart list update filtering to prevent duplicate en…
DerAndereAndi Aug 21, 2025
55d4c67
Merge branch 'dev' into feat…/update-partial-fixes
DerAndereAndi Aug 22, 2025
08a28fe
🐛 fix: add cmdFunction parameter to FilterType.Data() for partial fil…
DerAndereAndi Aug 22, 2025
8b8a192
Improved Unmarshalling
DerAndereAndi Dec 17, 2025
0b81b43
Fix potential crashes due to missing nil checks
DerAndereAndi Dec 17, 2025
5f5e000
Model references
DerAndereAndi Nov 13, 2025
e2058a3
Add missing sample data
DerAndereAndi Dec 17, 2025
f6b469e
refactor!: remove global Events, each DeviceLocal owns its events man…
DerAndereAndi Dec 29, 2025
dc71a3a
Add more references
DerAndereAndi Jan 12, 2026
0936421
feat: implement XSD-compliant factory function for NodeManagementFeat…
kirollosnct Jan 13, 2026
84364d4
remove device from featureAddress in expected NodeManagement JSON uni…
kirollosnct Jan 13, 2026
05a9cec
Model references (#71)
sthelen-enqs Jan 21, 2026
d893025
fix review point
kirollosnct Jan 21, 2026
a43ab88
Implement XSD-compliant factory function for NodeManagementFeatureInf…
sthelen-enqs Jan 21, 2026
9970150
Fix various spine model errors
DerAndereAndi Jan 5, 2026
cb74953
Add missing key attribute
DerAndereAndi Jan 14, 2026
1f279c0
Fix tests
DerAndereAndi Jan 21, 2026
b02c9fc
Remove global Events, each DeviceLocal owns its events manager (#74)
sthelen-enqs Feb 2, 2026
f303f24
Fix calendar-dependent duration encoding in NewDurationType
DerAndereAndi Feb 2, 2026
9a649ab
Fix calendar-dependent duration encoding in NewDurationType (#82)
DerAndereAndi Feb 9, 2026
29c2909
Apply suggestions from code review
DerAndereAndi Feb 9, 2026
aaac8bd
Fix missing import
DerAndereAndi Feb 9, 2026
ca7d5b4
Add log when invalid bindings and subscriptions are skipped
sthelen-enqs Feb 9, 2026
9564641
Fix potential crashes due to missing nil checks (#73)
sthelen-enqs Feb 9, 2026
50d3427
Add test and comment for case where {} is inside a string
Feb 11, 2026
8f7f5bd
Improved Unmarshalling (#72)
DerAndereAndi Feb 11, 2026
65ec71e
Fix various spine model errors (#76)
sthelen-enqs Feb 25, 2026
de15a9e
fix(spine): guard nil remoteFeature in SubscribeToRemote/BindToRemote
SAY-5 Apr 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ jobs:
uses: golangci/golangci-lint-action@master
with:
version: latest
skip-pkg-cache: true
skip-build-cache: true
skip-cache: true
args: --timeout=3m --issues-exit-code=0 ./...

- name: Test
Expand Down
232 changes: 232 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
# SPINE-Go Architecture Documentation

This document explains the overall architecture of the SPINE-Go library, which provides an implementation of the EEBUS SPINE 1.3 specification in Go.

## Overview

SPINE-Go is a library that implements the SPINE (Smart Premises Interoperable Neutral-message Exchange) protocol, which is part of the EEBUS specification for smart energy management systems. The library provides a complete stack for creating and managing SPINE devices that can communicate with each other over networks.

## Core Components

The architecture is organized into several key packages, each serving a specific purpose:

### 1. API Package (`api/`)

Contains the core interfaces that define contracts for all major components. This package serves as the foundation for the entire architecture and enables dependency injection and testing through mocking.

**Key Interfaces:**
- `DeviceInterface` - Common device functionality
- `DeviceLocalInterface` - Local device management
- `DeviceRemoteInterface` - Remote device representation
- `EntityInterface` - Entity management
- `FeatureInterface` - Feature functionality
- `SenderInterface` - Message sending capabilities
- `EventHandlerInterface` - Event handling

### 2. Model Package (`model/`)

Contains the Go representation of the SPINE data model with proper JSON serialization support and EEBUS tags for generic feature-to-function mapping.

**Key Components:**
- Data structures for all SPINE message types
- Command and function definitions
- Network management types
- Address and identification structures

### 3. SPINE Package (`spine/`)

The main implementation package containing the core business logic for SPINE devices, entities, features, functions, and data management.

## Hierarchical Architecture

The SPINE architecture follows a hierarchical structure:

```
Device
├── Entity (0..n)
├── Feature (0..n)
├── Function (0..n)
└── Data
```

### Device Level

**DeviceLocal** (`device_local.go`)
- Represents the local SPINE device
- Manages local entities and remote device connections
- Handles incoming SPINE messages and routing
- Provides node management, subscription management, and binding management
- Contains device information like brand, model, serial number

**DeviceRemote** (`device_remote.go`)
- Represents a remote SPINE device
- Manages remote entities discovered through detailed discovery
- Handles incoming messages from the associated device
- Maintains connection to the local device

### Entity Level

**EntityLocal** (`entity_local.go`)
- Represents a local entity within the device
- Manages local features
- Handles heartbeat management for non-device-information entities
- Examples: EV charging point, heat pump, battery storage

**EntityRemote** (`entity_remote.go`)
- Represents a remote entity from a connected device
- Manages remote features discovered through detailed discovery
- Maintains reference to parent remote device

### Feature Level

**FeatureLocal** (`feature_local.go`)
- Implements specific SPINE feature functionality
- Manages function data and operations
- Handles subscriptions and bindings to remote features
- Processes incoming messages for the feature
- Examples: Device Diagnosis, Load Control, Measurement

**FeatureRemote** (`feature_remote.go`)
- Represents a remote feature
- Stores data received from remote devices
- Maintains operation capabilities and response delays

## Communication Architecture

### Message Flow

1. **Outgoing Messages:**
```
Local Feature → Sender → SHIP Connection → Network
```

2. **Incoming Messages:**
```
Network → SHIP Connection → Device.ProcessCmd() → Feature.HandleMessage()
```

### Key Communication Components

**Sender** (`send.go`)
- Handles all outgoing SPINE messages
- Manages message counters and caching
- Supports different message types: Request, Reply, Notify, Write
- Implements message deduplication for certain message types

**Message Processing**
- `DeviceLocal.ProcessCmd()` - Main entry point for incoming messages
- Routes messages to appropriate local features
- Handles acknowledgments and error responses
- Manages message validation and addressing

## Management Systems

### Node Management (`nodemanagement.go`)

The Node Management feature is present on every device (Entity 0, Feature 0) and handles:

- **Detailed Discovery**: Exchange of device, entity, and feature information
- **Destination Lists**: Available communication endpoints
- **Use Case Data**: Supported use cases and their configurations
- **Subscription Management**: Managing data subscriptions between features
- **Binding Management**: Managing persistent connections between features

### Subscription Manager (`subscription_manager.go`)

Manages subscriptions between client and server features:
- Tracks active subscriptions between local and remote features
- Handles subscription requests and deletions
- Automatically notifies subscribed features when data changes
- Manages subscription data persistence

### Binding Manager (`binding_manager.go`)

Manages bindings (persistent connections) between features:
- Tracks active bindings between client and server features
- Handles binding requests and deletions
- Enforces binding constraints (e.g., one remote binding per local server feature)
- Manages binding data persistence

### Heartbeat Manager (`heartbeat_manager.go`)

Manages heartbeat functionality for device diagnosis:
- Sends periodic heartbeat messages to subscribed remote features
- Configurable heartbeat intervals
- Automatically starts/stops based on subscription state
- Used for connection monitoring and fault detection

## Event System (`events.go`)

The library includes a comprehensive event system for notifying applications about important state changes:

**Event Types:**
- `EventTypeDeviceChange` - Device connection/disconnection
- `EventTypeEntityChange` - Entity addition/removal
- `EventTypeSubscriptionChange` - Subscription state changes
- `EventTypeBindingChange` - Binding state changes
- `EventTypeDataChange` - Feature data updates

**Event Handling Levels:**
- `EventHandlerLevelCore` - For internal library components (synchronous)
- `EventHandlerLevelApplication` - For application code (asynchronous)

## Data Flow Examples

### Device Discovery Process

1. Local device connects to remote device via SHIP
2. Local device requests detailed discovery from remote device
3. Remote device responds with device, entity, and feature information
4. Local device creates corresponding remote device, entity, and feature objects
5. Events are published for each discovered component
6. Applications can then establish subscriptions and bindings

### Data Subscription Process

1. Local client feature requests subscription to remote server feature
2. Subscription manager validates and stores the subscription
3. Remote device acknowledges the subscription
4. When remote feature data changes, notifications are sent to subscriber
5. Local feature updates its cached data and publishes events

### Feature Communication

1. Local feature wants to read data from remote feature
2. Sender creates and sends a read request message
3. Remote feature receives request and sends reply with data
4. Local feature processes reply, updates cache, and publishes events
5. Applications receive events and can access the updated data

## Integration Points

### SHIP Integration

SPINE-Go integrates with the SHIP (Smart Home IP) protocol layer:
- Uses SHIP for device discovery and connection establishment
- SHIP handles network-level communication and security
- SPINE messages are transported as SHIP payload

### Application Integration

Applications integrate with SPINE-Go through:
- Event subscriptions for state change notifications
- Direct API calls for data access and control
- Feature-specific helper libraries for use case implementations

## Thread Safety

The library is designed to be thread-safe:
- Uses mutexes to protect shared data structures
- Event publishing is handled safely across goroutines
- Message processing includes proper synchronization
- Managers use appropriate locking for concurrent access

## Testing Architecture

The architecture supports comprehensive testing through:
- **Mocks Package** (`mocks/`) - Auto-generated mocks for all interfaces
- **Integration Tests** (`integration_tests/`) - End-to-end testing scenarios
- **Unit Tests** - Extensive unit test coverage for individual components
- **Test Helpers** - Common testing utilities and data generators

This modular and interface-driven architecture provides flexibility, testability, and clear separation of concerns while maintaining compliance with the EEBUS SPINE specification.
49 changes: 49 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.

Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at <mail@andreaslinde.de>. All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the reporter of any incident.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant](https://contributor-covenant.org/), version
[1.4](https://www.contributor-covenant.org/version/1/4/code-of-conduct/code_of_conduct.md) and
[2.0](https://www.contributor-covenant.org/version/2/0/code_of_conduct/code_of_conduct.md),
and was generated by [contributing-gen](https://github.com/bttger/contributing-gen).
Loading