Skip to content

hs485d: add the restoreConfigToDevice XML-RPC method - #217

Draft
jens-maus wants to merge 1 commit into
mainfrom
jens-maus/hs485d-restore-config-to-device
Draft

jens-maus wants to merge 1 commit into
mainfrom
jens-maus/hs485d-restore-config-to-device

Conversation

@jens-maus

Copy link
Copy Markdown
Member

Warning

Untested – hardware test required. This change has only been compiled. It has not been run with HomeMatic Wired (HMW) devices. Please do not merge before it has been tested on real Wired hardware (see the test plan below).

Interface.restoreConfigToDevice (Restore Config button of the device parameters page, #214) is only implemented by rfd (BidCos-RF, src/rfd/XmlRpcMethods.cpp). hs485d (BidCos-Wired) does not register the XML-RPC method, so #216 currently shows the button only for BidCos-RF devices.

hs485d already has the functionality internally. When a device is replaced, HS485Manager::ReplaceDevice() calls HS485Device::Rebuild(true, false), which:

  1. reads the stored configuration with GetConfig() (paramsets and links from the EEPROM cache, which hs485d saves in the .dev files on the CCU);
  2. writes it to the device with RestoreConfig().

This PR exposes that as an XML-RPC method:

  • HS485Device::RestoreConfigToDevice(): GetConfig() and then RestoreConfig(config, false), the same arguments as the replace path, followed by RequestSave().
  • HS485Manager::RestoreConfigToDevice(address): looks up the device of the address, like ClearConfigCache(). It throws Unknown instance (-2) for an unknown address.
  • XmlRpcMethodRestoreConfigToDevice (restoreConfigToDevice(String address)), registered next to clearConfigCache. It throws Failure when the restore fails, like rfd.
  • hs485d version 1.2.0 → 1.3.0.

Line endings (CRLF/LF per file and line) and encodings are preserved.

Risks to check on hardware

RestoreConfig() was written for a replaced, i.e. blank, device. For a device that is already configured:

  • It clears the EEPROM cache and then re-creates every link with AddLinkPeer(). It has to be checked whether existing links are duplicated or whether AddLinkPeer() fails. In the second case the restore stops in the middle and leaves a partly written configuration.
  • HS485Channel::GetConfig() leaves out the VALUES paramset, but HS485Channel::RestoreConfig() writes all paramsets except LINK, so it also calls PutParamsetValues("VALUES", …) with an empty struct. This seems to work in the replace path, but should be checked as well.

Test plan (Wired hardware)

  1. Configure an HMW device with direct links (e.g. HMW-IO-12-Sw7-DR or HMW-LC-Sw2-DR), change a few MASTER and link parameters.
  2. Call restoreConfigToDevice for the device address (XML-RPC on port 2000, or the WebUI button once the gate in ic_deviceparameters.cgi also allows BidCos-Wired).
  3. Check the hs485d log (log level LOG_ALL) for HS485Channel::RestoreConfig() errors. Check that getParamset and getLinks return the same values and links as before (no duplicate links), and that the device still behaves as configured.
  4. Repeat after resetting the device to factory settings: this is the case the method is meant for.

If this works, the WebUI gate of #216 can allow BidCos-Wired again ($iface eq $HMRFIdentifier || $iface eq "BidCos-Wired"); that is not part of this PR.

Validation

  • Native build with the x86_64-linux-gnu preset (BUILD_HS485D=ON only): compiles without warnings. git diff --check (with cr-at-eol) is clean.
  • Not run on a device.

Generated by Claude Code

Send the configuration of a device stored on the CCU (EEPROM cache,
paramsets and links) to the device again, like rfd's
restoreConfigToDevice. It reuses GetConfig() and RestoreConfig(),
which hs485d already uses to restore the configuration of a replaced
device.

Untested on Wired hardware.
@coderabbitai

coderabbitai Bot commented Oct 18, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant