Skip to content

Commit 9306809

Browse files
rusty-bitclaude
andcommitted
Expose Time of Use as per-bit switches instead of a select
Register 146 is a bit map (bit 0 enable, bits 1-7 Monday..Sunday), so a select over whole-register values could not represent every combination: an inverter with TOU enabled and no day bits reads 1, matched no option and left the entity blank, hiding that TOU was active. Each bit is now its own switch, written with the coordinator's read-modify-write so the other bits survive. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 6993336 commit 9306809

4 files changed

Lines changed: 97 additions & 28 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog (personal fork)
22

3+
## 0.1.8
4+
- Fix: Time of Use (register 146) is a bit map - bit 0 enables it, bits 1-7 are the
5+
weekdays - not an enumeration. The old `Time of Use` select listed whole-register
6+
values, so an inverter with TOU on and no day bits (146 = 1) matched nothing and the
7+
entity stayed blank. It is replaced by a `Time of Use` switch plus one switch per day
8+
(disabled by default); each writes only its own bit, leaving the others untouched.
9+
The old `time_of_use_days` select is gone - delete the stale entity in Home Assistant.
10+
311
## 0.1.7
412
- Change: "Battery Shutdown SOC" and "Battery Low SOC" are now named
513
"Battery Shutdown SOC (cutoff)" (register 115) and "Battery Low SOC (warning)"

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ Rebadged units on the same platform (Sunsynk, etc.) will generally work too.
133133
|------|----------|
134134
| Switch | Inverter On/Off, Solar Sell (Export), Grid Charge Enable, Generator Charge Enable |
135135
| Select | Work Mode (Selling First / Zero Export To Load / Zero Export To CT) |
136+
> **Time of Use.** Register 146 is a bit map: the **Time of Use** switch is bit 0 and the seven day switches (disabled by default) are bits 1-7. Each writes only its own bit.
137+
136138
> **SOC settings.** While Time of Use is enabled (register 146), the inverter discharges only to the active slot's **TOU SOC**, not to *Battery Low SOC (warning)* — that one is the warning level, and *Battery Shutdown SOC (cutoff)* is the real cutoff. The TOU SOC entities ship disabled; enable them to change the floor.
137139
138140
| Number | Max Sell Power, Max Grid Output Power, Active Power Regulation, Battery Max Charge/Discharge Current, Grid Charge Current, Battery Shutdown/Restart/Low SOC, Battery Capacity, Grid Voltage High/Low limits |

‎custom_components/deye_modbus/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
"requirements": [
1717
"pymodbus>=3.5.0"
1818
],
19-
"version": "0.1.7"
19+
"version": "0.1.8"
2020
}

‎custom_components/deye_modbus/maps/sun_3ph_hybrid.yaml‎

Lines changed: 86 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,39 +1597,98 @@ controls:
15971597
- label: Load First
15981598
value: 1
15991599

1600-
- type: select
1600+
# Register 146 is a bit map, not an enumeration: bit 0 enables Time of Use and
1601+
# bits 1-7 are Monday..Sunday. A select over whole-register values cannot show
1602+
# combinations the list does not contain (an inverter with TOU on and no day
1603+
# bits reads 1 and left the entity blank), so each bit gets its own switch and
1604+
# the write is a read-modify-write that leaves the other bits alone.
1605+
- type: switch
16011606
name: Time of Use
1602-
unique_id: time_of_use_days
1607+
unique_id: time_of_use_enable
16031608
group: Time of Use
16041609
register_type: holding
16051610
address: 146
1611+
bit: 0
16061612
icon: mdi:calendar-clock
16071613
entity_category: config
1608-
options:
1609-
- label: Disabled
1610-
value: 0
1611-
- label: Every day
1612-
value: 255
1613-
- label: Weekdays
1614-
value: 63
1615-
- label: Weekend
1616-
value: 193
1617-
- label: Monday
1618-
value: 3
1619-
- label: Tuesday
1620-
value: 5
1621-
- label: Wednesday
1622-
value: 9
1623-
- label: Thursday
1624-
value: 17
1625-
- label: Friday
1626-
value: 33
1627-
- label: Saturday
1628-
value: 65
1629-
- label: Sunday
1630-
value: 129
1631-
1632-
# ------------------------------------------------------ Battery Setting page
1614+
1615+
- type: switch
1616+
name: Time of Use Monday
1617+
unique_id: tou_day_monday
1618+
group: Time of Use
1619+
register_type: holding
1620+
address: 146
1621+
bit: 1
1622+
icon: mdi:calendar
1623+
entity_category: config
1624+
enabled_default: false
1625+
1626+
- type: switch
1627+
name: Time of Use Tuesday
1628+
unique_id: tou_day_tuesday
1629+
group: Time of Use
1630+
register_type: holding
1631+
address: 146
1632+
bit: 2
1633+
icon: mdi:calendar
1634+
entity_category: config
1635+
enabled_default: false
1636+
1637+
- type: switch
1638+
name: Time of Use Wednesday
1639+
unique_id: tou_day_wednesday
1640+
group: Time of Use
1641+
register_type: holding
1642+
address: 146
1643+
bit: 3
1644+
icon: mdi:calendar
1645+
entity_category: config
1646+
enabled_default: false
1647+
1648+
- type: switch
1649+
name: Time of Use Thursday
1650+
unique_id: tou_day_thursday
1651+
group: Time of Use
1652+
register_type: holding
1653+
address: 146
1654+
bit: 4
1655+
icon: mdi:calendar
1656+
entity_category: config
1657+
enabled_default: false
1658+
1659+
- type: switch
1660+
name: Time of Use Friday
1661+
unique_id: tou_day_friday
1662+
group: Time of Use
1663+
register_type: holding
1664+
address: 146
1665+
bit: 5
1666+
icon: mdi:calendar
1667+
entity_category: config
1668+
enabled_default: false
1669+
1670+
- type: switch
1671+
name: Time of Use Saturday
1672+
unique_id: tou_day_saturday
1673+
group: Time of Use
1674+
register_type: holding
1675+
address: 146
1676+
bit: 6
1677+
icon: mdi:calendar
1678+
entity_category: config
1679+
enabled_default: false
1680+
1681+
- type: switch
1682+
name: Time of Use Sunday
1683+
unique_id: tou_day_sunday
1684+
group: Time of Use
1685+
register_type: holding
1686+
address: 146
1687+
bit: 7
1688+
icon: mdi:calendar
1689+
entity_category: config
1690+
enabled_default: false
1691+
16331692
- type: select
16341693
name: Battery Control Mode
16351694
unique_id: batt_control_mode

0 commit comments

Comments
 (0)