-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/enumerations module #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ce47535
Add comprehensive enumerations module for type-safe device control
eman 276a9f5
Fix changelog: clarify enum serialization happens in model not CLI
eman 0e7c55b
Fix documentation: replace non-existent OperationMode with correct enums
eman 9416fb7
Update changelog with documentation fix
eman 237b03e
Clarify use_enum_values comment: affects validation not serialization
eman c603e41
Fix comment: replace invalid HYBRID with ENERGY_SAVER enum value
eman 0c85b44
Fix mode descriptions in event_emitter_demo for accuracy
eman f4b8143
Fix line length and move enum comment to docstring
eman 2b3ee28
Fix backwards OnOffFlag logic in device_feature_callback
eman 6af1d7a
Fix regression: restore DhwOperationSetting enum usage
eman 8933fe1
Replace all remaining magic numbers with enum values
eman 55bb1a6
Relocate CommandCode enum to enums.py module
eman 1c254db
Remove backward compatibility for CommandCode import
eman 5011d52
Fix anti_legionella_example import after CommandCode relocation
eman bdbc871
Fix documentation: replace DeviceControl with CommandCode
eman df04e50
Add cycle detection to _convert_enums_to_names method
eman ba14843
Use asyncio.Event for thread-safe shutdown handling
eman c2d92c7
Use explicit enum.value in format strings
eman f0a1092
Fix remaining self.running references to use shutdown_event
eman 6e2c358
Remove unnecessary temporary variable in _convert_enums_to_names
eman 571c408
Fix RST escape sequence in documentation
eman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,293 @@ | ||
| Enumerations Reference | ||
| ====================== | ||
|
|
||
| This document provides a comprehensive reference for all enumerations used in | ||
| the Navien NWP500 protocol. | ||
|
|
||
| Device Control Commands | ||
| ----------------------- | ||
|
|
||
| .. autoclass:: nwp500.enums.CommandCode | ||
| :members: | ||
| :undoc-members: | ||
|
|
||
| These command IDs are used in MQTT control messages to change device settings | ||
| and trigger actions. The most commonly used commands include: | ||
|
|
||
| - **Power Control**: ``POWER_ON``, ``POWER_OFF`` | ||
| - **Temperature**: ``DHW_TEMPERATURE`` | ||
| - **Operation Mode**: ``DHW_MODE`` | ||
| - **TOU**: ``TOU_ON``, ``TOU_OFF`` | ||
| - **Maintenance**: ``AIR_FILTER_RESET``, ``ANTI_LEGIONELLA_ON`` | ||
|
|
||
| Example usage:: | ||
|
|
||
| from nwp500 import CommandCode | ||
|
|
||
| # Send temperature command | ||
| command = CommandCode.DHW_TEMPERATURE | ||
| params = [120] # 60°C in half-degree units | ||
|
|
||
| Status Value Enumerations | ||
| -------------------------- | ||
|
|
||
| OnOffFlag | ||
| ~~~~~~~~~ | ||
|
|
||
| .. autoclass:: nwp500.enums.OnOffFlag | ||
| :members: | ||
| :undoc-members: | ||
|
|
||
| Generic on/off flag used throughout status fields for power status, TOU status, | ||
| recirculation status, vacation mode, anti-legionella, and other boolean settings. | ||
|
|
||
| **Note**: Device uses ``1=OFF, 2=ON`` (not standard 0/1 boolean). | ||
|
|
||
| Operation | ||
| ~~~~~~~~~ | ||
|
|
||
| .. autoclass:: nwp500.enums.Operation | ||
| :members: | ||
| :undoc-members: | ||
|
|
||
| Device operation state indicating overall device activity. | ||
|
|
||
| DhwOperationSetting | ||
| ~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| .. autoclass:: nwp500.enums.DhwOperationSetting | ||
| :members: | ||
| :undoc-members: | ||
|
|
||
| User-configured DHW heating mode preference. This determines which heat source(s) | ||
| the device will use when heating is needed: | ||
|
|
||
| - **HEAT_PUMP**: Most efficient but slower heating | ||
| - **ELECTRIC**: Fastest but uses most energy | ||
| - **ENERGY_SAVER**: Hybrid mode - balanced efficiency | ||
| - **HIGH_DEMAND**: Hybrid mode - maximum heating capacity | ||
| - **VACATION**: Energy-saving mode for extended absences | ||
| - **POWER_OFF**: Device powered off | ||
|
|
||
| Example:: | ||
|
|
||
| from nwp500 import DhwOperationSetting | ||
| from nwp500.enums import DHW_OPERATION_SETTING_TEXT | ||
|
|
||
| mode = DhwOperationSetting.ENERGY_SAVER | ||
| print(f"Current mode: {DHW_OPERATION_SETTING_TEXT[mode]}") # "Hybrid: Efficiency" | ||
|
|
||
| CurrentOperationMode | ||
| ~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| .. autoclass:: nwp500.enums.CurrentOperationMode | ||
| :members: | ||
| :undoc-members: | ||
|
|
||
| Real-time operational state (read-only). This reflects what the device is actually | ||
| doing right now, which may differ from the configured mode setting: | ||
|
|
||
| - **STANDBY**: Device idle, not actively heating | ||
| - **HEAT_PUMP_MODE**: Heat pump actively running | ||
| - **HYBRID_EFFICIENCY_MODE**: Actively heating in Energy Saver mode | ||
| - **HYBRID_BOOST_MODE**: Actively heating in High Demand mode | ||
|
|
||
| Example:: | ||
|
|
||
| from nwp500 import CurrentOperationMode | ||
| from nwp500.enums import CURRENT_OPERATION_MODE_TEXT | ||
|
|
||
| mode = CurrentOperationMode.HEAT_PUMP_MODE | ||
| print(f"Device state: {CURRENT_OPERATION_MODE_TEXT[mode]}") # "Heat Pump" | ||
|
|
||
| HeatSource | ||
| ~~~~~~~~~~ | ||
|
|
||
| .. autoclass:: nwp500.enums.HeatSource | ||
| :members: | ||
| :undoc-members: | ||
|
|
||
| Currently active heat source (read-only status). This reflects what the device | ||
| is *currently* using, not what mode it's set to. In Hybrid mode, this field | ||
| shows which heat source(s) are active at any moment. | ||
|
|
||
| DREvent | ||
| ~~~~~~~ | ||
|
|
||
| .. autoclass:: nwp500.enums.DREvent | ||
| :members: | ||
| :undoc-members: | ||
|
|
||
| Demand Response event status. Allows utilities to manage grid load by signaling | ||
| water heaters to reduce consumption (shed) or pre-heat (load up) before peak periods. | ||
|
|
||
| WaterLevel | ||
| ~~~~~~~~~~ | ||
|
|
||
| .. autoclass:: nwp500.enums.WaterLevel | ||
| :members: | ||
| :undoc-members: | ||
|
|
||
| Hot water level indicator displayed as gauge in app. IDs are non-sequential, | ||
| likely represent bit positions for multi-level displays. | ||
|
|
||
| FilterChange | ||
| ~~~~~~~~~~~~ | ||
|
|
||
| .. autoclass:: nwp500.enums.FilterChange | ||
| :members: | ||
| :undoc-members: | ||
|
|
||
| Air filter status for heat pump models. Indicates when air filter maintenance | ||
| is needed. | ||
|
|
||
| RecirculationMode | ||
| ~~~~~~~~~~~~~~~~~ | ||
|
|
||
| .. autoclass:: nwp500.enums.RecirculationMode | ||
| :members: | ||
| :undoc-members: | ||
|
|
||
| Recirculation pump operation mode: | ||
|
|
||
| - **ALWAYS**: Pump continuously runs | ||
| - **BUTTON**: Manual activation only (hot button) | ||
| - **SCHEDULE**: Runs on configured schedule | ||
| - **TEMPERATURE**: Activates when pipe temp drops below setpoint | ||
|
|
||
| Time of Use (TOU) Enumerations | ||
| ------------------------------- | ||
|
|
||
| TouWeekType | ||
| ~~~~~~~~~~~ | ||
|
|
||
| .. autoclass:: nwp500.enums.TouWeekType | ||
| :members: | ||
| :undoc-members: | ||
|
|
||
| Day grouping for TOU schedules. Allows separate schedules for weekdays and | ||
| weekends to account for different electricity rates and usage patterns. | ||
|
|
||
| TouRateType | ||
| ~~~~~~~~~~~ | ||
|
|
||
| .. autoclass:: nwp500.enums.TouRateType | ||
| :members: | ||
| :undoc-members: | ||
|
|
||
| Electricity rate period type. Device behavior can be configured for each period: | ||
|
|
||
| - **OFF_PEAK**: Lowest rates - device heats aggressively | ||
| - **MID_PEAK**: Medium rates - device heats normally | ||
| - **ON_PEAK**: Highest rates - device minimizes heating | ||
|
|
||
| Temperature and Unit Enumerations | ||
| ---------------------------------- | ||
|
|
||
| TemperatureType | ||
| ~~~~~~~~~~~~~~~ | ||
|
|
||
| .. autoclass:: nwp500.enums.TemperatureType | ||
| :members: | ||
| :undoc-members: | ||
|
|
||
| Temperature display unit preference (Celsius or Fahrenheit). | ||
|
|
||
| **Alias**: ``TemperatureUnit`` in models.py for backward compatibility. | ||
|
|
||
| TempFormulaType | ||
| ~~~~~~~~~~~~~~~ | ||
|
|
||
| .. autoclass:: nwp500.enums.TempFormulaType | ||
| :members: | ||
| :undoc-members: | ||
|
|
||
| Temperature conversion formula type. Different device models use slightly different | ||
| rounding algorithms when converting internal Celsius values to Fahrenheit: | ||
|
|
||
| - **ASYMMETRIC** (Type 0): Special rounding based on raw value remainder | ||
| - **STANDARD** (Type 1): Simple round to nearest integer | ||
|
|
||
| This ensures the mobile app matches the device's built-in display exactly. | ||
|
|
||
| Device Type Enumerations | ||
| ------------------------- | ||
|
|
||
| UnitType | ||
| ~~~~~~~~ | ||
|
|
||
| .. autoclass:: nwp500.enums.UnitType | ||
| :members: | ||
| :undoc-members: | ||
|
|
||
| Navien device/unit model types. Common values: | ||
|
|
||
| - **NPF** (513): Heat pump water heater (primary model for this library) | ||
| - **NPE**: Tankless water heater | ||
| - **NCB**: Condensing boiler | ||
| - **NPN**: Condensing water heater | ||
|
|
||
| Values with ``CAS_`` prefix indicate cascading systems where multiple units | ||
| work together. | ||
|
|
||
| DeviceType | ||
| ~~~~~~~~~~ | ||
|
|
||
| .. autoclass:: nwp500.enums.DeviceType | ||
| :members: | ||
| :undoc-members: | ||
|
|
||
| Communication device type (WiFi module model). | ||
|
|
||
| FirmwareType | ||
| ~~~~~~~~~~~~ | ||
|
|
||
| .. autoclass:: nwp500.enums.FirmwareType | ||
| :members: | ||
| :undoc-members: | ||
|
|
||
| Firmware component types. Devices may have multiple firmware components that | ||
| can be updated independently. | ||
|
|
||
| Display Text Helpers | ||
| -------------------- | ||
|
|
||
| The enums module also provides dictionaries for converting enum values to | ||
| user-friendly display text: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| from nwp500.enums import ( | ||
| DHW_OPERATION_SETTING_TEXT, | ||
| CURRENT_OPERATION_MODE_TEXT, | ||
| HEAT_SOURCE_TEXT, | ||
| DR_EVENT_TEXT, | ||
| RECIRC_MODE_TEXT, | ||
| TOU_RATE_TEXT, | ||
| FILTER_STATUS_TEXT, | ||
| ERROR_CODE_TEXT, | ||
| ) | ||
|
|
||
| # Usage examples | ||
| from nwp500 import DhwOperationSetting, CurrentOperationMode, ErrorCode | ||
|
|
||
| # User-configured mode | ||
| mode = DhwOperationSetting.ENERGY_SAVER | ||
| print(DHW_OPERATION_SETTING_TEXT[mode]) # "Hybrid: Efficiency" | ||
|
|
||
| # Current operational state | ||
| state = CurrentOperationMode.HEAT_PUMP_MODE | ||
| print(CURRENT_OPERATION_MODE_TEXT[state]) # "Heat Pump" | ||
|
|
||
| # Error codes | ||
| error = ErrorCode.E407_DHW_TEMP_SENSOR | ||
| print(ERROR_CODE_TEXT[error]) # "Abnormal DHW Temperature Sensor" | ||
|
|
||
| Related Documentation | ||
| --------------------- | ||
|
|
||
| For detailed protocol documentation, see: | ||
|
|
||
| - :doc:`protocol/device_status` - Status field definitions | ||
| - :doc:`guides/time_of_use` - TOU scheduling and rate types | ||
| - :doc:`protocol/control_commands` - Control command usage |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.