Skip to content

feat(1P): add Time of Use Sell Mode switches (registers 274-279, bit 6) - #125

Merged
Lewa-Reka merged 1 commit into
Lewa-Reka:mainfrom
SupermotoJerry:feature/tou-sell-mode
Sep 9, 2026
Merged

Lewa-Reka merged 1 commit into
Lewa-Reka:mainfrom
SupermotoJerry:feature/tou-sell-mode

Conversation

@SupermotoJerry

@SupermotoJerry SupermotoJerry commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds six "Time of Use N Sell Mode" switches for the single-phase inverter, toggling the undocumented bit 6 (0x40) of the per-slot Time-of-Use control registers 274-279 (hardware-validated; not in the V119 protocol). Implemented as native modbus_controller bitmask switches, mirroring the existing Charge Enable switches (bit 0); grid-charge (buy) and sell are mutually exclusive per slot.

Also sets restore_mode: DISABLED on the Sell Mode and Charge Enable switches so they no longer write registers 274-279 on boot: a modbus switch re-asserts its restored state during setup(), and a bitmask write clobbers the whole register, which wiped grid-charge/sell settings on every flash.

Changes relate to

  • Docs
  • Deye 3P LP
  • Deye 3P HV
  • Deye 1P LP
  • Other

Changes

Added six switches "Time of Use 1–6 Sell Mode" to the single-phase package — native modbus_controller bitmask switches on bit 6 (0x40) of registers 274–279, one per Time-of-Use slot, mirroring the existing "Charge Enable" switches (bit 0).
Added restore_mode: DISABLED to the new Sell Mode switches and the existing Charge Enable switches on registers 274–279.

Notes

Undocumented bit: bit 6 isn't in the 2025 V119 modbus protocol, but is hardware-validated — enabling "sell" for a time point on the inverter's own screen sets it (e.g. register 277 reads 0x0040 with sell enabled for slot 4) See image below.
Buy/sell are mutually exclusive per slot: a bitmask-switch write sets its own bit and clears the rest of the register, so enabling Sell clears grid-charge (bit 0) and vice-versa.
restore_mode: DISABLED is required: a modbus_controller switch otherwise re-asserts its restored state during setup(), and because a bitmask write overwrites the whole 16-bit register, that boot-write wiped the slot's grid-charge/sell bits on every flash. DISABLED makes these switches read-only on boot (state still comes from polling; writes happen only on user toggle). This also hardens the existing Charge Enable switches against the same boot-clobber.
Trade-off (identical to how Charge Enable already behaves): toggling a switch clears the other mode bits in that register at write time.
1P only — the 3P package is untouched.

How it was verified

Flashed to hardware: toggling Time of Use - Sell Mode sets/clears bit 6 (0x0040) of the matching register (274–279), cross-checked against the inverter's own Sell Mode setting for that slot.
Confirmed mutual exclusion: enabling Sell clears that slot's grid-charge bit, and enabling Charge Enable clears the sell bit.
Confirmed the boot fix: with restore_mode: DISABLED, grid-charge and sell settings now survive a flash (previously they were reset to 0 on every flash).

New Sell Mode inside system work mode

image

Inverter Firmware Version

image

@lucize

lucize commented Jul 8, 2026

Copy link
Copy Markdown

tested it on 3P LV and it didn't work, tried bitmask: 40 suggested by chatgpt based on kellerza/sunsynk#635 but the grid relay kept disconnecting until a full restart of the inverter so be warned about it

@SupermotoJerry

Copy link
Copy Markdown
Contributor Author

tested it on 3P LV and it didn't work, tried bitmask: 40 suggested by chatgpt based on kellerza/sunsynk#635 but the grid relay kept disconnecting until a full restart of the inverter so be warned about it

Its not for a 3P LV its only for 1P (single phase).

You need to make sure your inverter also has the sell mode otherwise it wont work.

@SupermotoJerry

Copy link
Copy Markdown
Contributor Author

tested it on 3P LV and it didn't work, tried bitmask: 40 suggested by chatgpt based on kellerza/sunsynk#635 but the grid relay kept disconnecting until a full restart of the inverter so be warned about it

Another way you can test it is online. You can send a modbus command directly to the inverter though the Deye Cloud.

