Skip to content

Conversation

@moehrem
Copy link
Owner

@moehrem moehrem commented Oct 17, 2025

breaking changes:

  • changed service data handling and mandatory parameters

major changes:

  • added support for developer tools actions UI
  • added support for automation UI

under the hood:

  • several bug fixes
  • major overhaul of entity handling
  • added automated tests

Implement device actions to enable service calls through Home Assistant's automation UI. This allows users to trigger Divera operations (alarms, vehicle status, messages, etc.) directly from device-based automations without manually specifying service calls.

Changes:
- Add device_action.py with action definitions and capability schemas
  * Implement async_get_actions with permission-based filtering
  * Add async_call_action_from_config for service call delegation
  * Implement async_get_action_capabilities with dynamic field generation
  * Add _get_selector_options helper for coordinator data extraction
  * Support multi-select dropdowns for groups, users, vehicles, statuses
  * Add ObjectSelector for flexible YAML inputs (properties, survey data)
  * Add DateTimeSelector for timestamp fields with auto-conversion
  * Add NumberSelector with range validation for coordinates and IDs

- Update __init__.py
  * Register device action platform on integration setup
  * Add device action support to platform loading

- Update service.py
  * Refactor service handlers to accept both list and string inputs
  * Add normalize_to_comma_separated for multi-select handling
  * Add get_coordinator_from_device_id utility function
  * Update all service handlers for device action compatibility
  * Add JSON parsing for flexible property inputs
  * Add datetime-to-timestamp conversion for survey deadlines

- Update utils.py
  * Add normalize_to_comma_separated utility function
  * Add get_coordinator_from_device_id for device-to-coordinator mapping
  * Enhance permission_check helper usage

- Update const.py
  * Add device action type constants
  * Add selector option constants
  * Add permission mapping for action filtering

- Update manifest.json
  * Declare device_action platform support

- Update divera_api.py
  * Add missing API methods for device actions
  * Enhance error handling for service calls
  * Add support for all service parameters

- Update divera_data.py
  * Add data models for device action responses
  * Enhance coordinator data structure for selector population

- Update entity.py
  * Add device info methods for device action integration
  * Enhance entity-device relationships

- Update config_flow.py
  * Add validation for device action parameters
  * Enhance error handling for action setup

- Update calendar.py
  * Minor adjustments for device action compatibility

- Update services.yaml
  * Add comprehensive field descriptions for all services
  * Add examples for complex parameters
  * Document multi-select and YAML input fields

- Update translations (de.json, en.json)
  * Add device action titles and descriptions
  * Add field labels for all action parameters
  * Add error messages for action validation
  * Add help text for complex inputs (JSON, YAML, multi-select)

Changes to be committed:
    modified:   custom_components/diveracontrol/__init__.py
    modified:   custom_components/diveracontrol/calendar.py
    modified:   custom_components/diveracontrol/config_flow.py
    modified:   custom_components/diveracontrol/const.py
    new file:   custom_components/diveracontrol/device_action.py
    modified:   custom_components/diveracontrol/divera_api.py
    modified:   custom_components/diveracontrol/divera_data.py
    modified:   custom_components/diveracontrol/entity.py
    modified:   custom_components/diveracontrol/manifest.json
    modified:   custom_components/diveracontrol/service.py
    modified:   custom_components/diveracontrol/services.yaml
    modified:   custom_components/diveracontrol/translations/de.json
    modified:   custom_components/diveracontrol/translations/en.json
    modified:   custom_components/diveracontrol/utils.py

Changes to be committed:
	modified:   custom_components/diveracontrol/__init__.py
	modified:   custom_components/diveracontrol/calendar.py
	modified:   custom_components/diveracontrol/config_flow.py
	modified:   custom_components/diveracontrol/const.py
	new file:   custom_components/diveracontrol/device_action.py
	modified:   custom_components/diveracontrol/divera_api.py
	modified:   custom_components/diveracontrol/divera_data.py
	modified:   custom_components/diveracontrol/entity.py
	modified:   custom_components/diveracontrol/manifest.json
	modified:   custom_components/diveracontrol/service.py
	modified:   custom_components/diveracontrol/services.yaml
	modified:   custom_components/diveracontrol/translations/de.json
	modified:   custom_components/diveracontrol/translations/en.json
	modified:   custom_components/diveracontrol/utils.py
