Skip to content

Commit c288af2

Browse files
authored
Merge pull request #8 from eman/device_status
power on / off feature in cli
2 parents fd4b2d4 + fc5cd60 commit c288af2

7 files changed

Lines changed: 480 additions & 32 deletions

File tree

README.rst

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ The library includes a command line interface for quick monitoring and device in
7979
# Get device feature/capability information
8080
python -m nwp500.cli --device-feature
8181
82+
# Turn device on
83+
python -m nwp500.cli --power-on
84+
85+
# Turn device off
86+
python -m nwp500.cli --power-off
87+
88+
# Turn device on and see updated status
89+
python -m nwp500.cli --power-on --status
90+
8291
# Set operation mode and see response
8392
python -m nwp500.cli --set-mode energy-saver
8493
@@ -105,6 +114,8 @@ The library includes a command line interface for quick monitoring and device in
105114
* ``--status``: Print current device status as JSON. Can be combined with control commands to see updated status.
106115
* ``--device-info``: Print comprehensive device information (firmware, model, capabilities) via MQTT as JSON and exit
107116
* ``--device-feature``: Print device capabilities and feature settings via MQTT as JSON and exit
117+
* ``--power-on``: Turn the device on and display response
118+
* ``--power-off``: Turn the device off and display response
108119
* ``--set-mode MODE``: Set operation mode and display response. Valid modes: heat-pump, energy-saver, high-demand, electric, vacation, standby
109120
* ``--set-dhw-temp TEMP``: Set DHW (Domestic Hot Water) target temperature in Fahrenheit (115-150°F) and display response
110121
* ``--monitor``: Continuously monitor status every 30 seconds and log to CSV (default)
@@ -156,19 +167,21 @@ Operation Modes
156167
* - Heat Pump Mode
157168
- 1
158169
- Most energy-efficient mode using only the heat pump. Longest recovery time.
159-
* - Energy Saver Mode
170+
* - Electric Mode
160171
- 2
172+
- Fastest recovery using only electric heaters. Least energy-efficient.
173+
* - Energy Saver Mode
174+
- 3
161175
- Default mode. Balances efficiency and recovery time using both heat pump and electric heater.
162176
* - High Demand Mode
163-
- 3
164-
- Uses electric heater more frequently for faster recovery time.
165-
* - Electric Mode
166177
- 4
167-
- Fastest recovery using only electric heaters. Least energy-efficient.
178+
- Uses electric heater more frequently for faster recovery time.
168179
* - Vacation Mode
169180
- 5
170181
- Suspends heating to save energy during extended absences.
171182

183+
**Important:** When you set a mode, you're configuring the ``dhwOperationSetting`` (what mode to use when heating). The device's current operational state is reported in ``operationMode`` (0=Standby, 32=Heat Pump active, 64=Energy Saver active, 96=High Demand active). See the `Device Status Fields documentation <docs/DEVICE_STATUS_FIELDS.rst>`_ for details on this distinction.
184+
172185
MQTT Protocol
173186
=============
174187

docs/DEVICE_STATUS_FIELDS.rst