image

on this page of changing the settings online. you can nagivate to the "Customised Command" tab

In the customised command tab you can send modbus frames

then create a modbus request according to the documentation online for a 3P inverter that would be

01 03 00 AC 00 06 (CRC)
01 03 00 AC 00 06 (05 E9)

if you send that to your inverter and send me the response I'll decode it.

I looked up the 3P modbus protocol and found a document V105.4-20240813

And it had this
image

@lucize

lucize commented Jul 8, 2026

Copy link
Copy Markdown

Yes, it's the latest firmware with sell enabled, I'll see about bit5.
thanks!

@lucize

lucize commented Jul 8, 2026

Copy link
Copy Markdown

seems that it was already implemented in #45
it also work like this (without lambda) but then it will clear the grid change:

 # TOU Time1 Sell Mode
 - platform: modbus_controller
   modbus_controller_id: ${modbus_controller_id}
   name: "Time of Use 1 Sell Mode"
   use_write_multiple: true
   restore_mode: DISABLED
   id: switch_time_of_use_1_sell
   register_type: holding
   address: 172
   bitmask: 0x20
   icon: "mdi:transmission-tower-export"

 # TOU Time2 Sell Mode
 - platform: modbus_controller
   modbus_controller_id: ${modbus_controller_id}
   use_write_multiple: true
   restore_mode: DISABLED
   name: "Time of Use 2 Sell Mode"
   id: switch_time_of_use_2_sell
   register_type: holding
   address: 173
   bitmask: 0x20
   icon: "mdi:transmission-tower-export"

 # TOU Time3 Sell Mode
 - platform: modbus_controller
   modbus_controller_id: ${modbus_controller_id}
   use_write_multiple: true
   restore_mode: DISABLED
   name: "Time of Use 3 Sell Mode"
   id: switch_time_of_use_3_sell
   register_type: holding
   address: 174
   bitmask: 0x20
   icon: "mdi:transmission-tower-export"

 # TOU Time4 Sell Mode
 - platform: modbus_controller
   modbus_controller_id: ${modbus_controller_id}
   use_write_multiple: true
   restore_mode: DISABLED
   name: "Time of Use 4 Sell Mode"
   id: switch_time_of_use_4_sell
   register_type: holding
   address: 175
   bitmask: 0x20
   icon: "mdi:transmission-tower-export"

 # TOU Time5 Sell Mode
 - platform: modbus_controller
   modbus_controller_id: ${modbus_controller_id}
   use_write_multiple: true
   restore_mode: DISABLED
   name: "Time of Use 5 Sell Mode"
   id: switch_time_of_use_5_sell
   register_type: holding
   address: 176
   bitmask: 0x20
   icon: "mdi:transmission-tower-export"

 # TOU Time6 Sell Mode
 - platform: modbus_controller
   modbus_controller_id: ${modbus_controller_id}
   use_write_multiple: true
   restore_mode: DISABLED
   name: "Time of Use 6 Sell Mode"
   id: switch_time_of_use_6_sell
   register_type: holding
   address: 177
   bitmask: 0x20
   icon: "mdi:transmission-tower-export"  

Adds six "Time of Use N Sell Mode" switches for the single-phase inverter,
toggling the undocumented bit 6 (0x40) of the per-slot Time-of-Use control
registers 274-279 (hardware-validated; not in the V119 protocol). Implemented
as native modbus_controller bitmask switches, mirroring the existing Charge
Enable switches (bit 0); grid-charge (buy) and sell are mutually exclusive per
slot.

Also sets restore_mode: DISABLED on the Sell Mode and Charge Enable switches so
they no longer write registers 274-279 on boot: a modbus switch re-asserts its
restored state during setup(), and a bitmask write clobbers the whole register,
which wiped grid-charge/sell settings on every flash.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Lewa-Reka

Copy link
Copy Markdown
Owner

@SupermotoJerry thx

@Lewa-Reka
Lewa-Reka merged commit 6489d10 into Lewa-Reka:main Sep 9, 2026
9 checks passed
@SupermotoJerry
SupermotoJerry deleted the feature/tou-sell-mode branch October 11, 2026 02:06
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.

3 participants