Skip to content

Releases

0.15.0

Choose a tag to compare

@david2069 david2069 released this 01 Dec 03:48
d7f7aea

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. VirtualModeController falls back to 100 %, not 20 %, when the reserve is unknown.

Added

  • read_native_mode() returns active_reserve_pct from undocumented register 16001 (None if it can't be read). Measured on V12R02B60D00 only, so get_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

Choose a tag to compare

@david2069 david2069 released this 30 Nov 14:44
6d74006

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 in consecutive_failures when 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 treated partial alone as "no reply" should also check for {} (#150).
  • Connection held open: persistent=True is the default, so the controller keeps one TCP session open between calls. Pass persistent=False if another Modbus client needs the aGate (#134).

Added

  • Library-owned register reads (#134). read_registers(addr, count, table='holding'|'input') and read_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 raise ModbusExceptionError (with the Modbus exception .code) or ModbusIOError instead of returning {}. A new franklinwh_modbus.codec module encodes and decodes int16, uint16, int32, uint32 and float32, with word order and scale factor. EXTENSION_REGISTRY is exported and now lists 15500–15509, 15510, 15512, 16000 and 16001 with access ('R' for all), status and the firmware_quirks.json entry 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=False closes the socket after each call so other Modbus clients can use the aGate.

Changed

  • The extension reads in read_solar_status() and read_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

Choose a tag to compare

@david2069 david2069 released this 02 Nov 06:49
c3126c9

⚠️ Breaking change

  • read_battery_status(): battery_temp_c, battery_current_a and the per-port power_w/voltage_v/current_a/temp_c in individual_batteries are now None when the aGate doesn't report them, instead of 0. On V12R02B60D00 they are always None. Code that does arithmetic or formatting on them must handle None. individual_batteries[i].power_w is now the port's own DCW, 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 in vendor_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

Choose a tag to compare

@david2069 david2069 released this 30 Oct 07:44
a081a0a

Added

  • Opt-in write trace: FranklinWHController(..., write_trace=callback) gets one WriteRecord for 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-set write_source. It covers model writes, the extension setters, clear_alarms and SunSpecSequencer raw writes. The same records go to the franklinwh_modbus.writes logger at DEBUG (#124).

Fixed

  • set_native_mode, set_self_consumption_reserve and set_tou_reserve now 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 DCW sign corrected to positive = discharging; WSetEnaRvrt read-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

Choose a tag to compare

@david2069 david2069 released this 29 Oct 08:53
0b5371c

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): 17 PICS_ENUMS entries were one higher than SunSpec. For example, WSetEna 1 returned DISABLED, and InvSt 3 returned STARTING instead of RUNNING. They now follow the SunSpec 2 model JSON (0 DISABLED, 1 ENABLED; InvSt 0 OFF … 7 STANDBY). This affects 701 ACType, St, InvSt, ConnSt, DERMode; 703 ES; and the 704 *Ena / *EnaRvrt points (#114 A1).
  • ControlMode has the two SunSpec WSetMod values: W_MAX_PCT (0) and WATTS (1). LIMIT_ABS, LIMIT_PCT, SET_EXPORT and SET_IMPORT are removed; use ControlMode.WATTS where code used LIMIT_ABS. BatteryCommand.mode defaults to WATTS. send_command used to ignore the mode; it now sends WATTS through WSet and W_MAX_PCT through WSetPct (#114 A2, A6, B1).
  • check_state(): actual_power was the setpoint, not measured power. Read setpoint_w (the Modbus setpoint) or measured_dc_w (M714 DCW). Both use the hardware sign: positive = discharge. actual_power remains as a deprecated alias that raises a DeprecationWarning when read. Under Modbus control, battery_activity now comes from measured DC power and shows the setpoint alongside, for example Discharging (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 sends WSetPct with WSetMod=0. BatteryCommand(mode=ControlMode.W_MAX_PCT, power_pct=N) is the new percent command, and send_command sends it through WSetPct. Watts still go through WSet; 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 the WSetPct write is refused after WSetMod was changed, WSetMod is 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), with quirks_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.py converted watts to WSetPct. It now sends watts through WSet with WSetMod=1 and 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.py wrote WSetMod=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

  • Model 704 conformance results on V12R02B60D00 (#104), and V12 heartbeat, inverted reversion, 40000-mirror write echo and extension-write re-test (#107).

franklinwh-modbus 0.10.1

Choose a tag to compare

@david2069 david2069 released this 23 Oct 12:43
47e0277

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_command writes WSetMod=1 + WSet (watts), not WSetPct. It no longer writes WSetEna=0 first, and returns (False, "Command not applied: …") if the read-back differs. Code that reads WSetPct to find the active command will now see 0: read read_control_status()['wset_mode'] / ['wset_watts'], not WSetPct.
  • 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 WSet or WSetPct, 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 a cleanup block 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

Choose a tag to compare

@david2069 david2069 released this 18 Oct 11:25
c69208c

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, and healthcheck() no longer turns unhealthy on alarms. A failed alarm read is never reported as "no alarms". Read the upgrade notes if you use healthcheck(), --check-alarms or check_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). Use read_alarms() or the new active_alarms() and apply your own rule.
    • healthcheck() lists active alarms in details['alarms'] and in its recommendations, but they no longer affect healthy or message. details['blocking_alarms'] and details['can_operate'] are gone.
    • The conflict check's result['alarms'] is now {'active', 'system_alrm', 'decoded'}; can_operate and blocking are 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-alarms exits 1, and the deprecated check_blocking_alarms() returns (False, ["ALARM_READ_FAILED: …"]). Its CRITICAL_BITS are still the set that is one bit off from model 701 (#46); it's kept unchanged until the function is removed.
    • --check-alarms exits 1 if any alarm is active (before: only the fixed "critical" set). --healthcheck and --status print "ACTIVE ALARMS".
  • read_alarms() now reads models 701, 713, 714 and 502 itself (pass refresh=False if you read them in the same poll), and it fills decoded. DC ports in decoded['dc_port'] are numbered from 1, the same as read_battery_status()['individual_batteries']. (#39)
  • If read_alarms() fails, the result has an error key and the failure is logged at warning level. It used to return zeros at debug level, which looked like "no alarms". Check error before 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), from read_alarms(). Reports only. (#46)

Fixed

  • --status --detail labels 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 left decoded empty, so --check-alarms printed Battery Status: UNKNOWN and empty lists. It now reads models 701, 713, 714 and 502 first (pass refresh=False if you read them moments ago) and lists every set bit, named from the SunSpec model definitions in pysunspec2: M701 Alrm, M502 Evt (new: solar_evt, decoded['solar']), M713 Sta (OK / WARNING / ERROR), M701 MnAlrmInfo (new: vendor_info), and per DC port the DCAlrm bits plus a WARNING/ERROR DCSta. M714 PrtAlrms only 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

Choose a tag to compare

@david2069 david2069 released this 17 Oct 04:36
9088fd7

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_writable stays None after connecting. Call test_extension_writability() explicitly if you need it. That call writes 15507–15509. (#24)
  • VirtualModeController calculators (_calc_*) return the opposite sign from before: positive = charge, negative = discharge, matching BatteryCommand. Subclasses or direct callers must follow. (#20)
  • Self-consumption grid-charges only below self_reserve_pct (default 20%), not below target_soc, and no longer refuses to start with a full battery. (#20)
  • verify_command_execution() returns ok=False when 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() or read_solar_status(), the result now carries partial (e.g. ['714']) and leaves that model's keys out. read_solar_status() used to report them as 0. Use .get() on ac_power_w, dc_power_w and battery_dc_power_w, and treat a present partial as 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() or read_solar_status() was logged at debug level only. Battery power, state, current and temperature disappeared without trace, and read_solar_status() reported 0 W, 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), updates last_error, and lists the model in partial. A failed M502 still falls back to the extension solar total when one is available. consecutive_failures keeps counting whole-read failures only. (#52)
  • Battery status is read with the SunSpec values. Model 713 defines Sta as 0 OK, 1 WARNING, 2 ERROR (pysunspec2 1.3.3 model_713.json); the library tested for 6, which SunSpec does not define, so a battery ERROR was never recognised. --status now prints ERROR or WARNING, and check_blocking_alarms() reports BATTERY_FAULT on 2 instead of 6. A WARNING, or a value SunSpec does not define, is logged. Only Sta = 0 has 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 explicit test_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 6000 on a 5 kW unit discharged at 5 kW). It now clamps to the rating in the requested direction. The same fix is in tools/franklinwh_control_standalone.py. (#28)
  • Virtual-mode calculators now return the BatteryCommand convention (positive = charge, negative = discharge) that the SoC limiter and send_command() expect. Self-consumption, peak-shave and the TOU discharge strategy 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 positive WSetPct, 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 and target_soc it covers home load from the battery and charges from excess solar. Before, it charged whenever SoC was below target_soc, which defaults to 100. Starting self-consumption with a full battery is no longer refused. (#20)
  • --power/--duration honours --min-discharge-soc 0 instead of coercing it to 20. The 20% default on that path is unchanged. (#20)
  • VirtualModeController.verify_command_execution() compared the never-written M704.WSet with battery power, so it always passed. It now reads the setpoint back from WSetPct and reports a failed readback instead of assuming success. (#21)

Added

  • FranklinWHController.verify_dispatch(expected_w, tolerance_pct=20, timeout_s=0) reads back WSetEna/WSetPct and M714.DCW, compares them in the BatteryCommand convention, and returns ok, dispatched, commanded_w, actual_w and reason. It detects a dispatch the device accepted but did not act on. With timeout_s it 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_failures and data_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 runs reset_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