Lines changed: 208 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ This document lists the fields found in the ``status`` object of device status m
4444
- Sub error code providing additional error details. See ERROR_CODES.rst for details.
4545
- None
4646
* - ``operationMode``
47-
- integer
47+
- OperationMode
4848
- None
49-
- The current operation mode of the device. See Operation Modes section below.
49+
- The current **actual operational state** of the device (what it's doing RIGHT NOW). Reports status values: 0=Standby, 32=Heat Pump active, 64=Energy Saver active, 96=High Demand active. See Operation Modes section below for the critical distinction between this and ``dhwOperationSetting``.
5050
- None
5151
* - ``operationBusy``
5252
- integer
@@ -229,9 +229,9 @@ This document lists the fields found in the ``status`` object of device status m
229229
- Type of program reservation.
230230
- None
231231
* - ``dhwOperationSetting``
232-
- integer
232+
- OperationMode
233233
- None
234-
- DHW operation setting.
234+
- User's configured DHW operation mode preference. This field uses the same ``OperationMode`` enum as ``operationMode`` but contains command mode values (1=HEAT_PUMP, 2=ELECTRIC, 3=ENERGY_SAVER, 4=HIGH_DEMAND, 5=VACATION, 6=POWER_OFF). When the device is powered off via the power-off command, this field will show 6 (POWER_OFF). This is how to distinguish between "powered off" vs "on but in standby". See the Operation Modes section below for details.
235235
- None
236236
* - ``temperatureType``
237237
- integer
@@ -469,31 +469,31 @@ The ``operationMode`` field is an integer that maps to the following modes. Thes
469469
- High
470470
- Most energy-efficient mode, using only the heat pump. Recovery time varies with ambient temperature and humidity. Higher ambient temperature and humidity improve efficiency and reduce recovery time.
471471
* - 2
472+
- Electric
473+
- Fast
474+
- Very Low
475+
- Uses only upper and lower electric heaters (not simultaneously). Least energy-efficient with shortest recovery time. Can operate continuously for up to 72 hours before automatically reverting to previous mode.
476+
* - 3
472477
- Energy Saver (Hybrid: Efficiency)
473478
- Fast
474479
- Very High
475480
- Default mode. Combines the heat pump and electric heater for balanced efficiency and recovery time. Heat pump is primarily used with electric heater for backup. Applied during initial shipment and factory reset.
476-
* - 3
481+
* - 4
477482
- High Demand (Hybrid: Boost)
478483
- Very Fast
479484
- Low
480485
- Combines heat pump and electric heater with more frequent use of electric heater for faster recovery. Suitable when higher hot water supply is needed.
481-
* - 4
482-
- Electric
483-
- Fast
484-
- Very Low
485-
- Uses only upper and lower electric heaters (not simultaneously). Least energy-efficient with shortest recovery time. Can operate continuously for up to 72 hours before automatically reverting to previous mode.
486486
* - 5
487487
- Vacation
488488
- None
489489
- Very High
490490
- Suspends heating to save energy during absences (0-99 days). Only minimal operations like freeze protection and anti-seize are performed. Heating resumes 9 hours before the vacation period ends.
491491

492492

493-
Observed Operation Modes (from network traffic analysis)
493+
Operation Modes
494494
--------------------------------------------------------
495495

496-
The following ``operationMode`` values have been observed in status messages from the device. These values appear to correspond to the commanded modes as follows:
496+
The following ``operationMode`` values in status messages from the device. These values appear to correspond to the commanded modes as follows:
497497

498498
.. list-table::
499499
:header-rows: 1
@@ -509,13 +509,204 @@ The following ``operationMode`` values have been observed in status messages fro
509509
- Heat Pump
510510
- Corresponds to commanded mode ``HEAT_PUMP`` (1).
511511
* - 64
512-
- Energy Saver
513-
- Corresponds to commanded mode ``ENERGY_SAVER`` (2).
512+
- Energy Saver (Hybrid: Efficiency)
513+
- Corresponds to commanded mode ``ENERGY_SAVER`` (3).
514514
* - 96
515-
- High Demand
516-
- Corresponds to commanded mode ``HIGH_DEMAND`` (3).
515+
- High Demand (Hybrid: Boost)
516+
- Corresponds to commanded mode ``HIGH_DEMAND`` (4).
517+
518+
The commanded mode ``ELECTRIC`` (2) has been observed to result in ``operationMode`` values of both 64 and 96 at different times.
519+
520+
Understanding operationMode vs dhwOperationSetting
521+
---------------------------------------------------
522+
523+
These two fields serve different purposes and it's critical to understand their relationship:
524+
525+
Field Definitions
526+
^^^^^^^^^^^^^^^^^
527+
528+
**dhwOperationSetting** (OperationMode enum with command values 1-5)
529+
The user's **configured mode preference** - what heating mode the device should use when it needs to heat water. This is set via the ``dhw-mode`` command and persists until changed by the user or device.
530+
531+
* Type: ``OperationMode`` enum
532+
* Values:
533+
534+
* 1 = ``HEAT_PUMP`` (Heat Pump Only)
535+
* 2 = ``ELECTRIC`` (Electric Only)
536+
* 3 = ``ENERGY_SAVER`` (Hybrid: Efficiency)
537+
* 4 = ``HIGH_DEMAND`` (Hybrid: Boost)
538+
* 5 = ``VACATION`` (Vacation mode)
539+
* 6 = ``POWER_OFF`` (Device is powered off)
540+
541+
* Set by: User via app, CLI, or MQTT command
542+
* Changes: Only when user explicitly changes the mode or powers device off/on
543+
* Meaning: "When heating is needed, use this mode" OR "I'm powered off" (if value is 6)
544+
* **Critical**: Value 6 (``POWER_OFF``) indicates the device was powered off via the power-off command. This is how to distinguish between "powered off" and "on but idle".
545+
546+
**operationMode** (OperationMode enum with status values 0, 32, 64, 96)
547+
The device's **current actual operational state** - what the device is doing RIGHT NOW. This reflects real-time operation and changes automatically based on whether the device is idle or actively heating.
548+
549+
* Type: ``OperationMode`` enum
550+
* Values:
551+
552+
* 0 = ``STANDBY`` (Idle, not heating)
553+
* 32 = ``HEAT_PUMP_MODE`` (Heat Pump actively running)
554+
* 64 = ``HYBRID_EFFICIENCY_MODE`` (Energy Saver actively heating)
555+
* 96 = ``HYBRID_BOOST_MODE`` (High Demand actively heating)
556+
557+
* Set by: Device automatically based on heating demand
558+
* Changes: Dynamically as device starts/stops heating
559+
* Meaning: "This is what I'm doing right now"
560+
* **Note**: This field shows ``STANDBY`` (0) both when device is powered off AND when it's on but not heating. Check ``dhwOperationSetting`` to determine if device is actually powered off (value 6).
561+
562+
Key Relationship
563+
^^^^^^^^^^^^^^^^
564+
565+
The relationship between these fields can be summarized as:
566+
567+
* ``dhwOperationSetting`` = "What mode to use when heating"
568+
* ``operationMode`` = "Am I heating right now, and if so, how?"
569+
570+
A device can be **idle** (``operationMode = STANDBY``) while still being **configured** for a specific heating mode (``dhwOperationSetting = ENERGY_SAVER``). When the tank temperature drops and heating begins, ``operationMode`` will change to reflect active heating (e.g., ``HYBRID_EFFICIENCY_MODE``), but ``dhwOperationSetting`` remains unchanged.
571+
572+
Real-World Examples
573+
^^^^^^^^^^^^^^^^^^^
574+
575+
**Example 1: Energy Saver Mode, Tank is Hot**
576+
::
577+
578+
dhwOperationSetting = 3 (ENERGY_SAVER) # Configured mode
579+
operationMode = 0 (STANDBY) # Currently idle
580+
dhwChargePer = 100 # Tank is fully charged
581+
582+
*Interpretation:* Device is configured for Energy Saver mode, but water is already at temperature so no heating is occurring.
583+
584+
**Example 2: Energy Saver Mode, Actively Heating**
585+
::
586+
587+
dhwOperationSetting = 3 (ENERGY_SAVER) # Configured mode
588+
operationMode = 64 (HYBRID_EFFICIENCY_MODE) # Actively heating
589+
operationBusy = true # Heating in progress
590+
dhwChargePer = 75 # Tank at 75%
591+
592+
*Interpretation:* Device is using Energy Saver mode to heat the tank, currently at 75% charge.
593+
594+
**Example 3: High Demand Mode, Heat Pump Running**
595+
::
596+
597+
dhwOperationSetting = 4 (HIGH_DEMAND) # Configured mode
598+
operationMode = 32 (HEAT_PUMP_MODE) # Heat pump active
599+
compUse = true # Compressor running
600+
601+
*Interpretation:* Device is configured for High Demand but is currently running just the heat pump component (hybrid heating will engage electric elements as needed).
602+
603+
**Example 4: Device Powered Off**
604+
::
605+
606+
dhwOperationSetting = 6 (POWER_OFF) # Device powered off
607+
operationMode = 0 (STANDBY) # Currently idle
608+
operationBusy = false # No heating
609+
610+
*Interpretation:* Device was powered off using the power-off command. Although ``operationMode`` shows ``STANDBY`` (same as an idle device), the ``dhwOperationSetting`` value of 6 indicates it's actually powered off, not just idle.
611+
612+
Displaying Status in a User Interface
613+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
614+
615+
For user-facing applications, follow these guidelines:
616+
617+
**Primary Mode Display**
618+
Use ``dhwOperationSetting`` to show the user's configured mode preference. This is what users expect to see as "the current mode" because it represents their selection.
619+
620+
**Important**: Check for value 6 (``POWER_OFF``) first to show "Off" or "Powered Off" status.
621+
622+
Example display::
623+
624+
Mode: Energy Saver [when dhwOperationSetting = 1-5]
625+
Mode: Off [when dhwOperationSetting = 6]
626+
627+
**Status Indicator**
628+
Use ``operationMode`` to show real-time operational status:
629+
630+
* ``STANDBY`` (0): Show "Idle" or "Standby" indicator (but check ``dhwOperationSetting`` for power-off state)
631+
* ``HEAT_PUMP_MODE`` (32): Show "Heating (Heat Pump)" or heating indicator
632+
* ``HYBRID_EFFICIENCY_MODE`` (64): Show "Heating (Energy Saver)" or heating indicator
633+
* ``HYBRID_BOOST_MODE`` (96): Show "Heating (High Demand)" or heating indicator
634+
635+
**Combined Display Examples**
636+
::
637+
638+
# Device on and idle
639+
Mode: Energy Saver
640+
Status: Idle ○
641+
Tank: 100%
642+
643+
# Device on and heating
644+
Mode: Energy Saver
645+
Status: Heating ●
646+
Tank: 75%
647+
648+
# Device powered off
649+
Mode: Off
650+
Status: Powered Off
651+
Tank: 100%
652+
653+
**Code Example**
654+
.. code-block:: python
655+
656+
def format_mode_display(status: DeviceStatus) -> dict:
657+
"""Format mode and status for UI display."""
658+
659+
# Check if device is powered off first
660+
if status.dhwOperationSetting == OperationMode.POWER_OFF:
661+
return {
662+
'configured_mode': 'Off',
663+
'operational_state': 'Powered Off',
664+
'is_heating': False,
665+
'is_powered_on': False,
666+
'tank_charge': status.dhwChargePer,
667+
}
668+
669+
# User's configured mode (what they selected)
670+
configured_mode = status.dhwOperationSetting.name.replace('_', ' ').title()
671+
672+
# Current operational state
673+
if status.operationMode == OperationMode.STANDBY:
674+
operational_state = "Idle"
675+
is_heating = False
676+
elif status.operationMode == OperationMode.HEAT_PUMP_MODE:
677+
operational_state = "Heating (Heat Pump)"
678+
is_heating = True
679+
elif status.operationMode == OperationMode.HYBRID_EFFICIENCY_MODE:
680+
operational_state = "Heating (Energy Saver)"
681+
is_heating = True
682+
elif status.operationMode == OperationMode.HYBRID_BOOST_MODE:
683+
operational_state = "Heating (High Demand)"
684+
is_heating = True
685+
else:
686+
operational_state = "Unknown"
687+
is_heating = False
688+
689+
return {
690+
'configured_mode': configured_mode, # "Energy Saver"
691+
'operational_state': operational_state, # "Idle" or "Heating..."
692+
'is_heating': is_heating, # True/False
693+
'is_powered_on': True, # Device is on
694+
'tank_charge': status.dhwChargePer, # 0-100
695+
}
696+
697+
**Display Notes**
698+
699+
1. **Never display operationMode as "the mode"** - users don't care that the device is in "HYBRID_EFFICIENCY_MODE", they want to know it's set to "Energy Saver"
700+
701+
2. **Do use operationMode for heating indicators** - it tells you whether the device is actively heating right now
702+
703+
3. **Mode changes affect dhwOperationSetting** - when a user changes the mode, you're setting ``dhwOperationSetting``
704+
705+
4. **operationMode changes automatically** - you cannot directly set this; it changes based on device operation
706+
707+
5. **Both fields use OperationMode enum** - but different value ranges (1-6 for dhwOperationSetting, 0/32/64/96 for operationMode)
517708

518-
The commanded mode ``ELECTRIC`` (4) has been observed to result in ``operationMode`` values of both 64 and 96 at different times.
709+
6. **Power off detection** - Check if ``dhwOperationSetting == 6`` (``POWER_OFF``) to determine if device is powered off vs just idle
519710

520711
Technical Notes
521712
---------------

docs/MQTT_CLIENT.rst

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -442,15 +442,21 @@ set_dhw_mode()
442442
443443
await mqtt_client.set_dhw_mode(device: Device, mode_id: int) -> int
444444
445-
Set DHW (Domestic Hot Water) operation mode.
445+
Set DHW (Domestic Hot Water) operation mode. This sets the ``dhwOperationSetting`` field, which determines what heating mode the device will use when it needs to heat water.
446446

447447
**Command:** ``33554433``
448448

449449
**Mode:** ``dhw-mode``
450450

451-
**Mode IDs:** - ``1``: Heat Pump (most efficient, longest recovery) -
452-
``2``: Electric (least efficient, fastest recovery) - ``3``: Energy
453-
Saver (default, balanced) - ``4``: High Demand (faster recovery)
451+
**Mode IDs (command values):**
452+
453+
* ``1``: Heat Pump Only (most efficient, longest recovery)
454+
* ``2``: Electric Only (least efficient, fastest recovery)
455+
* ``3``: Energy Saver (default, balanced - Hybrid: Efficiency)
456+
* ``4``: High Demand (faster recovery - Hybrid: Boost)
457+
* ``5``: Vacation (suspend heating for 0-99 days)
458+
459+
**Important:** Setting the mode updates ``dhwOperationSetting`` but does not immediately change ``operationMode``. The ``operationMode`` field reflects the device's current operational state and changes automatically when the device starts/stops heating. See :doc:`DEVICE_STATUS_FIELDS` for details on the relationship between these fields.
454460

455461
set_dhw_temperature()
456462
'''''''''''''''''''''
@@ -749,13 +755,16 @@ Response Message
749755
"dhwTemperature": 120,
750756
"tankUpperTemperature": 115,
751757
"tankLowerTemperature": 110,
752-
"operationMode": 3,
758+
"operationMode": 64,
759+
"dhwOperationSetting": 3,
753760
"dhwUse": true,
754761
"compUse": false
755762
}
756763
}
757764
}
758765
766+
Note: ``operationMode`` shows the current operational state (64 = Energy Saver actively heating), while ``dhwOperationSetting`` shows the configured mode preference (3 = Energy Saver). See :doc:`DEVICE_STATUS_FIELDS` for the distinction between these fields.
767+
759768
Error Handling
760769
--------------
761770

docs/MQTT_MESSAGES.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ The device sends a response to a control message on the ``responseTopic`` specif
133133

134134
The ``sessionID`` in the response corresponds to the ``sessionID`` of the request.
135135

136-
The ``response`` object contains a ``status`` object that reflects the new state. For example, after a ``dhw-mode`` command with ``param`` ``[3]``\ , the ``dhwOperationSetting`` in the ``status`` object of the response will be ``3``.
136+
The ``response`` object contains a ``status`` object that reflects the new state. For example, after a ``dhw-mode`` command with ``param`` ``[3]`` (Energy Saver), the ``dhwOperationSetting`` field in the ``status`` object will be ``3``. Note that ``operationMode`` may still show ``0`` (STANDBY) if the device is not currently heating. See :doc:`DEVICE_STATUS_FIELDS` for the important distinction between ``dhwOperationSetting`` (configured mode) and ``operationMode`` (current operational state).
137137

138138
Device Status Messages
139139
----------------------

0 commit comments

Comments
 (0)