Repository navigation
Releases
0.15.0
Upgrade advisory: all users should upgrade. Fixes an S1 safety defect: in Emergency Backup the discharge check used the Self-Consumption reserve (8 % on the test site) instead of 100 %, and a failed mode read skipped the reserve check altogether (#90).
⚠️ Breaking changes
- Discharge refused more often (safety, #90). In Emergency Backup the reserve is now 100 %, so
validate_target_soc()refuses any discharge. Before, it used the Self-Consumption reserve (8 % on the test site). If the mode can't be read or isn't recognised, a discharge is refused with E007 instead of skipping the reserve check.VirtualModeControllerfalls back to 100 %, not 20 %, when the reserve is unknown.
Added
read_native_mode()returnsactive_reserve_pctfrom undocumented register 16001 (None if it can't be read). Measured on V12R02B60D00 only, soget_effective_reserve_level()uses it to raise the reserve, never to lower it (#90).
Full changelog: https://github.com/david2069/franklinwh-modbus/blob/v0.15.0/CHANGELOG.md
0.14.0
Raw register reads on the library's own connection (#134). One shared socket by default, with typed errors and a codec.
⚠️ Breaking changes
These change behaviour callers may rely on, so this is a minor version.
- Different failure behaviour:
read_solar_status()now returns{}and counts inconsecutive_failureswhen every discovered model fails and the extension read returns nothing. Before, it returned{'partial': ['502', '714']}and counted as a successful read, so a dead link looked live. Code that treatedpartialalone as "no reply" should also check for{}(#150). - Connection held open:
persistent=Trueis the default, so the controller keeps one TCP session open between calls. Passpersistent=Falseif another Modbus client needs the aGate (#134).
Added
- Library-owned register reads (#134).
read_registers(addr, count, table='holding'|'input')andread_register_ranges(ranges, gap=8)read raw registers on the controller's connection; reads over 125 registers are split, and nearby ranges are merged into one request. They raiseModbusExceptionError(with the Modbus exception.code) orModbusIOErrorinstead of returning{}. A newfranklinwh_modbus.codecmodule encodes and decodes int16, uint16, int32, uint32 and float32, with word order and scale factor.EXTENSION_REGISTRYis exported and now lists 15500–15509, 15510, 15512, 16000 and 16001 withaccess('R'for all),statusand thefirmware_quirks.jsonentry behind each. FranklinWHController(persistent=True): one socket shared by every call, opened after the scan, under a re-entrant lock so threads can share a controller. After a socket error a register read reconnects and retries once (the aGate drops idle sessions after about 10 s).persistent=Falsecloses the socket after each call so other Modbus clients can use the aGate.
Changed
- The extension reads in
read_solar_status()andread_native_mode()now use the shared connection. They no longer close and reopen the TCP session on every call (#53).
Full changelog: https://github.com/david2069/franklinwh-modbus/blob/v0.14.0/CHANGELOG.md
0.13.0
⚠️ Breaking change
read_battery_status():battery_temp_c,battery_current_aand the per-portpower_w/voltage_v/current_a/temp_cinindividual_batteriesare nowNonewhen the aGate doesn't report them, instead of 0. On V12R02B60D00 they are alwaysNone. Code that does arithmetic or formatting on them must handleNone.individual_batteries[i].power_wis now the port's ownDCW, not the model total (#130).
Fixed
read_battery_status()never read the M714 port block, so temperature, voltage and current were always 0 (#130).disconnect()now closes the TCP socket. Before, a raw-socket read left the aGate's single Modbus session held (#138).read_alarms()no longer reports the fixed placeholder "Manufacturer custom error info" as vendor alarm text. The string as read is invendor_info_raw(#136).SunSpecSequencer:714.DCW_2-style names resolve repeating groups (#130).
Docs
New Alarms, Errors and Exceptions page; a full SunSpec point reference (#127); per-register extension records (#132); Model 714 corrected per firmware (#129).
Bridges: this release reaches the bridges only when they move their pin. Both are on 0.10.1 and capped below 0.11, so moving needs their own testing.
Full list: CHANGELOG.
0.12.0
Added
- Opt-in write trace:
FranklinWHController(..., write_trace=callback)gets oneWriteRecordfor every Modbus write the library sends. Each record has the register, function code, raw values, the aGate's reply (OK, the exception code, or an error), the point name, the firmware and a caller-setwrite_source. It covers model writes, the extension setters,clear_alarmsandSunSpecSequencerraw writes. The same records go to thefranklinwh_modbus.writeslogger at DEBUG (#124).
Fixed
set_native_mode,set_self_consumption_reserveandset_tou_reservenow log at WARNING when the aGate refuses the write, when the read-back differs from the value written, or when the read-back fails. For example:Extension write not applied: register 15508 wrote 20, read back 8, firmware V12R02B60D00. Before, they only returned the message. No claim is made that these registers can be written (#114 A5).
Docs
- QUIRKS: M714
DCWsign corrected to positive = discharging;WSetEnaRvrtread-back no longer called "works"; the V10 reversion section names its firmware (#114 C2, C3).
Upgrade notes: no breaking changes. The write trace is opt-in; nothing changes unless you pass write_trace=. Bridges move their own pin.
v0.11.0
Breaking changes: read them before upgrading. Bridges are unaffected until each one moves its pin (franklinwh-modbus-bridge builds from v0.10.1; franklinwh-direct-connect-bridge pins ==0.10.1).
⚠️ Breaking changes
- Enum descriptions change (
get_pics_enum_desc/get_enum_desc): 17PICS_ENUMSentries were one higher than SunSpec. For example,WSetEna1 returned DISABLED, andInvSt3 returned STARTING instead of RUNNING. They now follow the SunSpec 2 model JSON (0 DISABLED, 1 ENABLED;InvSt0 OFF … 7 STANDBY). This affects 701ACType,St,InvSt,ConnSt,DERMode; 703ES; and the 704*Ena/*EnaRvrtpoints (#114 A1). ControlModehas the two SunSpecWSetModvalues:W_MAX_PCT(0) andWATTS(1).LIMIT_ABS,LIMIT_PCT,SET_EXPORTandSET_IMPORTare removed; useControlMode.WATTSwhere code usedLIMIT_ABS.BatteryCommand.modedefaults toWATTS.send_commandused to ignore the mode; it now sendsWATTSthroughWSetandW_MAX_PCTthroughWSetPct(#114 A2, A6, B1).check_state():actual_powerwas the setpoint, not measured power. Readsetpoint_w(the Modbus setpoint) ormeasured_dc_w(M714DCW). Both use the hardware sign: positive = discharge.actual_powerremains as a deprecated alias that raises aDeprecationWarningwhen read. Under Modbus control,battery_activitynow comes from measured DC power and shows the setpoint alongside, for exampleDischarging (400W, setpoint 1000W)(#114 A3).- Percent is sent as percent (#114 B1).
dispatch(..., '40%')used to convert the percentage to watts of the rating, without logging it. It now sendsWSetPctwithWSetMod=0.BatteryCommand(mode=ControlMode.W_MAX_PCT, power_pct=N)is the new percent command, andsend_commandsends it throughWSetPct. Watts still go throughWSet; neither is converted to the other. On V12R02B60D00, percent commands above 10 % or below 0 are refused (exception 3, #92), and the refusal is logged. If theWSetPctwrite is refused afterWSetModwas changed,WSetModis written back to its previous value and that is logged (tested live, 3 runs).
Added
firmware_quirks.json, shipped as package data: a per-firmware record of aGate Modbus behaviour (WSet/WSetPct sign and accepted range, charge refusal, reversion, heartbeat, 40000 mirror, reserve registers), withquirks_for(firmware)to read it (behaviour id → list of observations for that firmware). Public facts only; the controller does not act on it yet (#91).
Fixed
tools/franklinwh_control_standalone.pyconverted watts toWSetPct. It now sends watts throughWSetwithWSetMod=1and verifies the read-back (#114 B2).- The four workarounds the owner approved to keep are documented in
docs/APPROVED_WORKAROUNDS.md, and every run is logged with the tag[approved workaround #114 …]. They are the standby handshake, the software timeout, the power clamps and the 5000 W rating fallback (B3), plus the home load read from 16000 instead of 15506 (B4). The rating fallback used to be silent (#114 B3, B4). tools/franklinwh_min_demo.pywroteWSetMod=2, which SunSpec doesn't define. It now writes 1 (WATTS). Its labels now use the aGate's sign (WSet positive = discharge), so the "+1000 W" step is labelled discharge (#114 A2).- A Modbus exception response from the aGate is now logged at WARNING. The log line gives the refused register, the raw values and the firmware, for example
Refused by the aGate: write to register 40324 [0xFFCE] -> Modbus exception: 3, firmware V12R02B60D00. It covers operations run through the controller's retry path (#114 A4).
Docs
franklinwh-modbus 0.10.1
Force Discharge works on V12R02B60D00. 0.10.0 sent power as a percentage, which V12 refuses above 10 % (500 W). 0.10.1 sends watts. Tested live: 5000 W.
⚠️ Breaking changes
These change behaviour callers may rely on. Under the release policy they warranted a minor version (0.11.0), not a patch.
- Different registers:
send_commandwritesWSetMod=1+WSet(watts), notWSetPct. It no longer writesWSetEna=0first, and returns(False, "Command not applied: …")if the read-back differs. Code that readsWSetPctto find the active command will now see 0: readread_control_status()['wset_mode']/['wset_watts'], notWSetPct. - Different failure behaviour: a refused write fails at once with "Rejected by the aGate (…)", with no reconnect or resend (#96).
Known issue (unchanged)
- V12 refuses charge by either route (negative
WSetorWSetPct, exception 3). A charge command returns that rejection.
Fixed
- Force Discharge above 500 W refused on V12 (exception 3): now sent as watts.
- Refused writes treated as connection errors and resent (#96).
- Sequencer raw-address reads/writes did nothing after the scan (#99).
- Sequencer: a rejected write skipped the restore steps (#101). Steps now take
on_error, and acleanupblock always runs.
Docs
- V12R02B60D00: firmware snapshot, 40000 mirror, reserve/mode readings (16001, 15509).
- New pages: Extension Registers, API Cookbook, Modbus vs Cloud, Modbus Client Libraries, HA Modbus YAML monitoring.
- Modbus addressing uses PDU terms; unsourced "SPAN unlock" claims removed.
franklinwh-modbus 0.10.0
Alarms are reported, not decided. The library now names every active alarm from the SunSpec models and leaves the decision to the caller.
check_blocking_alarms()is deprecated, andhealthcheck()no longer turns unhealthy on alarms. A failed alarm read is never reported as "no alarms". Read the upgrade notes if you usehealthcheck(),--check-alarmsorcheck_blocking_alarms().
Upgrade notes
- The library no longer decides what an alarm means; the client does. (#40, #46)
check_blocking_alarms()is deprecated (it warns, and will be removed). Useread_alarms()or the newactive_alarms()and apply your own rule.healthcheck()lists active alarms indetails['alarms']and in its recommendations, but they no longer affecthealthyormessage.details['blocking_alarms']anddetails['can_operate']are gone.- The conflict check's
result['alarms']is now{'active', 'system_alrm', 'decoded'};can_operateandblockingare gone. VirtualModeController.run_continuous(enable_safety_checks=True)no longer stops after two alarm checks. Its SoC-limit and dispatch-verification checks are unchanged.- A failed alarm read is never "no alarms":
active_alarms()returns["Alarm read failed: …"], so--check-alarmsexits 1, and the deprecatedcheck_blocking_alarms()returns(False, ["ALARM_READ_FAILED: …"]). ItsCRITICAL_BITSare still the set that is one bit off from model 701 (#46); it's kept unchanged until the function is removed. --check-alarmsexits 1 if any alarm is active (before: only the fixed "critical" set).--healthcheckand--statusprint "ACTIVE ALARMS".
read_alarms()now reads models 701, 713, 714 and 502 itself (passrefresh=Falseif you read them in the same poll), and it fillsdecoded. DC ports indecoded['dc_port']are numbered from 1, the same asread_battery_status()['individual_batteries']. (#39)- If
read_alarms()fails, the result has anerrorkey and the failure is logged at warning level. It used to return zeros at debug level, which looked like "no alarms". Checkerrorbefore trusting an empty alarm list. (#39)
Added
FranklinWHController.active_alarms(alarms=None): every active alarm by name (system, DC port, solar, and the battery when not OK), fromread_alarms(). Reports only. (#46)
Fixed
--status --detaillabels AC Type(derived from M701.LNV). It said(M701.ACType), a point the library doesn't read; the value comes from the voltage band. (#42)read_alarms()reads the device and names every active alarm. It returned whatever another call had last loaded into the models (it never read them itself) and leftdecodedempty, so--check-alarmsprintedBattery Status: UNKNOWNand empty lists. It now reads models 701, 713, 714 and 502 first (passrefresh=Falseif you read them moments ago) and lists every set bit, named from the SunSpec model definitions in pysunspec2: M701Alrm, M502Evt(new:solar_evt,decoded['solar']), M713Sta(OK / WARNING / ERROR), M701MnAlrmInfo(new:vendor_info), and per DC port theDCAlrmbits plus a WARNING/ERRORDCSta. M714PrtAlrmsonly flags which ports have an alarm; it is not an alarm-type field. The standalone tool's name tables were not ported: its system-alarm names are shifted by one bit from model 701, and its DC-port names are not in model 714. (#39)
Full changelog: v0.9.6...v0.10.0
franklinwh-modbus 0.9.6
Upgrade advisory: all 0.9.5 users should upgrade. 0.9.5 has two S1 defects that act on the battery.
connect()writes the operating mode and reserves (15507–15509) on every connection (#24), and a charge or discharge above the device rating is clamped to full power in the opposite direction (#28). 0.9.6 also fixes the battery ERROR status, which was never recognised (#38). Read the upgrade notes below before upgrading: several behaviours changed.
Upgrade notes
Behaviour changes that can affect code built on the library:
connect()no longer runs the extension writability test, so_extension_writablestaysNoneafter connecting. Calltest_extension_writability()explicitly if you need it. That call writes 15507–15509. (#24)VirtualModeControllercalculators (_calc_*) return the opposite sign from before: positive = charge, negative = discharge, matchingBatteryCommand. Subclasses or direct callers must follow. (#20)- Self-consumption grid-charges only below
self_reserve_pct(default 20%), not belowtarget_soc, and no longer refuses to start with a full battery. (#20) verify_command_execution()returnsok=Falsewhen the readback fails. It used to assume success. (#21)- Failed status reads log at warning level (first failure, then at most once a minute, then on recovery) instead of debug. (#22)
- When one model fails inside
read_battery_status()orread_solar_status(), the result now carriespartial(e.g.['714']) and leaves that model's keys out.read_solar_status()used to report them as0. Use.get()onac_power_w,dc_power_wandbattery_dc_power_w, and treat a presentpartialas an incomplete sample. (#52)
Fixed
- Partial read failures are no longer silent. A model 714 (or 502) read that failed inside an otherwise successful
read_battery_status()orread_solar_status()was logged at debug level only. Battery power, state, current and temperature disappeared without trace, andread_solar_status()reported0W, which looks the same as an idle battery or no solar. It now logs a warning (first failure, then at most once a minute per model, then on recovery), updateslast_error, and lists the model inpartial. A failed M502 still falls back to the extension solar total when one is available.consecutive_failureskeeps counting whole-read failures only. (#52) - Battery status is read with the SunSpec values. Model 713 defines
Staas 0 OK, 1 WARNING, 2 ERROR (pysunspec2 1.3.3model_713.json); the library tested for 6, which SunSpec does not define, so a battery ERROR was never recognised.--statusnow prints ERROR or WARNING, andcheck_blocking_alarms()reportsBATTERY_FAULTon 2 instead of 6. A WARNING, or a value SunSpec does not define, is logged. OnlySta = 0has been observed on the aGate. (#38) connect()no longer writes to the device. It ran the extension writability test on every connection: it wrote 15507 (operating mode), 15508 and 15509 (reserves) with test values and restored them only if the readback matched. On a unit where those registers are writable, every connect (including every bridge reconnect) briefly changed the mode and reserves, and a dropped link could leave them changed (a 100% reserve was tested as 0%). The test is now the explicittest_extension_writability(), still run by--test-extension-write. (#24)- The rating clamp no longer reverses the direction of over-limit commands.
send_command()clamped a charge above the device rating to a full-rate discharge, and a discharge above it to a full-rate charge (e.g.--power 6000on a 5 kW unit discharged at 5 kW). It now clamps to the rating in the requested direction. The same fix is intools/franklinwh_control_standalone.py. (#28) - Virtual-mode calculators now return the
BatteryCommandconvention (positive = charge, negative = discharge) that the SoC limiter andsend_command()expect. Self-consumption, peak-shave and the TOUdischargestrategy returned the opposite sign, so the limiter ramped and blocked the wrong direction (a charge near the discharge floor was cut back or blocked without any log), and the inverted setpoint went out as a positiveWSetPct, which the device ignores. Reported by @balloobbot in #12. (#20) - Self-consumption grid-charges at full power only below
self_reserve_pct(--reserve, previously accepted but unused). Between the reserve andtarget_socit covers home load from the battery and charges from excess solar. Before, it charged whenever SoC was belowtarget_soc, which defaults to 100. Starting self-consumption with a full battery is no longer refused. (#20) --power/--durationhonours--min-discharge-soc 0instead of coercing it to 20. The 20% default on that path is unchanged. (#20)VirtualModeController.verify_command_execution()compared the never-writtenM704.WSetwith battery power, so it always passed. It now reads the setpoint back fromWSetPctand reports a failed readback instead of assuming success. (#21)
Added
FranklinWHController.verify_dispatch(expected_w, tolerance_pct=20, timeout_s=0)reads backWSetEna/WSetPctandM714.DCW, compares them in theBatteryCommandconvention, and returnsok,dispatched,commanded_w,actual_wandreason. It detects a dispatch the device accepted but did not act on. Withtimeout_sit polls while the battery ramps. Tolerance has a 100 W floor (M714.DCW reads in 100 W steps), and commands under 150 W are verified on the setpoint only. (#21)- Controller I/O health:
last_success_ts,last_error,last_error_ts,consecutive_failuresanddata_age_s, so callers can tell a dead link from an empty read. (#22) - The SoC limiter logs when it ramps a command (once per distinct value), not only when it blocks one. (#20)
Changed
send_command(duration_s=…)documents that its timeout runsreset_control_state()on a timer thread without the caller's lock. Callers that share the controller across threads should release from their own watchdog instead. A lock fix is tracked in #54.- Failed status reads (
read_battery_status,read_grid_status,read_solar_status,read_control_status) log at warning level on the first failure and then at most once a minute, plus once on recovery. They were logged at debug level only. Return values are unchanged ({}on failure). (#22)
Full changelog: v0.9.5...v0.9.6