Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes are listed here. Versions follow [Semantic Versioning](https://semver.org/).

## Unreleased

### Changed

- The conversion log has a `friendly_name` column, so a named plug is recorded with the name you typed, its hostname and both MAC addresses.

## [0.5.0] - 2026-11-22

### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ Useful options for `convert`:
- `--server http://<box>` uses a `switchback serve` running on another machine, so you can carry a laptop to the plugs.
- `--fw-byte 0D` sets the update trigger's version byte. Switchback already tries 0C, 0D and 0E.
- `--domain .lan` finds converted plugs by DNS name when mDNS cannot cross VLANs.
- Every converted plug is recorded in `switchback-plugs.csv` in your home folder: time, name and both MAC addresses. The file stays on your computer. `--log other.csv` picks another file and `--no-log` turns it off.
- Every converted plug is recorded in `switchback-plugs.csv` in your home folder: time, the name you gave it, and both MAC addresses. The file stays on your computer. `--log other.csv` picks another file and `--no-log` turns it off.
- `--printer host:9100` prints a label on a ZPL printer. The layout is fixed for 1.5 x 0.5 inch labels at 203 dpi. On other label sizes it will print small or clipped.
- `--payload my.bin` serves your own ESPHome factory image instead of the portal one.

Expand Down
1 change: 1 addition & 0 deletions src/switchback/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ def name_plug(plug: Any, payloads: Payloads, mode: str, ssid: str, password: str
friendly = friendly[:-1]
payloads.select(mode, ssid, password, name=hostname, friendly_name=friendly)
plug.name = hostname
plug.friendly_name = friendly
say(f"It will be {hostname!r}, shown as {friendly!r}.")


Expand Down
11 changes: 9 additions & 2 deletions src/switchback/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,16 @@ def write_log(path: Path, plug: Plug, address: str) -> None:
with path.open("a", newline="", encoding="utf-8") as handle:
writer = csv.writer(handle)
if new:
writer.writerow(["time", "name", "wifi_mac", "ble_mac", "address"])
writer.writerow(["time", "name", "friendly_name", "wifi_mac", "ble_mac", "address"])
writer.writerow(
[datetime.datetime.now().isoformat(timespec="seconds"), plug.name, plug.wifi_mac, plug.ble_mac, address]
[
datetime.datetime.now().isoformat(timespec="seconds"),
plug.name,
getattr(plug, "friendly_name", "") or "",
plug.wifi_mac,
plug.ble_mac,
address,
]
)


Expand Down
22 changes: 22 additions & 0 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,25 @@ def test_a_name_is_patched_into_either_payload(server):
def test_old_firmware_cannot_be_named(flasher):
payloads = Payloads(flasher, make_factory(placeholders=False, name_slots=False), None)
assert not payloads.can_name("portal")


def test_log_records_the_name_with_both_macs(tmp_path, flasher, factory):
import csv

from switchback import cli, convert

class FakePlug:
name = "sbplug-a1b2c3"
wifi_mac = "aa:bb:cc:a1:b2:c3"
ble_mac = "aa:bb:cc:a1:b2:c5"

plug = FakePlug()
payloads = Payloads(flasher, factory, factory)
cli.name_plug(plug, payloads, "portal", "", "", "Garage Freezer")
log = tmp_path / "plugs.csv"
convert.write_log(log, plug, "hotspot")
convert.write_log(log, FakePlug(), "hotspot")
rows = list(csv.DictReader(log.open(encoding="utf-8")))
assert rows[0]["name"] == "garage-freezer" and rows[0]["friendly_name"] == "Garage Freezer"
assert rows[0]["wifi_mac"] == "aa:bb:cc:a1:b2:c3" and rows[0]["ble_mac"] == "aa:bb:cc:a1:b2:c5"
assert rows[1]["name"] == "sbplug-a1b2c3" and rows[1]["friendly_name"] == ""
Loading