Skip to content

Commit a9155a3

Browse files
feat(1P): add Time of Use Sell Mode switches (registers 274-279, bit 6)
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>
1 parent c0adb5c commit a9155a3

1 file changed

Lines changed: 80 additions & 0 deletions

File tree

  • pv_inverter/packages/deye_hybrid_1p

‎pv_inverter/packages/deye_hybrid_1p/tou.yaml‎

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ switch:
100100
modbus_controller_id: ${modbus_controller_id}
101101
name: "Time of Use 1 Charge Enable"
102102
id: switch_time_point_1_charge_enable
103+
restore_mode: DISABLED
103104
register_type: holding
104105
address: 274
105106
bitmask: 1
@@ -110,6 +111,7 @@ switch:
110111
modbus_controller_id: ${modbus_controller_id}
111112
name: "Time of Use 2 Charge Enable"
112113
id: switch_time_point_2_charge_enable
114+
restore_mode: DISABLED
113115
register_type: holding
114116
address: 275
115117
bitmask: 1
@@ -120,6 +122,7 @@ switch:
120122
modbus_controller_id: ${modbus_controller_id}
121123
name: "Time of Use 3 Charge Enable"
122124
id: switch_time_point_3_charge_enable
125+
restore_mode: DISABLED
123126
register_type: holding
124127
address: 276
125128
bitmask: 1
@@ -130,6 +133,7 @@ switch:
130133
modbus_controller_id: ${modbus_controller_id}
131134
name: "Time of Use 4 Charge Enable"
132135
id: switch_time_point_4_charge_enable
136+
restore_mode: DISABLED
133137
register_type: holding
134138
address: 277
135139
bitmask: 1
@@ -140,6 +144,7 @@ switch:
140144
modbus_controller_id: ${modbus_controller_id}
141145
name: "Time of Use 5 Charge Enable"
142146
id: switch_time_point_5_charge_enable
147+
restore_mode: DISABLED
143148
register_type: holding
144149
address: 278
145150
bitmask: 1
@@ -150,11 +155,86 @@ switch:
150155
modbus_controller_id: ${modbus_controller_id}
151156
name: "Time of Use 6 Charge Enable"
152157
id: switch_time_point_6_charge_enable
158+
restore_mode: DISABLED
153159
register_type: holding
154160
address: 279
155161
bitmask: 1
156162
icon: "mdi:battery-plus"
157163

164+
# Sell Mode = undocumented bit 6 (0x40) of the per-slot control registers 274-279.
165+
# Native modbus_controller bitmask switch. Writing a bitmask switch blind-writes
166+
# (state ? bitmask : 0), so toggling Sell clears the other bits (incl. grid-charge
167+
# bit0) and vice-versa -> buy and sell are mutually exclusive per slot.
168+
# restore_mode: DISABLED is REQUIRED here (and on the Charge Enable switches above):
169+
# a modbus switch otherwise writes its restored state on boot, and because the write
170+
# clobbers the whole register that boot-write would wipe grid-charge/sell on every
171+
# flash. DISABLED = read-only on boot, write only on user toggle.
172+
- platform: modbus_controller
173+
use_write_multiple: true
174+
modbus_controller_id: ${modbus_controller_id}
175+
name: "Time of Use 1 Sell Mode"
176+
id: switch_time_point_1_sell_mode
177+
restore_mode: DISABLED
178+
register_type: holding
179+
address: 274
180+
bitmask: 64
181+
icon: "mdi:transmission-tower-export"
182+
183+
- platform: modbus_controller
184+
use_write_multiple: true
185+
modbus_controller_id: ${modbus_controller_id}
186+
name: "Time of Use 2 Sell Mode"
187+
id: switch_time_point_2_sell_mode
188+
restore_mode: DISABLED
189+
register_type: holding
190+
address: 275
191+
bitmask: 64
192+
icon: "mdi:transmission-tower-export"
193+
194+
- platform: modbus_controller
195+
use_write_multiple: true
196+
modbus_controller_id: ${modbus_controller_id}
197+
name: "Time of Use 3 Sell Mode"
198+
id: switch_time_point_3_sell_mode
199+
restore_mode: DISABLED
200+
register_type: holding
201+
address: 276
202+
bitmask: 64
203+
icon: "mdi:transmission-tower-export"
204+
205+
- platform: modbus_controller
206+
use_write_multiple: true
207+
modbus_controller_id: ${modbus_controller_id}
208+
name: "Time of Use 4 Sell Mode"
209+
id: switch_time_point_4_sell_mode
210+
restore_mode: DISABLED
211+
register_type: holding
212+
address: 277
213+
bitmask: 64
214+
icon: "mdi:transmission-tower-export"
215+
216+
- platform: modbus_controller
217+
use_write_multiple: true
218+
modbus_controller_id: ${modbus_controller_id}
219+
name: "Time of Use 5 Sell Mode"
220+
id: switch_time_point_5_sell_mode
221+
restore_mode: DISABLED
222+
register_type: holding
223+
address: 278
224+
bitmask: 64
225+
icon: "mdi:transmission-tower-export"
226+
227+
- platform: modbus_controller
228+
use_write_multiple: true
229+
modbus_controller_id: ${modbus_controller_id}
230+
name: "Time of Use 6 Sell Mode"
231+
id: switch_time_point_6_sell_mode
232+
restore_mode: DISABLED
233+
register_type: holding
234+
address: 279
235+
bitmask: 64
236+
icon: "mdi:transmission-tower-export"
237+
158238
- platform: template
159239
name: "Time of Use All Charge Enable"
160240
id: switch_time_of_use_all_charge_enable

0 commit comments

Comments
 (0)