- Implement device actions for all major DiveraControl services, enabling automation UI support
- Refactor service handlers for unified validation and translation-based error messages
- Add dynamic selectors and schema generation in device_action.py for vehicles, alarms, groups, and properties
- Update divera_api.py to support new service calls and error handling
- Enhance config_flow.py for better validation and error reporting
- Extend translations (de/en) with user-facing error messages and field labels for device actions
- Update services.yaml with improved field descriptions and examples
- Add utility functions for normalization and translation lookup in utils.py
- Improve __init__.py to register device actions and support config entry setup

Changes to be committed:
	modified:   custom_components/diveracontrol/__init__.py
	modified:   custom_components/diveracontrol/config_flow.py
	modified:   custom_components/diveracontrol/device_action.py
	modified:   custom_components/diveracontrol/divera_api.py
	modified:   custom_components/diveracontrol/service.py
	modified:   custom_components/diveracontrol/services.yaml
	modified:   custom_components/diveracontrol/translations/de.json
	modified:   custom_components/diveracontrol/translations/en.json
	modified:   custom_components/diveracontrol/utils.py
- removed cluster_data and admin_data from coordinator
- added translations of actions
- changed overall translation handling
- optimized device actions

Changes to be committed:
	modified:   custom_components/diveracontrol/calendar.py
	modified:   custom_components/diveracontrol/config_flow.py
	modified:   custom_components/diveracontrol/coordinator.py
	modified:   custom_components/diveracontrol/device_action.py
	modified:   custom_components/diveracontrol/device_tracker.py
	modified:   custom_components/diveracontrol/diagnostics.py
	modified:   custom_components/diveracontrol/divera_data.py
	modified:   custom_components/diveracontrol/entity.py
	modified:   custom_components/diveracontrol/sensor.py
	modified:   custom_components/diveracontrol/service.py
	modified:   custom_components/diveracontrol/services.yaml
	modified:   custom_components/diveracontrol/translations/de.json
	modified:   custom_components/diveracontrol/translations/en.json
	modified:   custom_components/diveracontrol/utils.py
Changes to be committed:
	modified:   README.en.md
	modified:   README.md
- improved error handling and logging
- optimized permission checks
- updated untility functions

Changes to be committed:
	modified:   README.en.md
	modified:   README.md
	modified:   custom_components/diveracontrol/device_action.py
	modified:   custom_components/diveracontrol/divera_api.py
	modified:   custom_components/diveracontrol/divera_data.py
	modified:   custom_components/diveracontrol/service.py
	modified:   custom_components/diveracontrol/translations/de.json
	modified:   custom_components/diveracontrol/utils.py
bug: entity removal for device_tracker
updated readme to be less specific to firefighters

Changes to be committed:
	modified:   custom_components/diveracontrol/device_tracker.py
	modified:   custom_components/diveracontrol/entity.py
	modified:   custom_components/diveracontrol/sensor.py
	modified:   custom_components/diveracontrol/translations/en.json
- calendar: refactored update logic
- device_tracker: improved state management
- sensor: linted and optimized imports
- __init__: added migration logic for v1.2.*

Changes to be committed:
	modified:   custom_components/diveracontrol/__init__.py
	modified:   custom_components/diveracontrol/calendar.py
	modified:   custom_components/diveracontrol/device_tracker.py
	modified:   custom_components/diveracontrol/entity.py
	modified:   custom_components/diveracontrol/sensor.py
- moved structure initialization to divera_data.py
- fixed issue with empty calendar data (list instead of dict)
- deleted individual listener management
- minor code linting

Changes to be committed:
	modified:   custom_components/diveracontrol/__init__.py
	modified:   custom_components/diveracontrol/calendar.py
	modified:   custom_components/diveracontrol/config_flow.py
	modified:   custom_components/diveracontrol/coordinator.py
	modified:   custom_components/diveracontrol/divera_data.py
- changed position of parameters in some services for better usability
- added selectors to actions in developer tools for better usability
- added a normalizer module to refine service data
- changed all services to use the normalizer
- updated documentation
- added crew to be safed in HA while updating Divera
- removed unnecessary untility functions
- added some german translations, mainly for services

