A band above the prompt: is a Harmony remote on USB and ready, and how far a configuration write to it has got

Logitech's Harmony remotes were among the best universal remotes ever made. You told Logitech's software which equipment you had and what you wanted to watch or listen to, and the remote did the rest: it switched everything on, picked the right inputs and sent each button to the device that needed it.
The remote does all of that by itself, but changing what is on it has always gone through Logitech. Logitech stopped making Harmony remotes a couple of years ago and has been closing down the services behind them since. The original desktop software stopped working in May 2025, and the MyHarmony service that still programs the newer models could go the same way at any moment. When it does, a remote keeps doing what it did the day it was last synced, and nobody can add a device or change an activity on it again.
This project sets out to learn everything there is to know about these remotes, so that they can be programmed without any Logitech service at all: what the configuration file on the remote holds, what the firmware does with it, how a computer talks to the remote over USB and how the infrared codes are built. What we learn goes into FreeHarmony, a program for your own computer that reads the configuration off your remote, lets you change your devices and activities and writes it back. No account and no server, so nothing that can be switched off. It is early days and there is nothing to install yet.
Everything we have found out is collected in How a Harmony works: what the remotes do, each model in depth, and the configuration file, the USB protocol and the infrared codes. Each fact says how we know it, whether it was read in the firmware, measured on a remote or taken from Logitech.
It is a work in progress and some of it will turn out to be wrong. Much of the analysis was done with the help of an AI, which is why every conclusion is backed by a test that fails when it stops being true, and why mistakes are corrected in the open rather than quietly.
These remotes are on the bench: the Harmony One, 300, 350, 525, 600, 650, 700 and Touch.
Every configuration helps, whatever the model. Each one shows how Logitech's software set up a remote with devices and activities we have never configured ourselves, and that is exactly what we learn from.
Read the configuration off your remote with concordance, as described under backing up below. Then open an issue telling us which model you have and what is set up on it, and we will arrange a private way to send the file. Please don't attach it to the issue: this repository is public and a configuration can't be published here. A configuration holds the devices and activities you set up, and no account details.
Issues are also welcome when something in the reference doesn't match what your own remote does.
If you own a Harmony, back up its configuration now, whatever happens to this project: a remote that loses it can't be given a new one. concordance is an existing command line tool that reads it off:
concordance -c my-remote-config.EZHex # the configuration
concordance -f my-remote-firmware.bin # the firmware, on older models only
The firmware read works on the older models, such as the Harmony 880, 885 and the 520 and 525 family. On a Harmony One, 600, 650 or 700 it returns no usable firmware because of two entries in concordance's own list of remotes, so there the configuration is what to keep, docs/concordance-notes.md.
Use lower case flags only. -c reads the configuration and -C writes one to the remote, -f reads the firmware and -F overwrites it. A missed shift key is the difference between a backup and a reflash, and a filename without any flag lets concordance decide for itself, which for a configuration means writing it.
MIT, see LICENSE. Logitech and Harmony are trademarks of Logitech International S.A., used here only to say which hardware this is about. This project is not affiliated with Logitech.
hooks/register.tsx 217 lines1import { atom, read, update } from 'claude-code'
2import type { Register } from 'claude-code'
3
4// One line for the bench, drawn in the band above the prompt: whether a Harmony remote is on USB and ready, and how far a
5// configuration write to it has got. Everything here is read only: it asks the operating system what
6// is attached (ioreg, enumeration, never an open) and reads the journal the config writer appends to
7// beside the configuration it writes, so it can never touch a remote itself.
8//
9// It needs no lab path. The writer names its journal `<config>.write-<time>.log`, so the running
10// writer's own command line and working directory say where the journal is. Once the writer has
11// exited the journal is remembered from the last poll that saw it, which is what keeps "done" and
12// "stopped" on the line after the process is gone.
13
14// Drawn in the band above the prompt rather than on the status line, because the status line takes
15// text only and its colour is the engine's, which reads poorly on a light theme.
16const line = atom({ plugin: 'harmony-remote', key: 'line' } as const, null)
17const theme = atom({ plugin: 'harmony-remote', key: 'theme' } as const, '')
18
19// Blue on a light theme and the theme's own orange on a dark one. A theme of "auto" follows the
20// terminal, which a plugin cannot see, so it gets the orange: the theme key resolves per theme and
21// stays legible on both, where a fixed blue would not on a dark background.
22export function bandColour(themeSetting: string): string {
23 return themeSetting.startsWith('light') ? '#1f5fbf' : 'claude'
24}
25
26const POLL_MS = 3000
27// A finished or stopped write stays on the line this many polls, two minutes, so it is seen after
28// looking away.
29const LINGER_POLLS = 40
30
31// The bracket keeps a pattern from matching the shell that runs it: the shell's own command line
32// holds `confi[g]`, which the expression does not match, where a plain `config` would make every
33// poll find a writer.
34const WRITER = 'corpus/bin/write-confi[g][.]ts'
35const READER = 'corpus/bin/read-(regio[n]|confi[g])[.]ts'
36
37// Logitech's Harmony product range and Microchip's bootloader identity, which is what a Harmony in
38// recovery enumerates as (harmony-explorations packages/usb/src/transport.ts).
39const LOGITECH = 1133
40const FIRST = 0xc110
41const LAST = 0xc14f
42const MICROCHIP = 0x04d8
43const BOOTLOADER = 0x000b
44const MODELS: Record<number, string> = {
45 0xc111: 'Harmony 525',
46 0xc121: 'Harmony One',
47 0xc122: 'Harmony 600/650/700',
48 0xc124: 'Harmony 300/350',
49 0xc12b: 'Harmony Touch',
50}
51
52/** The numeric properties of each device block in an ioreg listing. */
53export function ioregBlocks(text: string): Map<string, string>[] {
54 return text.split('+-o ').slice(1).map((block) => {
55 const props = new Map<string, string>()
56 for (const m of block.matchAll(/"([A-Za-z ]+)" = ("[^"]*"|\d+)/g)) {
57 if (!props.has(m[1]!)) props.set(m[1]!, m[2]!.replace(/^"|"$/g, ''))
58 }
59 return props
60 })
61}
62
63const isHarmony = (vendor: number, product: number): boolean =>
64 vendor === LOGITECH && product >= FIRST && product <= LAST
65
66/** What the bus says: a Harmony on USB, whether its command interface is up, or one in recovery. */
67export function usbState(usb: string, hid: string): string {
68 const onBus = ioregBlocks(usb).map((p) => [Number(p.get('idVendor')), Number(p.get('idProduct'))] as const)
69 if (onBus.some(([v, p]) => v === MICROCHIP && p === BOOTLOADER)) return 'a remote in recovery (bootloader)'
70 const harmony = onBus.find(([v, p]) => isHarmony(v, p))
71 if (harmony === undefined) return 'no remote on USB'
72 const name = MODELS[harmony[1]] ?? `Harmony 0x${harmony[1].toString(16)}`
73 // The device can be on the bus while its HID interface is not up yet, or no longer: that is the
74 // state in which every read here answers "no matching Harmony remote attached".
75 const ready = ioregBlocks(hid).some((p) => isHarmony(Number(p.get('VendorID')), Number(p.get('ProductID'))))
76 return ready ? `${name} on USB, ready` : `${name} on USB, not answering yet`
77}
78
79export type WriteProgress = {
80 unit: string
81 total: number
82 erased: number
83 isDryRun: boolean
84 isVerified: boolean
85 isDone: boolean
86}
87
88/** How far a config write's journal says it got. */
89export function writeProgress(journal: string): WriteProgress {
90 return {
91 unit: /matches the recorded (\S+)/.exec(journal)?.[1] ?? 'remote',
92 total: Number(/in (\d+) block\(s\)/.exec(journal)?.[1] ?? 0),
93 erased: (journal.match(/^erasing 0x/gm) ?? []).length,
94 isDryRun: /^dry run:/m.test(journal),
95 isVerified: /reads back byte for byte identical/.test(journal),
96 isDone: /the restart is sent/.test(journal),
97 }
98}
99
100/** The status line for a write, given whether the writer is still running. */
101export function writeLine(w: WriteProgress, isRunning: boolean): string | undefined {
102 if (w.isDryRun) return undefined
103 if (w.isDone) return `${w.unit}: write done, verified, restarted`
104 if (w.isVerified) return `${w.unit}: written and verified, restarting`
105 if (!isRunning) return `${w.unit}: write STOPPED after ${w.erased} of ${w.total} blocks, rerun it`
106 if (w.total > 0 && w.erased === 0) return `${w.unit}: write starting, comparing ${w.total} blocks`
107 if (w.erased >= w.total && w.total > 0) return `${w.unit}: reading the whole configuration back`
108 return `${w.unit}: writing block ${w.erased} of ${w.total}`
109}
110
111/**
112 * The configuration a writer was started on, as an absolute path, from its command line and its
113 * working directory, or undefined when the command line names none.
114 */
115export function configOf(args: string, cwd: string): string | undefined {
116 const config = /--config[ =](\S+)/.exec(args)?.[1]
117 if (config === undefined) return undefined
118 return config.startsWith('/') ? config : `${cwd.replace(/\/$/, '')}/${config}`
119}
120
121const quote = (s: string): string => `'${s.replace(/'/g, `'\\''`)}'`
122
123export const register: Register = (on) => {
124 on('config.set', { key: 'theme' }, async ($, e, next) => {
125 const result = await next(e)
126 await update($, theme, () => String(e.value))
127 return result
128 // Not a guard: the setting has changed before this hook does anything, so a failure here only
129 // leaves the band in the old colour, and the change itself must go through either way.
130 }).catch(($, e, next) => next(e))
131
132 on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
133 const text = await read($, line)
134 if (e.props.hasSurvey || text === null) return next(e)
135 const { Box, Text } = $.ui.resolve(e)
136 // A rule above the line, so it reads as a panel of its own rather than as the tail of whatever
137 // notice the engine printed last. The rule is longer than any terminal and cut at the edge.
138 return (
139 <Box flexDirection="column" marginTop={1}>
140 <Text dimColor wrap="truncate">{'── Harmony remote ' + '─'.repeat(400)}</Text>
141 <Box paddingLeft={2}>
142 <Text color={bandColour(await read($, theme))} wrap="truncate-end">{text}</Text>
143 </Box>
144 </Box>
145 )
146 })
147
148 on('session.start', async ($, e, next) => {
149 try {
150 const row = (await $.config.list()).find((r) => r.key === 'theme')
151 await update($, theme, () => String(row?.value ?? ''))
152 } catch { /* no theme row: the band uses the orange */ }
153 let last: string | undefined
154 let busy = false
155 // The journal of the most recent write seen running, and how many polls ago it stopped.
156 let journal: string | undefined
157 let stoppedPolls = 0
158
159 const sh = async (script: string): Promise<string> => {
160 try {
161 const r = await $.process.run(['/bin/sh', '-c', script], { timeoutMs: 10_000 })
162 return r.stdout
163 } catch {
164 return ''
165 }
166 }
167
168 const poll = async (): Promise<void> => {
169 if (busy) return
170 busy = true
171 try {
172 const [usb, hid, writer, reader] = await Promise.all([
173 sh('ioreg -rc IOUSBHostDevice -w0'),
174 sh('ioreg -rc IOHIDInterface -w0'),
175 // The running writer's working directory on the first line and its command line on the
176 // second, or nothing when no write is running.
177 sh(`pid=$(pgrep -f '${WRITER}' | head -1); [ -n "$pid" ] && {`
178 + ` lsof -a -p "$pid" -d cwd -Fn 2>/dev/null | sed -n 's/^n//p'; ps -ww -o args= -p "$pid"; }`),
179 sh(`pgrep -f '${READER}' >/dev/null && echo yes`),
180 ])
181 const parts = [usbState(usb, hid)]
182 const [cwd, args] = writer.trim().split('\n')
183 const config = cwd !== undefined && args !== undefined ? configOf(args, cwd) : undefined
184 const isWriting = config !== undefined
185 if (config !== undefined) {
186 const newest = (await sh(`ls -t ${quote(config)}.write-*.log 2>/dev/null | head -1`)).trim()
187 if (newest !== '') journal = newest
188 stoppedPolls = 0
189 } else {
190 stoppedPolls += 1
191 }
192 if (journal !== undefined && (isWriting || stoppedPolls <= LINGER_POLLS)) {
193 let text = ''
194 try { text = await $.fs.read(journal) } catch { /* moved or deleted: show nothing */ }
195 const line = text === '' ? undefined : writeLine(writeProgress(text), isWriting)
196 if (line !== undefined) parts.push(line)
197 }
198 if (reader.trim() === 'yes') parts.push('reading flash')
199 const text = parts.join(' | ')
200 if (text !== last) {
201 // A toast on the two moments worth looking up for, once each.
202 if (/write done/.test(text) && !/write done/.test(last ?? '')) $.ui.toast('Harmony write done and verified')
203 if (/STOPPED/.test(text) && !/STOPPED/.test(last ?? '')) $.ui.toast('Harmony write stopped before it finished')
204 last = text
205 await update($, line, () => text)
206 }
207 } finally {
208 busy = false
209 }
210 }
211
212 await poll()
213 $.clock.every(POLL_MS, () => { void poll() })
214 return next(e)
215 })
216}
217types/index.d.ts 13 lines1// The line the band shows, or null before the first poll has finished.
2export type BandLine = string | null
3
4declare module 'claude-code' {
5 interface PluginState {
6 'harmony-remote': {
7 line: BandLine
8 // The theme setting's value, which picks the band's colour.
9 theme: string
10 }
11 }
12}
13