feat: SONOFF TRVZB add smart thermostat features (v1.4.4)#11466
feat: SONOFF TRVZB add smart thermostat features (v1.4.4)#11466CubeZ2mDeveloper wants to merge 5 commits intoKoenkk:masterfrom
Conversation
src/devices/sonoff.ts
Outdated
| smartTemControl(): ModernExtend { | ||
| const expose = e | ||
| .enum("smart_temperature_control", ea.ALL, ["off", "precision", "smart"]) | ||
| .withDescription("Manual mode: off or precision (same effect), Smart mode: automatic temperature control"); |
There was a problem hiding this comment.
As already described in Koenkk/zigbee-OTA#1056 (comment), I would suggest adding a bit more detail for clarity.
A very good explanation of the new Smart Temperature Control ("Adaptive Mode") can be found here:
zigpy/zigpy-ota#23
"This release adds Adaptive Mode. It is a feature designed to minimize temperature fluctuations.
When enabled, the device dynamically adjusts the valve opening based on the temperature changes and the target temperature to maintain a more stable environment.Note: Enabling Adaptive Mode will automatically disable Valve Opening Percentage and Temperature Accuracy."
If linking external references is acceptable, the official Sonoff blog announcement may also be helpful:
https://sonoff.tech/blogs/news/trvzb-upgrade-smart-temperature-control-for-more-stable-room-temperature
In particular, it would be great if the PR could explicitly include (or mention) the note that enabling Smart Temperature Control will disable the "Valve Opening Percentage" and "Temp. Accuracy" features, since this behavioural change is particularly important for users.
Thank you so much for your contribution!
There was a problem hiding this comment.
Thanks for the detailed feedback and the references!
We've updated the PR to add a clearer description of Smart Temperature Control (Adaptive Mode) and explicitly documented that enabling it will disable Valve Opening Percentage and Temperature Accuracy.
About the firmware: We are official maintainers of the Sonoff/eWeLink Zigbee firmware. The attached OTA image is provided by us and originates from the official Sonoff/eWeLink firmware release pipeline (i.e., an official build intended for end users).
There was a problem hiding this comment.
Nice, thanks!
Really appreciate the work you put into this. Happy to see more of your stuff down the road!
src/devices/sonoff.ts
Outdated
| commandsResponse: {}, | ||
| }); | ||
| }, | ||
| smartTemControl(): ModernExtend { |
There was a problem hiding this comment.
Use m.enumLookup instead, example:
zigbee-herdsman-converters/src/devices/sonoff.ts
Line 2245 in d4f085c
There was a problem hiding this comment.
Thanks for the review. I considered using m.enumLookup but the mapping for this attribute is asymmetric between write and report:
toZigbee (write):
| Mode | Value |
|---|---|
| off | 0x00 |
| precision | 0x00 |
| smart | 0x02 |
fromZigbee (report):
| Value | Mode |
|---|---|
0x00 |
off |
0x01 |
precision |
0x02 |
smart |
The device reports precision as 0x01, but to activate it you must write 0x00 (same as off). 0x01 is a report-only value — writing it to the device has no effect.
m.enumLookup uses a single lookup object for both directions (getFromLookup for toZigbee, getFromLookupByValue for fromZigbee), so it cannot represent this asymmetry. If we use {off: 0x00, precision: 0x01, smart: 0x02}, setting precision would incorrectly write 0x01 to the device.
Would you prefer I:
- Keep the custom extend as-is to preserve correct behavior, or
- Simplify to
m.enumLookupwith{off: 0x00, precision: 0x01, smart: 0x02}and accept that writingprecisionsends0x01(which the device will ignore)?
Happy to adjust either way.
There was a problem hiding this comment.
I've modified m.enumLookup to accept a custom converter: 3aac9b3
Example:
zigbee-herdsman-converters/src/devices/sonoff.ts
Line 2618 in af672bb
There was a problem hiding this comment.
Thanks @Koenkk! I've refactored smartTempControl to use m.enumLookup with a custom fzConvert to handle the asymmetric mapping (device reports 0x01 for manual mode, but write requires 0x00). Also renamed precision to manual for clarity.
Thanks for adding the fzConvert parameter to enumLookup — it made this much cleaner.
|
@CubeZ2mDeveloper I 've made an external converter of your PR to test. It seems to works ok : https://gist.github.com/KipK/448992d0f5abda3c934bd098b29e4408 Something you should add to this PR, is to force the valve position to 100% when the mode is switched to Smart or the other internal logic. If valve is previously set to 0 when in manual mode, then heating won't never start in Smart mode. Fixing this on firmware side would be even better |
|
I've tested the addition as an external converter as well. It appears to work correctly. I can hear the valve open and close partially when manipulating the temperature. I am just wondering, what is the 'precision mode'? Why is setting it to precision mode mapped to writing a |
Same here!, seems good. |
|
Wow finally. I made so many support tickets because of this feature. Then i finally sold my TRVs and bought aqaras w600. But they are so bad. They are very quiet, but the algoritm is really bad. How does it act on the sonoff? Someone got any graphs with current, target temp and valveposition?? Is there an expose for valve position now? |
There's no valve position on sonoff trvzb unfortunately. |
To bad. Would be an easy made expose when they now use PID control. |
Co-authored-by: grossermax <grossermax@users.noreply.github.com>
Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
a0fc160 to
f8b6b69
Compare
Thanks for testing! @ActuallyRuben Regarding your questions about precision mode: What is precision mode? Why does setting precision/manual write Is
This is why a custom |
Changes in this update
|
|
@CubeZ2mDeveloper thanks for support. Can you please then explain what is the difference between |
Does this mean:
|
Hi, @GigiPompieru |
|
So, the TRV is in off mode by default with valve values at 100% and 0%. If the user modifies these values in any way, as we can now, the TRV will switch to Will the TRV remain in manual until put into Smart or will it switch back to Sorry for all the questions, just trying to better understand the new feature. |
No worries, great questions! Does modifying valve values switch the TRV to manual ( Will it switch back to off if you restore the values to 100/0? To put it simply:
|
|
So couldn't we just leave the "off" and "on" options for smart mode, for the sake of the UX? |
I think that, even if they are not displayed in the UI, the Remember that when the |
Good point from a UX perspective! However, there are two reasons to keep the three-value enum:
|
|
When will the smart mode be available? I updated to 1.4.4, but can it already use it? |
With this #11466 (comment) yes, without it when this PR is merged, then when next Z2M release is out. |
ActuallyRuben
left a comment
There was a problem hiding this comment.
In my opinion the distinction between the 0x0 and 0x1 states is confusing. I propose presenting both values as an off state. If 0x1 is never sent to the device, and 0x0 is never reported by the device, then what difference does it make if these are encoded as the same state?
If a later firmware update adds a different meaning to these values, then we should deal with that, whenever that update arrives.
| m.enumLookup<"customSonoffTrvzb", SonoffTrvzb>({ | ||
| name: "smart_temperature_control", | ||
| // manual sends 0x00 (same as off), 0x01 is report-only | ||
| lookup: {off: 0x00, manual: 0x00, smart: 0x02}, |
There was a problem hiding this comment.
| lookup: {off: 0x00, manual: 0x00, smart: 0x02}, | |
| lookup: {off: 0x00, on: 0x02}, |
| access: "ALL", | ||
| fzConvert: (model, msg, publish, options, meta) => { | ||
| if ("smartTempControl" in msg.data) { | ||
| const valueToMode: Record<number, string> = {0: "off", 1: "manual", 2: "smart"}; |
There was a problem hiding this comment.
| const valueToMode: Record<number, string> = {0: "off", 1: "manual", 2: "smart"}; | |
| const valueToMode: Record<number, string> = {0: "off", 1: "off", 2: "on"}; |
| "Manual mode: off or manual (same effect), Smart mode: automatic temperature control. " + | ||
| 'After enabling the smart mode, "Valve Opening Percentage" and "Temperature Accuracy" will be automatically disabled.', |
There was a problem hiding this comment.
| "Manual mode: off or manual (same effect), Smart mode: automatic temperature control. " + | |
| 'After enabling the smart mode, "Valve Opening Percentage" and "Temperature Accuracy" will be automatically disabled.', | |
| 'Off: fully opens or closes the radiator valve based on a threshold temperature, ' + | |
| 'On: adjust valve opening based on a PID algorithm. ' + | |
| 'After enabling the smart mode, "Valve Opening Percentage" and "Temperature Accuracy" will be automatically disabled.', |
Although your statement is logical, as a 'basic' user I think the best way to implement it is as close as the vendor does it in its native app - be it flawed. This way there can be consistency of features and the terms used by users of all ecosystems. Secondly, even if Z2M is not strictly HA, we know most of us are also using HA. But TRVZB can he integrated in HA with ZHA and with eWelink. Having Z2M expose just |
|
For posterity, my TRVZB has been automatically upgraded to v1.4.4 and I had to send the following commands via MQTT:
|
|
yes that's how it's made on the fw, if smartTempControl is activated then you can't control the valve position. |
I understand, but:
I had to use the MQTT console to resolve the issue. Thanks |
|
In fact it is related. The converter should default to Off instead of Smart. I haven't checked but that would need to be fixed or there will have thousands of people complaining |
This is quite strange. I didn't even know that you can configure Z2M to auto-update. |
Do you know if:
|
Do you know if:
Currently my TRVs are on "smart", im using the external sensor and it is already 0.4°C below setpoint and the valves are closed. |
I agree that consistency is good. I have no clue how it's presented in eWelink. However, on SONOFF's official blog, they provided a ZHA script. In this script they appear to implement the smart temperature control setting as a simple on/off: .switch(
CustomSonoffCluster.AttributeDefs.smart_temperature_control.name,
# ControlModeType,
CustomSonoffCluster.cluster_id,
on_value=2,
off_value=0,
translation_key="adaptive_mode",
fallback_name="Adaptive mode",
)Supporting my suggestion to show it as an on/off setting in Z2M as well. |
Summary
What’s included
Testing
Tested with Zigbee2MQTT on SONOFF ZBDongle-P.
Verified:
Related
zigbee-OTA PR: Koenkk/zigbee-OTA#1056