Changes to be committed:
	modified:   README.en.md
	modified:   README.md
	modified:   custom_components/diveracontrol/coordinator.py
	new file:   custom_components/diveracontrol/data_normalizer.py
	modified:   custom_components/diveracontrol/device_action.py
	modified:   custom_components/diveracontrol/device_tracker.py
	modified:   custom_components/diveracontrol/divera_api.py
	modified:   custom_components/diveracontrol/sensor.py
	modified:   custom_components/diveracontrol/service.py
	modified:   custom_components/diveracontrol/services.yaml
	modified:   custom_components/diveracontrol/translations/de.json
	modified:   custom_components/diveracontrol/utils.py
Changes to be committed:
	modified:   custom_components/diveracontrol/translations/de.json
	modified:   custom_components/diveracontrol/translations/en.json
Changes to be committed:
	modified:   custom_components/diveracontrol/data_normalizer.py
	modified:   custom_components/diveracontrol/device_action.py
	modified:   custom_components/diveracontrol/service.py
	modified:   custom_components/diveracontrol/services.yaml
	modified:   custom_components/diveracontrol/translations/de.json
	modified:   custom_components/diveracontrol/translations/en.json
Changes to be committed:
	modified:   custom_components/diveracontrol/translations/de.json
	modified:   custom_components/diveracontrol/translations/en.json
Changes to be committed:
	modified:   README.en.md
	modified:   README.md
Major architectural improvements:
- Introduce ConfigEntry.runtime_data for coordinator access
- Split entity definitions into dedicated files by platform
- Implement manager pattern for dynamic entity lifecycle

Entity organization:
- Create sensor_entity.py with sensor-specific classes
- Create calendar_entity.py with calendar entity
- Create device_tracker_entity.py with tracker classes
- Keep only BaseDiveraEntity in entity.py

Platform improvements:
- Simplify platform setup files (sensor.py, calendar.py, device_tracker.py)
- Move dynamic entity management to manager classes
- Remove manual listener registration from platform files
- Use CoordinatorEntity pattern consistently

API enhancements:
- Improve error handling in divera_api.py
- Add centralized permission checking
- Implement response validation helper
- Better type hints and docstrings

Code quality:
- Remove redundant coordinator storage in hass.data
- Implement proper async patterns
- Add template rendering support in device_action.py
- Improve diagnostic data collection

Documentation:
- Update README with new architecture
- Add English translation improvements
- Update service descriptions in services.yaml

	modified:   README.en.md
	modified:   README.md
	modified:   custom_components/diveracontrol/__init__.py
	modified:   custom_components/diveracontrol/calendar.py
	new file:   custom_components/diveracontrol/calendar_entity.py
	modified:   custom_components/diveracontrol/device_action.py
	modified:   custom_components/diveracontrol/device_tracker.py
	new file:   custom_components/diveracontrol/device_tracker_entity.py
	modified:   custom_components/diveracontrol/diagnostics.py
	modified:   custom_components/diveracontrol/divera_api.py
	modified:   custom_components/diveracontrol/divera_data.py
	modified:   custom_components/diveracontrol/entity.py
	modified:   custom_components/diveracontrol/sensor.py
	new file:   custom_components/diveracontrol/sensor_entity.py
	modified:   custom_components/diveracontrol/service.py
	modified:   custom_components/diveracontrol/services.yaml
	modified:   custom_components/diveracontrol/translations/de.json
	modified:   custom_components/diveracontrol/translations/en.json
	modified:   custom_components/diveracontrol/utils.py
  * test_service.py (30 tests): Service handlers
  * test_device_action.py (24 tests): Device automations
  * test_divera_api.py (25 tests): API client
  * test_config_flow.py (8 tests): Configuration flows
  * test_coordinator.py (3 tests): Data coordinator
  * test_init.py (3 tests): Integration setup
- Test coverage: 63% overall
  * service.py: 88%
  * device_action.py: 79%
  * divera_api.py: 98%
  * config_flow.py: 92%
  * coordinator.py: 100%
- Add test infrastructure
  * pytest.ini with coverage configuration
  * requirements_test.txt
  * conftest.py with centralized fixtures
  * Optimized test fixtures (94% size reduction)
- Fix code quality issues (Ruff linting)
  * Remove unused imports and variables
  * Fix duplicate imports

Changes to be committed:
	new file:   .coveragerc
	new file:   .github/workflows/test.yml
	new file:   .vscode/settings.json
	modified:   README.md
	new file:   coverage_DaMonsta_Okt-15-221814-2025_Conflict.xml
	modified:   custom_components/diveracontrol/__init__.py
	modified:   custom_components/diveracontrol/config_flow.py
	modified:   custom_components/diveracontrol/divera_api.py
	modified:   custom_components/diveracontrol/divera_credentials.py
	modified:   custom_components/diveracontrol/divera_data.py
	modified:   custom_components/diveracontrol/utils.py
	new file:   pytest.ini
	new file:   requirements_test.txt
	new file:   tests/__init__.py
	new file:   tests/conftest.py
	new file:   tests/fixtures/api_get_pull_all.json
	new file:   tests/fixtures/api_post_auth_invalid.json
	new file:   tests/fixtures/api_post_auth_multi_ucr.json
	new file:   tests/fixtures/api_post_auth_single_ucr.json
	new file:   tests/test_calendar.py
	new file:   tests/test_config_flow.py
	new file:   tests/test_coordinator.py
	new file:   tests/test_device_action.py
	new file:   tests/test_device_tracker.py
	new file:   tests/test_divera_api.py
	new file:   tests/test_init.py
	new file:   tests/test_sensor.py
	new file:   tests/test_service.py
Refactor manager entities into helper classes and improve entity setup

Convert sensor and device tracker managers to plain helpers (start/stop)
Ensure platforms start managers and register unload hooks
Improve entity naming and unique_id handling to avoid unnamed entities
Tighten unsubscribe typing and add hass references where required
Fix service handlers and payload parsing

Accept both int and str keys for message channel lookups
Make news survey extraction robust to list and string inputs
Align news/news-survey payload structure with tests
Improve input validation and error handling for service calls
Tests, CI and quality

Update and add unit tests (tests/test_divera_credentials.py, tests/test_divera_data.py, tests/test_utils.py)
Update existing tests to reflect refactor and service changes
Update CI workflow (ci_pipeline.yml) and services schema (services.yaml)
Misc

Update translations (de/en) and various module fixes (config_flow, utils, data normalizer, device action, coordinator, div era_api, div era_data)
Small typing, import-order and lint fixes applied across the integration

Changes to be committed:
	modified:   .github/workflows/ci_pipeline.yml
	deleted:    coverage_DaMonsta_Okt-15-221814-2025_Conflict.xml
	modified:   custom_components/diveracontrol/__init__.py
	modified:   custom_components/diveracontrol/calendar.py
	modified:   custom_components/diveracontrol/calendar_entity.py
	modified:   custom_components/diveracontrol/config_flow.py
	modified:   custom_components/diveracontrol/const.py
	modified:   custom_components/diveracontrol/coordinator.py
	modified:   custom_components/diveracontrol/data_normalizer.py
	modified:   custom_components/diveracontrol/device_action.py
	modified:   custom_components/diveracontrol/device_tracker.py
	modified:   custom_components/diveracontrol/device_tracker_entity.py
	modified:   custom_components/diveracontrol/divera_api.py
	modified:   custom_components/diveracontrol/divera_data.py
	modified:   custom_components/diveracontrol/entity.py
	modified:   custom_components/diveracontrol/sensor.py
	modified:   custom_components/diveracontrol/sensor_entity.py
	modified:   custom_components/diveracontrol/service.py
	modified:   custom_components/diveracontrol/services.yaml
	modified:   custom_components/diveracontrol/translations/de.json
	modified:   custom_components/diveracontrol/translations/en.json
	modified:   custom_components/diveracontrol/utils.py
	modified:   tests/conftest.py
	modified:   tests/test_calendar.py
	modified:   tests/test_device_action.py
	modified:   tests/test_divera_api.py
	new file:   tests/test_divera_credentials.py
	new file:   tests/test_divera_data.py
	modified:   tests/test_init.py
	modified:   tests/test_service.py
	new file:   tests/test_utils.py
Changes to be committed:
	modified:   tests/test_service.py
…ames in conftest\n\n- Update service tests to use (matches ServiceDataNormalizer)\n- Add autouse fixture to rename threads so pytest-homeassistant plugin does not fail in CI\n\nNo production code changed.
@moehrem moehrem merged commit 9afc1d9 into main Oct 17, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants