<?xml-stylesheet type="text/xsl" href="https://nbr23.com/style.xsl"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>nbr23</title>
    <link>https://nbr23.com/</link>
    <description>A collection of things I tinker with during my free time.</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Wed, 28 Oct 2026 00:58:10 -0400</lastBuildDate>
    
      <atom:link href="https://nbr23.com/index.xml" rel="self" type="application/rss+xml" />
    
    
      <item>
        <title>How I use Claude Code in 2026</title>
        <link>https://nbr23.com/posts/how-i-use-claude-code-in-2026/?utm_source=rss</link>
        <pubDate>Wed, 28 Oct 2026 00:58:10 -0400</pubDate>
        <guid isPermaLink="false">/posts/how-i-use-claude-code-in-2026/</guid>
        <description>My Claude Code setup in 2026: Docker isolation, work and personal profiles, and searchable plans and sessions with the planviewer TUI.</description>
        <content:encoded><![CDATA[<div class="text-to-speech-container">
    <span class="text-to-speech-label">Listen to this post:</span>
    <audio class="text-to-speech-audio" controls>
      <source src="https://nbr23.com/audio/tts/how-i-use-claude-code-in-2026.mp3" type="audio/mpeg">
      <a href="https://nbr23.com/audio/tts/how-i-use-claude-code-in-2026.mp3">Download the audio</a>
    </audio>
  </div>
  
<p>While I occasionally use <code>antigravity</code> at work or <code>codex</code> at home, I mostly favor <code>claude</code>, both through API at work and a paid subscription at home.</p>
<p>To avoid giving them full <!-- tts say="machine and filesystem" -->machine/filesystem<!-- /tts --> access and relying on their self-policing, I have always run agent through Docker. It brings me a level of isolation I am comfortable with, and which is consistent across all harnesses I use now or in the future (compared to each harness&rsquo;s built-in sandbox). It also gives me profile isolation for &ldquo;free&rdquo;, to separate work and personal environments.</p>
<p>In this post, I explain the current state of my setup: <a href="https://nbr23.com/posts/how-i-use-claude-code-in-2026/#dockerised-harnesses">dockerised harnesses</a>, <a href="https://nbr23.com/posts/how-i-use-claude-code-in-2026/#profiles">work / personal profiles</a> with <a href="https://nbr23.com/posts/how-i-use-claude-code-in-2026/#read-only-access">scoped API access</a>, and <a href="https://nbr23.com/posts/how-i-use-claude-code-in-2026/#planviewer">an improvement over <code>/resume</code></a> to search and recover past sessions and plans using <a href="https://github.com/nbr23/planviewer">planviewer</a>.</p>
<h2 id="dockerised-harnesses">Dockerised harnesses</h2>
<p><a href="https://github.com/nbr23/claudecode">claudecode</a> builds images for each of the harnesses I use (claude, codex, agy, &hellip;), with a selection of tools I need for my day to day (interpreters, compilers, cloud CLIs, dev tools, etc). It also contains Chromium and Playwright for some QA validation.</p>
<p>I start them with aliases for the following commands:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash"><span class="line"><span class="cl"><span class="c1"># claude (personal profile)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># cap memory usage and process count</span>
</span></span><span class="line"><span class="cl"><span class="c1"># No Linux capabilities, no privilege gains/setuid etc</span>
</span></span><span class="line"><span class="cl">docker run --rm -ti --init <span class="se">\
</span></span></span><span class="line"><span class="cl">  --memory <span class="s2">&#34;</span><span class="si">${</span><span class="nv">AI_MEM</span><span class="k">:-</span><span class="nv">1536m</span><span class="si">}</span><span class="s2">&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">  --memory-swap <span class="s2">&#34;</span><span class="si">${</span><span class="nv">AI_MEM</span><span class="k">:-</span><span class="nv">1536m</span><span class="si">}</span><span class="s2">&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">  --pids-limit <span class="m">4096</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">  <span class="se">\
</span></span></span><span class="line"><span class="cl">  --cap-drop ALL <span class="se">\
</span></span></span><span class="line"><span class="cl">  --security-opt no-new-privileges <span class="se">\
</span></span></span><span class="line"><span class="cl">  <span class="se">\
</span></span></span><span class="line"><span class="cl">  --env <span class="nv">COLORTERM</span><span class="o">=</span>truecolor <span class="se">\
</span></span></span><span class="line"><span class="cl">  --volume <span class="s2">&#34;</span><span class="nv">$PWD</span><span class="s2">:/home/node/dev/</span><span class="si">${</span><span class="nv">PWD</span><span class="p">##*/</span><span class="si">}</span><span class="s2">&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">  --workdir <span class="s2">&#34;/home/node/dev/</span><span class="si">${</span><span class="nv">PWD</span><span class="p">##*/</span><span class="si">}</span><span class="s2">&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">  --volume <span class="s2">&#34;</span><span class="nv">$HOME</span><span class="s2">/dotfiles/claude:/home/node/.claude&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">  --mount <span class="s2">&#34;type=bind,source=</span><span class="nv">$HOME</span><span class="s2">/dotfiles/claude/claude.json,target=/home/node/.claude.json&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">  --env-file <span class="s2">&#34;</span><span class="nv">$HOME</span><span class="s2">/.claudeenv&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">  nbr23/claudecode
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># codex (personal profile)</span>
</span></span><span class="line"><span class="cl">docker run --rm -ti --init <span class="se">\
</span></span></span><span class="line"><span class="cl">  <span class="o">[</span>...<span class="o">]</span>
</span></span><span class="line"><span class="cl">  --volume <span class="s2">&#34;</span><span class="nv">$HOME</span><span class="s2">/dotfiles/codex:/home/node/.codex&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">  --volume <span class="s2">&#34;</span><span class="nv">$HOME</span><span class="s2">/dotfiles/claude/skills:/home/node/.agents/skills&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">  --volume <span class="s2">&#34;</span><span class="nv">$HOME</span><span class="s2">/dotfiles/claude/skills:/home/node/.claude/skills&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">  --mount <span class="s2">&#34;type=bind,source=</span><span class="nv">$HOME</span><span class="s2">/dotfiles/claude/CLAUDE.md,target=/home/node/.codex/AGENTS.md&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">  --env-file <span class="s2">&#34;</span><span class="nv">$HOME</span><span class="s2">/.claudeenv&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">  nbr23/claudecode:codex
</span></span></code></pre></div><!-- /noTTS -->
<p>It is essentially mounting a global and shared <code>CLAUDE.md</code>/<code>AGENTS.md</code> file, skills folder, as well as the current working directory. The <code>codex</code>, <code>agy</code>, etc. variants differ only in the image/entrypoint and a couple of mountpoints for their settings. The agent&rsquo;s filesystem access is limited to the mounted volumes.</p>
<p>I have a scheduled <code>docker pull</code> on each <code>nbr23/claudecode</code> image tag I use, to keep them up to date. The images themselves keep the harnesses and tools up to date using <a href="https://github.com/nbr23/claudecode/blob/master/renovate.json">Renovate</a>.</p>
<h2 id="profiles">Profiles</h2>
<p>As I use these same harnesses for work and personal projects, with obviously different billing constraints, Docker makes it easy to isolate both.
For work, I have similar <code>w</code>-prefixed aliases like:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash"><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># wclaude (work profile)</span>
</span></span><span class="line"><span class="cl">docker run --rm -ti --init <span class="se">\
</span></span></span><span class="line"><span class="cl">  <span class="o">[</span>...<span class="o">]</span>
</span></span><span class="line"><span class="cl">  --volume <span class="s2">&#34;claudework-gcloud:/home/node/.config/gcloud&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">  --mount <span class="s2">&#34;type=bind,source=</span><span class="nv">$HOME</span><span class="s2">/.config/workgcp/readonly-key.json,target=/gcp/key.json,readonly&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">  --env <span class="nv">GOOGLE_APPLICATION_CREDENTIALS</span><span class="o">=</span>/gcp/key.json <span class="se">\
</span></span></span><span class="line"><span class="cl">  --add-host XXX.local.DNS:host-gateway <span class="se">\
</span></span></span><span class="line"><span class="cl">  --add-host YYY.local.DNS:host-gateway <span class="se">\
</span></span></span><span class="line"><span class="cl">  --add-host ZZZ.local.DNS:host-gateway <span class="se">\
</span></span></span><span class="line"><span class="cl">  --volume <span class="s2">&#34;</span><span class="nv">$HOME</span><span class="s2">/dotfiles/claudework:/home/node/.claude&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">  --env-file <span class="s2">&#34;</span><span class="nv">$HOME</span><span class="s2">/.claudeworkenv&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">  nbr23/claudecode
</span></span></code></pre></div><!-- /noTTS -->
<p>Follows the same principle, but mounts separate <code>~/.claude</code> volumes, allowing different credentials entirely, and different CLAUDE.md, skills set etc. It also loads its own env file, with its own readonly credentials.</p>
<p>The <!-- tts say="dash dash add host" --><code>--add-host</code><!-- /tts --> lines expose my local application web services to the agent for easy debugging and Playwright-driven QA.</p>
<h3 id="profile-themes">Profile themes</h3>
<p>To avoid mixing up the profiles when my fingers accidentally type <!-- tts say="W claude" --><code>wclaude</code><!-- /tts --> at a time I don&rsquo;t plan on working, I&rsquo;ve added a colored &ldquo;WORK&rdquo; / &ldquo;PERSO&rdquo; label to my Claude status line, and a slightly different terminal background color.</p>
<p><img src="https://nbr23.com/posts/how-i-use-claude-code-in-2026/images/claude-code-work-profile.png" alt="work status line with a dark red background and red WORK label" width="1294" height="300" loading="lazy" decoding="async">
</p>
<p><img src="https://nbr23.com/posts/how-i-use-claude-code-in-2026/images/claude-code-personal-profile.png" alt="personal status line with a dark gray background and green PERSO label" width="1294" height="300" loading="lazy" decoding="async">
</p>
<p>Codex doesn&rsquo;t easily allow the same right now. Instead we can send OSC escape sequences in a wrapper when running the harness:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash"><span class="line"><span class="cl">_with_bg<span class="o">()</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">  <span class="nb">local</span> <span class="nv">color</span><span class="o">=</span><span class="nv">$1</span> rc
</span></span><span class="line"><span class="cl">  <span class="nb">shift</span>
</span></span><span class="line"><span class="cl">  <span class="o">[[</span> -t <span class="m">1</span> <span class="o">]]</span> <span class="o">&amp;&amp;</span> <span class="nb">printf</span> <span class="s1">&#39;\e]11;%s\a&#39;</span> <span class="s2">&#34;</span><span class="nv">$color</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="s2">&#34;</span><span class="nv">$@</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="nv">rc</span><span class="o">=</span><span class="nv">$?</span>
</span></span><span class="line"><span class="cl">  <span class="o">[[</span> -t <span class="m">1</span> <span class="o">]]</span> <span class="o">&amp;&amp;</span> <span class="nb">printf</span> <span class="s1">&#39;\e]111\a&#39;</span>
</span></span><span class="line"><span class="cl">  <span class="k">return</span> <span class="s2">&#34;</span><span class="nv">$rc</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">_with_bg <span class="s1">&#39;#081c08&#39;</span> codex
</span></span></code></pre></div><!-- /noTTS -->
<p>This will not work with an alias, define codex as a bash function instead to use this wrapper.</p>
<h2 id="read-only-access">Read-only access</h2>
<p>Isolating the agent from my machine using Docker gives me an easy way to grant the agent read only or limited scope access to services, while retaining broader rights myself on the host.
Through env variables and mounted files (like the GCP readonly key), the agents are given enough rights to pull metrics, logs, LangSmith traces, search for cloud resources, without using my broader scoped credentials.</p>
<p>I extend this when needed to the host&rsquo;s Docker socket: when developing and running a stack of apps locally through Docker Compose for example, I run <a href="https://github.com/wollomatic/socket-proxy"><code>wollomatic/socket-proxy</code></a> with a restricted configuration (allowing log reads, container state reads and container restarts) to give <code>claude</code> some autonomy in debugging in progress work, without giving full Docker socket access (which could effectively open the door to host root access).</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-yaml"><span class="line"><span class="cl"><span class="nt">services</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">docker-socket-proxy</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">image</span><span class="p">:</span><span class="w"> </span><span class="l">wollomatic/socket-proxy:1</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">restart</span><span class="p">:</span><span class="w"> </span><span class="l">unless-stopped</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">read_only</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">cap_drop</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="l">ALL</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">security_opt</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="kc">no</span>-<span class="l">new-privileges:true</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">command</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="s1">&#39;-listenip=0.0.0.0&#39;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="s1">&#39;-allowfrom=0.0.0.0/0&#39;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="s1">&#39;-allowGET=/(v[0-9.]+/)?(_ping|version|info|events(\?.*)?|containers/json(\?.*)?|containers/[a-zA-Z0-9_.-]+/(json|logs|top|stats|changes)(\?.*)?)&#39;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="s1">&#39;-allowHEAD=/(v[0-9.]+/)?_ping&#39;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="s1">&#39;-allowPOST=/(v[0-9.]+/)?containers/[a-zA-Z0-9_.-]+/restart(\?.*)?&#39;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">ports</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="s1">&#39;127.0.0.1:2375:2375&#39;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">volumes</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="l">/var/run/docker.sock:/var/run/docker.sock:ro</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">networks</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="l">agent-proxy</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">networks</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">agent-proxy</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">external</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="w"> </span><span class="c"># create it once with `docker network create agent-proxy`</span><span class="w">
</span></span></span></code></pre></div><!-- /noTTS -->
<p>Note that the current <!-- tts say="allow get" --><code>allowGET</code><!-- /tts --> rule permits full container inspection. Depending on what environment vars (API secrets etc) get injected, this would give your agent read access to those secrets.</p>
<p>The agents can then do Docker operations using the API directly, or the Docker CLI, e.g.:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash"><span class="line"><span class="cl"><span class="nb">export</span> <span class="nv">DOCKER_HOST</span><span class="o">=</span>tcp://docker-socket-proxy:2375
</span></span><span class="line"><span class="cl">docker restart mycontainer
</span></span></code></pre></div><!-- /noTTS -->
<p>You will need to pass <!-- tts say="dash dash network agent proxy" --><code>--network agent-proxy</code><!-- /tts --> to your agents. On Docker Desktop, we can do without the <code>networks:</code> declaration and simply use:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash"><span class="line"><span class="cl"><span class="nb">export</span> <span class="nv">DOCKER_HOST</span><span class="o">=</span>tcp://host.docker.internal:2375
</span></span></code></pre></div><!-- /noTTS -->
<h2 id="planviewer">Planviewer</h2>
<p>Being the kind of person with too many tabs open in Firefox, I promptly adapted to the AI era, and typically have many Claude sessions open and many plans planned.
I often defer them (sometimes with the OOM Killer&rsquo;s kind help), and always struggle to find them back using <code>/resume</code>.</p>
<p><img src="https://nbr23.com/posts/how-i-use-claude-code-in-2026/images/firefox-tabs.png#xsmaller" alt="Firefox offering to close 492 tabs" width="442" height="78" loading="lazy" decoding="async">
</p>
<p>This meant having to grep through my <code>~/.claude</code> for words I thought had appeared during the session or plan, or burning tokens and money asking Claude for some introspection to try and find old sessions/plans to restore.</p>
<p>I recently built <a href="https://github.com/nbr23/planviewer">planviewer</a>, which helps with this. In keeping with my work/life balance ethos, I have 2 aliases:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash"><span class="line"><span class="cl"><span class="nb">alias</span> <span class="nv">plans</span><span class="o">=</span><span class="s1">&#39;go run github.com/nbr23/planviewer@latest -claude-dir ~/dotfiles/claude -codex-dir ~/dotfiles/codex/&#39;</span>
</span></span><span class="line"><span class="cl"><span class="nb">alias</span> <span class="nv">wplans</span><span class="o">=</span><span class="s1">&#39;go run github.com/nbr23/planviewer@latest -claude-dir ~/dotfiles/claudework -codex-dir ~/dotfiles/workcodex/ -agy-dir ~/dotfiles/geminiwork/ -cache-dir ~/Library/Caches/planviewerwork&#39;</span>
</span></span></code></pre></div><!-- /noTTS -->
<p>These let me search and find sessions and plans easily by matching terms not only in the session/plan titles, but their contents and the entire session conversations too.
It searches across the different harnesses as well, for when I don&rsquo;t remember if I worked on something using <code>claude</code>, <code>codex</code>, or <code>agy</code>!</p>
<!-- noTTS -->
<div class="photo-gallery"><figure class="photo-gallery-item">
<a class="lightbox" href="https://nbr23.com/posts/how-i-use-claude-code-in-2026/images/planviewer-tui-plans.png"><img src="https://nbr23.com/posts/how-i-use-claude-code-in-2026/images/planviewer-tui-plans-thumb.png" alt="Plans across Claude, Codex and Antigravity, with approval statuses" loading="lazy"></a><figcaption>Plans across Claude, Codex and Antigravity, with approval statuses</figcaption></figure><figure class="photo-gallery-item">
<a class="lightbox" href="https://nbr23.com/posts/how-i-use-claude-code-in-2026/images/planviewer-tui-sessions.png"><img src="https://nbr23.com/posts/how-i-use-claude-code-in-2026/images/planviewer-tui-sessions-thumb.png" alt="Sessions across harnesses, with projects and branches" loading="lazy"></a><figcaption>Sessions across harnesses, with projects and branches</figcaption></figure><figure class="photo-gallery-item">
<a class="lightbox" href="https://nbr23.com/posts/how-i-use-claude-code-in-2026/images/planviewer-tui-plan.png"><img src="https://nbr23.com/posts/how-i-use-claude-code-in-2026/images/planviewer-tui-plan-thumb.png" alt="A rendered plan with the command to resume its session" loading="lazy"></a><figcaption>A rendered plan with the command to resume its session</figcaption></figure></div>
<!-- /noTTS -->
<h3 id="increased-session-retention">Increased session retention</h3>
<p>To make <a href="https://github.com/nbr23/planviewer">planviewer</a> even more valuable, I bumped the session <a href="https://code.claude.com/docs/en/claude-directory#cleaned-up-automatically">retention setting</a> to a full year (it controls the plans and transcript retention and defaults to 30 days) in Claude&rsquo;s <code>settings.json</code>:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-json"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="nt">&#34;cleanupPeriodDays&#34;</span><span class="p">:</span> <span class="mi">365</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><!-- /noTTS -->
<h2 id="skills-commands-and-other-fancy-things">Skills, commands, and other fancy things</h2>
<p>My Claude usage is kind of boring. At work I use a few MCP servers to reach the different cloud/SaaS providers we have. My global <code>AGENTS.md</code> files are simple, and I don&rsquo;t really have skills worth sharing directly, but here are a few &ldquo;highlights&rdquo;:</p>
<ul>
<li>A <!-- tts say="slash Q A" --><code>/qa</code><!-- /tts --> skill, that leverages Playwright to run scenarios/charters against my apps. Some of them are non deterministic, so having an actual &ldquo;<!-- tts say="eye plus brain" -->eye + brain<!-- /tts -->&rdquo;, albeit non-human, using the app, filing bug reports, validating fixes etc is neat.</li>
<li>I used to write a daily work journal (and I still do, but less) to keep track of the work I had done during the day, the things I had pending, and the things I wanted to do the next day. In addition to helping me wrap up my days and organize my thoughts, it helped me not forget half of my work during standup. I now have a <code>/standup</code> skill to recap my week&rsquo;s significant work based on commit and ticket history. <!-- tts say="slash half review" --><code>/halfreview</code><!-- /tts --> does the same over the past 6 months, in preparation for my performance reviews.</li>
<li>A <!-- tts say="slash what's next" --><code>/whatsnext</code><!-- /tts --> skill that helps me find the next ticket to work on based on some criteria.</li>
<li>I recently added a <!-- tts say="slash butt in seat" --><code>/buttinseat</code><!-- /tts --> skill, which keeps track of my in-office days by looking up the IP I work from each day of the week, and reminds me where I stand against our in office policy (I do pretty good!).</li>
</ul>
<h2 id="vs-code--vscodium--agent-tweaks">VS Code / VSCodium / Agent tweaks</h2>
<p>I usually run Claude/Codex from the integrated terminal in VS Code (for work stuff) or VSCodium (for personal projects). I made a few adjustments to my configuration to make things easier:</p>
<h3 id="terminal-profiles-for-each-alias">Terminal profiles for each alias</h3>
<p>Integrated terminal profiles in VSCodium to quickly launch agent containers are somewhat useful. Closing the agent closes the terminal, so you won&rsquo;t see the quick resume command or your history anymore. But we have <a href="https://github.com/nbr23/planviewer">planviewer</a> for that!</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-json"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">&#34;terminal.integrated.profiles.osx&#34;</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;claude&#34;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&#34;path&#34;</span><span class="p">:</span> <span class="s2">&#34;bash&#34;</span><span class="p">,</span> <span class="nt">&#34;args&#34;</span><span class="p">:</span> <span class="p">[</span><span class="s2">&#34;-lic&#34;</span><span class="p">,</span> <span class="s2">&#34;claude&#34;</span><span class="p">],</span> <span class="nt">&#34;color&#34;</span><span class="p">:</span> <span class="s2">&#34;terminal.ansiRed&#34;</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">      <span class="err">...</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;codex&#34;</span><span class="p">:</span>   <span class="p">{</span> <span class="nt">&#34;path&#34;</span><span class="p">:</span> <span class="s2">&#34;bash&#34;</span><span class="p">,</span> <span class="nt">&#34;args&#34;</span><span class="p">:</span> <span class="p">[</span><span class="s2">&#34;-lic&#34;</span><span class="p">,</span> <span class="s2">&#34;codex&#34;</span><span class="p">],</span>   <span class="nt">&#34;color&#34;</span><span class="p">:</span> <span class="s2">&#34;terminal.ansiBlue&#34;</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">  <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><!-- /noTTS -->
<h3 id="prevent-misclicks-from-killing-my-containers">Prevent misclicks from killing my containers</h3>
<p>Not that I&rsquo;ve ever unintentionally clicked the close button on VSCodium and lost all my integrated terminals and their Claude sessions in the process&hellip;</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-json"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="nt">&#34;terminal.integrated.confirmOnExit&#34;</span><span class="p">:</span> <span class="s2">&#34;hasChildProcesses&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">  <span class="nt">&#34;terminal.integrated.confirmOnKill&#34;</span><span class="p">:</span> <span class="s2">&#34;always&#34;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><!-- /noTTS -->
<h3 id="fix-multiline-prompts">Fix multiline prompts</h3>
<p>In VSCodium/VS Code&rsquo;s <code>keybindings.json</code>, this makes Shift+Enter send a new line and allows multiline prompts:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-json"><span class="line"><span class="cl"><span class="p">[</span>
</span></span><span class="line"><span class="cl">  <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;key&#34;</span><span class="p">:</span> <span class="s2">&#34;shift+enter&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;command&#34;</span><span class="p">:</span> <span class="s2">&#34;workbench.action.terminal.sendSequence&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;args&#34;</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;text&#34;</span><span class="p">:</span> <span class="s2">&#34;\u001b\r&#34;</span>
</span></span><span class="line"><span class="cl">    <span class="p">},</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;when&#34;</span><span class="p">:</span> <span class="s2">&#34;terminalFocus&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">]</span>
</span></span></code></pre></div><!-- /noTTS -->
<h3 id="disabling-annoying-tui-mouse-control-and-fancy-things">Disabling annoying TUI, mouse control and fancy things</h3>
<p>These might be more user preference than IDE integration, but here are some settings to keep Claude/Codex as regular non fancy CLI apps:</p>
<!-- noTTS -->
<p>Claude:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-json"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="nt">&#34;tui&#34;</span><span class="p">:</span> <span class="s2">&#34;default&#34;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><p>Codex:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-ini"><span class="line"><span class="cl"><span class="k">[tui]</span>
</span></span><span class="line"><span class="cl"><span class="na">alternate_screen</span> <span class="o">=</span> <span class="s">&#34;never&#34;</span>
</span></span></code></pre></div><!-- /noTTS -->
<p>A few VS Code/VSCodium settings to keep things to my taste:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-json"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;editor.accessibilitySupport&#34;</span><span class="p">:</span> <span class="s2">&#34;off&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;terminal.integrated.fontFamily&#34;</span><span class="p">:</span> <span class="s2">&#34;DejaVu Sans Mono, Menlo, monospace&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;terminal.integrated.macOptionIsMeta&#34;</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;terminal.integrated.scrollback&#34;</span><span class="p">:</span> <span class="mi">3000</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;terminal.integrated.mouseWheelScrollSensitivity&#34;</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;terminal.integrated.initialHint&#34;</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;terminal.integrated.suggest.enabled&#34;</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;terminal.integrated.stickyScroll.enabled&#34;</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;terminal.integrated.shellIntegration.decorationsEnabled&#34;</span><span class="p">:</span> <span class="s2">&#34;never&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;terminal.integrated.altClickMovesCursor&#34;</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;terminal.integrated.minimumContrastRatio&#34;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;terminal.integrated.drawBoldTextInBrightColors&#34;</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><!-- /noTTS -->
<h2 id="conclusion">Conclusion</h2>
<p>None of this is revolutionary, but it has allowed me to run agents with some confidence that I won&rsquo;t be the next &ldquo;<!-- tts say="A I wiped my whole life" -->AI WIPED MY WHOLE LIFE<!-- /tts -->&rdquo; victim. Telling apart work and personal agents has prevented awkward situations, and being able to search efficiently through all my session&rsquo;s history has been a huge time saver.</p>
<p>A few accepted risks should be noted:</p>
<ul>
<li>I don&rsquo;t filter network egress at all.</li>
<li>The current directory is shared with the container, so if it contains secrets, <code>.git</code> folders (<code>.git/hooks</code> !) etc., the agent has access and can read/write them and potentially trick the host into running code.</li>
</ul>
<p>I am dating this setup to October 2026, as things evolve fast&hellip; <a href="https://nbr23.com/posts/jira-claude-commit/">A year or so ago</a>, I thought I was pretty clever for having Claude write my commits and find the proper Jira ticket ID for the commit, so all this might look very lame in 6 months (or tomorrow).</p>
]]></content:encoded>
      </item>
    
      <item>
        <title>tts-bookmarklet: inject a listen button on every paragraph</title>
        <link>https://nbr23.com/posts/bookmarklet-inject-text-to-speech-buttons-page-paragraphs/?utm_source=rss</link>
        <pubDate>Thu, 30 Jul 2026 22:27:23 -0400</pubDate>
        <guid isPermaLink="false">https://wip.tf/posts/bookmarklet-inject-text-to-speech-buttons-page-paragraphs/</guid>
        <description>A bookmarklet that injects per-paragraph listen buttons into any page, read aloud by a self-hosted gopipertts endpoint.</description>
        <content:encoded><![CDATA[<div class="text-to-speech-container">
    <span class="text-to-speech-label">Listen to this post:</span>
    <audio class="text-to-speech-audio" controls>
      <source src="https://nbr23.com/audio/tts/bookmarklet-inject-text-to-speech-buttons-page-paragraphs.mp3" type="audio/mpeg">
      <a href="https://nbr23.com/audio/tts/bookmarklet-inject-text-to-speech-buttons-page-paragraphs.mp3">Download the audio</a>
    </audio>
  </div>
  
<p>I have not been using <a href="https://github.com/nbr23/sayoutloud">sayoutloud</a>, the Firefox addon from my <a href="https://nbr23.com/posts/tts-setup/">TTS setup</a>, as much as I expected to when I built it. It requires too many clicks, is too hidden in right-click menus. Also, browser add-ons are not getting much love from browser vendors these days, and I would rather avoid them when possible.</p>
<!-- noTTS -->
<div class="photo-gallery"><figure class="photo-gallery-item">
<img src="https://nbr23.com/posts/bookmarklet-inject-text-to-speech-buttons-page-paragraphs/images/bookmarklets.png" alt="The bookmarklets, one per language/config" loading="lazy"><figcaption>The bookmarklets, one per language/config</figcaption></figure></div>
<!-- /noTTS -->
<p>I made <a href="https://github.com/nbr23/tts-bookmarklet">tts-bookmarklet</a> instead: it is just a simple bookmarklet, templated with whatever <a href="https://github.com/nbr23/gopipertts">gopipertts</a> endpoint and config you want, that inserts a bunch of &ldquo;listen&rdquo; buttons into the current page&rsquo;s (hopefully) relevant elements.</p>
<!-- noTTS -->
<div class="photo-gallery"><figure class="photo-gallery-item">
<img src="https://nbr23.com/posts/bookmarklet-inject-text-to-speech-buttons-page-paragraphs/images/player.png" alt="Listen buttons injected at the start of each paragraph of the page" loading="lazy"><figcaption>Listen buttons injected at the start of each paragraph of the page</figcaption></figure></div>
<!-- /noTTS -->
<p>So it&rsquo;s one initial click to get the listen buttons to show up, and then one click per paragraph, instead of selecting the text you want to hear, right-clicking, finding sayoutloud, etc., for each paragraph/section.</p>
<p>Having to think about what you are selecting with sayoutloud got tiring too: too large a selection, and funky web design means you might drag in random side navs or adverts along with it; too small, and you keep having to select, right-click, look for the option in the menu, look for the suboption for the proper language, repeat.</p>
<p>A lot of fancy sites restrict which origins an in-page script is allowed to fetch from through their Content Security Policy: GitHub allowlists a handful of its own hosts in <code>connect-src</code>, and Reddit sets no <code>connect-src</code> at all, falling back to a <!-- tts say="default source none" --><code>default-src 'none'</code><!-- /tts --> that blocks the request. Plain CORS on the TTS endpoint fails the fetch too (but that one you can fix on your gopipertts deployment). When the request is blocked, the bookmarklet opens the TTS audio URL in a new tab, instead of playing it through the in-page button.</p>
<p><a href="https://github.com/nbr23/sayoutloud">sayoutloud</a> is still useful for custom selection or full-page reads, and I will keep it around for now, but I am hoping this bookmarklet pushes me to use TTS more.</p>
]]></content:encoded>
      </item>
    
      <item>
        <title>Radio-gaga: turning a cheap Panasonic radio into a toddler jukebox controller</title>
        <link>https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/?utm_source=rss</link>
        <pubDate>Wed, 08 Jul 2026 00:59:46 -0400</pubDate>
        <guid isPermaLink="false">https://wip.tf/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/</guid>
        <description>Gutting a cheap Panasonic radio and rewiring its dials and switch to an ESP32 running the radio-gaga firmware, turning it into a toddler-friendly jukebox controller for a networked speaker.</description>
        <content:encoded><![CDATA[<div class="text-to-speech-container">
    <span class="text-to-speech-label">Listen to this post:</span>
    <audio class="text-to-speech-audio" controls>
      <source src="https://nbr23.com/audio/tts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller.mp3" type="audio/mpeg">
      <a href="https://nbr23.com/audio/tts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller.mp3">Download the audio</a>
    </audio>
  </div>
  
<p>During a stay at a relative&rsquo;s house, we noticed Toddler&rsquo;s interest in an old-school radio with volume and tuning dials. It was easy to operate and <em>ludique</em>: the sound changes when you turn the things!</p>
<p>Unfortunately, radio stations are not super kid-friendly (lots of ads trying to sell lawyer services, talk shows, and very few Disney songs). So I decided to build my own, with custom stations.</p>
<!-- noTTS -->
<figure class="center">
    <video controls>
        <source src="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/radio-gaga.mp4" type="video/mp4"><a href="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/radio-gaga.mp4">Download the video</a>
    </video>
</figure>
<!-- /noTTS -->
<p>Since I already had a speaker exposed through a REST API from a <a href="https://nbr23.com/posts/controlling-an-air-gapped-robot-vacuum-from-home-assistant-using-synthesized-speech/">previous project</a>, I turned a cheap Panasonic radio (an RF-2400) with manual dials, coupled with an ESP32, into a remote controller for it.</p>
<p>I wanted to keep the ESP32 side of things simple: no onboard audio decoding and playback, no speaker to handle, and make it simple to update audio content without having to reflash the firmware every time, so reusing <a href="https://github.com/nbr23/jacadi">jacadi</a> was a perfect fit.</p>
<h2 id="architecture">Architecture</h2>
<!-- noTTS -->
<p><img src="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/diagram.svg#center" alt="The radio&#39;s original dials and switch are read by an ESP32 running radio-gaga, which calls the jacadi REST API on a Raspberry Pi over WiFi. jacadi plays songs and stories from an NFS share through a USB speaker" title="The radio&#39;s original dials and switch are read by an ESP32 running radio-gaga, which calls the jacadi REST API on a Raspberry Pi over WiFi. jacadi plays songs and stories from an NFS share through a USB speaker" loading="lazy" decoding="async">
</p>
<!-- /noTTS -->
<h2 id="hardware">Hardware</h2>
<h3 id="gutting-and-child-proofing">Gutting and child proofing</h3>
<p>The first step was to unscrew the antenna and discard it from this project. Pointy metal things that can break into pointier metal things are better kept away from toddlers.</p>
<p>After removing and safeguarding the PCBs, components and switches for future use, I disconnected and removed the speaker entirely (it is heavy, unused, and we will need the room for our ESP32).</p>
<!-- noTTS -->
<div class="photo-gallery photo-gallery-fixed"><figure class="photo-gallery-item">
<a class="lightbox" href="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/dials_and_led.jpg"><img src="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/dials_and_led-thumb.jpg" alt="Frequency dial, OFF/FM/AM switch, and power LED" loading="lazy"></a><figcaption>Frequency dial, OFF/FM/AM switch, and power LED</figcaption></figure><figure class="photo-gallery-item">
<a class="lightbox" href="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/potentiometers_and_switch_front.jpg"><img src="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/potentiometers_and_switch_front-thumb.jpg" alt="Main PCB, with potentiometers and switch" loading="lazy"></a><figcaption>Main PCB, with potentiometers and switch</figcaption></figure><figure class="photo-gallery-item">
<a class="lightbox" href="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/potentiometers_and_switch_back.jpg"><img src="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/potentiometers_and_switch_back-thumb.jpg" alt="Main PCB, with potentiometers and switch" loading="lazy"></a><figcaption>Main PCB, with potentiometers and switch</figcaption></figure></div>
<!-- /noTTS -->
<p>Note: removing the speaker will leave a gap behind the speaker grille, showing the wiring and ESP32. To fix this aesthetic issue, I had the brilliant idea of putting the discarded speaker on my photocopier, and printing a copy. While the result looks fine, it obviously drained my black ink cartridge pretty quickly. In hindsight, I should have just reused a dark page from a magazine or other existing paper.</p>
<h3 id="wiring">Wiring</h3>
<p>While most of the PCB and components will be rendered useless by our ESP32, we want to retain and repurpose the user interfaces:</p>
<ul>
<li>volume dial and potentiometer</li>
<li>frequency dial and potentiometer</li>
<li>OFF/FM/AM switch</li>
<li>red Power LED</li>
</ul>
<p>I wanted to keep these components soldered to the original PCB, to retain the structure and stability of the internals.</p>
<p>To make them work in our new circuit, we needed to isolate them from the original circuit and its components and wiring. For this I crudely cut out the copper traces using an X-acto knife.</p>
<p>The LED and battery packs had connection wires directly exposed, so I was able to easily desolder the old ones and solder mine instead.</p>
<!-- noTTS -->
<div class="photo-gallery"><figure class="photo-gallery-item">
<a class="lightbox" href="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/wiring-led.jpg"><img src="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/wiring-led-thumb.jpg" alt="We can just de-solder the old wires from the LED and solder our own in" loading="lazy"></a><figcaption>We can just de-solder the old wires from the LED and solder our own in</figcaption></figure></div>
<!-- /noTTS -->
<p>Once the two potentiometers and the 3-position switch were isolated from the rest of the PCB, I soldered new jump wires to a common ground, and to the different GPIO ports on the ESP32, as schematized below:</p>
<!-- noTTS -->
<pre tabindex="0"><code>      ┌─────────────┐
      │    ESP32    │
      │             │           ┌──────────────────┐
      │         VIN ├───────────┤ Battery (+)      │
      │         GND ├───────────┤ Battery (−)      │
      │             │           │ 4x AA NiMH       │
      │             │           └──────────────────┘
      │             │           ┌──────────────────┐
      │             │           │   TUNING POT     │
      │        3.3V ├───────────┤ pin 1            │
      │      GPIO34 ├───────────┤ pin 2 (wiper)    │
      │         GND ├───────────┤ pin 3            │
      │             │           └──────────────────┘
      │             │           ┌──────────────────┐
      │             │           │   VOLUME POT     │
      │        3.3V ├───────────┤ pin 1            │
      │      GPIO35 ├───────────┤ pin 2 (wiper)    │
      │         GND ├───────────┤ pin 3            │
      │             │           └──────────────────┘
      │             │           ┌──────────────────────────────────┐
      │             │           │  SWITCH (SW1, 10-pin DP3T)       │
      │             │           │       ┌───┬───┬───┬───┬───┐      │
      │             │           │   top │ A │ B │ C │ D │ E │      │
      │             │           │       └─┬─┴───┴─┬─┴─┬─┴───┘      │
      │             │           │         │       │   │            │
      │         GND ├───────────┼─────────┘       │   │            │
      │      GPIO33 ├───────────┼─────────────────┘   │            │
      │      GPIO32 ├───────────┼─────────────────────┘            │
      │             │           │ bottom: F  G  H  I  J  (unused)  │
      │             │           └──────────────────────────────────┘
      │             │           ┌──────────┐
      │      GPIO27 ├───────────┤ LED (+)  │
      │         GND ├───────────┤ LED (−)  │
      │             │           └──────────┘
      └─────────────┘

      Shared rails (multiple connections spliced):
        3.3V  → tuning pot pin 1, volume pot pin 1
        GND   → battery (−), switch pin A, tuning pot pin 3,
                volume pot pin 3, LED cathode
</code></pre><!-- /noTTS -->
<p>Most of the solder joints and connection pads had to be hot glued to be resistant to toddler S.O.P. (shaking, dropping, etc).</p>
<!-- noTTS -->
<div class="photo-gallery photo-gallery-fixed"><figure class="photo-gallery-item">
<a class="lightbox" href="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/main_pcb_rewired_back.jpg"><img src="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/main_pcb_rewired_back-thumb.jpg" alt="Main PCB solder side, with new jump wires soldered in" loading="lazy"></a><figcaption>Main PCB solder side, with new jump wires soldered in</figcaption></figure><figure class="photo-gallery-item">
<a class="lightbox" href="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/disassembled_overview.jpg"><img src="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/disassembled_overview-thumb.jpg" alt="Disassembled radio: case shell, main PCB, and dial assembly" loading="lazy"></a><figcaption>Disassembled radio: case shell, main PCB, and dial assembly</figcaption></figure><figure class="photo-gallery-item">
<a class="lightbox" href="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/internals_with_frequency_scale.jpg"><img src="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/internals_with_frequency_scale-thumb.jpg" alt="Internals laid out next to the frequency scale" loading="lazy"></a><figcaption>Internals laid out next to the frequency scale</figcaption></figure><figure class="photo-gallery-item">
<a class="lightbox" href="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/internals_wired_in_case.jpg"><img src="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/internals_wired_in_case-thumb.jpg" alt="Everything wired back inside the case" loading="lazy"></a><figcaption>Everything wired back inside the case</figcaption></figure></div>
<!-- /noTTS -->
<h3 id="powering">Powering</h3>
<h4 id="power-source-choice">Power source choice</h4>
<p>I ruled out plugging it in (except for debugging) to have a wireless user experience. A sensible approach might have been to use LiPo batteries. I am however not familiar with them, and although unlikely, the <a href="https://learn.adafruit.com/li-ion-and-lipoly-batteries">disclaimers about risks carried by damaged batteries</a> (irrationally?) scared me off.</p>
<p>I opted for a set of 8 eneloops (4 in charging rotation). This simplifies the project a bunch, as I just reuse the 4xAA slot from the original radio, and prevents me from burning through too many regular AA batteries (as explained below, the idle radio still consumes some energy).</p>
<h4 id="improving-battery-life">Improving battery life</h4>
<p>When the switch is in the OFF position, the ESP32 enters deep sleep.
While this still uses some energy (<!-- tts say="roughly ten to fifty microamps" -->~10–50µA<!-- /tts --> according to <a href="https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf">the datasheet</a> and <a href="https://lastminuteengineers.com/esp32-sleep-modes-power-consumption/">real-world breakdowns per wake source</a>), a significant &ldquo;deep sleep&rdquo; power draw was the DevKit&rsquo;s red power LED which stays on at all times on my ESP32 board. This LED is hardwired to the <!-- tts say="three point three volt" -->3.3V<!-- /tts --> rail, and draws <a href="https://hubble.com/community/guides/esp32-deep-sleep-current-what-the-datasheet-says-vs-what-you-ll-actually-measure/"><!-- tts say="roughly two to three milliamps" -->~2-3mA<!-- /tts --></a>, significantly undermining the deep sleep (while being a nuisance&hellip; Who needs yet another constantly on red LED in their life?). I chose to physically remove it from the board. I have not at this point addressed the two other power draw sources (the LDO and USB-UART bridge).</p>
<p>When working on boot time improvements (see <a href="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/#improving-boot-time">below</a>), I naively disabled the WiFi powersaving mode (<!-- tts say="WiFi dot set sleep, WiFi P S none" --><code>WiFi.setSleep(WIFI_PS_NONE);</code><!-- /tts -->), expecting it to reduce <!-- tts say="access point" -->AP<!-- /tts --> association time and improve overall responsiveness. This did not help boot time, but the setting stayed in for a while, and brought significant battery draw during ON time: <code>WIFI_PS_NONE</code> prevents the modem receiver from going into sleep between beacon intervals. I reverted it to the default <!-- tts say="WiFi P S min modem" --><code>WIFI_PS_MIN_MODEM</code><!-- /tts -->, and this has been a significant improvement.</p>
<p>I now change batteries roughly every 2 to 3 weeks using the 4xAA eneloops.</p>
<h3 id="user-interface-and-visual-cues">User interface and visual cues</h3>
<p>As previously mentioned, the user interface reuses the dials, switch and LED from the original radio (that is the whole point).</p>
<p>To provide some feedback to the user about station changes, and potential issues, I used the red LED with the following states:</p>
<ul>
<li>OFF when the radio is in deep sleep</li>
<li>BLINKING when booting / connecting to WiFi</li>
<li>ON when sound is playing</li>
<li>BLINKING OFF once when switching from one &ldquo;station&rdquo; to another</li>
</ul>
<p>As a useful side effect, when the batteries are low, the LED tends to blink, in a not so regular fashion, informing us of the need to change them.</p>
<p>The frequencies are not annotated, and there is no user-visible map of what station will be played in which zone, but that&rsquo;s part of the fun of old-school radios: the struggle of finding the tune you want, wondering which station you&rsquo;re currently on and what it will play next.</p>
<h2 id="software">Software</h2>
<h3 id="radio-gaga">Radio-gaga</h3>
<p>The ESP32 firmware (<a href="https://github.com/nbr23/radio-gaga">radio-gaga</a>) is a fairly simple HTTP REST client. It divides the hertzian frequency dial into 7 (by default) zones. Each is assigned a specific endpoint in the <a href="https://github.com/nbr23/radio-gaga/blob/master/config.example.h">config</a>, which informs the speaker of the selected &ldquo;station&rdquo;. The volume potentiometer is averaged and rate-limited, <a href="https://github.com/nbr23/radio-gaga/blob/master/config.example.h#L48-L51">capped to a safe range</a>, and the new value is sent to the speaker API.</p>
<p>The OFF/FM/AM switch wakes the ESP32 from deep sleep when out of the OFF position. Switching back from AM/FM to OFF triggers a <code>POST /stop</code> call, before entering the device into deep sleep.</p>
<p>This switch allows us to select between two sets of hertzian-zone-to-API-endpoint mappings. This gives us <!-- tts say="two times seven" -->2 x 7<!-- /tts --> different audio stations, and offers a nice distinction between two modes. I used this to separate a &ldquo;storytime&rdquo; mode and a &ldquo;music&rdquo; mode.</p>
<!-- noTTS -->
<div class="github-embed">
            <div class="github-embed-header">
                <span class="github-embed-header-left">
                    
                    <span class="github-embed-title">config.example.h#L58-L76</span>
                </span>
                <span class="github-embed-header-right">
                    <a href="https://github.com/nbr23/radio-gaga/blob/master/config.example.h#L58-L76">view code (lines 58-76)</a></span>
            </div>
            <div class="github-embed-body"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-c"><span class="line"><span class="cl"><span class="k">const</span> <span class="kt">char</span><span class="o">*</span> <span class="n">amZones</span><span class="p">[</span><span class="n">NUM_ZONES</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="s">&#34;/play/radio/1&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">  <span class="s">&#34;/play/radio/2&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">  <span class="s">&#34;/play/radio/3&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">  <span class="s">&#34;/play/radio/4&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">  <span class="s">&#34;/play/radio/5&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">  <span class="s">&#34;/play/radio/6&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">  <span class="s">&#34;/play/radio/7&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"><span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="k">const</span> <span class="kt">char</span><span class="o">*</span> <span class="n">fmZones</span><span class="p">[</span><span class="n">NUM_ZONES</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="s">&#34;/play/radio/11&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">  <span class="s">&#34;/play/radio/12&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">  <span class="s">&#34;/play/radio/13&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">  <span class="s">&#34;/play/radio/14&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">  <span class="s">&#34;/play/radio/15&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">  <span class="s">&#34;/play/radio/16&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">  <span class="s">&#34;/play/radio/17&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"><span class="p">};</span></span></span></code></pre></div></div>
        </div>
<!-- /noTTS -->
<p>The values read from the volume and tuning potentiometers through the ESP32&rsquo;s Analog-to-Digital Converter (ADC) are pretty jittery by nature. Even untouched, their values fluctuate constantly.</p>
<p>This raised two issues to fix:</p>
<ul>
<li>
<p>The volume and frequency would get updated constantly. While 1% volume change might go undetected by the users, this hammers the <code>jacadi</code> API with unnecessary requests. To remediate this, we average 8 sample reads from the ADCs, and only send a request when the mapped value actually changes (by more than 1 step on its scale for the volume).</p>
</li>
<li>
<p>A frequency dial resting close to the boundary between two stations would cause a constant switching between the two audio tracks. <code>radio-gaga</code> handles this through a simple hysteresis: once a station is selected, we only move to the next (or previous) one once we pass over the boundary <!-- tts say="plus or minus" -->+ (or -)<!-- /tts --> the hysteresis value. This ensures actual user intent, and prevents constant back and forth on the boundaries.</p>
</li>
</ul>
<p><img src="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/hysteresis.svg#center" alt="Once a station is selected, its boundaries move 50 ADC counts away from the needle: readings inside the gray band keep the current station playing, so ADC jitter alone will not flip stations back and forth" title="Once a station is selected, its boundaries move 50 ADC counts away from the needle: readings inside the gray band keep the current station playing, so ADC jitter alone will not flip stations back and forth" loading="lazy" decoding="async">
</p>
<h3 id="debugging">Debugging</h3>
<p>I have a small USB to USB micro cable, plugged into the ESP32&rsquo;s USB micro port sticking out of the old power input hole, for easy debugging and flashing of updates.</p>
<!-- noTTS -->
<div class="photo-gallery"><figure class="photo-gallery-item">
<a class="lightbox" href="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/debug-usb.jpg"><img src="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/debug-usb-thumb.jpg" alt="Debugging USB plugged, lightly chewed by a cat" loading="lazy"></a><figcaption>Debugging USB plugged, lightly chewed by a cat</figcaption></figure></div>
<!-- /noTTS -->
<p>While it is currently loose, I might have to hot glue it in place to reduce toddler temptations to pull on it (or worse, stick it fully inside, forcing me to unscrew the whole thing or wrangle with pliers to make it stick out again).</p>
<p>For flashing and debugging, I use the <a href="https://www.arduino.cc/en/software">Arduino IDE</a>.</p>
<h3 id="improving-boot-time">Improving boot time</h3>
<p>In my first implementation, there was a significant delay between flipping the switch on and the music starting to play. This was a bit frustrating, but I initially attributed it to the ESP32&rsquo;s low computing power, network lag, and the API itself (it runs on a Raspberry Pi, with media on an NFS share).</p>
<p>After a bit of investigation, the pain point turned out to be establishing the wireless connection, and most significantly negotiating a DHCP lease. I assigned a static IP on my router, and along with BSSID/channel caching on the initial connection, dropped the &ldquo;switched-on-to-music-playing&rdquo; time to under a second, which feels pretty much instantaneous to the user.</p>
<!-- noTTS -->
<figure class="center">
    <video controls>
        <source src="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/boot-time-comparison.mp4" type="video/mp4"><a href="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/images/boot-time-comparison.mp4">Download the video</a>
    </video>
</figure>
<!-- /noTTS -->
<h3 id="rest-api-speaker">REST API Speaker</h3>
<p>I covered in more detail the <a href="https://github.com/nbr23/jacadi">jacadi</a> REST API in an <a href="https://nbr23.com/posts/controlling-an-air-gapped-robot-vacuum-from-home-assistant-using-synthesized-speech/">earlier post</a>, but it essentially exposes a USB Speaker plugged into a Raspberry Pi in my living room, through a REST API.</p>
<p>For this to work, I stored the songs and stories I want to expose on an NFS share mounted on the <code>jacadi</code> container, and added this to my configuration as an <code>EXTRA_ROUTES_JSON</code>:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-json"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="nt">&#34;radio&#34;</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;commands&#34;</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;1&#34;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&#34;text&#34;</span><span class="p">:</span> <span class="s2">&#34;1&#34;</span><span class="p">,</span> <span class="nt">&#34;type&#34;</span><span class="p">:</span> <span class="s2">&#34;folder&#34;</span><span class="p">,</span> <span class="nt">&#34;path&#34;</span><span class="p">:</span> <span class="s2">&#34;/audio/extra/folders/beatles&#34;</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;2&#34;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&#34;text&#34;</span><span class="p">:</span> <span class="s2">&#34;2&#34;</span><span class="p">,</span> <span class="nt">&#34;type&#34;</span><span class="p">:</span> <span class="s2">&#34;folder&#34;</span><span class="p">,</span> <span class="nt">&#34;path&#34;</span><span class="p">:</span> <span class="s2">&#34;/audio/extra/folders/wheels-on-the-bus&#34;</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;3&#34;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&#34;text&#34;</span><span class="p">:</span> <span class="s2">&#34;3&#34;</span><span class="p">,</span> <span class="nt">&#34;type&#34;</span><span class="p">:</span> <span class="s2">&#34;folder&#34;</span><span class="p">,</span> <span class="nt">&#34;path&#34;</span><span class="p">:</span> <span class="s2">&#34;/audio/extra/folders/disney&#34;</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;4&#34;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&#34;text&#34;</span><span class="p">:</span> <span class="s2">&#34;4&#34;</span><span class="p">,</span> <span class="nt">&#34;type&#34;</span><span class="p">:</span> <span class="s2">&#34;folder&#34;</span><span class="p">,</span> <span class="nt">&#34;path&#34;</span><span class="p">:</span> <span class="s2">&#34;/audio/extra/folders/itsy-bitsy-spider&#34;</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;5&#34;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&#34;text&#34;</span><span class="p">:</span> <span class="s2">&#34;5&#34;</span><span class="p">,</span> <span class="nt">&#34;type&#34;</span><span class="p">:</span> <span class="s2">&#34;folder&#34;</span><span class="p">,</span> <span class="nt">&#34;path&#34;</span><span class="p">:</span> <span class="s2">&#34;/audio/extra/folders/abc&#34;</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;6&#34;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&#34;text&#34;</span><span class="p">:</span> <span class="s2">&#34;6&#34;</span><span class="p">,</span> <span class="nt">&#34;type&#34;</span><span class="p">:</span> <span class="s2">&#34;folder&#34;</span><span class="p">,</span> <span class="nt">&#34;path&#34;</span><span class="p">:</span> <span class="s2">&#34;/audio/extra/folders/cleanup&#34;</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;7&#34;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&#34;text&#34;</span><span class="p">:</span> <span class="s2">&#34;7&#34;</span><span class="p">,</span> <span class="nt">&#34;type&#34;</span><span class="p">:</span> <span class="s2">&#34;folder&#34;</span><span class="p">,</span> <span class="nt">&#34;path&#34;</span><span class="p">:</span> <span class="s2">&#34;/audio/extra/folders/black-sabbath&#34;</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;11&#34;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&#34;text&#34;</span><span class="p">:</span> <span class="s2">&#34;11&#34;</span><span class="p">,</span> <span class="nt">&#34;type&#34;</span><span class="p">:</span> <span class="s2">&#34;folder&#34;</span><span class="p">,</span> <span class="nt">&#34;path&#34;</span><span class="p">:</span> <span class="s2">&#34;/audio/extra/folders/cigale-fourmi&#34;</span><span class="p">,</span> <span class="nt">&#34;restart&#34;</span><span class="p">:</span> <span class="kc">true</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;12&#34;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&#34;text&#34;</span><span class="p">:</span> <span class="s2">&#34;12&#34;</span><span class="p">,</span> <span class="nt">&#34;type&#34;</span><span class="p">:</span> <span class="s2">&#34;folder&#34;</span><span class="p">,</span> <span class="nt">&#34;path&#34;</span><span class="p">:</span> <span class="s2">&#34;/audio/extra/folders/corbeau-renard&#34;</span><span class="p">,</span> <span class="nt">&#34;restart&#34;</span><span class="p">:</span> <span class="kc">true</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;13&#34;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&#34;text&#34;</span><span class="p">:</span> <span class="s2">&#34;13&#34;</span><span class="p">,</span> <span class="nt">&#34;type&#34;</span><span class="p">:</span> <span class="s2">&#34;folder&#34;</span><span class="p">,</span> <span class="nt">&#34;path&#34;</span><span class="p">:</span> <span class="s2">&#34;/audio/extra/folders/chien-loup&#34;</span><span class="p">,</span> <span class="nt">&#34;restart&#34;</span><span class="p">:</span> <span class="kc">true</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;14&#34;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&#34;text&#34;</span><span class="p">:</span> <span class="s2">&#34;14&#34;</span><span class="p">,</span> <span class="nt">&#34;type&#34;</span><span class="p">:</span> <span class="s2">&#34;folder&#34;</span><span class="p">,</span> <span class="nt">&#34;path&#34;</span><span class="p">:</span> <span class="s2">&#34;/audio/extra/folders/grenouille-boeuf&#34;</span><span class="p">,</span> <span class="nt">&#34;restart&#34;</span><span class="p">:</span> <span class="kc">true</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;15&#34;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&#34;text&#34;</span><span class="p">:</span> <span class="s2">&#34;15&#34;</span><span class="p">,</span> <span class="nt">&#34;type&#34;</span><span class="p">:</span> <span class="s2">&#34;folder&#34;</span><span class="p">,</span> <span class="nt">&#34;path&#34;</span><span class="p">:</span> <span class="s2">&#34;/audio/extra/folders/lievre-tortue&#34;</span><span class="p">,</span> <span class="nt">&#34;restart&#34;</span><span class="p">:</span> <span class="kc">true</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;16&#34;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&#34;text&#34;</span><span class="p">:</span> <span class="s2">&#34;16&#34;</span><span class="p">,</span> <span class="nt">&#34;type&#34;</span><span class="p">:</span> <span class="s2">&#34;folder&#34;</span><span class="p">,</span> <span class="nt">&#34;path&#34;</span><span class="p">:</span> <span class="s2">&#34;/audio/extra/folders/rat-des-villes-rat-des-champs&#34;</span><span class="p">,</span> <span class="nt">&#34;restart&#34;</span><span class="p">:</span> <span class="kc">true</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;17&#34;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&#34;text&#34;</span><span class="p">:</span> <span class="s2">&#34;17&#34;</span><span class="p">,</span> <span class="nt">&#34;type&#34;</span><span class="p">:</span> <span class="s2">&#34;folder&#34;</span><span class="p">,</span> <span class="nt">&#34;path&#34;</span><span class="p">:</span> <span class="s2">&#34;/audio/extra/folders/war-and-peace&#34;</span><span class="p">,</span> <span class="nt">&#34;restart&#34;</span><span class="p">:</span> <span class="kc">true</span> <span class="p">}</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl">  <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><!-- /noTTS -->
<p>This sets <code>FM</code> band as stories mode, and the <code>AM</code> band as songs.</p>
<p>The REST endpoints created will be <!-- tts say="slash play slash radio slash one through seven, and slash play slash radio slash eleven through seventeen" --><code>/play/radio/1</code>&hellip;<code>/play/radio/7</code> and <code>/play/radio/11</code>&hellip;<code>/play/radio/17</code><!-- /tts -->. Not exposing the media folder names on the endpoint means I don&rsquo;t need to update the radio config when I change the media. The media wiring happens directly in the <code>jacadi</code> configuration, without a need to connect the radio to a computer and flash the ESP32.</p>
<p>All these route entries have the type <code>folder</code>, which means all the files in the folder will be looped through. The stories endpoints have <!-- tts say="restart set to true" --><code>&quot;restart&quot;: true</code><!-- /tts -->, so that the stories get started from the beginning every time we switch to their station. Song stations will resume from where we left off during the last listening.</p>
<h2 id="conclusion-and-future-improvements">Conclusion and future improvements</h2>
<p>First, a couple of parental warnings:</p>
<ol>
<li>You are building a tool to enable your kid to play <a href="https://www.youtube.com/watch?v=L0MK7qz13bU&amp;list=PLnLeK30ZhTk9iazN9mfufFFhNeaMxC9JG">&ldquo;Let it go!&rdquo;</a> whenever they want (that is to say, all the time). This might impinge on your tranquility.</li>
<li>When the batteries die during playback, the remote controller stops working, but the USB speaker is very much still on. You should always have hot spares available to make Idina Menzel stop &ldquo;letting it go&rdquo; ASAP (<a href="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/#2026-11-15-update-keepalive">see update</a>).</li>
</ol>
<p>That being said, the radio has been a success amongst kids. It is easy and fun to use, and very easy to update as a DJ: I just need to drop mp3 files in an <!-- tts say="N F S" -->nfs<!-- /tts --> folder.</p>
<p>The target age range is pretty broad as it can evolve well: <!-- tts say="five to seven" -->5-7<!-- /tts --> stations with a couple of songs each for toddlers who have limited motor skills and love repetitions; more stations with more files each for older kids who get bored and want broader content choices.</p>
<p>A couple of improvements I am considering:</p>
<ul>
<li>to solve problem <!-- tts say="number two" -->#2<!-- /tts --> mentioned above, I am considering implementing a simple keepalive: the radio sends a ping every <!-- tts say="thirty seconds" -->30s<!-- /tts -->. When <code>jacadi</code> stops getting pings from the client, it stops the ongoing playback (<a href="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/#2026-11-15-update-keepalive">see update</a>).</li>
<li>a portable version? I didn&rsquo;t want to bother with audio playing on the ESP32, and still want to keep <code>radio-gaga</code> a dumb client, but perhaps hooking it up to a nearby smartphone for on-the-road listening?</li>
<li>address the LDO and USB-UART bridge power draw we discussed in <a href="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/#improving-battery-life">the battery life section</a>. They have <a href="https://hubble.com/community/guides/esp32-deep-sleep-current-what-the-datasheet-says-vs-what-you-ll-actually-measure/#three-fixes-that-dont-require-a-custom-pcb">well-documented solutions</a>.</li>
<li>as I am writing this, <a href="https://www.nemunai.re/">nemunaire</a> sent me his recent project <a href="https://git.nemunai.re/nemunaire/radieo">radieo</a>, which lets you create your own music radio station! Hooking up a couple of <code>radieo</code>-based <strong>Kids FM</strong> / <strong>Père Castor FM</strong> stations to <code>jacadi</code> and having them play from <code>radio-gaga</code> would be a terrific way for older kids to get more tunes/stories diversity! And you can intersperse your own homemade jingles between songs too!!</li>
</ul>
<h2 id="2026-11-15-update-keepalive">2026-11-15 Update: Keepalive</h2>
<p>The previously mentioned &ldquo;batteries died and Frozen keeps singing forever&rdquo; having happened too many times, I have added support for a keepalive in both <a href="https://github.com/nbr23/radio-gaga/commit/dd84fbd07a5ab4e0fcf373c76dbf2182efae5986"><code>radio-gaga</code></a> and <a href="https://github.com/nbr23/jacadi/commit/5d50c438337d68a4f612b9cf84fdc67cd33de023"><code>jacadi</code></a>.</p>
<p>To make <code>jacadi</code> require a keepalive on a specific route, just add this to your <a href="https://nbr23.com/posts/turning-a-cheap-panasonic-radio-into-a-toddler-jukebox-controller/#rest-api-speaker"><code>EXTRA_ROUTES_JSON</code></a>:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-json"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="nt">&#34;radio&#34;</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;keepalive&#34;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&#34;timeout&#34;</span><span class="p">:</span> <span class="mi">60</span><span class="p">,</span> <span class="nt">&#34;on_timeout&#34;</span><span class="p">:</span> <span class="s2">&#34;battery-low&#34;</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;commands&#34;</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;battery-low&#34;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&#34;text&#34;</span><span class="p">:</span> <span class="s2">&#34;I am out of batteries, please change them!&#34;</span><span class="p">,</span> <span class="nt">&#34;language&#34;</span><span class="p">:</span> <span class="s2">&#34;en&#34;</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;1&#34;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&#34;text&#34;</span><span class="p">:</span> <span class="s2">&#34;1&#34;</span><span class="p">,</span> <span class="nt">&#34;type&#34;</span><span class="p">:</span> <span class="s2">&#34;folder&#34;</span><span class="p">,</span> <span class="nt">&#34;path&#34;</span><span class="p">:</span> <span class="s2">&#34;/audio/extra/folders/beatles&#34;</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">      <span class="err">[...]</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl">  <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><!-- /noTTS -->
<p>The <code>on_timeout</code> config is optional, and just plays a TTS message when the keepalive times out.</p>
<p>On the <code>radio-gaga</code> side, we just add:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-c"><span class="line"><span class="cl"><span class="cp">#define KEEPALIVE_ROUTE &#34;/keepalive/radio&#34;
</span></span></span><span class="line"><span class="cl"><span class="cp">#define KEEPALIVE_INTERVAL 20000
</span></span></span></code></pre></div><!-- /noTTS -->
<p>This makes the radio send a keepalive every 20 seconds, and <code>jacadi</code> will assume the client is dead after 60 seconds without any.</p>
]]></content:encoded>
      </item>
    
      <item>
        <title>Turn your favorite RSS feeds into podcasts</title>
        <link>https://nbr23.com/posts/turn-your-favorite-rss-feeds-into-podcasts/?utm_source=rss</link>
        <pubDate>Sun, 19 Apr 2026 22:03:25 -0400</pubDate>
        <guid isPermaLink="false">https://wip.tf/posts/turn-your-favorite-rss-feeds-into-podcasts/</guid>
        <description>Convert any RSS feed into a listenable podcast using rss2podcast and piper TTS.</description>
        <content:encoded><![CDATA[<div class="text-to-speech-container">
    <span class="text-to-speech-label">Listen to this post:</span>
    <audio class="text-to-speech-audio" controls>
      <source src="https://nbr23.com/audio/tts/turn-your-favorite-rss-feeds-into-podcasts.mp3" type="audio/mpeg">
      <a href="https://nbr23.com/audio/tts/turn-your-favorite-rss-feeds-into-podcasts.mp3">Download the audio</a>
    </audio>
  </div>
  
<p><a href="https://nbr23.com/posts/this-blog-is-a-podcast/">Turning this blog into a podcast</a> was fun&hellip; But long form articles from other people are actually the ones I want to listen to on my commute.</p>
<p><img src="https://nbr23.com/posts/turn-your-favorite-rss-feeds-into-podcasts/images/ars-pod-list.png#hmedium" alt="Podcast Addict showing the Ars Technica feed as a podcast, with articles listed as playable episodes" width="1080" height="2424" loading="lazy" decoding="async">
</p>
<p>By running <a href="https://github.com/nbr23/rss2podcast">rss2podcast</a> on a cron, we can get a <a href="https://nbr23.com/tags/tts/">piper</a> read podcast out of any RSS feed!</p>
<p>rss2podcast parses the RSS feed, fetches the full post content via <a href="https://pypi.org/project/trafilatura/">trafilatura</a> by default and pipes the cleaned-up text to <a href="https://github.com/nbr23/gopipertts">gopipertts</a>.</p>
<p>Using the resulting mp3 files, rss2podcast builds a standard podcast feed that can be added in your favorite reader.</p>
<figure class="img-side-by-side">
<div class="img-side-by-side-images">
<a href="https://arstechnica.com/"><img src="https://nbr23.com/posts/turn-your-favorite-rss-feeds-into-podcasts/images/ars-sharks.png" alt="An Ars Technica article playing as a podcast episode in Podcast Addict, with its summary and link to the original post" width="1080" height="2424" loading="lazy" decoding="async">
</a>
<a href="https://nemunai.re/"><img src="https://nbr23.com/posts/turn-your-favorite-rss-feeds-into-podcasts/images/nemunaire.png" alt="Blog posts from nemunai.re listed as podcast episodes in Podcast Addict" width="1080" height="2424" loading="lazy" decoding="async">
</a>
</div>
</figure>
<p>Some tweaking is sometimes necessary when trafilatura is involved. For <a href="https://arstechnica.com/">ArsTechnica</a>, which is part of the <a href="https://github.com/nbr23/rss2podcast/blob/master/config.sample.yaml">sample config</a>, I had to merge the <!-- tts say="dot post content div" --><code>.post-content</code> <code>div</code><!-- /tts --> elements to get the full blog post (articles are split across multiple divs of that class).</p>
<p>If by chance the feed you want to hear embeds the full text, you can disable trafilatura to keep things simple (<!-- tts say="dash dash no fetch" --><code>--no-fetch</code><!-- /tts -->).</p>
<p>You can check out <a href="https://nbr23.com/r/podcasts/eff/eff-updates.xml">this podcast</a> from the <a href="https://www.eff.org/rss/updates.xml">EFF updates feed</a> for a sample.</p>
<p>Keep in mind that a synthetic voice is reading. TextToSpeech has become quite good, but the audio can still get randomly <a href="https://nbr23.com/posts/tts-setup/audio/tartine.wav">weird</a>, and trafilatura sometimes needs some adjusting before you get the result you want.</p>
<p>For English, most voices are acceptable, and rss2podcast defaults to <!-- tts say="the Amy medium voice" --><code>en_US-amy-medium</code><!-- /tts -->. For French, I&rsquo;m liking <!-- tts say="the French Siwis medium voice" --><code>fr_FR-siwis-medium</code><!-- /tts -->.</p>
<p>Happy listening!</p>
]]></content:encoded>
      </item>
    
      <item>
        <title>This blog is also a podcast</title>
        <link>https://nbr23.com/posts/this-blog-is-a-podcast/?utm_source=rss</link>
        <pubDate>Thu, 09 Apr 2026 23:01:31 -0400</pubDate>
        <guid isPermaLink="false">https://wip.tf/posts/this-blog-is-a-podcast/</guid>
        <description>Publishing this blog as a podcast feed.</description>
        <content:encoded><![CDATA[<div class="text-to-speech-container">
    <span class="text-to-speech-label">Listen to this post:</span>
    <audio class="text-to-speech-audio" controls>
      <source src="https://nbr23.com/audio/tts/this-blog-is-a-podcast.mp3" type="audio/mpeg">
      <a href="https://nbr23.com/audio/tts/this-blog-is-a-podcast.mp3">Download the audio</a>
    </audio>
  </div>
  
<p>Each post in this <a href="https://nbr23.com/tags/hugo/">hugo</a> powered blog already has its own <a href="https://nbr23.com/posts/listen-to-this-article/">audio version</a>. It only made sense to turn it into a podcast!</p>
<p>I added the following template to the blog&rsquo;s hugo blueprint:</p>
<!-- noTTS -->
<div class="github-embed">
            <div class="github-embed-header">
                <span class="github-embed-header-left">
                    
                    <span class="github-embed-title">Gist</span>
                </span>
                <span class="github-embed-header-right">
                    <a href="https://gist.github.com/nbr23/2b330af8a4af65ba73cadc1d7a805b33">view gist</a></span>
            </div>
            <div class="github-embed-body"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-go-html-template"><span class="line"><span class="cl"><span class="cp">{{</span><span class="w"> </span><span class="nx">$style</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="nx">resources</span><span class="na">.Get</span><span class="w"> </span><span class="s">&#34;xsl/style.xsl&#34;</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="nx">resources</span><span class="na">.ExecuteAsTemplate</span><span class="w"> </span><span class="s">&#34;podcast-style.xsl&#34;</span><span class="w"> </span><span class="o">(</span><span class="nx">dict</span><span class="w"> </span><span class="s">&#34;Site&#34;</span><span class="w"> </span><span class="na">.Site</span><span class="w"> </span><span class="s">&#34;IsPodcast&#34;</span><span class="w"> </span><span class="k">true</span><span class="o">)</span><span class="w"> </span><span class="cp">}}</span>
</span></span><span class="line"><span class="cl"><span class="cp">{{</span><span class="w"> </span><span class="k">printf</span><span class="w"> </span><span class="s">&#34;&lt;?xml-stylesheet type=\&#34;text/xsl\&#34; href=\&#34;&#34;</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="nx">safeHTML</span><span class="w"> </span><span class="cp">}}{{</span><span class="w"> </span><span class="nx">$style</span><span class="na">.Permalink</span><span class="w"> </span><span class="cp">}}{{</span><span class="w"> </span><span class="k">printf</span><span class="w"> </span><span class="s">&#34;\&#34;?&gt;&#34;</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="nx">safeHTML</span><span class="w"> </span><span class="cp">}}</span>
</span></span><span class="line"><span class="cl"><span class="p">&lt;</span><span class="nt">rss</span> <span class="na">version</span><span class="o">=</span><span class="s">&#34;2.0&#34;</span> <span class="na">xmlns:atom</span><span class="o">=</span><span class="s">&#34;http://www.w3.org/2005/Atom&#34;</span> <span class="na">xmlns:itunes</span><span class="o">=</span><span class="s">&#34;http://www.itunes.com/dtds/podcast-1.0.dtd&#34;</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl">  <span class="p">&lt;</span><span class="nt">channel</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl">    <span class="p">&lt;</span><span class="nt">title</span><span class="p">&gt;</span><span class="cp">{{</span><span class="w"> </span><span class="na">.Site.Title</span><span class="w"> </span><span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">title</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl">    <span class="p">&lt;</span><span class="nt">link</span><span class="p">&gt;</span><span class="cp">{{</span><span class="w"> </span><span class="na">.Permalink</span><span class="w"> </span><span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">link</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl">    <span class="p">&lt;</span><span class="nt">description</span><span class="p">&gt;</span><span class="cp">{{</span><span class="w"> </span><span class="na">$.Site.Params.description</span><span class="w"> </span><span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">description</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl">    <span class="cp">{{</span><span class="w"> </span><span class="k">with</span><span class="w"> </span><span class="na">.Site.LanguageCode</span><span class="w"> </span><span class="cp">}}</span><span class="p">&lt;</span><span class="nt">language</span><span class="p">&gt;</span><span class="cp">{{</span><span class="w"> </span><span class="na">.</span><span class="w"> </span><span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">language</span><span class="p">&gt;</span><span class="cp">{{</span><span class="w"> </span><span class="k">end</span><span class="w"> </span><span class="cp">}}</span>
</span></span><span class="line"><span class="cl">    <span class="p">&lt;</span><span class="nt">itunes:image</span> <span class="na">href</span><span class="o">=</span><span class="s">&#34;</span><span class="cp">{{</span><span class="w"> </span><span class="na">.Site.BaseURL</span><span class="w"> </span><span class="cp">}}</span><span class="s">images/podcast-cover.png&#34;</span><span class="p">/&gt;</span>
</span></span><span class="line"><span class="cl">    <span class="p">&lt;</span><span class="nt">itunes:explicit</span><span class="p">&gt;</span>no<span class="p">&lt;/</span><span class="nt">itunes:explicit</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl">    <span class="cp">{{</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="k">not</span><span class="w"> </span><span class="na">.Date.IsZero</span><span class="w"> </span><span class="cp">}}</span><span class="p">&lt;</span><span class="nt">lastBuildDate</span><span class="p">&gt;</span><span class="cp">{{</span><span class="w"> </span><span class="na">.Date.Format</span><span class="w"> </span><span class="s">&#34;Mon, 02 Jan 2006 15:04:05 -0700&#34;</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="nx">safeHTML</span><span class="w"> </span><span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">lastBuildDate</span><span class="p">&gt;</span><span class="cp">{{</span><span class="w"> </span><span class="k">end</span><span class="w"> </span><span class="cp">}}</span>
</span></span><span class="line"><span class="cl">    <span class="cp">{{</span><span class="w"> </span><span class="k">with</span><span class="w"> </span><span class="na">.OutputFormats.Get</span><span class="w"> </span><span class="s">&#34;Podcast&#34;</span><span class="w"> </span><span class="cp">}}</span>
</span></span><span class="line"><span class="cl">      <span class="cp">{{</span><span class="w"> </span><span class="k">printf</span><span class="w"> </span><span class="s">&#34;&lt;atom:link href=%q rel=\&#34;self\&#34; type=%q /&gt;&#34;</span><span class="w"> </span><span class="na">.Permalink</span><span class="w"> </span><span class="na">.MediaType</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="nx">safeHTML</span><span class="w"> </span><span class="cp">}}</span>
</span></span><span class="line"><span class="cl">    <span class="cp">{{</span><span class="w"> </span><span class="k">end</span><span class="w"> </span><span class="cp">}}</span>
</span></span><span class="line"><span class="cl">    <span class="cp">{{</span><span class="w"> </span><span class="k">range</span><span class="w"> </span><span class="na">.Site.RegularPages</span><span class="w"> </span><span class="cp">}}</span>
</span></span><span class="line"><span class="cl">      <span class="cp">{{</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="na">.Params.podcast</span><span class="w"> </span><span class="cp">}}</span>
</span></span><span class="line"><span class="cl">      <span class="p">&lt;</span><span class="nt">item</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl">        <span class="p">&lt;</span><span class="nt">title</span><span class="p">&gt;</span><span class="cp">{{</span><span class="w"> </span><span class="na">.Title</span><span class="w"> </span><span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">title</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl">        <span class="p">&lt;</span><span class="nt">link</span><span class="p">&gt;</span><span class="cp">{{</span><span class="w"> </span><span class="na">.Permalink</span><span class="w"> </span><span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">link</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl">        <span class="p">&lt;</span><span class="nt">pubDate</span><span class="p">&gt;</span><span class="cp">{{</span><span class="w"> </span><span class="na">.Date.Format</span><span class="w"> </span><span class="s">&#34;Mon, 02 Jan 2006 15:04:05 -0700&#34;</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="nx">safeHTML</span><span class="w"> </span><span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">pubDate</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl">        <span class="p">&lt;</span><span class="nt">guid</span><span class="p">&gt;</span><span class="cp">{{</span><span class="w"> </span><span class="na">.Permalink</span><span class="w"> </span><span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">guid</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl">        <span class="p">&lt;</span><span class="nt">description</span><span class="p">&gt;</span><span class="cp">{{</span><span class="w"> </span><span class="k">with</span><span class="w"> </span><span class="na">.Description</span><span class="w"> </span><span class="cp">}}{{</span><span class="w"> </span><span class="na">.</span><span class="w"> </span><span class="cp">}}{{</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="cp">}}{{</span><span class="w"> </span><span class="na">.Summary</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="nx">plainify</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="nx">replaceRE</span><span class="w"> </span><span class="s">&#34;Listen to this post:\\s*&#34;</span><span class="w"> </span><span class="s">&#34;&#34;</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="nx">strings</span><span class="na">.TrimSpace</span><span class="w"> </span><span class="cp">}}{{</span><span class="w"> </span><span class="k">end</span><span class="w"> </span><span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">description</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl">        <span class="p">&lt;</span><span class="nt">enclosure</span> <span class="na">url</span><span class="o">=</span><span class="s">&#34;</span><span class="cp">{{</span><span class="w"> </span><span class="k">printf</span><span class="w"> </span><span class="s">&#34;%saudio/tts/%s.mp3&#34;</span><span class="w"> </span><span class="na">.Site.BaseURL</span><span class="w"> </span><span class="na">.File.ContentBaseName</span><span class="w"> </span><span class="cp">}}</span><span class="s">&#34;</span> <span class="na">type</span><span class="o">=</span><span class="s">&#34;audio/mpeg&#34;</span> <span class="p">/&gt;</span>
</span></span><span class="line"><span class="cl">      <span class="p">&lt;/</span><span class="nt">item</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl">      <span class="cp">{{</span><span class="w"> </span><span class="k">end</span><span class="w"> </span><span class="cp">}}</span>
</span></span><span class="line"><span class="cl">    <span class="cp">{{</span><span class="w"> </span><span class="k">end</span><span class="w"> </span><span class="cp">}}</span>
</span></span><span class="line"><span class="cl">  <span class="p">&lt;/</span><span class="nt">channel</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl"><span class="p">&lt;/</span><span class="nt">rss</span><span class="p">&gt;</span>
</span></span></code></pre></div></div>
        </div>
<!-- /noTTS -->
<p>The template gathers all my blog posts, and if they have the <code>podcast</code> flag set in their front matter, creates an entry in the <a href="https://nbr23.com/posts/podcast.xml">Podcast feed</a> (<a href="pcast://nbr23.com/posts/podcast.xml">Subscribe here!</a>)</p>
<!-- noTTS -->
<p><img src="https://nbr23.com/posts/this-blog-is-a-podcast/images/podcast-addict.png#smaller" alt="Screenshot of this blog in the excellent Podcast Addict podcast reader" width="1080" height="2424" loading="lazy" decoding="async">
</p>
<!-- /noTTS -->
<p>To be consistent with our <a href="https://nbr23.com/posts/rss-xsl/">pretty RSS feed</a>, I added a similar <a href="https://nbr23.com/podcast-style.xsl">XSLT stylesheet</a> to style the podcast feed.</p>
<p>While I don&rsquo;t think my blog specifically warrants being a podcast, it&rsquo;s a feature I&rsquo;d love to see on more long form, storytelling-focused sites.</p>
]]></content:encoded>
      </item>
    
      <item>
        <title>Building a trilingual kid alphabet poster</title>
        <link>https://nbr23.com/posts/building-a-trilingual-kid-alphabet/?utm_source=rss</link>
        <pubDate>Tue, 17 Mar 2026 00:23:46 -0500</pubDate>
        <guid isPermaLink="false">https://wip.tf/posts/building-a-trilingual-kid-alphabet/</guid>
        <description>Building a trilingual alphabet poster with consistent letter examples in English, French, and Portuguese.</description>
        <content:encoded><![CDATA[<div class="text-to-speech-container">
    <span class="text-to-speech-label">Listen to this post:</span>
    <audio class="text-to-speech-audio" controls>
      <source src="https://nbr23.com/audio/tts/building-a-trilingual-kid-alphabet.mp3" type="audio/mpeg">
      <a href="https://nbr23.com/audio/tts/building-a-trilingual-kid-alphabet.mp3">Download the audio</a>
    </audio>
  </div>
  
<figure class="floatright">
<a class="lightbox" href="https://nbr23.com/posts/building-a-trilingual-kid-alphabet/images/final-physical.jpg"><img src="https://nbr23.com/posts/building-a-trilingual-kid-alphabet/images/final-physical-thumb.jpg" alt="Printed version of the English/French/Portuguese alphabet poster"></a>
</figure>
<p>We speak <strong>English</strong>, <strong>Portuguese</strong> and <strong>French</strong> at home, and learning the alphabet can be tricky when it gets to letter examples: &ldquo;G as in <strong>Grapefruit</strong>&rdquo;, but that&rsquo;s <strong>Pamplemousse</strong> in French and <strong>Toranja</strong> in Portuguese, so the correspondence doesn&rsquo;t work in other languages and can lead to confusion.</p>
<br/>
<h2 id="building-a-trilingual-alphabet">Building a trilingual alphabet</h2>
<p>My goal was to build a small dictionary where each letter is assigned a concept that:</p>
<ul>
<li>is understandable by a toddler (not &ldquo;Q as in Quantum&rdquo;)</li>
<li>can be illustrated easily (not &ldquo;W as in World Wide Web&rdquo;)</li>
<li>is referenced by a word starting by the same letter in all 3 languages (not &ldquo;Apple/Pomme/Maçã&rdquo;)</li>
</ul>
<p>I used LLMs to get started with an initial list, but with my constraints, LLMs weren&rsquo;t great at this and hallucinated a lot. I ended up mostly relying on online dictionaries, kids books we had hanging around, and home knowledge to assemble a list I liked.</p>
<!-- noTTS -->
<div class="csv-wrap">
<table>
<thead>
<tr><th>Letter</th><th>English</th><th>French</th><th>Portuguese</th></tr>
</thead>
<tbody><tr><td>A</td><td>Astronaut</td><td>Astronaute</td><td>Astronauta</td></tr><tr><td>B</td><td>Banana</td><td>Banane</td><td>Banana</td></tr><tr><td>C</td><td>Crocodile</td><td>Crocodile</td><td>Crocodilo</td></tr><tr><td>D</td><td>Dinosaur</td><td>Dinosaure</td><td>Dinossauro</td></tr><tr><td>E</td><td>Elephant</td><td>Éléphant</td><td>Elefante</td></tr><tr><td>F</td><td>Flower</td><td>Fleur</td><td>Flor</td></tr><tr><td>G</td><td>Gorilla</td><td>Gorille</td><td>Gorila</td></tr><tr><td>H</td><td>Helicopter</td><td>Hélicoptère</td><td>Helicóptero</td></tr><tr><td>I</td><td>Iguana</td><td>Iguane</td><td>Iguana</td></tr><tr><td>J</td><td>Jaguar</td><td>Jaguar</td><td>Jaguar</td></tr><tr><td>K</td><td>Kiwi</td><td>Kiwi</td><td>Kiwi</td></tr><tr><td>L</td><td>Lion</td><td>Lion</td><td>Leão</td></tr><tr><td>M</td><td>Melon</td><td>Melon</td><td>Melão</td></tr><tr><td>N</td><td>Narwhal</td><td>Narval</td><td>Narval</td></tr><tr><td>O</td><td>Orca</td><td>Orque</td><td>Orca</td></tr><tr><td>P</td><td>Panda</td><td>Panda</td><td>Panda</td></tr><tr><td>Q</td><td>Quetzal</td><td>Quetzal</td><td>Quetzal</td></tr><tr><td>R</td><td>Rhinoceros</td><td>Rhinocéros</td><td>Rinoceronte</td></tr><tr><td>S</td><td>Snake</td><td>Serpent</td><td>Serpente</td></tr><tr><td>T</td><td>Tiger</td><td>Tigre</td><td>Tigre</td></tr><tr><td>U</td><td>Ukulele</td><td>Ukulele</td><td>Ukulele</td></tr><tr><td>V</td><td>Volcano</td><td>Volcan</td><td>Vulcão</td></tr><tr><td>W</td><td>Wall-E</td><td>Wall-E</td><td>Wall-E</td></tr><tr><td>X</td><td>Xylophone</td><td>Xylophone</td><td>Xilofone</td></tr><tr><td>Y</td><td>Yoga</td><td>Yoga</td><td>Yoga</td></tr><tr><td>Z</td><td>Zebra</td><td>Zèbre</td><td>Zebra</td></tr></tbody>
</table>
</div>
<!-- /noTTS -->
<p>While most letters had very obvious kid friendly examples, a few gave me some trouble, and one (<code>W</code>) proved impossible to satisfy without copyright bending.</p>
<p>These two charts illustrate the language differences, and the challenge I faced. They are based on word counts from the <a href="https://hunspell.github.io/">hunspell</a> dictionaries using <a href="https://github.com/nbr23/dict-size-comparator">this script</a>.</p>
<!-- noTTS -->
<div class="grouped-bar-chart">
<table><caption>Words Starting With Each Letter</caption><thead><tr><th></th><th>English (en_GB)</th><th>French (fr)</th><th>Portuguese (pt_BR)</th></tr></thead>
<tbody><tr><th>A</th><td>3953</td><td>6361</td><td>29732</td></tr><tr><th>B</th><td>3298</td><td>3690</td><td>15326</td></tr><tr><th>C</th><td>5555</td><td>7917</td><td>36273</td></tr><tr><th>D</th><td>2959</td><td>4903</td><td>11641</td></tr><tr><th>E</th><td>2534</td><td>2640</td><td>21755</td></tr><tr><th>F</th><td>2445</td><td>2628</td><td>11687</td></tr><tr><th>G</th><td>1944</td><td>2509</td><td>10508</td></tr><tr><th>H</th><td>2584</td><td>2245</td><td>8974</td></tr><tr><th>I</th><td>2298</td><td>3299</td><td>8574</td></tr><tr><th>J</th><td>405</td><td>562</td><td>4034</td></tr><tr><th>K</th><td>582</td><td>368</td><td>54</td></tr><tr><th>L</th><td>1970</td><td>2019</td><td>10638</td></tr><tr><th>M</th><td>3923</td><td>4684</td><td>24374</td></tr><tr><th>N</th><td>1834</td><td>1517</td><td>6547</td></tr><tr><th>O</th><td>1822</td><td>1569</td><td>7655</td></tr><tr><th>P</th><td>6173</td><td>7364</td><td>30345</td></tr><tr><th>Q</th><td>339</td><td>454</td><td>3354</td></tr><tr><th>R</th><td>2778</td><td>4268</td><td>9614</td></tr><tr><th>S</th><td>6563</td><td>5534</td><td>15144</td></tr><tr><th>T</th><td>2942</td><td>3927</td><td>17728</td></tr><tr><th>U</th><td>2241</td><td>450</td><td>2650</td></tr><tr><th>V</th><td>879</td><td>1680</td><td>5748</td></tr><tr><th>W</th><td>1249</td><td>149</td><td>32</td></tr><tr><th>X</th><td>81</td><td>162</td><td>764</td></tr><tr><th>Y</th><td>158</td><td>89</td><td>22</td></tr><tr><th>Z</th><td>151</td><td>268</td><td>821</td></tr></tbody>
</table>
</div>


<!-- /noTTS -->
<p>The <strong>hunspell</strong> <!-- tts say="Brazilian Portuguese" --><code>pt_BR</code><!-- /tts --> dictionary is impressively large (likely just due different choices made by the maintainers rather than some linguistic fact), but that only makes the 54 <code>K</code> words, 32 <code>W</code> words and 22 <code>Y</code> words all the more striking.</p>
<!-- noTTS -->
<div class="grouped-bar-chart">
<table><caption>Words Starting With Each Letter - Normalized by language</caption><thead><tr><th></th><th>English (en_GB)</th><th>French (fr)</th><th>Portuguese (pt_BR)</th></tr></thead>
<tbody><tr><th>A</th><td>6.41%</td><td>8.93%</td><td>10.11%</td></tr><tr><th>B</th><td>5.35%</td><td>5.18%</td><td>5.21%</td></tr><tr><th>C</th><td>9.01%</td><td>11.11%</td><td>12.34%</td></tr><tr><th>D</th><td>4.8%</td><td>6.88%</td><td>3.96%</td></tr><tr><th>E</th><td>4.11%</td><td>3.7%</td><td>7.4%</td></tr><tr><th>F</th><td>3.97%</td><td>3.69%</td><td>3.98%</td></tr><tr><th>G</th><td>3.15%</td><td>3.52%</td><td>3.57%</td></tr><tr><th>H</th><td>4.19%</td><td>3.15%</td><td>3.05%</td></tr><tr><th>I</th><td>3.73%</td><td>4.63%</td><td>2.92%</td></tr><tr><th>J</th><td>0.66%</td><td>0.79%</td><td>1.37%</td></tr><tr><th>K</th><td>0.94%</td><td>0.52%</td><td>0.02%</td></tr><tr><th>L</th><td>3.19%</td><td>2.83%</td><td>3.62%</td></tr><tr><th>M</th><td>6.36%</td><td>6.57%</td><td>8.29%</td></tr><tr><th>N</th><td>2.97%</td><td>2.13%</td><td>2.23%</td></tr><tr><th>O</th><td>2.95%</td><td>2.2%</td><td>2.6%</td></tr><tr><th>P</th><td>10.01%</td><td>10.33%</td><td>10.32%</td></tr><tr><th>Q</th><td>0.55%</td><td>0.64%</td><td>1.14%</td></tr><tr><th>R</th><td>4.51%</td><td>5.99%</td><td>3.27%</td></tr><tr><th>S</th><td>10.64%</td><td>7.77%</td><td>5.15%</td></tr><tr><th>T</th><td>4.77%</td><td>5.51%</td><td>6.03%</td></tr><tr><th>U</th><td>3.63%</td><td>0.63%</td><td>0.9%</td></tr><tr><th>V</th><td>1.43%</td><td>2.36%</td><td>1.96%</td></tr><tr><th>W</th><td>2.03%</td><td>0.21%</td><td>0.01%</td></tr><tr><th>X</th><td>0.13%</td><td>0.23%</td><td>0.26%</td></tr><tr><th>Y</th><td>0.26%</td><td>0.12%</td><td>0.01%</td></tr><tr><th>Z</th><td>0.24%</td><td>0.38%</td><td>0.28%</td></tr></tbody>
</table>
</div>


<!-- /noTTS -->
<h3 id="kwy">K,W,Y</h3>
<p><code>K</code>, <code>W</code>, and <code>Y</code> were <a href="https://en.wikipedia.org/wiki/Portuguese-Language_Orthographic_Agreement_of_1990#Changes">absent from the official Portuguese alphabet until the 2000s</a>. As a result, hardly any word exist with these letters. A Brazilian children&rsquo;s book we have at home gives &ldquo;Windsurf&rdquo; (&ldquo;planche à voile&rdquo; in French, not a usable in our case), &ldquo;Yakisoba&rdquo; (not a simple visual concept) for these letters.</p>
<p>Common examples of <code>K</code>-words existing in English and French were adapted to use letters from the Portuguese alphabet: <a href="https://pt.wikipedia.org/wiki/Caiaque">Kayak is Caiaque</a>, <a href="https://pt.wikipedia.org/wiki/Canguru">Kangaroo is Canguru</a> and <a href="https://pt.wikipedia.org/wiki/Coala">Koala is Coala</a>. I settled for Kiwi, but even that is commonly spelt with a <a href="https://pt.wikipedia.org/wiki/Actinidia_deliciosa">Q</a>, especially the <a href="https://pt.wikipedia.org/wiki/Quiu%C3%AD_%28ave%29">bird</a>.</p>
<p>French barely has words in <code>Y</code> either, doubling the challenge. <a href="https://fr.wikipedia.org/wiki/Yack">Yak</a> is usually my go-to <code>Y</code>-word, but uses <a href="https://pt.wikipedia.org/wiki/Iaque">an I</a> in Portuguese. I settled on Yoga which seems acceptable as <a href="https://pt.wikipedia.org/wiki/Ioga">Ioga and Yoga</a> in Portuguese.</p>
<p><code>W</code> is entirely impossible. Despite Claude Sonnet&rsquo;s attempts at convincing me <a href="https://en.wikipedia.org/wiki/Wombat">Wombat</a>/<a href="https://pt.wikipedia.org/wiki/Vombate">Vombat</a> started with a <code>W</code> in Portuguese, I had to resort to the proper noun and <a href="https://en.wikipedia.org/wiki/Copyright_Term_Extension_Act#Support">disney/pixar IP</a> &ldquo;Wall-E&rdquo; which allowed for a cuter illustration than WiFi, or Web (as in World Wide Web).</p>
<h3 id="u">U</h3>
<p><code>U</code> was simple because Ukulele is a very common example in all 3 languages, but I was surprised to realize how few are the French words beginning with <code>U</code>, and how few alternatives I would have had to Ukulele.</p>
<h3 id="q">Q</h3>
<p><code>Q</code>s in English, French and Portuguese, usually come from <a href="https://www.cours-de-latin.com/mot-du-jour/">latin</a> words, where the <!-- tts say="K" --><code>/k/</code><!-- /tts --> sound is already mostly handled by the letter <code>C</code>. <code>Q</code>s usually come in the <!-- tts say="Q U" --><code>qu</code><!-- /tts --> form. This leads to a pretty small sample. I ended using <a href="https://en.wikipedia.org/wiki/Quetzal#Etymology">Quetzal</a>, a clear exception from this latin tendency, but a visual and colorful one.</p>
<figure class="xsmaller">
<a class="lightbox" href="https://commons.wikimedia.org/wiki/File:057_Male_Resplendent_quetzal_in_Los_Quetzales_National_Park_Photo_by_Giles_Laurent.jpg"><img src="https://nbr23.com/posts/building-a-trilingual-kid-alphabet/images/057_Male_Resplendent_quetzal_in_Los_Quetzales_National_Park_Photo_by_Giles_Laurent.jpg" alt="Male Resplendent quetzal in Los Quetzales National Park. Photo by Giles Laurent, CC BY-SA 4.0, via Wikimedia Commons"></a>
</figure>
<br/>
<h2 id="generating-a-visual">Generating a visual</h2>
<p>I used <a href="https://ai.google.dev/gemini-api/docs/models/gemini-3-pro-image-preview">Gemini</a> to generate a visual based on this list. It took a few rounds and iterations, switching between <code>gemini-3-pro-image-preview</code> and <code>gemini-3.1-flash-image-preview</code>.</p>
<p>The version I retained was a result of <code>gemini-3-pro-image-preview</code> and the following prompt:</p>
<!-- noTTS -->
<div class="collapsable">
<div class="collapsable-inner">
<p>Here is a list of letters and words in english, french, portuguese that start with that letter.</p>
<p>Generate a poster style visual for kids, that lists all the letters of the alphabet, in order, with a drawing representing the concept of the word for each. For Wall-E, we can just generate a little robot in the style of wall-e. For yoga, it should be a unisex person doing a yoga pose. Make all the drawings in the same style, cartoonish, child friendly, not too bright colors. The letters should be big an readable. The kiwi should show the bird and the fruit.</p>
<p>The format should be a A4 page. Don&rsquo;t add a title to the poster.</p>
<p>Write the words in the three languages (English, French, Portuguese in this order) for each. If only one word is specified, it is because it&rsquo;s the same in the 3 languages, so just write it once.</p>
<p>The letters should be arranged in rows of 4. The first and last row should only contain 3 letters, and be centered to have equal space on both sides, offsetting their 1 letter deficiency. Keep similar size for letter, drawing and words across all letters.</p>
<p>Make sure the letters are readable and not obstructed by the illustrations.</p>
<p>The letters should be of different colors, matching the general color of their illustration</p>
<pre tabindex="0"><code>Letter,English,French,Portuguese
A,Astronaut,Astronaute,Astronauta
B,Banana,Banane,Banana
C,Crocodile,Crocodile,Crocodilo
D,Dinosaur,Dinosaure,Dinossauro
E,Elephant,Éléphant,Elefante
F,Flower,Fleur,Flor
G,Gorilla,Gorille,Gorila
H,Helicopter,Hélicoptère,Helicóptero
I,Iguana,Iguane,Iguana
J,Jaguar
K,Kiwi
L,Lion,Lion,Leão
M,Melon,Melon,Melão
N,Narwhal,Narval,Narval
O,Orca,Orque,Orca
P,Panda
Q,Quetzal
R,Rhinoceros,Rhinocéros,Rinoceronte
S,Snake,Serpent,Serpente
T,Tiger,Tigre,Tigre
U,Ukulele
V,Volcano,Volcan,Vulcão
W,Wall-E
X,Xylophone,Xylophone,Xilofone
Y,Yoga
Z,Zebra,Zèbre,Zebra
</code></pre><p>Make extra sure that we are not missing any letter (26 total), and that the drawing corresponds to the letter and is in order.</p>
</div>
</div>
<!-- /noTTS -->
<br/>
<h2 id="printing">Printing</h2>
<p>In the US, UPS, FedEx, etc offer printing services that seem adequate for this use. I picked Vistaprint, because their upload and editing tools made it very easy to adapt my image to their constraints (other vendors have similar tools. I just liked Vistaprint&rsquo;s better after very brief testing).</p>
<p>I chose the <a href="https://www.vistaprint.com/signs-posters/posters">&ldquo;Custom Poster&rdquo; <!-- tts say="eleven by seventeen inch" -->11&quot;x17&quot;<!-- /tts --> option</a>, Vertical, with semi-gloss lamination.</p>
<br/>
<h2 id="bloopers">Bloopers</h2>
<p>A few examples of the text hallucinations LLMs (Sonnet 4.6 in this specific case) insisted made sense:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-csv"><span class="line"><span class="cl"><span class="s">Letter</span><span class="p">,</span><span class="s">English</span><span class="p">,</span><span class="s">French</span><span class="p">,</span><span class="s">Portuguese</span><span class="p">
</span></span></span><span class="line"><span class="cl"><span class="s">A</span><span class="p">,</span><span class="s">Ant</span><span class="p">,</span><span class="s">Fourmi</span><span class="p">,</span><span class="s">Formiga</span><span class="p">
</span></span></span><span class="line"><span class="cl"><span class="s">D</span><span class="p">,</span><span class="s">Duck</span><span class="p">,</span><span class="s">Canard</span><span class="p">,</span><span class="s">Pato</span><span class="p">
</span></span></span><span class="line"><span class="cl"><span class="s">K</span><span class="p">,</span><span class="s">Kangaroo</span><span class="p">,</span><span class="s">Kangourou</span><span class="p">,</span><span class="s">Canguru</span><span class="p">
</span></span></span><span class="line"><span class="cl"><span class="s">Q</span><span class="p">,</span><span class="s">Quail</span><span class="p">,</span><span class="s">Caille</span><span class="p">,</span><span class="s">Codorniz</span><span class="p">
</span></span></span><span class="line"><span class="cl"><span class="s">U</span><span class="p">,</span><span class="s">Urchin (sea)</span><span class="p">,</span><span class="s">Oursin</span><span class="p">,</span><span class="s">Ouriço</span><span class="p">
</span></span></span><span class="line"><span class="cl"><span class="s">V</span><span class="p">,</span><span class="s">Vulture</span><span class="p">,</span><span class="s">Vautour</span><span class="p">,</span><span class="s">Urubu</span><span class="p">
</span></span></span></code></pre></div><!-- /noTTS -->
<p>And some image generation goofs from gemini (3-pro and 3.1 flash):</p>
<!-- noTTS -->
<div class="photo-gallery"><figure class="photo-gallery-item">
<a class="lightbox" href="https://nbr23.com/posts/building-a-trilingual-kid-alphabet/images/4-lang-xylophone.png"><img src="https://nbr23.com/posts/building-a-trilingual-kid-alphabet/images/4-lang-xylophone-thumb.png" alt="Xylophone in 4 languages?" loading="lazy"></a><figcaption>Xylophone in 4 languages?</figcaption></figure><figure class="photo-gallery-item">
<a class="lightbox" href="https://nbr23.com/posts/building-a-trilingual-kid-alphabet/images/no-q.jpg"><img src="https://nbr23.com/posts/building-a-trilingual-kid-alphabet/images/no-q-thumb.jpg" alt="Missing the letter Q" loading="lazy"></a><figcaption>Missing the letter Q</figcaption></figure><figure class="photo-gallery-item">
<a class="lightbox" href="https://nbr23.com/posts/building-a-trilingual-kid-alphabet/images/still-no-q.jpg"><img src="https://nbr23.com/posts/building-a-trilingual-kid-alphabet/images/still-no-q-thumb.jpg" alt="Still no Q after asking for correction" loading="lazy"></a><figcaption>Still no Q after asking for correction</figcaption></figure><figure class="photo-gallery-item">
<a class="lightbox" href="https://nbr23.com/posts/building-a-trilingual-kid-alphabet/images/cool-bad-spacing.png"><img src="https://nbr23.com/posts/building-a-trilingual-kid-alphabet/images/cool-bad-spacing-thumb.png" alt="Cute but poor formatting" loading="lazy"></a><figcaption>Cute but poor formatting</figcaption></figure><figure class="photo-gallery-item">
<a class="lightbox" href="https://nbr23.com/posts/building-a-trilingual-kid-alphabet/images/uu.png"><img src="https://nbr23.com/posts/building-a-trilingual-kid-alphabet/images/uu-thumb.png" alt="28 letters, a lot going on after R" loading="lazy"></a><figcaption>28 letters, a lot going on after R</figcaption></figure></div>
<!-- /noTTS -->
<br/>
<h2 id="conclusion">Conclusion</h2>
<p>With shipping, hanging strips, taxes and adding the <code>$4.27</code> I spent on the Gemini API during image iterations, the entire project cost around <code>$35</code>.</p>
<!-- noTTS -->
<figure class="smaller">
<a class="lightbox" href="https://nbr23.com/posts/building-a-trilingual-kid-alphabet/images/trilingual-alphabet-final.jpg"><img src="https://nbr23.com/posts/building-a-trilingual-kid-alphabet/images/trilingual-alphabet-final-thumb.jpg" alt="Final version of the English/French/Portuguese alphabet poster"></a>
</figure>
<!-- /noTTS -->
<p>The physical result is of good dimensions and decent printing quality. I expected the poster to be more rigid / resistant, and less prone to bending marks from the travel. Framing it might be necessary to protect it better from touching.</p>
]]></content:encoded>
      </item>
    
      <item>
        <title>TGIF-Claude: visualizing Claude Pro usage relative to the week</title>
        <link>https://nbr23.com/posts/tgif-claude-visualizing-claude-pro-usage-relative-to-the-week/?utm_source=rss</link>
        <pubDate>Thu, 05 Mar 2026 21:11:11 -0500</pubDate>
        <guid isPermaLink="false">https://wip.tf/posts/tgif-claude-visualizing-claude-pro-usage-relative-to-the-week/</guid>
        <description>A bookmarklet that visualizes Claude Pro usage against weekly limits to help plan usage around the reset cycle.</description>
        <content:encoded><![CDATA[<div class="text-to-speech-container">
    <span class="text-to-speech-label">Listen to this post:</span>
    <audio class="text-to-speech-audio" controls>
      <source src="https://nbr23.com/audio/tts/tgif-claude-visualizing-claude-pro-usage-relative-to-the-week.mp3" type="audio/mpeg">
      <a href="https://nbr23.com/audio/tts/tgif-claude-visualizing-claude-pro-usage-relative-to-the-week.mp3">Download the audio</a>
    </audio>
  </div>
  
<p>Earlier this week, my yearly <a href="https://support.claude.com/en/articles/11049762-choosing-a-claude-plan">Claude Pro</a> subscription auto-renewed. This seems to have triggered a &ldquo;service improvement&rdquo;, making me subject to <a href="https://news.ycombinator.com/item?id=44713754">weekly limits</a>. I had heard of these, but had until then only been subject to the <!-- tts say="five-hour" -->5h<!-- /tts --> session limits.</p>
<p>With this came a new form of anxiety summarized as &ldquo;OMG I think I might be ahead in my consumption of the weekly limit, compared to the passage of time.&rdquo;</p>
<p>To fight this new existential dread and live with facts not fear, I overlay the week&rsquo;s time elapsed against the token usage progress, directly on the <a href="https://claude.ai/settings/usage">Claude usage page</a>.</p>
<p><img src="https://nbr23.com/posts/tgif-claude-visualizing-claude-pro-usage-relative-to-the-week/images/tgif-claude.png#center" alt="Claude usage page with week time elapsed overlaid against token consumption" title="tgif-claude overlay" width="1984" height="788" loading="lazy" decoding="async">
</p>
<p>I use a bookmarklet for this: <a href="https://github.com/nbr23/tgif-claude/">tgif-claude</a>. It auto-refreshes, but obviously requires to be clicked on when the page is loaded (a <a href="https://en.wikipedia.org/wiki/Userscript_manager">userscript manager</a> or full-on browser add-on seemed overkill).</p>
<p>Copy it from here:</p>
<!-- noTTS -->
<div class="github-embed github-embed--wrap">
            <div class="github-embed-header">
                <span class="github-embed-header-left">
                    
                    <span class="github-embed-title">bookmarklet.js</span>
                </span>
                <span class="github-embed-header-right">
                    <a href="https://github.com/nbr23/tgif-claude/blob/main/bookmarklet.js">view code</a></span>
            </div>
            <div class="github-embed-body"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text"><span class="line"><span class="cl">javascript:(function%20()%20%7B%20var%20WEEK_MS%20%3D%207%20*%2024%20*%2060%20*%2060%20*%201000%3B%20var%20SESSION_MS%20%3D%205%20*%2060%20*%2060%20*%201000%3B%20var%20DAY_MS%20%3D%2024%20*%2060%20*%2060%20*%201000%3B%20var%20HOUR_MS%20%3D%2060%20*%2060%20*%201000%3B%20var%20MIN_MS%20%3D%2060%20*%201000%3B%20var%20TOOLTIP_TOLERANCE_MS%20%3D%202%20*%20HOUR_MS%3B%20function%20teardown()%20%7B%20var%20prev%20%3D%20window.__tgif%3B%20if%20(prev)%20%7B%20(prev.intervals%20%7C%7C%20%5B%5D).forEach(clearInterval)%3B%20(prev.observers%20%7C%7C%20%5B%5D).forEach(function%20(o)%20%7B%20o.disconnect()%3B%20%7D)%3B%20%7D%20window.__tgif%20%3D%20%7B%20intervals%3A%20%5B%5D%2C%20observers%3A%20%5B%5D%20%7D%3B%20Array.from(document.querySelectorAll(&#39;%5Bdata-tgif%5D&#39;)).forEach(function%20(el)%20%7B%20el.remove()%3B%20%7D)%3B%20%7D%20function%20track(kind%2C%20value)%20%7B%20window.__tgif%5Bkind%5D.push(value)%3B%20return%20value%3B%20%7D%20function%20roundToHour(date)%20%7B%20if%20(date.getMinutes()%20%3E%3D%2030)%20date.setHours(date.getHours()%20%2B%201)%3B%20date.setMinutes(0%2C%200%2C%200)%3B%20return%20date%3B%20%7D%20function%20roundToTenMinutes(date)%20%7B%20date.setMinutes(Math.round(date.getMinutes()%20%2F%2010)%20*%2010%2C%200%2C%200)%3B%20return%20date%3B%20%7D%20function%20formatClockTime(lang%2C%20date)%20%7B%20var%20h%20%3D%20date.getHours()%3B%20var%20m%20%3D%20date.getMinutes()%3B%20var%20mm%20%3D%20(m%20%3C%2010%20%3F%20&#39;0&#39;%20%3A%20&#39;&#39;)%20%2B%20m%3B%20if%20(lang.ampm)%20%7B%20return%20(h%20%25%2012%20%7C%7C%2012)%20%2B%20&#39;%3A&#39;%20%2B%20mm%20%2B%20(h%20%3E%3D%2012%20%3F%20&#39;%20PM&#39;%20%3A%20&#39;%20AM&#39;)%3B%20%7D%20return%20h%20%2B%20&#39;%3A&#39;%20%2B%20mm%3B%20%7D%20function%20formatTooltipTime(lang%2C%20date)%20%7B%20return%20lang.dayNames%5Bdate.getDay()%5D%20%2B%20&#39;%20&#39;%20%2B%20formatClockTime(lang%2C%20date)%3B%20%7D%20function%20formatDuration(ms)%20%7B%20var%20days%20%3D%20Math.floor(ms%20%2F%20DAY_MS)%3B%20var%20hours%20%3D%20Math.floor((ms%20%25%20DAY_MS)%20%2F%20HOUR_MS)%3B%20var%20mins%20%3D%20Math.floor((ms%20%25%20HOUR_MS)%20%2F%20MIN_MS)%3B%20var%20parts%20%3D%20%5B%5D%3B%20if%20(days%20%3E%200)%20parts.push(days%20%2B%20&#39;d&#39;)%3B%20if%20(hours%20%3E%200%20%7C%7C%20days%20%3E%200)%20parts.push(hours%20%2B%20&#39;h&#39;)%3B%20parts.push(mins%20%2B%20&#39;m&#39;)%3B%20return%20parts.join(&#39;%20&#39;)%3B%20%7D%20function%20parseRelative(text%2C%20relParse)%20%7B%20var%20m%20%3D%20text.match(relParse)%3B%20if%20(!m)%20return%20null%3B%20var%20d%20%3D%20parseInt(m%5B1%5D%2C%2010)%20%7C%7C%200%3B%20var%20h%20%3D%20parseInt(m%5B2%5D%2C%2010)%20%7C%7C%200%3B%20var%20mi%20%3D%20parseInt(m%5B3%5D%2C%2010)%20%7C%7C%200%3B%20return%20((d%20*%2024%20%2B%20h)%20*%2060%20%2B%20mi)%20*%20MIN_MS%3B%20%7D%20function%20dispatchHover(el%2C%20entering)%20%7B%20var%20types%20%3D%20entering%20%3F%20%5B&#39;pointerover&#39;%2C%20&#39;pointerenter&#39;%2C%20&#39;mouseover&#39;%2C%20&#39;mouseenter&#39;%5D%20%3A%20%5B&#39;pointerout&#39;%2C%20&#39;pointerleave&#39;%2C%20&#39;mouseout&#39;%2C%20&#39;mouseleave&#39;%5D%3B%20types.forEach(function%20(type)%20%7B%20var%20Ctor%20%3D%20(type.indexOf(&#39;pointer&#39;)%20%3D%3D%3D%200%20%26%26%20window.PointerEvent)%20%7C%7C%20MouseEvent%3B%20el.dispatchEvent(new%20Ctor(type%2C%20%7B%20bubbles%3A%20%2Fover%7Cout%2F.test(type)%2C%20cancelable%3A%20true%2C%20view%3A%20window%2C%20relatedTarget%3A%20document.body%2C%20pointerType%3A%20&#39;mouse&#39;%2C%20%7D))%3B%20%7D)%3B%20%7D%20function%20tooltipFor(trigger)%20%7B%20var%20id%20%3D%20trigger.getAttribute(&#39;popovertarget&#39;)%20%7C%7C%20trigger.getAttribute(&#39;aria-describedby&#39;)%3B%20return%20id%20%3F%20document.getElementById(id)%20%3A%20null%3B%20%7D%20function%20tooltipText(tip)%20%7B%20return%20tip.textContent.replace(%2F%5Cs%2B%2Fg%2C%20&#39;%20&#39;).trim()%3B%20%7D%20function%20revealTooltip(trigger%2C%20tip)%20%7B%20return%20new%20Promise(function%20(resolve)%20%7B%20var%20focused%20%3D%20document.activeElement%3B%20var%20settled%20%3D%20false%3B%20var%20observer%20%3D%20new%20MutationObserver(function%20()%20%7B%20if%20(tooltipText(tip))%20finish()%3B%20%7D)%3B%20function%20finish()%20%7B%20if%20(settled)%20return%3B%20settled%20%3D%20true%3B%20observer.disconnect()%3B%20var%20text%20%3D%20tooltipText(tip)%3B%20dispatchHover(trigger%2C%20false)%3B%20try%20%7B%20tip.hidePopover()%3B%20%7D%20catch%20(e)%20%7B%7D%20trigger.blur()%3B%20if%20(focused%20%26%26%20focused%20!%3D%3D%20document.body%20%26%26%20focused.isConnected)%20%7B%20focused.focus(%7B%20preventScroll%3A%20true%20%7D)%3B%20%7D%20tip.style.visibility%20%3D%20&#39;&#39;%3B%20resolve(text%20%7C%7C%20null)%3B%20%7D%20observer.observe(tip%2C%20%7B%20childList%3A%20true%2C%20subtree%3A%20true%2C%20characterData%3A%20true%20%7D)%3B%20tip.style.visibility%20%3D%20&#39;hidden&#39;%3B%20dispatchHover(trigger%2C%20true)%3B%20trigger.focus(%7B%20preventScroll%3A%20true%20%7D)%3B%20try%20%7B%20tip.showPopover()%3B%20%7D%20catch%20(e)%20%7B%7D%20setTimeout(finish%2C%201500)%3B%20%7D)%3B%20%7D%20function%20parseTooltipTime(text%2C%20expectedMs%2C%20lang)%20%7B%20var%20time%20%3D%20text.match(%2F(%5Cd%7B1%2C2%7D)%3A(%5Cd%7B2%7D)(%3F%3A%3A%5Cd%7B2%7D)%3F(%3F%3A%5Cs*(%5Bap%5D)%5C.%3Fm%5Cb%5C.%3F)%3F%2Fi)%3B%20if%20(!time)%20return%20null%3B%20var%20hour%20%3D%20parseInt(time%5B1%5D%2C%2010)%3B%20var%20minute%20%3D%20parseInt(time%5B2%5D%2C%2010)%3B%20var%20meridiem%20%3D%20(time%5B3%5D%20%7C%7C%20&#39;&#39;).toLowerCase()%3B%20if%20(meridiem%20%3D%3D%3D%20&#39;p&#39;%20%26%26%20hour%20!%3D%3D%2012)%20hour%20%2B%3D%2012%3B%20if%20(meridiem%20%3D%3D%3D%20&#39;a&#39;%20%26%26%20hour%20%3D%3D%3D%2012)%20hour%20%3D%200%3B%20var%20rest%20%3D%20text.toLowerCase().replace(time%5B0%5D.toLowerCase()%2C%20&#39;%20&#39;)%3B%20var%20md%20%3D%20rest.match(%2F%5Cb(jan%7Cfeb%7Cmar%7Capr%7Cmay%7Cjun%7Cjul%7Caug%7Csep%7Coct%7Cnov%7Cdec)%5Ba-z%5D*%5C.%3F%5Cs%2B(%5Cd%7B1%2C2%7D)%5Cb%2F)%3B%20var%20dm%20%3D%20rest.match(%2F%5Cb(%5Cd%7B1%2C2%7D)%5Cs%2B(jan%7Cfeb%7Cmar%7Capr%7Cmay%7Cjun%7Cjul%7Caug%7Csep%7Coct%7Cnov%7Cdec)%5Ba-z%5D*%2F)%3B%20var%20wd%20%3D%20rest.match(lang.weekday)%3B%20var%20expected%20%3D%20new%20Date(expectedMs)%3B%20var%20candidates%20%3D%20%5B%5D%3B%20if%20(md%20%7C%7C%20dm)%20%7B%20var%20month%20%3D%20lang.months%5Bmd%20%3F%20md%5B1%5D%20%3A%20dm%5B2%5D%5D%3B%20var%20day%20%3D%20parseInt(md%20%3F%20md%5B2%5D%20%3A%20dm%5B1%5D%2C%2010)%3B%20%5B-1%2C%200%2C%201%5D.forEach(function%20(dy)%20%7B%20candidates.push(new%20Date(expected.getFullYear()%20%2B%20dy%2C%20month%2C%20day%2C%20hour%2C%20minute))%3B%20%7D)%3B%20%7D%20else%20%7B%20var%20weekday%20%3D%20wd%20%3F%20lang.days%5Bwd%5B1%5D%5D%20%3A%20-1%3B%20for%20(var%20offset%20%3D%20-8%3B%20offset%20%3C%3D%208%3B%20offset%2B%2B)%20%7B%20var%20c%20%3D%20new%20Date(expected.getFullYear()%2C%20expected.getMonth()%2C%20expected.getDate()%20%2B%20offset%2C%20hour%2C%20minute)%3B%20if%20(weekday%20%3C%200%20%7C%7C%20c.getDay()%20%3D%3D%3D%20weekday)%20candidates.push(c)%3B%20%7D%20%7D%20var%20best%20%3D%20candidates.reduce(function%20(a%2C%20b)%20%7B%20return%20Math.abs(b%20-%20expectedMs)%20%3C%20Math.abs(a%20-%20expectedMs)%20%3F%20b%20%3A%20a%3B%20%7D)%3B%20return%20Math.abs(best%20-%20expectedMs)%20%3C%3D%20TOOLTIP_TOLERANCE_MS%20%3F%20best.getTime()%20%3A%20null%3B%20%7D%20function%20textNodes(root)%20%7B%20return%20Array.from(root.querySelectorAll(&#39;p%2C%20span%2C%20div&#39;))%3B%20%7D%20function%20findByText(root%2C%20text)%20%7B%20return%20textNodes(root).find(function%20(el)%20%7B%20return%20el.textContent.trim()%20%3D%3D%3D%20text%3B%20%7D)%3B%20%7D%20function%20createMarker()%20%7B%20var%20marker%20%3D%20document.createElement(&#39;div&#39;)%3B%20marker.dataset.tgif%20%3D%20&#39;marker&#39;%3B%20marker.style.cssText%20%3D%20&#39;position%3Aabsolute%3Btop%3A0%3Bheight%3A100%25%3Bwidth%3A3px%3B&#39;%20%2B%20&#39;background%3A%23f97316%3Bpointer-events%3Anone%3Bborder-radius%3A1px%3B&#39;%3B%20return%20marker%3B%20%7D%20function%20createTooltip()%20%7B%20var%20tooltip%20%3D%20document.createElement(&#39;div&#39;)%3B%20tooltip.dataset.tgif%20%3D%20&#39;tooltip&#39;%3B%20tooltip.style.cssText%20%3D%20&#39;position%3Afixed%3Bdisplay%3Anone%3Bpointer-events%3Anone%3B&#39;%20%2B%20&#39;background%3A%231e1e2e%3Bcolor%3A%23fff%3Bfont-size%3A11px%3Bpadding%3A3px%207px%3B&#39;%20%2B%20&#39;border-radius%3A4px%3Bwhite-space%3Anowrap%3Bz-index%3A9999%3B&#39;%3B%20var%20text%20%3D%20document.createElement(&#39;span&#39;)%3B%20tooltip.appendChild(text)%3B%20var%20arrow%20%3D%20document.createElement(&#39;div&#39;)%3B%20arrow.style.cssText%20%3D%20&#39;position%3Aabsolute%3Bleft%3A50%25%3Btransform%3AtranslateX(-50%25)%3Btop%3A100%25%3B&#39;%20%2B%20&#39;border%3A5px%20solid%20transparent%3Bborder-top-color%3A%23fff%3B&#39;%3B%20tooltip.appendChild(arrow)%3B%20document.body.appendChild(tooltip)%3B%20return%20%7B%20el%3A%20tooltip%2C%20text%3A%20text%20%7D%3B%20%7D%20function%20attachHoverTooltip(bar%2C%20getState%2C%20lang)%20%7B%20var%20tooltip%20%3D%20createTooltip()%3B%20bar.addEventListener(&#39;mousemove&#39;%2C%20function%20(e)%20%7B%20var%20state%20%3D%20getState()%3B%20if%20(!state)%20return%3B%20var%20rect%20%3D%20bar.getBoundingClientRect()%3B%20var%20pct%20%3D%20Math.max(0%2C%20Math.min(100%2C%20((e.clientX%20-%20rect.left)%20%2F%20rect.width)%20*%20100))%3B%20if%20(state.inverted)%20pct%20%3D%20100%20-%20pct%3B%20var%20time%20%3D%20new%20Date(state.windowStartMs%20%2B%20(pct%20%2F%20100)%20*%20state.windowMs)%3B%20tooltip.text.textContent%20%3D%20formatTooltipTime(lang%2C%20time)%3B%20tooltip.el.style.display%20%3D%20&#39;block&#39;%3B%20tooltip.el.style.left%20%3D%20(e.clientX%20-%20(tooltip.el.offsetWidth%20%2F%202))%20%2B%20&#39;px&#39;%3B%20tooltip.el.style.top%20%3D%20(rect.top%20-%20tooltip.el.offsetHeight%20-%208)%20%2B%20&#39;px&#39;%3B%20%7D)%3B%20bar.addEventListener(&#39;mouseleave&#39;%2C%20function%20()%20%7B%20tooltip.el.style.display%20%3D%20&#39;none&#39;%3B%20%7D)%3B%20%7D%20function%20renderPace(lang%2C%20label%2C%20opts)%20%7B%20var%20usagePct%20%3D%20opts.usagePct%3B%20var%20elapsedPct%20%3D%20Math.max(0%2C%20Math.min(100%2C%20((opts.windowMs%20-%20opts.msLeft)%20%2F%20opts.windowMs)%20*%20100))%3B%20var%20windowStartMs%20%3D%20Date.now()%20%2B%20opts.msLeft%20-%20opts.windowMs%3B%20var%20delta%20%3D%20usagePct%20-%20elapsedPct%3B%20var%20overPace%20%3D%20delta%20%3E%200%3B%20var%20statusColor%20%3D%20overPace%20%3F%20&#39;%23dc2626&#39;%20%3A%20&#39;%2316a34a&#39;%3B%20var%20usageTime%20%3D%20formatTooltipTime(lang%2C%20new%20Date(windowStartMs%20%2B%20(usagePct%20%2F%20100)%20*%20opts.windowMs))%3B%20var%20deltaTimeStr%20%3D%20formatDuration(Math.abs(delta)%20%2F%20100%20*%20opts.windowMs)%20%2B%20&#39;%20&#39;%20%2B%20(overPace%20%3F%20lang.ahead%20%3A%20lang.behind)%3B%20if%20(opts.marker)%20%7B%20opts.marker.style.left%20%3D%20(opts.inverted%20%3F%20100%20-%20elapsedPct%20%3A%20elapsedPct).toFixed(2)%20%2B%20&#39;%25&#39;%3B%20%7D%20label.innerHTML%20%3D%20lang.timeElapsed%20%2B%20&#39;%20%3Cb%3E&#39;%20%2B%20elapsedPct.toFixed(1)%20%2B%20&#39;%25%3C%2Fb%3E&#39;%20%2B%20&#39;%20%7C%20&#39;%20%2B%20lang.resetsIn%20%2B%20&#39;%20%3Cb%3E&#39;%20%2B%20formatDuration(opts.msLeft)%20%2B%20&#39;%3C%2Fb%3E&#39;%20%2B%20&#39;%3Cbr%3E&#39;%20%2B%20&#39;Delta%3A%20%3Cb%20style%3D%22color%3A&#39;%20%2B%20statusColor%20%2B%20&#39;%22%3E&#39;%20%2B%20(delta%20%3E%3D%200%20%3F%20&#39;%2B&#39;%20%3A%20&#39;&#39;)%20%2B%20delta.toFixed(1)%20%2B%20&#39;%25%20%E2%80%94%20&#39;%20%2B%20deltaTimeStr%20%2B%20&#39;%3C%2Fb%3E&#39;%20%2B%20&#39;%20%3Cspan%20style%3D%22opacity%3A0.7%22%3E(%E2%89%88%20&#39;%20%2B%20usageTime%20%2B%20&#39;)%3C%2Fspan%3E&#39;%3B%20return%20%7B%20windowStartMs%3A%20windowStartMs%2C%20windowMs%3A%20opts.windowMs%2C%20inverted%3A%20opts.inverted%20%7D%3B%20%7D%20var%20CLAUDE_LANGS%20%3D%20%7B%20en%3A%20%7B%20detect%3A%20%2F%5EResets%20%5Cw%2B%20%5Cd%7B1%2C2%7D%3A%5Cd%7B2%7D%20%5BAP%5DM%24%2F%2C%20parse%3A%20%2FResets%20(%5Cw%2B)%20(%5Cd%2B)%3A(%5Cd%2B)%20(%5BAP%5DM)%2F%2C%20relative%3A%20%2F%5EResets%20in%20%2F%2C%20relParse%3A%20%2FResets%20in%20(%3F%3A(%5Cd%2B)%5Cs*d%5Cs*)%3F(%3F%3A(%5Cd%2B)%5Cs*hr%3F%5Cs*)%3F(%3F%3A(%5Cd%2B)%5Cs*min)%3F%2F%2C%20days%3A%20%7B%20Sun%3A%200%2C%20Mon%3A%201%2C%20Tue%3A%202%2C%20Wed%3A%203%2C%20Thu%3A%204%2C%20Fri%3A%205%2C%20Sat%3A%206%20%7D%2C%20dayNames%3A%20%5B&#39;Sun&#39;%2C%20&#39;Mon&#39;%2C%20&#39;Tue&#39;%2C%20&#39;Wed&#39;%2C%20&#39;Thu&#39;%2C%20&#39;Fri&#39;%2C%20&#39;Sat&#39;%5D%2C%20ampm%3A%20true%2C%20startsText%3A%20%2F%5EStarts%20(%3F%3Awhen%20a%20message%20is%20sent%7Cwith%20your%20first%20message)%24%2F%2C%20wouldEndAt%3A%20&#39;would%20end%20at&#39;%2C%20ifStartedNow%3A%20&#39;if%20started%20now&#39;%2C%20lastUpdated%3A%20&#39;Last%20updated%3A&#39;%2C%20sessionText%3A%20&#39;Current%20session&#39;%2C%20timeElapsed%3A%20&#39;Elapsed%3A&#39;%2C%20resetsIn%3A%20&#39;Resets%20in&#39;%2C%20overPace%3A%20&#39;over%20pace&#39;%2C%20underPace%3A%20&#39;under%20pace&#39;%2C%20ahead%3A%20&#39;ahead&#39;%2C%20behind%3A%20&#39;behind&#39;%2C%20parseError%3A%20&#39;tgif-claude%3A%20could%20not%20parse%20reset%20time&#39;%2C%20notFound%3A%20&#39;tgif-claude%3A%20weekly%20reset%20text%20not%20found&#39;%2C%20weeklyHeading%3A%20&#39;Weekly%20limits&#39;%2C%20weeklyText%3A%20&#39;This%20week&#39;%2C%20%7D%2C%20fr%3A%20%7B%20detect%3A%20%2F%5ER%C3%A9initialisation%20%5Cw%7B3%7D%5C.%20%5Cd%7B1%2C2%7D%3A%5Cd%7B2%7D%24%2F%2C%20parse%3A%20%2FR%C3%A9initialisation%20(%5Cw%2B)%5C.%20(%5Cd%2B)%3A(%5Cd%2B)%2F%2C%20relative%3A%20%2F%5ER%C3%A9initialisation%20dans%20%2F%2C%20relParse%3A%20%2FR%C3%A9initialisation%20dans%20(%3F%3A(%5Cd%2B)%5Cs*j%5Cs*)%3F(%3F%3A(%5Cd%2B)%5Cs*h%5Cs*)%3F(%3F%3A(%5Cd%2B)%5Cs*min)%3F%2F%2C%20days%3A%20%7B%20dim%3A%200%2C%20lun%3A%201%2C%20mar%3A%202%2C%20mer%3A%203%2C%20jeu%3A%204%2C%20ven%3A%205%2C%20sam%3A%206%20%7D%2C%20dayNames%3A%20%5B&#39;dim&#39;%2C%20&#39;lun&#39;%2C%20&#39;mar&#39;%2C%20&#39;mer&#39;%2C%20&#39;jeu&#39;%2C%20&#39;ven&#39;%2C%20&#39;sam&#39;%5D%2C%20ampm%3A%20false%2C%20startsText%3A%20%2F%5ECommence%20quand%20un%20message%20est%20envoy%C3%A9%24%2F%2C%20wouldEndAt%3A%20&#39;se%20terminerait%20%C3%A0&#39;%2C%20ifStartedNow%3A%20&#39;si%20d%C3%A9marr%C3%A9e%20maintenant&#39;%2C%20lastUpdated%3A%20&#39;Derni%C3%A8re%20mise%20%C3%A0%20jour%20%3A&#39;%2C%20sessionText%3A%20&#39;Session%20actuelle&#39;%2C%20timeElapsed%3A%20&#39;%C3%89coul%C3%A9%20%3A&#39;%2C%20resetsIn%3A%20&#39;R%C3%A9init.%20dans&#39;%2C%20overPace%3A%20&#39;en%20avance&#39;%2C%20underPace%3A%20&#39;en%20retard&#39;%2C%20ahead%3A%20&#39;d%5C&#39;avance&#39;%2C%20behind%3A%20&#39;de%20retard&#39;%2C%20parseError%3A%20&#39;tgif-claude%20%3A%20impossible%20de%20lire%20l%E2%80%99heure%20de%20r%C3%A9initialisation&#39;%2C%20notFound%3A%20&#39;tgif-claude%20%3A%20texte%20de%20r%C3%A9initialisation%20hebdomadaire%20introuvable&#39;%2C%20weeklyHeading%3A%20&#39;Limites%20hebdomadaires&#39;%2C%20weeklyText%3A%20&#39;Cette%20semaine&#39;%2C%20%7D%2C%20%7D%3B%20function%20runClaude()%20%7B%20var%20htmlLang%20%3D%20(document.documentElement.getAttribute(&#39;lang&#39;)%20%7C%7C%20&#39;en&#39;).toLowerCase().split(&#39;-&#39;)%5B0%5D%3B%20var%20lang%20%3D%20CLAUDE_LANGS%5BhtmlLang%5D%20%7C%7C%20CLAUDE_LANGS.en%3B%20var%20BAR_SELECTOR%20%3D%20&#39;%5Brole%3D%22meter%22%5D%2C%20%5Brole%3D%22progressbar%22%5D&#39;%3B%20function%20findRow(el)%20%7B%20var%20node%20%3D%20el.parentElement%3B%20while%20(node%20%26%26%20!node.querySelector(BAR_SELECTOR))%20node%20%3D%20node.parentElement%3B%20return%20node%3B%20%7D%20var%20weeklyLabel%20%3D%20findByText(document%2C%20lang.weeklyText)%3B%20var%20weeklySection%20%3D%20weeklyLabel%20%26%26%20findRow(weeklyLabel)%3B%20if%20(!weeklySection)%20%7B%20var%20weeklyHeading%20%3D%20Array.from(document.querySelectorAll(&#39;h2%2C%20h3&#39;)).find(function%20(h)%20%7B%20return%20h.textContent.trim()%20%3D%3D%3D%20lang.weeklyHeading%3B%20%7D)%3B%20weeklySection%20%3D%20weeklyHeading%20%26%26%20(weeklyHeading.closest(&#39;section&#39;)%20%7C%7C%20weeklyHeading.closest(&#39;.space-y-6&#39;))%3B%20if%20(!weeklySection)%20weeklySection%20%3D%20weeklyHeading%20%26%26%20weeklyHeading.parentElement%20%26%26%20weeklyHeading.parentElement.parentElement%3B%20%7D%20if%20(!weeklySection)%20%7B%20alert(lang.notFound)%3B%20return%3B%20%7D%20var%20dialog%20%3D%20weeklySection.closest(&#39;%5Brole%3D%22dialog%22%5D&#39;)%3B%20if%20(dialog)%20%7B%20dialog.style.maxWidth%20%3D%20&#39;none&#39;%3B%20dialog.style.maxHeight%20%3D%20&#39;none&#39;%3B%20dialog.style.width%20%3D%20&#39;100vw&#39;%3B%20dialog.style.height%20%3D%20&#39;100vh&#39;%3B%20dialog.style.inset%20%3D%20&#39;0&#39;%3B%20dialog.style.margin%20%3D%20&#39;0&#39;%3B%20dialog.style.borderRadius%20%3D%20&#39;0&#39;%3B%20%7D%20var%20weeklyPs%20%3D%20Array.from(weeklySection.querySelectorAll(&#39;p%2C%20span&#39;))%3B%20var%20resetEl%20%3D%20weeklyPs.find(function%20(p)%20%7B%20return%20lang.detect.test(p.textContent.trim())%3B%20%7D)%3B%20if%20(!resetEl)%20%7B%20resetEl%20%3D%20weeklyPs.find(function%20(p)%20%7B%20return%20lang.relative.test(p.textContent.trim())%3B%20%7D)%3B%20%7D%20if%20(!resetEl)%20%7B%20var%20startsEl%20%3D%20weeklyPs.find(function%20(p)%20%7B%20return%20lang.startsText.test(p.textContent.trim())%3B%20%7D)%3B%20if%20(startsEl)%20%7B%20var%20weeklyEndAt%20%3D%20roundToHour(new%20Date(Date.now()%20%2B%20WEEK_MS))%3B%20var%20startsSpan%20%3D%20document.createElement(&#39;span&#39;)%3B%20startsSpan.dataset.tgif%20%3D%20&#39;weekly-starts&#39;%3B%20startsSpan.textContent%20%3D%20&#39;%20(&#39;%20%2B%20lang.wouldEndAt%20%2B%20&#39;%20&#39;%20%2B%20formatTooltipTime(lang%2C%20weeklyEndAt)%20%2B%20&#39;%20&#39;%20%2B%20lang.ifStartedNow%20%2B%20&#39;)&#39;%3B%20startsEl.appendChild(startsSpan)%3B%20var%20waitObserver%20%3D%20track(&#39;observers&#39;%2C%20new%20MutationObserver(function%20()%20%7B%20waitObserver.disconnect()%3B%20runClaude()%3B%20%7D))%3B%20waitObserver.observe(weeklySection%2C%20%7B%20childList%3A%20true%2C%20subtree%3A%20true%2C%20characterData%3A%20true%20%7D)%3B%20return%3B%20%7D%20alert(lang.notFound)%3B%20return%3B%20%7D%20var%20row%20%3D%20findRow(resetEl)%3B%20var%20barContainer%20%3D%20row%20%26%26%20row.querySelector(BAR_SELECTOR)%3B%20if%20(!barContainer)%20return%3B%20var%20lastUpdatedEl%20%3D%20Array.from(document.querySelectorAll(&#39;p%2C%20span&#39;)).find(function%20(p)%20%7B%20return%20p.textContent.trim().startsWith(lang.lastUpdated)%3B%20%7D)%3B%20function%20readUsagePct(bar)%20%7B%20var%20valueNow%20%3D%20bar.getAttribute(&#39;aria-valuenow&#39;)%3B%20if%20(valueNow%20!%3D%3D%20null%20%26%26%20valueNow%20!%3D%3D%20&#39;&#39;)%20return%20parseFloat(valueNow)%20%7C%7C%200%3B%20var%20fill%20%3D%20bar.querySelector(&#39;%5Bstyle*%3D%22width%22%5D&#39;)%20%7C%7C%20bar.firstElementChild%3B%20return%20(fill%20%26%26%20parseFloat(fill.style.width))%20%7C%7C%200%3B%20%7D%20function%20updateSession()%20%7B%20var%20existing%20%3D%20document.querySelector(&#39;%5Bdata-tgif%3D%22session%22%5D&#39;)%3B%20if%20(existing)%20existing.remove()%3B%20var%20lel%20%3D%20Array.from(document.querySelectorAll(&#39;p%2C%20span&#39;)).find(function%20(p)%20%7B%20return%20p.textContent.trim()%20%3D%3D%3D%20lang.sessionText%3B%20%7D)%3B%20if%20(!lel)%20return%3B%20var%20sessionRow%20%3D%20findRow(lel)%3B%20if%20(!sessionRow)%20return%3B%20var%20els%20%3D%20Array.from(sessionRow.querySelectorAll(&#39;p%2C%20span&#39;))%3B%20var%20span%20%3D%20document.createElement(&#39;span&#39;)%3B%20span.dataset.tgif%20%3D%20&#39;session&#39;%3B%20var%20sel%20%3D%20els.find(function%20(p)%20%7B%20return%20lang.relative.test(p.textContent.trim())%3B%20%7D)%3B%20if%20(sel)%20%7B%20var%20ms%20%3D%20parseRelative(sel.textContent.trim()%2C%20lang.relParse)%3B%20if%20(ms%20%3D%3D%3D%20null)%20return%3B%20var%20resetAt%20%3D%20roundToTenMinutes(new%20Date(Date.now()%20%2B%20ms))%3B%20span.textContent%20%3D%20&#39;%20(at%20&#39;%20%2B%20formatClockTime(lang%2C%20resetAt)%20%2B%20&#39;)&#39;%3B%20sel.appendChild(span)%3B%20return%3B%20%7D%20var%20startsEl%20%3D%20els.find(function%20(p)%20%7B%20return%20lang.startsText.test(p.textContent.trim())%3B%20%7D)%3B%20if%20(!startsEl)%20return%3B%20var%20endAt%20%3D%20roundToTenMinutes(new%20Date(Date.now()%20%2B%20SESSION_MS))%3B%20span.textContent%20%3D%20&#39;%20(&#39;%20%2B%20lang.wouldEndAt%20%2B%20&#39;%20&#39;%20%2B%20formatClockTime(lang%2C%20endAt)%20%2B%20&#39;%20&#39;%20%2B%20lang.ifStartedNow%20%2B%20&#39;)&#39;%3B%20startsEl.appendChild(span)%3B%20%7D%20function%20updateWeeklyAt(msLeft)%20%7B%20var%20existing%20%3D%20document.querySelector(&#39;%5Bdata-tgif%3D%22weekly-at%22%5D&#39;)%3B%20if%20(existing)%20existing.remove()%3B%20if%20(!lang.relative.test(resetEl.textContent.trim()))%20return%3B%20var%20resetAt%20%3D%20roundToHour(new%20Date(Date.now()%20%2B%20msLeft))%3B%20var%20span%20%3D%20document.createElement(&#39;span&#39;)%3B%20span.dataset.tgif%20%3D%20&#39;weekly-at&#39;%3B%20span.textContent%20%3D%20&#39;%20(at%20&#39;%20%2B%20formatTooltipTime(lang%2C%20resetAt)%20%2B%20&#39;)&#39;%3B%20resetEl.appendChild(span)%3B%20%7D%20function%20parseMsLeft()%20%7B%20var%20text%20%3D%20resetEl.textContent.trim()%3B%20var%20abs%20%3D%20text.match(lang.parse)%3B%20if%20(abs)%20%7B%20var%20targetDay%20%3D%20lang.days%5Babs%5B1%5D.slice(0%2C%203)%5D%3B%20if%20(targetDay%20%3D%3D%3D%20undefined)%20return%20null%3B%20var%20hour%20%3D%20parseInt(abs%5B2%5D%2C%2010)%3B%20var%20minute%20%3D%20parseInt(abs%5B3%5D%2C%2010)%3B%20if%20(lang.ampm)%20%7B%20if%20(abs%5B4%5D%20%3D%3D%3D%20&#39;PM&#39;%20%26%26%20hour%20!%3D%3D%2012)%20hour%20%2B%3D%2012%3B%20if%20(abs%5B4%5D%20%3D%3D%3D%20&#39;AM&#39;%20%26%26%20hour%20%3D%3D%3D%2012)%20hour%20%3D%200%3B%20%7D%20var%20now%20%3D%20new%20Date()%3B%20var%20reset%20%3D%20new%20Date(now)%3B%20reset.setHours(hour%2C%20minute%2C%200%2C%200)%3B%20var%20daysUntil%20%3D%20(targetDay%20-%20now.getDay()%20%2B%207)%20%25%207%3B%20if%20(daysUntil%20%3D%3D%3D%200%20%26%26%20reset%20%3C%3D%20now)%20daysUntil%20%3D%207%3B%20reset.setDate(reset.getDate()%20%2B%20daysUntil)%3B%20return%20reset%20-%20now%3B%20%7D%20return%20parseRelative(text%2C%20lang.relParse)%3B%20%7D%20barContainer.style.position%20%3D%20&#39;relative&#39;%3B%20var%20marker%20%3D%20createMarker()%3B%20barContainer.appendChild(marker)%3B%20var%20hoverState%20%3D%20null%3B%20attachHoverTooltip(barContainer%2C%20function%20()%20%7B%20return%20hoverState%3B%20%7D%2C%20lang)%3B%20var%20label%20%3D%20document.createElement(&#39;div&#39;)%3B%20label.dataset.tgif%20%3D%20&#39;label&#39;%3B%20label.className%20%3D%20resetEl.className%3B%20label.style.width%20%3D%20&#39;100%25&#39;%3B%20label.style.whiteSpace%20%3D%20&#39;normal&#39;%3B%20row.appendChild(label)%3B%20function%20update()%20%7B%20var%20usagePct%20%3D%20readUsagePct(barContainer)%3B%20var%20msLeft%20%3D%20parseMsLeft()%3B%20if%20(msLeft%20%3D%3D%3D%20null)%20%7B%20if%20(lang.startsText.test(resetEl.textContent.trim()))%20%7B%20teardown()%3B%20runClaude()%3B%20return%3B%20%7D%20label.textContent%20%3D%20lang.parseError%3B%20return%3B%20%7D%20updateSession()%3B%20updateWeeklyAt(msLeft)%3B%20hoverState%20%3D%20renderPace(lang%2C%20label%2C%20%7B%20usagePct%3A%20usagePct%2C%20windowMs%3A%20WEEK_MS%2C%20msLeft%3A%20msLeft%2C%20marker%3A%20marker%2C%20inverted%3A%20false%2C%20%7D)%3B%20%7D%20update()%3B%20if%20(lastUpdatedEl)%20%7B%20var%20observer%20%3D%20track(&#39;observers&#39;%2C%20new%20MutationObserver(update))%3B%20observer.observe(lastUpdatedEl%2C%20%7B%20childList%3A%20true%2C%20subtree%3A%20true%2C%20characterData%3A%20true%20%7D)%3B%20%7D%20%7D%20var%20CHATGPT_LANG%20%3D%20%7B%20relative%3A%20%2F%5EResets%20in%5Cb%2F%2C%20relParse%3A%20%2FResets%20in%5Cs*(%3F%3A(%5Cd%2B)%5Cs*d%5Cs*)%3F(%3F%3A(%5Cd%2B)%5Cs*h%5Cs*)%3F(%3F%3A(%5Cd%2B)%5Cs*m)%3F%2F%2C%20pctLeft%3A%20%2F%5E(%5Cd%2B(%3F%3A%5C.%5Cd%2B)%3F)%25%5Cs%2Bleft%24%2F%2C%20creditsLeft%3A%20%2F%5E(%5Cd%2B(%3F%3A%2C%5Cd%7B3%7D)*(%3F%3A%5C.%5Cd%2B)%3F)%5Cs%2Bcredits%3F%5Cs%2B(%3F%3Aleft%7Cremaining)%24%2F%2C%20resetsPrefix%3A%20%2F%5Eresets%5Cs%2B(%3F%3Aon%7Cat)%3F%5Cs*%2Fi%2C%20weekday%3A%20%2F%5Cb(sun%7Cmon%7Ctue%7Cwed%7Cthu%7Cfri%7Csat)(%3F%3A%5Ba-z%5D*day%7Cs%7Crs)%3F%5Cb%2F%2C%20days%3A%20%7B%20sun%3A%200%2C%20mon%3A%201%2C%20tue%3A%202%2C%20wed%3A%203%2C%20thu%3A%204%2C%20fri%3A%205%2C%20sat%3A%206%20%7D%2C%20months%3A%20%7B%20jan%3A%200%2C%20feb%3A%201%2C%20mar%3A%202%2C%20apr%3A%203%2C%20may%3A%204%2C%20jun%3A%205%2C%20jul%3A%206%2C%20aug%3A%207%2C%20sep%3A%208%2C%20oct%3A%209%2C%20nov%3A%2010%2C%20dec%3A%2011%20%7D%2C%20dayNames%3A%20%5B&#39;Sun&#39;%2C%20&#39;Mon&#39;%2C%20&#39;Tue&#39;%2C%20&#39;Wed&#39;%2C%20&#39;Thu&#39;%2C%20&#39;Fri&#39;%2C%20&#39;Sat&#39;%5D%2C%20ampm%3A%20true%2C%20planLimits%3A%20&#39;Plan%20limits&#39;%2C%20sessionText%3A%20&#39;5-hour%20limit&#39;%2C%20weeklyText%3A%20&#39;Weekly%20limit&#39;%2C%20wouldEndAt%3A%20&#39;would%20end%20at&#39;%2C%20ifStartedNow%3A%20&#39;if%20started%20now&#39;%2C%20timeElapsed%3A%20&#39;Elapsed%3A&#39;%2C%20resetsIn%3A%20&#39;Resets%20in&#39;%2C%20ahead%3A%20&#39;ahead&#39;%2C%20behind%3A%20&#39;behind&#39;%2C%20notFound%3A%20&#39;tgif-claude%3A%20usage%20panel%20not%20found%20%E2%80%94%20open%20Settings%2C%20then%20Usage&#39;%2C%20%7D%3B%20function%20runChatgpt()%20%7B%20var%20lang%20%3D%20CHATGPT_LANG%3B%20var%20CREDITS_PER_USD%20%3D%202500%20%2F%20100%3B%20function%20findFill(root)%20%7B%20return%20Array.from(root.querySelectorAll(&#39;%5Bstyle*%3D%22width%22%5D&#39;)).find(function%20(el)%20%7B%20return%20%2F%25%24%2F.test((el.style.width%20%7C%7C%20&#39;&#39;).trim())%3B%20%7D)%3B%20%7D%20function%20findBar(root)%20%7B%20var%20progress%20%3D%20root.querySelector(&#39;progress&#39;)%3B%20if%20(progress)%20return%20progress.parentElement%3B%20var%20fill%20%3D%20findFill(root)%3B%20return%20fill%20%3F%20fill.parentElement%20%3A%20null%3B%20%7D%20function%20findRow(el)%20%7B%20var%20node%20%3D%20el.parentElement%3B%20while%20(node%20%26%26%20!findBar(node))%20node%20%3D%20node.parentElement%3B%20return%20node%3B%20%7D%20function%20unclamp(from%2C%20upTo)%20%7B%20var%20node%20%3D%20from%3B%20while%20(node)%20%7B%20var%20computed%20%3D%20getComputedStyle(node)%3B%20if%20(computed.maxWidth%20!%3D%3D%20&#39;none&#39;)%20node.style.maxWidth%20%3D%20&#39;none&#39;%3B%20if%20(computed.maxHeight%20!%3D%3D%20&#39;none&#39;)%20node.style.maxHeight%20%3D%20&#39;none&#39;%3B%20if%20(node%20%3D%3D%3D%20upTo)%20break%3B%20node%20%3D%20node.parentElement%3B%20%7D%20%7D%20var%20panel%20%3D%20document.getElementById(&#39;usage-panel-usage&#39;)%20%7C%7C%20document.querySelector(&#39;%5Brole%3D%22tabpanel%22%5D%5Baria-labelledby%24%3D%22trigger-Usage%22%5D%3Anot(%5Bhidden%5D)&#39;)%3B%20var%20planLimitsEl%20%3D%20findByText(panel%20%7C%7C%20document%2C%20lang.planLimits)%3B%20var%20sessionLabel%20%3D%20findByText(panel%20%7C%7C%20document%2C%20lang.sessionText)%3B%20var%20weeklyLabel%20%3D%20findByText(panel%20%7C%7C%20document%2C%20lang.weeklyText)%3B%20if%20(!sessionLabel%20%26%26%20!weeklyLabel)%20%7B%20alert(lang.notFound)%3B%20return%3B%20%7D%20var%20card%20%3D%20findRow(sessionLabel%20%7C%7C%20weeklyLabel)%3B%20if%20(card)%20card%20%3D%20card.parentElement%3B%20var%20dialog%20%3D%20(planLimitsEl%20%7C%7C%20sessionLabel%20%7C%7C%20weeklyLabel).closest(&#39;%5Brole%3D%22dialog%22%5D&#39;)%3B%20if%20(dialog)%20%7B%20dialog.style.cssText%20%2B%3D%20&#39;%3Bposition%3Afixed%3Binset%3A0%3Bmargin%3A0%3Bwidth%3A100vw%3Bheight%3A100vh%3B&#39;%20%2B%20&#39;max-width%3Anone%3Bmax-height%3Anone%3Bborder-radius%3A0%3Btransform%3Anone%3Btranslate%3Anone%3B&#39;%3B%20unclamp(card%20%7C%7C%20panel%2C%20dialog)%3B%20%7D%20function%20readUsagePct(row%2C%20bar)%20%7B%20var%20pctEl%20%3D%20textNodes(row).find(function%20(el)%20%7B%20return%20lang.pctLeft.test(el.textContent.trim())%3B%20%7D)%3B%20if%20(pctEl)%20return%20100%20-%20parseFloat(pctEl.textContent.trim().match(lang.pctLeft)%5B1%5D)%3B%20var%20progress%20%3D%20bar%20%26%26%20bar.querySelector(&#39;progress&#39;)%3B%20if%20(progress)%20return%20100%20-%20(progress.value%20%2F%20(progress.max%20%7C%7C%20100))%20*%20100%3B%20var%20fill%20%3D%20bar%20%26%26%20findFill(bar)%3B%20return%20fill%20%3F%20100%20-%20parseFloat(fill.style.width)%20%3A%200%3B%20%7D%20function%20findResetEl(row)%20%7B%20var%20button%20%3D%20Array.from(row.querySelectorAll(&#39;button%5Baria-label%5D&#39;)).find(function%20(el)%20%7B%20return%20lang.relative.test(el.getAttribute(&#39;aria-label&#39;).trim())%3B%20%7D)%3B%20if%20(button)%20%7B%20return%20%7B%20el%3A%20button%2C%20text%3A%20button.getAttribute(&#39;aria-label&#39;).trim()%2C%20title%3A%20null%2C%20tip%3A%20tooltipFor(button)%20%7D%3B%20%7D%20var%20span%20%3D%20textNodes(row).find(function%20(el)%20%7B%20return%20!el.children.length%20%26%26%20lang.relative.test(el.textContent.trim())%3B%20%7D)%3B%20if%20(!span)%20return%20null%3B%20return%20%7B%20el%3A%20span%2C%20text%3A%20span.textContent.trim()%2C%20title%3A%20span.getAttribute(&#39;title&#39;)%2C%20tip%3A%20null%20%7D%3B%20%7D%20function%20readMsLeft(row)%20%7B%20var%20reset%20%3D%20findResetEl(row)%3B%20return%20reset%20%3F%20parseRelative(reset.text%2C%20lang.relParse)%20%3A%20null%3B%20%7D%20function%20setup(labelEl%2C%20windowMs%2C%20weekly)%20%7B%20var%20row%20%3D%20labelEl%20%26%26%20findRow(labelEl)%3B%20var%20bar%20%3D%20row%20%26%26%20findBar(row)%3B%20if%20(!bar)%20return%20null%3B%20bar.style.position%20%3D%20&#39;relative&#39;%3B%20bar.style.overflow%20%3D%20&#39;visible&#39;%3B%20var%20marker%20%3D%20createMarker()%3B%20marker.style.top%20%3D%20&#39;-4px&#39;%3B%20marker.style.height%20%3D%20&#39;calc(100%25%20%2B%208px)&#39;%3B%20bar.appendChild(marker)%3B%20var%20pctEl%20%3D%20textNodes(row).find(function%20(el)%20%7B%20return%20lang.pctLeft.test(el.textContent.trim())%3B%20%7D)%3B%20var%20label%20%3D%20document.createElement(&#39;div&#39;)%3B%20label.dataset.tgif%20%3D%20&#39;label&#39;%3B%20if%20(pctEl)%20label.className%20%3D%20pctEl.className%3B%20label.style.width%20%3D%20&#39;100%25&#39;%3B%20label.style.whiteSpace%20%3D%20&#39;normal&#39;%3B%20label.style.textAlign%20%3D%20&#39;start&#39;%3B%20row.appendChild(label)%3B%20var%20ctx%20%3D%20%7B%20row%3A%20row%2C%20bar%3A%20bar%2C%20marker%3A%20marker%2C%20label%3A%20label%2C%20windowMs%3A%20windowMs%2C%20weekly%3A%20weekly%2C%20hoverState%3A%20null%2C%20reset%3A%20null%2C%20lastRelMs%3A%20null%2C%20probing%3A%20false%2C%20probes%3A%200%2C%20%7D%3B%20attachHoverTooltip(bar%2C%20function%20()%20%7B%20return%20ctx.hoverState%3B%20%7D%2C%20lang)%3B%20return%20ctx%3B%20%7D%20function%20makeReset(text%2C%20relMs)%20%7B%20return%20%7B%20text%3A%20text.replace(lang.resetsPrefix%2C%20&#39;&#39;)%2C%20at%3A%20parseTooltipTime(text%2C%20Date.now()%20%2B%20relMs%2C%20lang)%2C%20%7D%3B%20%7D%20var%20probeQueue%20%3D%20Promise.resolve()%3B%20function%20captureReset(ctx%2C%20relMs%2C%20allowProbe)%20%7B%20var%20reset%20%3D%20findResetEl(ctx.row)%3B%20if%20(!reset)%20return%3B%20if%20(reset.title)%20%7B%20ctx.reset%20%3D%20%7B%20text%3A%20null%2C%20at%3A%20parseTooltipTime(reset.title%2C%20Date.now()%20%2B%20relMs%2C%20lang)%20%7D%3B%20return%3B%20%7D%20var%20tip%20%3D%20reset.tip%3B%20if%20(!tip)%20return%3B%20var%20visible%20%3D%20tooltipText(tip)%3B%20if%20(visible)%20%7B%20ctx.reset%20%3D%20makeReset(visible%2C%20relMs)%3B%20return%3B%20%7D%20if%20(!allowProbe%20%7C%7C%20ctx.probing%20%7C%7C%20ctx.probes%20%3E%3D%203)%20return%3B%20ctx.probing%20%3D%20true%3B%20probeQueue%20%3D%20probeQueue.then(function%20()%20%7B%20return%20revealTooltip(reset.el%2C%20tip)%3B%20%7D).then(function%20(text)%20%7B%20ctx.probing%20%3D%20false%3B%20ctx.probes%2B%2B%3B%20var%20current%20%3D%20readMsLeft(ctx.row)%3B%20if%20(!text%20%7C%7C%20current%20%3D%3D%3D%20null)%20return%3B%20ctx.reset%20%3D%20makeReset(text%2C%20current)%3B%20update(false)%3B%20%7D)%3B%20%7D%20function%20formatResetAt(ctx%2C%20date)%20%7B%20return%20ctx.weekly%20%3F%20formatTooltipTime(lang%2C%20date)%20%3A%20formatClockTime(lang%2C%20date)%3B%20%7D%20function%20annotateResetAt(ctx%2C%20msLeft)%20%7B%20var%20reset%20%3D%20findResetEl(ctx.row)%3B%20var%20anchor%20%3D%20reset%20%3F%20reset.el.parentElement%20%3A%20null%3B%20if%20(!anchor)%20return%3B%20var%20span%20%3D%20document.createElement(&#39;span&#39;)%3B%20span.dataset.tgif%20%3D%20&#39;reset-at&#39;%3B%20var%20at%3B%20if%20(ctx.reset%20%26%26%20ctx.reset.text)%20%7B%20at%20%3D%20ctx.reset.text%3B%20%7D%20else%20if%20(ctx.reset%20%26%26%20ctx.reset.at%20!%3D%3D%20null)%20%7B%20at%20%3D%20&#39;at%20&#39;%20%2B%20formatResetAt(ctx%2C%20new%20Date(ctx.reset.at))%3B%20%7D%20else%20%7B%20var%20round%20%3D%20ctx.weekly%20%3F%20roundToHour%20%3A%20roundToTenMinutes%3B%20at%20%3D%20&#39;at%20&#39;%20%2B%20formatResetAt(ctx%2C%20round(new%20Date(Date.now()%20%2B%20msLeft)))%3B%20%7D%20span.textContent%20%3D%20&#39;%20(&#39;%20%2B%20at%20%2B%20&#39;)&#39;%3B%20anchor.appendChild(span)%3B%20%7D%20function%20updateCtx(ctx%2C%20allowProbe)%20%7B%20Array.from(ctx.row.querySelectorAll(&#39;%5Bdata-tgif%3D%22reset-at%22%5D&#39;)).forEach(function%20(el)%20%7B%20el.remove()%3B%20%7D)%3B%20var%20relMs%20%3D%20readMsLeft(ctx.row)%3B%20if%20(relMs%20%3D%3D%3D%20null)%20%7B%20ctx.reset%20%3D%20null%3B%20ctx.lastRelMs%20%3D%20null%3B%20ctx.probes%20%3D%200%3B%20ctx.marker.style.display%20%3D%20&#39;none&#39;%3B%20ctx.hoverState%20%3D%20null%3B%20var%20endAt%20%3D%20ctx.weekly%20%3F%20formatTooltipTime(lang%2C%20roundToHour(new%20Date(Date.now()%20%2B%20ctx.windowMs)))%20%3A%20formatClockTime(lang%2C%20roundToTenMinutes(new%20Date(Date.now()%20%2B%20ctx.windowMs)))%3B%20ctx.label.textContent%20%3D%20lang.wouldEndAt%20%2B%20&#39;%20&#39;%20%2B%20endAt%20%2B%20&#39;%20&#39;%20%2B%20lang.ifStartedNow%3B%20return%3B%20%7D%20if%20(ctx.lastRelMs%20!%3D%3D%20null%20%26%26%20relMs%20%3E%20ctx.lastRelMs)%20%7B%20ctx.reset%20%3D%20null%3B%20ctx.probes%20%3D%200%3B%20%7D%20ctx.lastRelMs%20%3D%20relMs%3B%20if%20(!ctx.reset)%20captureReset(ctx%2C%20relMs%2C%20allowProbe)%3B%20var%20msLeft%20%3D%20ctx.reset%20%26%26%20ctx.reset.at%20!%3D%3D%20null%20%3F%20Math.max(0%2C%20ctx.reset.at%20-%20Date.now())%20%3A%20relMs%3B%20ctx.marker.style.display%20%3D%20&#39;&#39;%3B%20annotateResetAt(ctx%2C%20msLeft)%3B%20ctx.hoverState%20%3D%20renderPace(lang%2C%20ctx.label%2C%20%7B%20usagePct%3A%20readUsagePct(ctx.row%2C%20ctx.bar)%2C%20windowMs%3A%20ctx.windowMs%2C%20msLeft%3A%20msLeft%2C%20marker%3A%20ctx.marker%2C%20inverted%3A%20true%2C%20%7D)%3B%20%7D%20var%20contexts%20%3D%20%5B%20setup(sessionLabel%2C%20SESSION_MS%2C%20false)%2C%20setup(weeklyLabel%2C%20WEEK_MS%2C%20true)%2C%20%5D.filter(Boolean)%3B%20if%20(!contexts.length)%20%7B%20alert(lang.notFound)%3B%20return%3B%20%7D%20var%20observer%20%3D%20null%3B%20var%20observedRoot%20%3D%20panel%20%7C%7C%20card%3B%20function%20annotateCredits()%20%7B%20var%20root%20%3D%20panel%20%7C%7C%20document%3B%20Array.from(root.querySelectorAll(&#39;%5Bdata-tgif%3D%22credit-value%22%5D&#39;)).forEach(function%20(el)%20%7B%20el.remove()%3B%20%7D)%3B%20textNodes(root).forEach(function%20(el)%20%7B%20if%20(el.children.length)%20return%3B%20var%20match%20%3D%20el.textContent.trim().match(lang.creditsLeft)%3B%20if%20(!match)%20return%3B%20var%20credits%20%3D%20parseFloat(match%5B1%5D.replace(%2F%2C%2Fg%2C%20&#39;&#39;))%3B%20var%20span%20%3D%20document.createElement(&#39;span&#39;)%3B%20span.dataset.tgif%20%3D%20&#39;credit-value&#39;%3B%20span.textContent%20%3D%20&#39;%20(%24&#39;%20%2B%20(credits%20%2F%20CREDITS_PER_USD).toFixed(2)%20%2B%20&#39;)&#39;%3B%20el.appendChild(span)%3B%20%7D)%3B%20%7D%20function%20update(allowProbe)%20%7B%20if%20(observer)%20observer.disconnect()%3B%20annotateCredits()%3B%20contexts.forEach(function%20(ctx)%20%7B%20updateCtx(ctx%2C%20allowProbe)%3B%20%7D)%3B%20if%20(observer%20%26%26%20observedRoot)%20%7B%20observer.observe(observedRoot%2C%20%7B%20childList%3A%20true%2C%20subtree%3A%20true%2C%20characterData%3A%20true%20%7D)%3B%20%7D%20%7D%20update(true)%3B%20track(&#39;intervals&#39;%2C%20setInterval(function%20()%20%7B%20update(true)%3B%20%7D%2C%2030000))%3B%20if%20(observedRoot)%20%7B%20observer%20%3D%20track(&#39;observers&#39;%2C%20new%20MutationObserver(function%20()%20%7B%20update(false)%3B%20%7D))%3B%20observer.observe(observedRoot%2C%20%7B%20childList%3A%20true%2C%20subtree%3A%20true%2C%20characterData%3A%20true%20%7D)%3B%20%7D%20%7D%20teardown()%3B%20var%20host%20%3D%20location.hostname%3B%20if%20(%2F(%5E%7C%5C.)claude%5C.ai%24%2F.test(host))%20%7B%20runClaude()%3B%20%7D%20else%20if%20(%2F(%5E%7C%5C.)(chatgpt%5C.com%7Copenai%5C.com)%24%2F.test(host))%20%7B%20runChatgpt()%3B%20%7D%20else%20if%20(document.getElementById(&#39;usage-panel-usage&#39;)%20%7C%7C%20document.getElementById(&#39;modal-settings&#39;))%20%7B%20runChatgpt()%3B%20%7D%20else%20%7B%20runClaude()%3B%20%7D%20%7D)()%3B
</span></span></code></pre></div></div>
        </div>
<!-- /noTTS -->
<p>Or check the readable code on <a href="https://github.com/nbr23/tgif-claude/blob/main/index.js">github</a>.</p>
]]></content:encoded>
      </item>
    
      <item>
        <title>Badging in at the gym with my Garmin watch</title>
        <link>https://nbr23.com/posts/badging-gym-garmin-watch/?utm_source=rss</link>
        <pubDate>Mon, 16 Feb 2026 06:45:47 -0500</pubDate>
        <guid isPermaLink="false">https://wip.tf/posts/badging-gym-garmin-watch/</guid>
        <description>Storing a gym barcode on a Garmin watch to check in without carrying a key tag.</description>
        <content:encoded><![CDATA[<div class="text-to-speech-container">
    <span class="text-to-speech-label">Listen to this post:</span>
    <audio class="text-to-speech-audio" controls>
      <source src="https://nbr23.com/audio/tts/badging-gym-garmin-watch.mp3" type="audio/mpeg">
      <a href="https://nbr23.com/audio/tts/badging-gym-garmin-watch.mp3">Download the audio</a>
    </audio>
  </div>
  
<p>The gym I go to requires you to scan a small key tag with a barcode, to check in. I don&rsquo;t like bulky keychains, so I keep taking it off and tend to forget it when I need it.</p>
<p>To solve this very important and relatable issue, I built <a href="https://github.com/nbr23/garmin-gymcode">gymcode</a>, which allows me to display that barcode on my watch.</p>
<p><img src="https://nbr23.com/posts/badging-gym-garmin-watch/images/badging.gif#center" alt="badging in" title="badging in" width="352" height="358" loading="lazy" decoding="async">
</p>
<p>Gymcode is a Garmin <a href="https://developer.garmin.com/connect-iq/connect-iq-basics/app-types/#widgets">widget</a>, written in <a href="https://developer.garmin.com/connect-iq/monkey-c/">Monkey C</a>. It can be accessed from the &ldquo;at a glance&rdquo; menu of the watch by pressing the down button from the watch face, making it quick to pull up at the gym&rsquo;s entrance.</p>
<p>The app is not distributed through the Connect IQ store. The membership barcode values are hardcoded in <a href="https://github.com/nbr23/garmin-gymcode/blob/master/source/GymCodeView.mc#L4-L10">GymCodeView.mc</a> and need to be set before building. The resulting binary must be manually uploaded to the watch as described in the <a href="https://github.com/nbr23/garmin-gymcode?tab=readme-ov-file#setup">README</a>.</p>
<!-- noTTS -->
<div class="github-embed">
            <div class="github-embed-header">
                <span class="github-embed-header-left">
                    
                    <span class="github-embed-title">GymCodeView.mc</span>
                </span>
                <span class="github-embed-header-right">
                    <a href="https://github.com/nbr23/garmin-gymcode/blob/75ffd639029a669a508188c04400dabdb27f34b0/source/GymCodeView.mc#L4-L10">view code (lines 4-10)</a></span>
            </div>
            <div class="github-embed-body"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-mc"><span class="line"><span class="cl"><span class="kd">class</span> <span class="nc">GymCodeView</span> <span class="kd">extends</span> <span class="nc">WatchUi.View</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="c1">// [name, numeric code] — FIXME set your memberships here
</span></span></span><span class="line"><span class="cl">    <span class="kt">private</span> <span class="kt">const</span> <span class="n">MEMBERSHIPS</span> <span class="o">=</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl">        <span class="p">[</span><span class="s2">&#34;Gym&#34;</span><span class="p">,</span> <span class="s2">&#34;&#34;</span><span class="p">],</span>
</span></span><span class="line"><span class="cl">        <span class="p">[</span><span class="s2">&#34;Pool&#34;</span><span class="p">,</span> <span class="s2">&#34;&#34;</span><span class="p">]</span>
</span></span><span class="line"><span class="cl">    <span class="p">];</span>
</span></span></code></pre></div></div>
        </div>
<!-- /noTTS -->
<p>I have the fenix 7 pro, which has a fairly large screen. Barcodes are one-dimensional, so height doesn&rsquo;t matter too much (except to give me &ldquo;reading surface&rdquo;). I was able to use nearly the full watch screen, despite its roundedness, to make it as readable as possible by the scanner.</p>
<p>The fenix 7 pro has a decent backlight, and I have had no issues getting the code scanned properly at my local gym.</p>
<p>YMMV depending on watch model, barcode type (gymcode&rsquo;s current implementation supports <a href="https://en.wikipedia.org/wiki/Code_39">Code 39</a>) and your gym&rsquo;s barcode scanner.</p>
<h2 id="2026-05-26-update">2026-05-26 Update:</h2>
<p>Added support for multiple memberships. Barcodes and their names are defined as a list in <a href="https://github.com/nbr23/garmin-gymcode/blob/master/source/GymCodeView.mc#L4-L10">GymCodeView.mc</a>, and can be cycled through with the up/down buttons.</p>
]]></content:encoded>
      </item>
    
      <item>
        <title>Controlling an air-gapped robot vacuum from Home Assistant using synthesized speech</title>
        <link>https://nbr23.com/posts/controlling-an-air-gapped-robot-vacuum-from-home-assistant-using-synthesized-speech/?utm_source=rss</link>
        <pubDate>Mon, 26 Jan 2026 22:20:22 -0500</pubDate>
        <guid isPermaLink="false">https://wip.tf/posts/controlling-an-air-gapped-robot-vacuum-from-home-assistant-using-synthesized-speech/</guid>
        <description>Running a Dreame L40 Ultra robot vacuum offline using Home Assistant and synthesized voice commands.</description>
        <content:encoded><![CDATA[<div class="text-to-speech-container">
    <span class="text-to-speech-label">Listen to this post:</span>
    <audio class="text-to-speech-audio" controls>
      <source src="https://nbr23.com/audio/tts/controlling-an-air-gapped-robot-vacuum-from-home-assistant-using-synthesized-speech.mp3" type="audio/mpeg">
      <a href="https://nbr23.com/audio/tts/controlling-an-air-gapped-robot-vacuum-from-home-assistant-using-synthesized-speech.mp3">Download the audio</a>
    </audio>
  </div>
  
<p>I have a <a href="https://www.dreametech.com/products/l40ultra-robot-vacuum">Dreame L40 Ultra</a> to vacuum and mop around my home.</p>
<p>The Dreame app requires the robot to have internet access to receive commands, send status information, or modify scheduling. Not being a fan of audio-video recording devices roaming freely in my home, I keep it offline. Unfortunately, this means no Home Assistant integration possibilities, and painful schedule changes (log in to firewall, temporarily allow traffic, open the app, update schedule, block again&hellip;).</p>
<p>However, this robot (and many others) recognizes a set of voice commands (a feature that works fully offline), so I built <a href="https://github.com/nbr23/jacadi">jacadi</a>, a Go HTTP server that maps endpoints to audio file playback, to play these voice commands on demand.</p>
<p>Note: I am aware of <a href="https://valetudo.cloud/">Valetudo</a>, which solves this problem and more. However, Valetudo requires rooting the robot, losing OTA firmware updates, potentially voiding the warranty, and accepting that not all features are implemented. For now, I wanted a quick zero-modification approach that leaves the robot&rsquo;s software and hardware untouched.</p>
<h2 id="overview">Overview</h2>
<p><img src="https://nbr23.com/posts/controlling-an-air-gapped-robot-vacuum-from-home-assistant-using-synthesized-speech/images/diagram.svg" alt="System diagram" loading="lazy" decoding="async">
</p>
<p>Home-assistant performs a <code>POST</code> request to jacadi. Jacadi plays the wake word <!-- tts say="and then" -->+<!-- /tts --> the command using aplay on the USB speaker connected to the raspberry pi. The Dreame robot hears the wake word followed by the command, and performs the action.</p>
<figure class="center">
    <video controls>
        <source src="https://nbr23.com/posts/controlling-an-air-gapped-robot-vacuum-from-home-assistant-using-synthesized-speech/images/jacadi-clean.mp4" type="video/mp4"><a href="https://nbr23.com/posts/controlling-an-air-gapped-robot-vacuum-from-home-assistant-using-synthesized-speech/images/jacadi-clean.mp4">Download the video</a>
    </video><figcaption class="center"><a href="https://github.com/nbr23/jacadi/blob/master/Dockerfile#L5">en_US-amy-low</a> bossing the vacuum cleaner around</figcaption>
</figure>
<h2 id="setup">Setup</h2>
<h3 id="hardware">Hardware</h3>
<p>I connected a <a href="https://www.amazon.com/dp/B08QRYTPGH">USB speaker</a> to a raspberry pi located near the robot&rsquo;s homebase.</p>
<h3 id="software">Software</h3>
<p>On the raspberry pi, we need to install <code>alsa-utils</code>, and add the user the container will be running as to the audio group.</p>
<p>With the USB speaker plugged into the raspberry pi, <!-- tts say="A play dash L" --><code>aplay -l</code><!-- /tts --> will help us figure out which card to use (card 1 here):</p>
<p><img src="https://nbr23.com/posts/controlling-an-air-gapped-robot-vacuum-from-home-assistant-using-synthesized-speech/images/aplay-l.png" alt="aplay -l" title="Card 1 is our USB Speaker" width="1114" height="516" loading="lazy" decoding="async">
</p>
<p>A simple test will confirm we have this right:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash"><span class="line"><span class="cl">speaker-test -D plughw:1,0 -t wav
</span></span></code></pre></div><!-- /noTTS -->
<!-- noTTS -->
<p>If the volume blasts your eardrums, adjust:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash"><span class="line"><span class="cl">amixer -c <span class="m">1</span> sset PCM 20%
</span></span></code></pre></div><!-- /noTTS -->
<p>We can then deploy the jacadi api using ansible (or simply run the <code>docker-compose.yml</code> from the repo):</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-yaml"><span class="line"><span class="cl">- <span class="nt">hosts</span><span class="p">:</span><span class="w"> </span><span class="l">raspberry-pi</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">roles</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span>- <span class="nt">role</span><span class="p">:</span><span class="w"> </span><span class="l">ansible-role-jacadi</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">jacadi_audiodev</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;plughw:1,0&#34;</span><span class="w"> </span><span class="c"># adjust to match your card</span><span class="w">
</span></span></span></code></pre></div><!-- /noTTS -->
<h3 id="supporting-new-devices">Supporting new devices</h3>
<p>The shipped image only contains commands for the Dreame L40 Ultra, but this can easily be expanded for other devices.</p>
<h4 id="add-commands-to-the-image">Add commands to the image</h4>
<p>Create a new set of commands in jacadi&rsquo;s <code>routes/</code> folder (check <a href="https://github.com/nbr23/jacadi/blob/master/routes/dreame.json">dreame.json</a> for reference), then build your custom image:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash"><span class="line"><span class="cl">docker build --target slim --build-arg <span class="nv">ROUTES</span><span class="o">=</span>mydevice -t jacadi:mydevice .
</span></span></code></pre></div><!-- /noTTS -->
<p>The new audio files will be generate during build and baked into the image.</p>
<h4 id="add-commands-through-mounted-volume">Add commands through mounted volume</h4>
<p>The docker images tagged <code>full</code> embed  <a href="https://nbr23.com/posts/tts-setup/">piper</a> and can generate text to speech audio files at runtime or startup. Creating and mounting an extra_routes file to your container will generate the missing audio files at start up. See <a href="https://github.com/nbr23/jacadi?tab=readme-ov-file#extra-routes">jacadi&rsquo;s README for details</a></p>
<h3 id="home-assistant">Home Assistant</h3>
<h4 id="generating-the-rest_command-yaml-list">Generating the <code>rest_command</code> yaml list</h4>
<p>With the API up and running, we can generate the corresponding Home-Assistant <code>rest_command</code> using the <code>generate-homeassistant</code> script in the <a href="https://github.com/nbr23/jacadi/blob/master/cmd/generate-homeassistant/main.go">jacadi</a> repo:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash"><span class="line"><span class="cl">go run cmd/generate-homeassistant/main.go -base-url<span class="o">=</span><span class="s2">&#34;http://jacadi.local:8080&#34;</span> -device<span class="o">=</span>dreame
</span></span></code></pre></div><!-- /noTTS -->
<p><img src="https://nbr23.com/posts/controlling-an-air-gapped-robot-vacuum-from-home-assistant-using-synthesized-speech/images/ha-gen.png" alt="generate-homeassistant config" width="1190" height="428" loading="lazy" decoding="async">
</p>
<p>This will generate the <!-- tts say="H A config slash home assistant rest dot yaml" --><code>ha-config/homeassistant-rest.yml</code><!-- /tts --> file that contains a mapping of all the routes to home-assistant rest commands. We paste them in the configuration.yml&rsquo;s <code>rest_command</code> entry:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-yaml"><span class="line"><span class="cl"><span class="nt">rest_command</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">jacadi_dreame_battery_level</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">url</span><span class="p">:</span><span class="w"> </span><span class="l">http://jacadi.local:8080/play/dreame/battery-level</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">method</span><span class="p">:</span><span class="w"> </span><span class="l">post</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">jacadi_dreame_clean_balcony</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">url</span><span class="p">:</span><span class="w"> </span><span class="l">http://jacadi.local:8080/play/dreame/clean-balcony</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">method</span><span class="p">:</span><span class="w"> </span><span class="l">post</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="p">[</span><span class="l">...]</span><span class="w">
</span></span></span></code></pre></div><!-- /noTTS -->
<h4 id="wake-word-script">Wake word script</h4>
<p>For the Dreame vacuum, all commands need the wake word (&ldquo;Okay Dreame&rdquo;) spoken before, so we can add this small script to our HA config:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-yaml"><span class="line"><span class="cl"><span class="nt">script</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">vacuum_command</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">alias</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;Vacuum Command with Wake&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">fields</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">command</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">description</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;The rest_command to execute after wake up&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">example</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;jacadi_dreame_clean_balcony&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">sequence</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="nt">service</span><span class="p">:</span><span class="w"> </span><span class="l">rest_command.jacadi_dreame_ok_dream</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="nt">delay</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">          </span><span class="nt">seconds</span><span class="p">:</span><span class="w"> </span><span class="m">2</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="nt">service</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;rest_command.{{ command }}&#34;</span><span class="w">
</span></span></span></code></pre></div><!-- /noTTS -->
<h4 id="dashboard">Dashboard</h4>
<p><a href="https://gist.github.com/nbr23/0ce30e2c6d3185624550c369b7318152">This dashboard</a> makes all of the vacuum cleaner&rsquo;s commands easy to invoke.</p>
<p><img src="https://nbr23.com/posts/controlling-an-air-gapped-robot-vacuum-from-home-assistant-using-synthesized-speech/images/ha-dashboard.png" alt="Home Assistant Vacuum Dashboard" width="2950" height="1368" loading="lazy" decoding="async">
</p>
<h2 id="caveats">Caveats</h2>
<h3 id="audio-annoyance">Audio annoyance</h3>
<p>Audio playback on the Pi&rsquo;s USB speaker from Go within Docker was frustrating. Getting the right audio encoding, bitrate, and device mapping working through Go audio libraries added complexity that wasn&rsquo;t worth it for this hack. Calling <code>aplay</code> with pre-generated wav files was the path of least resistance.</p>
<h3 id="unilateral-communication">Unilateral communication</h3>
<p>The robot listens to us, and acts, but we don&rsquo;t get any confirmation it has heard our command, or that the command was successfully performed.</p>
<h3 id="limited-controls">Limited controls</h3>
<p>We are limited to the set of commands Dreame has set up for voice recognition. They cannot be combined or chained. We cannot ask the robot to &ldquo;Vacuum only&rdquo; and &ldquo;Clean the bathroom&rdquo;. The &ldquo;Clean the bathroom&rdquo; command will clean the bathroom with whatever setting was last used through the app. We cannot ask for multiple rooms to be cleaned (and as we have no feedback when the cleaning is over, we need to add time buffers between manually chained tasks).</p>
<h3 id="inconsistent-names">Inconsistent names</h3>
<p>The room names in the app don&rsquo;t always map to the voice commands.
Here are a few mappings I figured out:</p>
<ul>
<li>Saying &ldquo;clean the hallway&rdquo; cleans the corridor</li>
<li>Saying &ldquo;clean the bedroom&rdquo; cleans all bedrooms</li>
<li>Saying &ldquo;clean the master room&rdquo; cleans the primary bedroom</li>
<li>Saying &ldquo;clean the guest room&rdquo; cleans the second bedroom</li>
</ul>
<h2 id="conclusion">Conclusion</h2>
<p>Despite a few caveats, this set up has allowed me, through Home-Assistant, to set up and easily update my home&rsquo;s cleaning schedule, fire one off cleaning actions whether I am home or not, and build some simple automations (like &ldquo;clean around the <a href="https://nbr23.com/posts/fixing-litter-robot-weight-tracking-multi-cat/">litter box</a> after a <a href="https://nbr23.com/posts/bistrobot-orchestrating-cat-foot-dispensing-raspberry-pi/">cat</a> has been in there&rdquo;), while keeping the vacuum cleaner fully offline and preserving some feeling of privacy.</p>
<p>A somewhat obvious next step would involve adding voice recognition to jacadi, and registering the robot&rsquo;s (very verbose) vocal feedback to home-assistant to get information about task success, things the robot wants me to fix or clean, etc. Although that would mean adding a new device listening in&hellip;</p>
<p>Although the only non-human voice activated device in my home is the Dreame, I am sure more applications can be found for this type of voice bridging with air-gapped devices.</p>
]]></content:encoded>
      </item>
    
      <item>
        <title>Fixing the Litter-Robot&#39;s SmartScale weight tracking with Home Assistant</title>
        <link>https://nbr23.com/posts/fixing-litter-robot-weight-tracking-multi-cat/?utm_source=rss</link>
        <pubDate>Fri, 16 Jan 2026 22:02:07 -0500</pubDate>
        <guid isPermaLink="false">https://wip.tf/posts/fixing-litter-robot-weight-tracking-multi-cat/</guid>
        <description>Fixing the Litter-Robot&#39;s SmartScale weight tracking with a Home Assistant custom integration that tracks (better) which cat used the litter box based on weight readings from the Litter-Robot 4&#39;s SmartScale</description>
        <content:encoded><![CDATA[<div class="text-to-speech-container">
    <span class="text-to-speech-label">Listen to this post:</span>
    <audio class="text-to-speech-audio" controls>
      <source src="https://nbr23.com/audio/tts/fixing-litter-robot-weight-tracking-multi-cat.mp3" type="audio/mpeg">
      <a href="https://nbr23.com/audio/tts/fixing-litter-robot-weight-tracking-multi-cat.mp3">Download the audio</a>
    </audio>
  </div>
  
<p>My <a href="https://nbr23.com/posts/bistrobot-orchestrating-cat-foot-dispensing-raspberry-pi/">two cats</a> recently acquired a <a href="https://www.litter-robot.com/">Litter-Robot 4</a>, and are now using it mostly full time after a few weeks of transition.</p>
<p>Apart from promising to save precious manual scooping energy, shielding from the smell of the cats expertly timing their bowel movements with dinner time, the Litter-Robot 4 boasts a <a href="https://www.litter-robot.com/smartscale">&ldquo;SmartScale®&rdquo;</a>.</p>
<p>The SmartScale® promises, through <code>an advanced algorithm</code> to identify which cat is using the litter when, track their weight through time, and bathroom habits.</p>
<p>As silly as the need for tracking these metrics on a cat sounds, they were actually a pretty big selling point for us:</p>
<ul>
<li>Cat 1 has a history of urinary tract issues (which apparently is common for male ginger cats). It tends to manifest itself with him visiting the litter an unusual number of times (as he is unable to actually urinate).</li>
<li>Cat 2 is picky, and will pee on anything but litter if the box is not clean enough. This is mostly handled by the robot&rsquo;s autocleaning, but keeping track of his bathroom visits (or lack thereof) should warn us of a possible incident.</li>
</ul>
<p>After a few days of usage however, I was disappointed to notice that the SmartScale® is not actually that smart. To Litter-Robot&rsquo;s own admission, &ldquo;<a href="https://www.reddit.com/r/litterrobot/comments/1nz54db/comment/ni2w0fi/">Cats within 1 pound of each other may register incorrectly</a>&rdquo;.</p>
<p>As a casual home-assistant user, I built <a href="https://github.com/nbr23/litter-ha-dumbscale"><!-- tts say="litter H A Dumb Scale" -->litter-ha-DumbScale<!-- /tts --></a>, which relies on the <a href="https://www.home-assistant.io/integrations/litterrobot/">Litter-Robot</a> integration. SmartScale®&rsquo;s &lsquo;advanced algorithm&rsquo; is apparently too clever for its own good. DumbScale does the obvious thing: compare the current weight to each cat&rsquo;s last recorded weight, assign the visit to the closest match, and update accordingly.</p>
<figure class="img-side-by-side">
<div class="img-side-by-side-images">
<img src="https://nbr23.com/posts/fixing-litter-robot-weight-tracking-multi-cat/images/sc-bad-cat.png" alt="SmartScale® detecting Cat 1, always" title="SmartScale® detecting Cat 1, always" width="1080" height="993" loading="lazy" decoding="async">
<img src="https://nbr23.com/posts/fixing-litter-robot-weight-tracking-multi-cat/images/ha-good-cat.png" alt="DumbScale detecting the right cat!" title="DumbScale detecting the right cat!" width="954" height="468" loading="lazy" decoding="async">
</div>
<figcaption>SmartScale® seeing Cat 1 everywhere</figcaption>
</figure>
<p>There will still be limitations with cats that are very close in weight, especially as the scale doesn&rsquo;t appear to be of great accuracy, but this has worked well for me so far (Cat 1 and Cat 2&rsquo;s weight differ by slightly less than a pound).</p>
<p>I must also say that as Litter-Robot mentions <a href="https://www.reddit.com/r/litterrobot/comments/1nz54db/comment/ni2w0fi/">here</a>, the cat detection does get better with time, and after a few weeks I see less cat confusion.</p>
<p>There are also other issues where the SmartScale® will just skip attribution of box usage like these, which DumbScale fixes as well.</p>
<figure class="img-side-by-side">
<div class="img-side-by-side-images">
<img src="https://nbr23.com/posts/fixing-litter-robot-weight-tracking-multi-cat/images/sc-skipped-cat.png" alt="SmartScale® skipping attribution, even though it&#39;s obvious" title="SmartScale® skipping attribution, even though it&#39;s obvious" width="999" height="994" loading="lazy" decoding="async">
<img src="https://nbr23.com/posts/fixing-litter-robot-weight-tracking-multi-cat/images/ha-notskipped-cat.png" alt="DumbScale doing its job!" title="DumbScale doing its job!" width="954" height="482" loading="lazy" decoding="async">
</div>
<figcaption>SmartScale® discarding/not attributing pit stops</figcaption>
</figure>
<p>A month in, DumbScale hasn&rsquo;t misattributed a single visit. If you&rsquo;re running into the same issues, the <a href="https://github.com/nbr23/litter-ha-dumbscale">repo</a> has everything you need to set it up.</p>
]]></content:encoded>
      </item>
    
      <item>
        <title>Mapping my reading log by author birthplace</title>
        <link>https://nbr23.com/posts/map-your-read-books-list-by-author-birthplace/?utm_source=rss</link>
        <pubDate>Tue, 30 Dec 2025 15:40:19 -0500</pubDate>
        <guid isPermaLink="false">https://wip.tf/posts/map-your-read-books-list-by-author-birthplace/</guid>
        <description>Visualizing a personal reading log on a world map, plotting each book by its author&#39;s birthplace.</description>
        <content:encoded><![CDATA[<div class="text-to-speech-container">
    <span class="text-to-speech-label">Listen to this post:</span>
    <audio class="text-to-speech-audio" controls>
      <source src="https://nbr23.com/audio/tts/map-your-read-books-list-by-author-birthplace.mp3" type="audio/mpeg">
      <a href="https://nbr23.com/audio/tts/map-your-read-books-list-by-author-birthplace.mp3">Download the audio</a>
    </audio>
  </div>
  
<p>For the past few years, I have been keeping track of most of the books I read.</p>
<p>It gives me some feeling of accomplishment and progress, adding a notch to the reading log, but also helps me keep track of what I&rsquo;ve read, and where I am in the backlog of <a href="https://en.wikipedia.org/wiki/Am%C3%A9lie_Nothomb">prolific authors</a> or <a href="https://en.wikipedia.org/wiki/The_Murderbot_Diaries">book series</a>.</p>
<p>I initially tracked these books on goodreads, but it was <a href="https://en.wikipedia.org/wiki/Goodreads#2013_acquisition_by_Amazon">acquired by amazon</a> and later <a href="https://web.archive.org/web/20250228182523/https://www.goodreads.com/api">deprecated its API</a>, making the platform less desirable. Instead, I have been tracking them in a simple yaml file that I render using a <a href="https://github.com/nbr23/hugo-reading-log">Hugo theme I built for this purpose</a> and <a href="https://maxence.ardou.in/reading_log.html">push to my personal site</a>.</p>
<p>Being French and living in the US, I tend to mostly read books by French or American and British authors, but wanted a clearer picture. So I built <a href="https://github.com/nbr23/around-the-word/">around-the-word</a> to <a href="https://maxence.ardou.in/authors_map.html">put the authors of the books I read on a map</a>.</p>
<p><a href="https://maxence.ardou.in/authors_map.html"><img src="https://nbr23.com/posts/map-your-read-books-list-by-author-birthplace/images/map.png" alt="a world map with the distribution of authors I have read, by birthplace" title="a world map with the distribution of authors I have read, by birthplace" width="3268" height="1812" loading="lazy" decoding="async">
</a></p>
<p>The map is an interactive HTML country-level map — hover over countries to see counts.</p>
<p>The <a href="https://github.com/nbr23/around-the-word/">python script</a> that generates it takes a <a href="https://www.goodreads.com/review/import">goodreads export</a> or a simple markdown list and looks up each author on Wikidata (with a lazy Wikipedia parser fallback) and maps their birthplace. Results get cached to JSON, so you can manually fix the inevitable historical and geopolitical edge cases: borders change, colonization and decolonization happened. George Orwell was born in India, but is considered British.</p>
<p>The map is rendered using <a href="https://d3js.org/d3-geo">D3</a> and <a href="https://github.com/topojson/world-atlas"><!-- tts say="topo JSON's" -->topojson&rsquo;s<!-- /tts --> world atlas</a>. The resulting HTML file embeds all the javascript it needs.</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash"><span class="line"><span class="cl">uvx around-the-word -i goodreads_export.csv -f goodreads -c cache.json -o map.html
</span></span></code></pre></div><!-- /noTTS -->
<p>The result confirms what I suspected: my reading is overwhelmingly Western. The US dominates (partly due to technical books), followed by France, the UK, and Canada. Beyond that, the map is sparse — a few books from South America, the rest of Europe and a handful of other countries leaving entire continents close to empty.</p>
<p>If you have suggestions from regions I haven&rsquo;t explored, <a href="mailto:max@nbr23.com">send them my way</a>!</p>
<h2 id="2026-04-09-update">2026-04-09 Update:</h2>
<p>I have since built a <a href="https://github.com/nbr23/hugo-reading-log">Hugo theme</a> to render the reading log alongside the authors map, replacing the previous pandoc-based setup.</p>
]]></content:encoded>
      </item>
    
      <item>
        <title>Building Téléfonefix - baby&#39;s first international landline</title>
        <link>https://nbr23.com/posts/telefonefix-building-babys-first-international-landline/?utm_source=rss</link>
        <pubDate>Tue, 23 Sep 2025 05:31:06 -0400</pubDate>
        <guid isPermaLink="false">https://wip.tf/posts/telefonefix-building-babys-first-international-landline/</guid>
        <description>Téléfonefix is a kid-friendly telephone system allowing kids to safely call relatives, locally and abroad.</description>
        <content:encoded><![CDATA[<div class="text-to-speech-container">
    <span class="text-to-speech-label">Listen to this post:</span>
    <audio class="text-to-speech-audio" controls>
      <source src="https://nbr23.com/audio/tts/telefonefix-building-babys-first-international-landline.mp3" type="audio/mpeg">
      <a href="https://nbr23.com/audio/tts/telefonefix-building-babys-first-international-landline.mp3">Download the audio</a>
    </audio>
  </div>
  
<p><img src="https://nbr23.com/posts/telefonefix-building-babys-first-international-landline/images/telefonefix-logo.png#floatright" alt="a gaulois·e placing intercontinental calls using telefonefix" title="a gaulois·e placing intercontinental calls using telefonefix" width="620" height="929" loading="lazy" decoding="async">
</p>
<p><strong>Téléfonefix</strong> is a <strong>kid-friendly</strong> telephone system allowing kids to <strong>safely</strong> call relatives, locally and abroad.</p>
<p>The main features I sought when building téléfonefix were:</p>
<ul>
<li>Do not expose the user to a screen (no apps or fancy phones)</li>
<li>Use a physical phone</li>
<li>Perform calls locally and internationally</li>
<li>Permit/decline calls based on a ruleset. Specifically:
<ul>
<li>only permit calls to be made to an adult-controlled set of numbers</li>
<li>timezones and &ldquo;awake/asleep&rdquo; schedules, to avoid calling Europe at their <!-- tts say="one A M" -->1am<!-- /tts --></li>
<li>prevent inbound calls entirely</li>
</ul>
</li>
<li>As user-friendly as possible</li>
</ul>
<h2 id="shopping-list">Shopping list</h2>
<p><img src="https://nbr23.com/posts/telefonefix-building-babys-first-international-landline/images/telefonefix-full.jpeg#smaller" alt="the phone plugged to the HT801 Grandstream plugged to the Raspberry Pi 4B, beaming to the PTSN through twilio" title="the phone plugged to the HT801 Grandstream plugged to the Raspberry Pi 4B, beaming to the PTSN through twilio" width="960" height="878" loading="lazy" decoding="async">
</p>
<ul>
<li>A <strong>corded phone</strong>: any phone with an RJ11 connector will work. A rotary dial phone would add cool factor for kids old enough to dial them. I used this <a href="https://www.amazon.com/dp/B0CN7BZ5N8">&ldquo;Telephone for Seniors&rdquo;</a>. The pictured speed dial numbers are perfect for very young kids to choose who they want to call</li>
<li>An <strong>analog telephone adapter</strong>: I use the <a href="https://www.amazon.com/Grandstream-HT801-Single-Port-Telephone-Adapter/dp/B06XW1BQHC">Grandstream HT801</a>. It is well-documented and reliable</li>
<li>A <strong>Raspberry Pi</strong> (or any compute really) to run the software PBX <strong>asterisk</strong> on. For this setup, I used a Pi 4 B. It embeds WiFi and an ethernet port making it easy to connect both to your network and directly wire the HT801 to the Pi</li>
<li>A <strong>twilio</strong> account with a number purchased (~ $1.15/month)</li>
</ul>
<h2 id="architecture">Architecture</h2>
<p><img src="https://nbr23.com/posts/telefonefix-building-babys-first-international-landline/images/diagram.svg#center" alt="The phone connects to the HT801. The HT801 to asterisk running on the Raspberry Pi. Asterisk queries allo-wed for call approval, and places the call through twilio" title="The phone connects to the HT801. The HT801 to asterisk running on the Raspberry Pi. Asterisk queries allo-wed for call approval, and places the call through twilio" loading="lazy" decoding="async">
</p>
<h2 id="hardware-setup">Hardware setup</h2>
<h3 id="phone-to-ht801">Phone to HT801</h3>
<p>We simply plug an <code>RJ11</code> cable in between the Phone and the HT801.</p>
<h3 id="ht801-to-raspberry-pi">HT801 to Raspberry Pi</h3>
<p>I opted to connect these two directly with an <code>RJ45</code> as we will see below.</p>
<h3 id="phone">Phone</h3>
<p>On the phone itself, to make updating phone numbers easier, I assigned each of the 9 speed dial picture buttons with a number from <code>100</code> to <code>107</code> and assigned <code>200</code> to the last one (which I keep for debugging). Those extensions will be translated later on to actual numbers by a small golang program I built for the occasion, <a href="https://github.com/nbr23/allo-wed/">allo-wed</a>.</p>
<p><img src="https://nbr23.com/posts/telefonefix-building-babys-first-international-landline/images/telefonefix-phone.jpeg#xsmaller" alt="A phone designed for old humans, that works great with young humans too" title="A phone designed for old humans, that works great with young humans too" width="530" height="519" loading="lazy" decoding="async">
</p>
<h2 id="twilio-setup">Twilio setup</h2>
<p>First, you will need to create an <a href="https://console.twilio.com/us1/develop/sip-trunking/manage/trunks?frameUrl=%2Fconsole%2Fsip-trunking%2Ftrunks%3Fx-target-region%3Dus1">Elastic SIP Trunk</a> in twilio.</p>
<p><img src="https://nbr23.com/posts/telefonefix-building-babys-first-international-landline/images/twilio-sip.png#center" alt="A screenshot of the twilio Elastic SIP Trunk page" title="A screenshot of the twilio Elastic SIP Trunk page" width="2392" height="882" loading="lazy" decoding="async">
</p>
<p>Once created, in the <em>Termination</em> tab, set up the <em>Authentication</em>. Create a new set of credentials (your <code>telefonefix_twilio_user</code> and <code>telefonefix_twilio_password</code> in <strong>asterisk</strong>&rsquo;s configuration&rsquo;). IP Access control lists are also available.</p>
<p>In the <em>Numbers</em> tab, buy a new number and assign it to the trunk. That number will be your <code>telefonefix_twilio_phone_number</code> value (formatted as <!-- tts say="plus one, five five five, five five five, five five five five" --><code>'+15555555555'</code><!-- /tts -->). Note that numbers have a monthly cost independent of usage (~ $1.15/month).</p>
<p>Incoming calls are not something I am looking for, so I did not change <em>Origination</em>.</p>
<h2 id="téléfonefix-stack-configuration">Téléfonefix stack configuration</h2>
<p>I built <a href="https://github.com/nbr23/ansible-role-telefonefix">ansible-role-telefonefix</a> to handle the configuration.
Let&rsquo;s look at a <code>telefonefix.yml</code> playbook example and detail each task:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-yml"><span class="line"><span class="cl">- <span class="nt">hosts</span><span class="p">:</span><span class="w"> </span><span class="l">telefonefix</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">become</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">gather_facts</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">vars</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">telefonefix_asterisk_playback_patterns</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">connecting</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">fr</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;Un instant, je vous connecte à \&#34;${contact_name}\&#34;&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">pt</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;Só um momento. Ligando para \&#34;${contact_name}.\&#34;&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">not-allowed</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">fr</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\&#34;${contact_name}\&#34; fait dodo, rappelle plus tard!&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">pt</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\&#34;${contact_name}.\&#34; está dormindo, ligue mais tarde!&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">currently-busy</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">fr</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\&#34;${contact_name}\&#34; est occupé, rappelle plus tard!&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">pt</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\&#34;${contact_name}.\&#34; está occupado, ligue mais tarde!&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">unavailable</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">fr</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\&#34;${contact_name}\&#34; est occupé, rappelle plus tard!&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">pt</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\&#34;${contact_name}.\&#34; está occupado, ligue mais tarde!&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">telefonefix_voice_map</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">en</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;en_US-amy-low&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">fr</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;fr_FR-siwis-low&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">pt</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;pt_BR-cadu-medium&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">telefonefix_network_subnet</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;192.168.100.0/24&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">telefonefix_gateway_ip</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;192.168.100.1&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">ht801_mac</span><span class="p">:</span><span class="w"> </span><span class="c"># TODO</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">ht801_static_ip</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;192.168.100.20&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">telefonefix_dns_servers</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="s2">&#34;8.8.8.8&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="s2">&#34;8.8.4.4&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">telefonefix_ethernet_interface</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;eth0&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">telefonefix_asterisk_extra_sounds_folder</span><span class="p">:</span><span class="w"> </span><span class="l">/tmp/telefonefix/extra_sounds</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">telefonefix_super_user_override_prefix</span><span class="p">:</span><span class="w"> </span><span class="s1">&#39;23&#39;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">telefonefix_public_ip</span><span class="p">:</span><span class="w"> </span><span class="c"># TODO</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">telefonefix_asterisk_phone_user</span><span class="p">:</span><span class="w"> </span><span class="s1">&#39;6001&#39;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">telefonefix_asterisk_phone_password</span><span class="p">:</span><span class="w"> </span><span class="c"># TODO</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">telefonefix_twilio_domaine</span><span class="p">:</span><span class="w"> </span><span class="c"># TODO</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">telefonefix_twilio_phone_number</span><span class="p">:</span><span class="w"> </span><span class="c"># TODO</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">telefonefix_twilio_user</span><span class="p">:</span><span class="w"> </span><span class="c"># TODO</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">telefonefix_twilio_password</span><span class="p">:</span><span class="w"> </span><span class="c"># TODO</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">ht801_password</span><span class="p">:</span><span class="w"> </span><span class="c"># TODO</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">tasks</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">Generating asterisk voices</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">include_role</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">ansible-role-telefonefix</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">tasks_from</span><span class="p">:</span><span class="w"> </span><span class="l">asterisk_playbacks_generate.yml</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">DHCP config</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">include_role</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">ansible-role-telefonefix</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">tasks_from</span><span class="p">:</span><span class="w"> </span><span class="l">dhcp.yml</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">Asterisk setup</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">include_role</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">ansible-role-telefonefix</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">tasks_from</span><span class="p">:</span><span class="w"> </span><span class="l">asterisk.yml</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">HT801 setup</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">include_role</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">ansible-role-telefonefix</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">tasks_from</span><span class="p">:</span><span class="w"> </span><span class="l">ht801.yml</span><span class="w">
</span></span></span></code></pre></div><!-- /noTTS -->
<p>The variables are mostly self-explanatory and can be updated to fit different needs and setups.</p>
<p>We will review the <code>Generating asterisk voices</code> task at the end, and start with the main tasks first.</p>
<h3 id="task-dhcp-config">Task <code>DHCP config</code></h3>
<p>Configures a <!-- tts say="D H C P" -->dhcp<!-- /tts --> server on the raspberry pi, and has it assign a fixed <!-- tts say="I P" -->ip<!-- /tts --> to the HT801 in their own shared very local LAN to keep things isolated and simple.</p>
<p>We can also easily run asterisk on a VPS, and have the HT801 point directly to it.</p>
<h3 id="task-asterisk-setup">Task <code>Asterisk setup</code></h3>
<p>This is the main task. It:</p>
<ul>
<li>installs docker</li>
<li>pushes the main configuration files</li>
<li>pushes optional sound files for asterisk</li>
<li>launches the <code>asterisk</code> docker container (<a href="https://github.com/nbr23/docker-asterisk">asterisk</a> + <a href="https://github.com/nbr23/allo-wed/blob/master/Dockerfile">allo-wed</a>)</li>
</ul>
<p>Let&rsquo;s review the main configuration files.</p>
<h4 id="file-extensionsconf">File <code>extensions.conf</code></h4>
<p><a href="https://github.com/nbr23/ansible-role-telefonefix/blob/master/templates/asterisk/extensions.conf">extensions.conf</a> defines what happens when a number is dialed.</p>
<p>On the physical phone, I have defined each speed dial pictured number to dial a number from <code>100</code> to <code>107</code>. The last picture is defined as <code>200</code>, and currently <a href="https://github.com/nbr23/ansible-role-telefonefix/blob/master/templates/asterisk/extensions.conf#L47-L51">used for debugging</a>.</p>
<p>Calls coming in using one of those numbers are handled here:</p>
<!-- noTTS -->
<div class="github-embed">
            <div class="github-embed-header">
                <span class="github-embed-header-left">
                    
                    <span class="github-embed-title">extensions.conf#L17-L21</span>
                </span>
                <span class="github-embed-header-right">
                    <a href="https://github.com/nbr23/ansible-role-telefonefix/blob/master/templates/asterisk/extensions.conf#L17-L21">view code (lines 17-21)</a></span>
            </div>
            <div class="github-embed-body"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-ini"><span class="line"><span class="cl"><span class="c1">; Pattern _1XX matches any three-digit number starting with 1</span>
</span></span><span class="line"><span class="cl"><span class="na">exten</span> <span class="o">=</span><span class="s">&gt; _1XX,1,NoOp(Calling extension ${EXTEN})</span>
</span></span><span class="line"><span class="cl"><span class="na">exten</span> <span class="o">=</span><span class="s">&gt; _1XX,n,Set(TRANSLATED_NUMBER=${SHELL(allo-wed -config /opt/asterisk/allo-wed.yml -is-allowed -phone ${EXTEN})})</span>
</span></span><span class="line"><span class="cl"><span class="na">exten</span> <span class="o">=</span><span class="s">&gt; _1XX,n,NoOp(Translated to: ${TRANSLATED_NUMBER})</span>
</span></span><span class="line"><span class="cl"><span class="na">exten</span> <span class="o">=</span><span class="s">&gt; _1XX,n,GotoIf($[&#34;${TRANSLATED_NUMBER}&#34; = &#34;&#34;]?not_allowed)</span></span></span></code></pre></div></div>
        </div>
<!-- /noTTS -->
<p>We call the <a href="https://github.com/nbr23/allo-wed">allo-wed</a> script with the dialed extension as a parameter. If calls are allowed to this number, it returns the <!-- tts say="one X X" --><code>1XX</code><!-- /tts --> number to real world number translation, based on its <a href="https://github.com/nbr23/allo-wed/blob/master/config.sample.yaml">configuration file</a>.</p>
<p>If the call is denied, we let the user know:</p>
<!-- noTTS -->
<div class="github-embed">
            <div class="github-embed-header">
                <span class="github-embed-header-left">
                    
                    <span class="github-embed-title">extensions.conf#L31-L33</span>
                </span>
                <span class="github-embed-header-right">
                    <a href="https://github.com/nbr23/ansible-role-telefonefix/blob/master/templates/asterisk/extensions.conf#L31-L33">view code (lines 31-33)</a></span>
            </div>
            <div class="github-embed-body"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-ini"><span class="line"><span class="cl"><span class="c1">; Call not allowed or no mapping found</span>
</span></span><span class="line"><span class="cl"><span class="na">exten</span> <span class="o">=</span><span class="s">&gt; _1XX,n(not_allowed),Playback(extra/${EXTEN}/not-allowed)</span>
</span></span><span class="line"><span class="cl"><span class="na">exten</span> <span class="o">=</span><span class="s">&gt; _1XX,n,Hangup()</span></span></span></code></pre></div></div>
        </div>
<!-- /noTTS -->
<p>Otherwise, we announce success and perform the call:</p>
<!-- noTTS -->
<div class="github-embed">
            <div class="github-embed-header">
                <span class="github-embed-header-left">
                    
                    <span class="github-embed-title">extensions.conf#L23-L29</span>
                </span>
                <span class="github-embed-header-right">
                    <a href="https://github.com/nbr23/ansible-role-telefonefix/blob/master/templates/asterisk/extensions.conf#L23-L29">view code (lines 23-29)</a></span>
            </div>
            <div class="github-embed-body"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-ini"><span class="line"><span class="cl"><span class="c1">; Call is allowed and number was translated</span>
</span></span><span class="line"><span class="cl"><span class="na">exten</span> <span class="o">=</span><span class="s">&gt; _1XX,n,Playback(extra/${EXTEN}/connecting)</span>
</span></span><span class="line"><span class="cl"><span class="na">exten</span> <span class="o">=</span><span class="s">&gt; _1XX,n,Dial(PJSIP/${TRANSLATED_NUMBER}@twilio,30,L({{ telefonefix_call_duration_limit_minutes * 60 * 1000 }}))</span>
</span></span><span class="line"><span class="cl"><span class="na">exten</span> <span class="o">=</span><span class="s">&gt; _1XX,n,GotoIf($[&#34;${DIALSTATUS}&#34; = &#34;BUSY&#34;]?busy)</span>
</span></span><span class="line"><span class="cl"><span class="na">exten</span> <span class="o">=</span><span class="s">&gt; _1XX,n,GotoIf($[&#34;${DIALSTATUS}&#34; = &#34;NOANSWER&#34;]?noanswer)</span>
</span></span><span class="line"><span class="cl"><span class="na">exten</span> <span class="o">=</span><span class="s">&gt; _1XX,n,GotoIf($[&#34;${DIALSTATUS}&#34; = &#34;UNAVAILABLE&#34;]?unavailable)</span>
</span></span><span class="line"><span class="cl"><span class="na">exten</span> <span class="o">=</span><span class="s">&gt; _1XX,n,Hangup()</span></span></span></code></pre></div></div>
        </div>
<!-- /noTTS -->
<p>A <strong><a href="https://github.com/nbr23/ansible-role-telefonefix/blob/master/templates/asterisk/extensions.conf#L2-L15">parental override</a></strong> can be enabled by setting a <code>telefonefix_super_user_override_prefix</code> value.</p>
<p>For example, with <!-- tts say="telefonefix super user override prefix set to twenty three" --><code>telefonefix_super_user_override_prefix = 23</code><!-- /tts -->, you will be able to bypass call restrictions on the <!-- tts say="one oh one" --><code>101</code><!-- /tts --> extensions by dialing <!-- tts say="two three one oh one" --><code>23101</code><!-- /tts -->.</p>
<h4 id="file-pjsipconf">File <code>pjsip.conf</code></h4>
<p>This is where we configure the actual communication stack.</p>
<p><a href="https://github.com/nbr23/ansible-role-telefonefix/blob/master/templates/asterisk/pjsip.conf#L28-L47">First</a> we setup our <strong>local extension</strong> <!-- tts say="six oh oh one" --><code>[6001]</code><!-- /tts -->, our physical phone, and set up authentication for it so the HT801 can connect to asterisk.</p>
<p><a href="https://github.com/nbr23/ansible-role-telefonefix/blob/master/templates/asterisk/pjsip.conf#L49-L92">Then</a> we set up the <strong>Twilio trunk</strong> for outbound calls, linking and authenticating to our domain.</p>
<h4 id="file-rtpconf">File <code>rtp.conf</code></h4>
<p>The RTP configuration is lightly edited to reduce the port range. We have a single user, and not having to add port forwarding for the full range can make home router/firewall configuration easier.</p>
<h4 id="file-allo-wedyml">File <code>allo-wed.yml</code></h4>
<p>You need an <code>asterisk/allo-wed.yml</code> file alongside your calling playbook (<!-- tts say="for example" -->eg<!-- /tts --> in <code>files/asterisk/allo-wed.yml</code>). A configuration example is available in the <a href="https://github.com/nbr23/allo-wed/blob/master/config.sample.yaml">allo-wed repo</a>.</p>
<p>This file will define who each speed dial extension will call, their language and name (for fancy spoken messages), their timezone and awake hours, and the number to dial.</p>
<p>Number format tends to be the tricky part here. I have had success putting the full number with country code and leading <!-- tts say="plus sign" --><code>+</code><!-- /tts -->. For example, to dial a French cell: <!-- tts say="plus three three six, then eight digits" --><code>'+336XXXXXXXX'</code><!-- /tts -->.</p>
<h3 id="task-ht801-setup">Task <code>HT801 setup</code></h3>
<p>We send a <code>POST</code> request to the HT801&rsquo;s administration API, essentially setting up communication and authentication with the asterisk server.</p>
<h3 id="bonus-generating-asterisk-voices">Bonus: Generating asterisk voices</h3>
<p>Using my previous <strong><a href="https://nbr23.com/posts/tts-setup/">Text To Speech Setup</a></strong> and <strong>asterisk</strong>&rsquo;s <code>Playback</code> feature, I generate custom messages that asterisk will play for different occasion. For example, when dialing a specific contact, asterisk will announce in the callee&rsquo;s language <em>&ldquo;Dialing <!-- tts say="so-and-so" -->XXX<!-- /tts -->, please hold&rdquo;</em>.</p>
<p>The messages are generated based on these variables:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-yml"><span class="line"><span class="cl"><span class="w">    </span><span class="nt">telefonefix_asterisk_playback_patterns</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">connecting</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">fr</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;Un instant, je vous connecte à \&#34;${contact_name}\&#34;&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">pt</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;Só um momento. Ligando para \&#34;${contact_name}.\&#34;&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">not-allowed</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">fr</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\&#34;${contact_name}\&#34; fait dodo, rappelle plus tard!&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">pt</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\&#34;${contact_name}.\&#34; está dormindo, ligue mais tarde!&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">currently-busy</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">fr</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\&#34;${contact_name}\&#34; est occupé, rappelle plus tard!&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">pt</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\&#34;${contact_name}.\&#34; está occupado, ligue mais tarde!&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">unavailable</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">fr</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\&#34;${contact_name}\&#34; est occupé, rappelle plus tard!&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">pt</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;\&#34;${contact_name}.\&#34; está occupado, ligue mais tarde!&#34;</span><span class="w">
</span></span></span></code></pre></div><!-- /noTTS -->
<p>Using these voices, which I found to be the best for each language I was interested in:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-yml"><span class="line"><span class="cl"><span class="w">    </span><span class="nt">telefonefix_voice_map</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">en</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;en_US-amy-low&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">fr</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;fr_FR-siwis-low&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">pt</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;pt_BR-cadu-medium&#34;</span><span class="w">
</span></span></span></code></pre></div><!-- /noTTS -->
<p>The <code>Generating asterisk voices</code> task will start <a href="https://github.com/nbr23/gopipertts">gopipertts</a> on the local machine, generate all the messages we need, and convert them to be playable by asterisk.</p>
<h2 id="firewall-configuration">Firewall configuration</h2>
<p>Twilio needs to be able to reach asterisk on the following ports, you will need to configure your firewall and port forwarding accordingly:</p>
<ul>
<li><code>5060/udp</code>: SIP port</li>
<li><code>10000-10100/udp</code>: the RTP port range</li>
</ul>
<h2 id="conclusion-and-future-improvements">Conclusion and future improvements</h2>
<p>The phone has been a huge success, and the concept easily graspable by young kids!</p>
<p>A few potential improvements:</p>
<ul>
<li>preventing hangups&hellip; Kids get excited, pick up the phone, hang it up, pick it up again. Being able to prevent premature call end would be useful (twilio starts charging immediately too, so you&rsquo;ll be billed the full minute for that <!-- tts say="three second" -->3s<!-- /tts --> call-hang-up)</li>
<li>limiting calls per day/hours? It could be useful to have <code>allo-wed</code> prevent the user from calling the same contact 15 times within a minute</li>
<li>better error handling. There are cases where calls fail with little to no feedback. I&rsquo;m not sure where the issues come from, but gathering more information from twilio/asterisk and speaking it to the user would be helpful</li>
<li>forcing speaker mode&hellip; But that would require tweaking with the phone itself</li>
</ul>
<p><strong>If you implement this and have feedback, please <a href="mailto:max@nbr23.com">reach out</a>!</strong></p>
<h2 id="links">Links</h2>
<h3 id="core-components">Core Components</h3>
<ul>
<li><a href="https://www.asterisk.org/">Asterisk</a> - The open source PBX system</li>
<li><a href="https://console.twilio.com/">Twilio</a> - SIP trunking and phone number provider</li>
<li><a href="https://www.amazon.com/Grandstream-HT801-Single-Port-Telephone-Adapter/dp/B06XW1BQHC">Grandstream HT801</a> - Analog telephone adapter</li>
</ul>
<h3 id="software--configuration">Software &amp; Configuration</h3>
<ul>
<li><a href="https://github.com/nbr23/allo-wed">allo-wed</a> - Extension translation and call scheduling</li>
<li><a href="https://github.com/nbr23/ansible-role-telefonefix">ansible-role-telefonefix</a> - Ansible automation for the entire setup</li>
<li><a href="https://github.com/nbr23/docker-asterisk">docker-asterisk</a> - Ubuntu-based Asterisk container</li>
<li><a href="https://github.com/nbr23/gopipertts">gopipertts</a> - Text-to-speech voice generation</li>
</ul>
<h3 id="references--inspiration">References &amp; Inspiration</h3>
<ul>
<li><a href="https://www.michaellunzer.com/blogs/connecting-a-grandstream-ht80x-ht801-or-ht802-to-twilio-sip">Connecting a Grandstream HT80x to Twilio SIP</a> - Helpful setup guide</li>
<li><a href="https://nickbusey.com/article/2020-05-04-twilio-grandstream/">Twilio + Grandstream Setup</a> - Another useful walkthrough</li>
<li><a href="https://en.wikipedia.org/wiki/Asterix">Astérix et Obélix</a> - Naming convention inspiration</li>
</ul>
]]></content:encoded>
      </item>
    
      <item>
        <title>Jira compliant and Claude powered commits</title>
        <link>https://nbr23.com/posts/jira-claude-commit/?utm_source=rss</link>
        <pubDate>Tue, 12 Aug 2025 23:47:26 -0400</pubDate>
        <guid isPermaLink="false">https://wip.tf/posts/jira-claude-commit/</guid>
        <description>Bash functions that combine Jira context and Claude Code to auto-generate compliant commit messages.</description>
        <content:encoded><![CDATA[<div class="text-to-speech-container">
    <span class="text-to-speech-label">Listen to this post:</span>
    <audio class="text-to-speech-audio" controls>
      <source src="https://nbr23.com/audio/tts/jira-claude-commit.mp3" type="audio/mpeg">
      <a href="https://nbr23.com/audio/tts/jira-claude-commit.mp3">Download the audio</a>
    </audio>
  </div>
  
<p>Using the same <a href="https://github.com/nbr23/jira-buddy" class="github-link"><span>jira-buddy</span></a> from <a href="https://nbr23.com/posts/vim-jira/">earlier</a> and combining it with claude code, we can stop writing commits entirely and let the LLMs do it.</p>
<p>This <a href="https://gist.github.com/nbr23/33cfa30b3dd2b724ec28c08948016379">gist</a> suggests two bash functions to add to your <!-- tts say="bash R C" --><code>bashrc</code><!-- /tts --> to never write commits again!</p>
<p>This first function, <code>ai-commit</code>, passes:</p>
<ul>
<li>the staged changes (whatever you <!-- tts say="git added" --><code>git add</code>&lsquo;ed<!-- /tts -->)</li>
<li>the current directory&rsquo;s name (you&rsquo;ll want to run this at the root of the repo, so this would likely be your project name, which adds some context to your change)</li>
<li>anything you pass to the command as extra context</li>
</ul>
<p>to <code>claude code</code> and asks it for a concise commit message.</p>
<!-- noTTS -->
<p>For example:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash"><span class="line"><span class="cl">host:~/dev/superapp&gt; ai-commit ai powered security
</span></span></code></pre></div><div class="github-embed">
            <div class="github-embed-header">
                <span class="github-embed-header-left">
                    
                    <span class="github-embed-title">ai-commits.sh</span>
                </span>
                <span class="github-embed-header-right">
                    <a href="https://gist.github.com/nbr23/33cfa30b3dd2b724ec28c08948016379#file-ai-commits-sh-L1-L27">view gist (lines 1-27)</a></span>
            </div>
            <div class="github-embed-body"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash"><span class="line"><span class="cl">ai-commit<span class="o">()</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">  <span class="nb">local</span> <span class="nv">profile</span><span class="o">=</span><span class="s2">&#34;</span><span class="si">${</span><span class="nv">DEFAULT_CLAUDE_COMMIT_PROFILE</span><span class="k">:-</span><span class="nv">claude</span><span class="si">}</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="nb">local</span> <span class="nv">context</span><span class="o">=</span><span class="s2">&#34;</span><span class="nv">$@</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="nb">echo</span> <span class="s2">&#34;Generating commit message with Claude using profile &#39;</span><span class="nv">$profile</span><span class="s2">&#39;... with extra context: &#39;</span><span class="nv">$context</span><span class="s2">&#39;&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="nb">local</span> <span class="nv">project_dir_name</span><span class="o">=</span><span class="s2">&#34;</span><span class="si">${</span><span class="nv">PWD</span><span class="p">##*/</span><span class="si">}</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="nb">local</span> commit_message
</span></span><span class="line"><span class="cl">  <span class="nb">local</span> <span class="nv">prompt</span><span class="o">=</span><span class="s2">&#34;Analyze the staged git changes for the &#39;</span><span class="nv">$project_dir_name</span><span class="s2">&#39; project and generate a concise commit message following conventional commit format (type: description). Keep the message under 72 characters for the first line. Only output the commit message, nothing else - the output goes directly to git commit -m.&#34;</span>
</span></span><span class="line"><span class="cl">  
</span></span><span class="line"><span class="cl">  <span class="k">if</span> <span class="o">[[</span> -n <span class="s2">&#34;</span><span class="nv">$context</span><span class="s2">&#34;</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then</span>
</span></span><span class="line"><span class="cl">    <span class="nv">prompt</span><span class="o">=</span><span class="s2">&#34;</span><span class="nv">$prompt</span><span class="s2">
</span></span></span><span class="line"><span class="cl"><span class="s2">
</span></span></span><span class="line"><span class="cl"><span class="s2">Additional context: </span><span class="nv">$context</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="k">fi</span>
</span></span><span class="line"><span class="cl">  <span class="nv">commit_message</span><span class="o">=</span><span class="k">$(</span>docker run --rm <span class="se">\
</span></span></span><span class="line"><span class="cl">    --volume <span class="s2">&#34;</span><span class="nv">$PWD</span><span class="s2">:/home/node/dev/</span><span class="nv">$project_dir_name</span><span class="s2">&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">    -w <span class="s2">&#34;/home/node/dev/</span><span class="nv">$project_dir_name</span><span class="s2">&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">    --volume <span class="s2">&#34;</span><span class="nv">$HOME</span><span class="s2">/.</span><span class="si">${</span><span class="nv">profile</span><span class="si">}</span><span class="s2">:/home/node/.claude&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">    --volume <span class="s2">&#34;</span><span class="nv">$HOME</span><span class="s2">/.</span><span class="si">${</span><span class="nv">profile</span><span class="si">}</span><span class="s2">.json:/home/node/.claude.json&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">    nbr23/claudecode -p <span class="s2">&#34;</span><span class="si">${</span><span class="nv">prompt</span><span class="si">}</span><span class="s2">&#34;</span> <span class="p">|</span> awk <span class="s1">&#39;{$1=$1;print}&#39;</span><span class="k">)</span>
</span></span><span class="line"><span class="cl">  <span class="k">if</span> <span class="o">[[</span> -z <span class="s2">&#34;</span><span class="nv">$commit_message</span><span class="s2">&#34;</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then</span>
</span></span><span class="line"><span class="cl">    <span class="nb">echo</span> <span class="s2">&#34;Error: Failed to generate a commit message from Claude. Aborting.&#34;</span>
</span></span><span class="line"><span class="cl">    <span class="k">return</span> <span class="m">1</span>
</span></span><span class="line"><span class="cl">  <span class="k">fi</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">  <span class="nb">echo</span> <span class="s2">&#34;Committing...&#34;</span>
</span></span><span class="line"><span class="cl">  git commit -m <span class="s2">&#34;</span><span class="nv">$commit_message</span><span class="s2">&#34;</span> <span class="o">&amp;&amp;</span> git commit --amend
</span></span><span class="line"><span class="cl"><span class="o">}</span></span></span></code></pre></div></div>
        </div>
<!-- /noTTS -->
<p><code>ai-jira-commit</code> works similarly to <code>ai-commit</code> but also calls <code>jira-buddy</code> to fetch the list of open tickets assigned to ourselves on Jira. It passes this list as extra context to <code>claude code</code>, and asks it to deliver a commit message prepended with the most appropriate ticket ID.</p>
<!-- noTTS -->
<div class="github-embed">
            <div class="github-embed-header">
                <span class="github-embed-header-left">
                    
                    <span class="github-embed-title">ai-commits.sh</span>
                </span>
                <span class="github-embed-header-right">
                    <a href="https://gist.github.com/nbr23/33cfa30b3dd2b724ec28c08948016379#file-ai-commits-sh-L29-L113">view gist (lines 29-113)</a></span>
            </div>
            <div class="github-embed-body"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash"><span class="line"><span class="cl">ai-jira-commit<span class="o">()</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">  <span class="nb">local</span> <span class="nv">profile</span><span class="o">=</span><span class="s2">&#34;</span><span class="si">${</span><span class="nv">DEFAULT_CLAUDE_COMMIT_PROFILE</span><span class="k">:-</span><span class="nv">claude</span><span class="si">}</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="nb">local</span> <span class="nv">context</span><span class="o">=</span><span class="s2">&#34;</span><span class="nv">$@</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="nb">echo</span> <span class="s2">&#34;Generating Jira-aware commit message with Claude using profile &#39;</span><span class="nv">$profile</span><span class="s2">&#39;... with extra context: &#39;</span><span class="nv">$context</span><span class="s2">&#39;&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="nb">local</span> <span class="nv">project_dir_name</span><span class="o">=</span><span class="s2">&#34;</span><span class="si">${</span><span class="nv">PWD</span><span class="p">##*/</span><span class="si">}</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="nb">local</span> commit_message
</span></span><span class="line"><span class="cl">  <span class="nb">local</span> jira_tickets
</span></span><span class="line"><span class="cl">  
</span></span><span class="line"><span class="cl">  <span class="nv">jira_tickets</span><span class="o">=</span><span class="k">$(</span>uvx jira-buddy --own --json --fields key,summary,status,issuetype<span class="k">)</span>
</span></span><span class="line"><span class="cl">  <span class="k">if</span> <span class="o">[[</span> -z <span class="s2">&#34;</span><span class="nv">$jira_tickets</span><span class="s2">&#34;</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then</span>
</span></span><span class="line"><span class="cl">    <span class="nb">echo</span> <span class="s2">&#34;Error: Failed to fetch Jira tickets.&#34;</span>
</span></span><span class="line"><span class="cl">    <span class="k">return</span>
</span></span><span class="line"><span class="cl">  <span class="k">fi</span>
</span></span><span class="line"><span class="cl">  
</span></span><span class="line"><span class="cl">  <span class="nb">local</span> <span class="nv">prompt</span><span class="o">=</span><span class="s2">&#34;CRITICAL INSTRUCTIONS: You MUST respond with ONLY a single line containing the commit message. NO explanations, NO reasoning, NO additional text, NO line breaks.
</span></span></span><span class="line"><span class="cl"><span class="s2">
</span></span></span><span class="line"><span class="cl"><span class="s2">Analyze the staged git changes for the &#39;</span><span class="nv">$project_dir_name</span><span class="s2">&#39; project. Based on the changes and the following Jira tickets JSON, pick the most appropriate ticket and generate a commit message in the format &#39;TICKET-KEY - commit message&#39;. Keep under 72 characters total.
</span></span></span><span class="line"><span class="cl"><span class="s2">
</span></span></span><span class="line"><span class="cl"><span class="s2">IMPORTANT: Only pick a ticket if you have confidence it matches the changes or that the changes could be a subtask of. If no ticket clearly matches, respond with exactly &#39;None&#39; instead.&#34;</span>
</span></span><span class="line"><span class="cl">  
</span></span><span class="line"><span class="cl">  <span class="k">if</span> <span class="o">[[</span> -n <span class="s2">&#34;</span><span class="nv">$context</span><span class="s2">&#34;</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then</span>
</span></span><span class="line"><span class="cl">    <span class="nv">prompt</span><span class="o">=</span><span class="s2">&#34;</span><span class="nv">$prompt</span><span class="s2">
</span></span></span><span class="line"><span class="cl"><span class="s2">
</span></span></span><span class="line"><span class="cl"><span class="s2">Additional context: </span><span class="nv">$context</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="k">fi</span>
</span></span><span class="line"><span class="cl">  
</span></span><span class="line"><span class="cl">  <span class="nv">prompt</span><span class="o">=</span><span class="s2">&#34;</span><span class="nv">$prompt</span><span class="s2">
</span></span></span><span class="line"><span class="cl"><span class="s2">
</span></span></span><span class="line"><span class="cl"><span class="s2">Jira tickets:
</span></span></span><span class="line"><span class="cl"><span class="nv">$jira_tickets</span><span class="s2">
</span></span></span><span class="line"><span class="cl"><span class="s2">
</span></span></span><span class="line"><span class="cl"><span class="s2">RESPOND WITH ONLY THE COMMIT MESSAGE LINE. NOTHING ELSE.&#34;</span>
</span></span><span class="line"><span class="cl">  
</span></span><span class="line"><span class="cl">  <span class="nb">local</span> claude_response
</span></span><span class="line"><span class="cl">  <span class="nv">claude_response</span><span class="o">=</span><span class="k">$(</span>docker run --rm <span class="se">\
</span></span></span><span class="line"><span class="cl">    --volume <span class="s2">&#34;</span><span class="nv">$PWD</span><span class="s2">:/home/node/dev/</span><span class="nv">$project_dir_name</span><span class="s2">&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">    -w <span class="s2">&#34;/home/node/dev/</span><span class="nv">$project_dir_name</span><span class="s2">&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">    --volume <span class="s2">&#34;</span><span class="nv">$HOME</span><span class="s2">/.</span><span class="si">${</span><span class="nv">profile</span><span class="si">}</span><span class="s2">:/home/node/.claude&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">    --volume <span class="s2">&#34;</span><span class="nv">$HOME</span><span class="s2">/.</span><span class="si">${</span><span class="nv">profile</span><span class="si">}</span><span class="s2">.json:/home/node/.claude.json&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">    nbr23/claudecode -p <span class="s2">&#34;</span><span class="nv">$prompt</span><span class="s2">&#34;</span> <span class="p">|</span> awk <span class="s1">&#39;{$1=$1;print}&#39;</span><span class="k">)</span>
</span></span><span class="line"><span class="cl">  
</span></span><span class="line"><span class="cl">  <span class="k">if</span> <span class="o">[[</span> -z <span class="s2">&#34;</span><span class="nv">$claude_response</span><span class="s2">&#34;</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then</span>
</span></span><span class="line"><span class="cl">    <span class="nb">echo</span> <span class="s2">&#34;Error: Failed to generate a commit message from Claude. Aborting.&#34;</span>
</span></span><span class="line"><span class="cl">    <span class="k">return</span> <span class="m">1</span>
</span></span><span class="line"><span class="cl">  <span class="k">fi</span>
</span></span><span class="line"><span class="cl">  
</span></span><span class="line"><span class="cl">  <span class="k">if</span> <span class="o">[[</span> <span class="s2">&#34;</span><span class="nv">$claude_response</span><span class="s2">&#34;</span> <span class="o">==</span> <span class="s2">&#34;None&#34;</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then</span>
</span></span><span class="line"><span class="cl">    <span class="nb">echo</span> <span class="s2">&#34;No appropriate Jira ticket found.&#34;</span>
</span></span><span class="line"><span class="cl">    <span class="k">return</span>
</span></span><span class="line"><span class="cl">  <span class="k">fi</span>
</span></span><span class="line"><span class="cl">  
</span></span><span class="line"><span class="cl">  <span class="nv">commit_message</span><span class="o">=</span><span class="k">$(</span><span class="nb">echo</span> <span class="s2">&#34;</span><span class="nv">$claude_response</span><span class="s2">&#34;</span> <span class="p">|</span> grep -oE <span class="s1">&#39;^[A-Z]+-[0-9]+ - .*$&#39;</span> <span class="p">|</span> head -n 1<span class="k">)</span>
</span></span><span class="line"><span class="cl">  
</span></span><span class="line"><span class="cl">  <span class="k">if</span> <span class="o">[[</span> -z <span class="s2">&#34;</span><span class="nv">$commit_message</span><span class="s2">&#34;</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then</span>
</span></span><span class="line"><span class="cl">    <span class="nb">echo</span> <span class="s2">&#34;Error: Claude response doesn&#39;t match expected commit message format.&#34;</span>
</span></span><span class="line"><span class="cl">    <span class="nb">echo</span> <span class="s2">&#34;Claude response: </span><span class="nv">$claude_response</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl">    <span class="k">return</span>
</span></span><span class="line"><span class="cl">  <span class="k">fi</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">  <span class="nb">local</span> line_count
</span></span><span class="line"><span class="cl">  <span class="nv">line_count</span><span class="o">=</span><span class="k">$(</span><span class="nb">echo</span> <span class="s2">&#34;</span><span class="nv">$commit_message</span><span class="s2">&#34;</span> <span class="p">|</span> wc -l<span class="k">)</span>
</span></span><span class="line"><span class="cl">  
</span></span><span class="line"><span class="cl">  <span class="k">if</span> <span class="o">[[</span> <span class="nv">$line_count</span> -gt <span class="m">1</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then</span>
</span></span><span class="line"><span class="cl">    <span class="nb">echo</span> <span class="s2">&#34;Error: Commit message must be only one line long.&#34;</span>
</span></span><span class="line"><span class="cl">    <span class="nb">echo</span> <span class="s2">&#34;Generated message:&#34;</span>
</span></span><span class="line"><span class="cl">    <span class="nb">echo</span> <span class="s2">&#34;</span><span class="nv">$commit_message</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl">    <span class="k">return</span> <span class="m">1</span>
</span></span><span class="line"><span class="cl">  <span class="k">fi</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">  <span class="nb">local</span> ticket_key
</span></span><span class="line"><span class="cl">  <span class="nv">ticket_key</span><span class="o">=</span><span class="k">$(</span><span class="nb">echo</span> <span class="s2">&#34;</span><span class="nv">$commit_message</span><span class="s2">&#34;</span> <span class="p">|</span> grep -oE <span class="s1">&#39;^[A-Z]+-[0-9]+&#39;</span> <span class="p">|</span> head -n 1<span class="k">)</span>
</span></span><span class="line"><span class="cl">  
</span></span><span class="line"><span class="cl">  <span class="k">if</span> <span class="o">[[</span> -z <span class="s2">&#34;</span><span class="nv">$ticket_key</span><span class="s2">&#34;</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then</span>
</span></span><span class="line"><span class="cl">    <span class="nb">echo</span> <span class="s2">&#34;Error: Commit message must start with a ticket number (e.g., ABC-123).&#34;</span>
</span></span><span class="line"><span class="cl">    <span class="nb">echo</span> <span class="s2">&#34;Generated message: </span><span class="nv">$commit_message</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl">    <span class="k">return</span> <span class="m">1</span>
</span></span><span class="line"><span class="cl">  <span class="k">fi</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">  <span class="nb">echo</span> <span class="s2">&#34;Selected Jira ticket: </span><span class="nv">$ticket_key</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="nb">echo</span> <span class="s2">&#34;</span><span class="nv">$jira_tickets</span><span class="s2">&#34;</span> <span class="p">|</span> jq -r <span class="s2">&#34;.[] | select(.key == \&#34;</span><span class="nv">$ticket_key</span><span class="s2">\&#34;) | \&#34;Key: \(.key)\nSummary: \(.summary)\nStatus: \(.status)\nIssue Type: \(.issuetype)\&#34;&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="nb">echo</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">  <span class="nb">echo</span> <span class="s2">&#34;Committing...&#34;</span>
</span></span><span class="line"><span class="cl">  git commit -m <span class="s2">&#34;</span><span class="nv">$commit_message</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span></span></span></code></pre></div></div>
        </div>
<!-- /noTTS -->
<p>Both run claude inside <a href="https://github.com/nbr23/claudecode/">docker</a>, but can be easily modified to run natively.</p>
<p>YMMV, and sometimes you need to run it a couple of times before it accepts to deliver a commit message and not a monologue on git (despite the <!-- tts say="all caps" -->ALL CAPS<!-- /tts --> instructions!!!), or figures out which LLM-generated ticket your <!-- tts say="project manager" -->PM<!-- /tts --> created matches the LLM-generated code you staged.</p>
]]></content:encoded>
      </item>
    
      <item>
        <title>Lookup and insert Jira ticket IDs in Vim</title>
        <link>https://nbr23.com/posts/vim-jira/?utm_source=rss</link>
        <pubDate>Wed, 25 Jun 2025 22:01:22 -0400</pubDate>
        <guid isPermaLink="false">https://wip.tf/posts/vim-jira/</guid>
        <description>A Vim integration to fuzzy-search and insert Jira ticket IDs without leaving the editor.</description>
        <content:encoded><![CDATA[<div class="text-to-speech-container">
    <span class="text-to-speech-label">Listen to this post:</span>
    <audio class="text-to-speech-audio" controls>
      <source src="https://nbr23.com/audio/tts/vim-jira.mp3" type="audio/mpeg">
      <a href="https://nbr23.com/audio/tts/vim-jira.mp3">Download the audio</a>
    </audio>
  </div>
  
<p>Navigating Jira’s UI to find your Task/Epic/Bug is a pain. Even copying the ticket ID is its own quest. You end up switching tabs, losing focus, and forgetting what you were doing.</p>
<p>To skip all that, I use a <a href="https://github.com/nbr23/jira-buddy">jira-buddy</a> and a Vim function to hit the Jira API, look up the ticket, and insert the ID directly into my document. I use it to insert the ticket ID for the current work in my commit messages.</p>
<p><img src="https://nbr23.com/posts/vim-jira/images/vim-jira.gif" alt="Animated demo of fuzzy-searching a Jira ticket from Vim and inserting its ID into the buffer" width="1702" height="722" loading="lazy" decoding="async">
</p>
<p>I tried without success to figure out which scopes my scoped API token needed. So I just use a personal API token instead.</p>
]]></content:encoded>
      </item>
    
      <item>
        <title>Listen to this article</title>
        <link>https://nbr23.com/posts/listen-to-this-article/?utm_source=rss</link>
        <pubDate>Fri, 06 Jun 2025 21:50:10 -0400</pubDate>
        <guid isPermaLink="false">https://wip.tf/posts/listen-to-this-article/</guid>
        <description>Adding a text-to-speech audio player to Hugo blog posts using a shortcode and a self-hosted TTS API.</description>
        <content:encoded><![CDATA[<div class="text-to-speech-container">
    <span class="text-to-speech-label">Listen to this post:</span>
    <audio class="text-to-speech-audio" controls>
      <source src="https://nbr23.com/audio/tts/listen-to-this-article.mp3" type="audio/mpeg">
      <a href="https://nbr23.com/audio/tts/listen-to-this-article.mp3">Download the audio</a>
    </audio>
  </div>
  
<p>Now that we know how to <a href="https://nbr23.com/posts/tts-setup/">listen to other people&rsquo;s content</a>, let&rsquo;s make sure other people can listen to our content!</p>
<p>This blog is generated using <a href="https://gohugo.io">hugo</a> and uses a theme based on <a href="https://github.com/SeriousBug/hugo-theme-catafalque">catafalque</a>.</p>
<p>Leveraging my <a href="https://github.com/nbr23/gopipertts">piper api wrapper</a>, I created a <a href="https://github.com/nbr23/hugo-shortcodes-tts">hugo-shortcodes-tts</a>. The shortcode sends the hugo post&rsquo;s content to the TTS API, saves it as a static file, and embeds a player into the post&rsquo;s page as can be seen at the top of this article.</p>
<p>Setup and configuration documentation is available in the shortcode&rsquo;s <a href="https://github.com/nbr23/hugo-shortcodes-tts#hugo-shortcodes-tts">README</a> for the hugo setup and in gopipertts&rsquo;s <a href="https://github.com/nbr23/gopipertts?tab=readme-ov-file#gopipertts">README</a> for the TTS API.</p>
]]></content:encoded>
      </item>
    
      <item>
        <title>My self-hosted TextToSpeech setup</title>
        <link>https://nbr23.com/posts/tts-setup/?utm_source=rss</link>
        <pubDate>Sun, 13 Apr 2025 20:33:45 -0400</pubDate>
        <guid isPermaLink="false">https://wip.tf/posts/tts-setup/</guid>
        <description>My self-hosted text-to-speech pipeline for reading web content aloud on Linux.</description>
        <content:encoded><![CDATA[<div class="text-to-speech-container">
    <span class="text-to-speech-label">Listen to this post:</span>
    <audio class="text-to-speech-audio" controls>
      <source src="https://nbr23.com/audio/tts/tts-setup.mp3" type="audio/mpeg">
      <a href="https://nbr23.com/audio/tts/tts-setup.mp3">Download the audio</a>
    </audio>
  </div>
  
<p>For a while, I had been using a simple keyboard shortcut for <!-- tts say="x clip piped into e speak N G" --><code>xclip -o | espeak-ng</code><!-- /tts --> as my TextToSpeech setup. I mostly use it in-browser, highlighting text and using the shortcut to speak the highlighted text.</p>
<p>I have been meaning to update it, get more modern voices and make it easier to setup on heterogenous environments (fancy way to say I struggle to have reliable hotkey actions on my work macbook).</p>
<p>After setting up a <a href="https://www.home-assistant.io/voice_control/voice_remote_local_assistant/">voice assistant on homeassistant</a> using <a href="https://github.com/rhasspy/piper">piper</a>, and being impressed with the quality of the voices, I decided to give piper a go.</p>
<h2 id="new-setup">New Setup</h2>
<p>I am now using this simple <a href="https://github.com/nbr23/sayoutloud">Firefox Addon</a> I built to grab the highlighted text, and send it to <a href="https://github.com/nbr23/gopipertts">this API wrapper</a> I built around the piper binary.</p>
<h3 id="firefox-addon">Firefox Addon</h3>
<p><img src="https://nbr23.com/posts/tts-setup/images/sayoutloud-menu.png#smaller" alt="Firefox context menu on highlighted Wikipedia text showing the SayOutLoud entry with English and French options" width="1680" height="1422" loading="lazy" decoding="async">
</p>
<p>The addon simply adds a keyboard shortcut and context menu. When executed, the addon&rsquo;s background script sends the highlighted text to the TTS API through a <code>POST</code> request (along with the saved voice and speech speed preferences) to the <code>/api/stream</code> endpoint.
The API instantly returns a unique URL for the stream. The Addon then injects through the content script an audio player pointing to the returned URL into the current page. It then starts the playback.</p>
<p><img src="https://nbr23.com/posts/tts-setup/images/sayoutloud-player.png#smaller" alt="Audio player injected into the page by SayOutLoud, playing the synthesized speech of the highlighted text" width="1024" height="378" loading="lazy" decoding="async">
</p>
<p>I initially tried relying only on the background script to play the speech, but audio playback would get cut after a few seconds (it seems background scripts are not meant to run for this long). Combining the background script with a content script turned out to be a better option with the UI allowing the user some control on the playback.</p>
<h3 id="piper-api-wrapper">Piper API Wrapper</h3>
<p>The <code>/api/stream</code> endpoint accepts <code>POST</code> requests with playback options (voice, speed, &hellip;) and text. It assigns a <code>UUID</code> to the request, saves it in memory, and returns a URL referencing this stream <code>UUID</code>.</p>
<p>When a stream <code>UUID</code> <!-- tts say="U R L" -->url<!-- /tts --> is accessed, the options are fetched from the cache and passed to the <code>piper</code> binary to start generating the raw audio.</p>
<p>Streaming compatible WAV headers are sent back to the client. Raw audio chunks are sent back to the client as soon as <code>piper</code> starts generating them.</p>
<p>The <code>/api/stream</code> endpoint returning a unique stream URL trick allows us to easily play the audio in the browser using an <!-- tts say="audio" --><code>&lt;audio&gt;</code><!-- /tts --> tag (which performs a <code>GET</code> request).</p>
<p>I initially opted for an <a href="https://github.com/nbr23/wyoming-piper-http-bridge">HTTP to wyoming bridge</a>. This worked fine, but wyoming was an unnecessary overhead, and waited for the full text to be processed to start returning audio, resulting in long delays (especially running this on a raspi) before the TTS started its speaking.
Calling directly the piper binary from my wrapper allowed me to pass the <!-- tts say="dash dash output raw" --><code>--output-raw</code><!-- /tts --> flag, and start getting audio data much earlier, streaming it back to the client without waiting for the entire potentially large text to be processed.</p>
<h2 id="final-thoughts">Final thoughts</h2>
<p>Even with streaming, there&rsquo;s still slightly more delay on speech start with piper compared to the local <code>xclip</code> to <code>espeak</code>. YMMV if you use a beefier box than me.</p>
<p>Overall I like the in-browser integration and the <!-- tts say="H T M L" -->html<!-- /tts --> interface on <a href="https://github.com/nbr23/gopipertts">gopipertts</a> if I need to quickly TTS from a non browser source.</p>
<p><img src="https://nbr23.com/posts/tts-setup/images/gopipertts-tartines.png#smaller" alt="gopipertts web interface: a text box with French text, language and voice selectors, and an audio player with the generated speech" width="1702" height="1410" loading="lazy" decoding="async">
</p>
<p>The piper voices are a real improvement over what <code>espeak</code> provides&hellip; In English.</p>
<p>French is a different story&hellip; or perhaps this is what we sound like when saying &ldquo;tartine&rdquo;?</p>

<p>
<audio controls="" src="https://nbr23.com/posts/tts-setup/audio/tartine.wav"><a href="https://nbr23.com/posts/tts-setup/audio/tartine.wav">Download the audio</a></audio>
</p>

]]></content:encoded>
      </item>
    
      <item>
        <title>XSLT - make your RSS feed look like your front page</title>
        <link>https://nbr23.com/posts/rss-xsl/?utm_source=rss</link>
        <pubDate>Wed, 10 Jul 2024 22:18:24 -0400</pubDate>
        <guid isPermaLink="false">https://wip.tf/posts/rss-xsl/</guid>
        <description>Using XSLT to style my blog&#39;s RSS feed so it renders like the site&#39;s front page in browsers.</description>
        <content:encoded><![CDATA[<div class="text-to-speech-container">
    <span class="text-to-speech-label">Listen to this post:</span>
    <audio class="text-to-speech-audio" controls>
      <source src="https://nbr23.com/audio/tts/rss-xsl.mp3" type="audio/mpeg">
      <a href="https://nbr23.com/audio/tts/rss-xsl.mp3">Download the audio</a>
    </audio>
  </div>
  
<p>After stumbling upon <a href="https://darekkay.com/blog/rss-styling/">this post</a> I decided to give <a href="https://en.wikipedia.org/wiki/XSLT">XSLT</a> a go.</p>
<h2 id="a-few-examples">A few examples</h2>
<ol>
<li>
<p>Making my blog&rsquo;s RSS feed look like my front page: This site&rsquo;s <a href="https://nbr23.com/posts/index.xml">RSS feed</a> visually mimics its <a href="https://nbr23.com/">front page</a>.</p>
</li>
<li>
<p><a href="https://github.com/nbr23/rss-banquet/blob/master/style/style.go">Prettifying</a> the output of my <a href="https://github.com/nbr23/rss-banquet/">feed generator</a>.
<img src="https://nbr23.com/posts/rss-xsl/images/rss-banquet.png#center" alt="rss-banquet RSS feed styled with XSLT: Lego product announcements rendered as a readable list with images, titles and prices, topped by a banner explaining the page is an RSS feed" width="2460" height="1552" loading="lazy" decoding="async">
</p>
</li>
<li>
<p><a href="https://github.com/nbr23/ydl-podcast/blob/master/ydl_podcast/templates/style.py">Beautiful Podcast Feed</a> with embedded episode player for my <a href="https://github.com/nbr23/ydl-podcast">youtube to podcast</a> project.</p>
</li>
</ol>
<figure class="img-side-by-side">
<div class="img-side-by-side-images">
<img src="https://nbr23.com/posts/rss-xsl/images/audio-podcast.png" alt="XSLT-styled audio podcast feed for the EFF podcast, each episode shown with its artwork, description and an embedded audio player" width="1272" height="1540" loading="lazy" decoding="async">
<img src="https://nbr23.com/posts/rss-xsl/images/video-podcast.png" alt="XSLT-styled video podcast feed of Blender release reels, each episode with an embedded video player" width="1272" height="1540" loading="lazy" decoding="async">
</div>
</figure>
<h2 id="some-notes-after-playing-with-xslt-in-a-few-projects">Some notes after playing with XSLT in a few projects:</h2>
<ol>
<li>Styling your site&rsquo;s feed to match your site&rsquo;s appearance is trivial, but probably confusing when a user expects to have clicked on an RSS feed (thus the orange banner on this site&rsquo;s feed).</li>
<li>Poor support across browsers:</li>
</ol>
<ul>
<li>Safari appears to ignore <code>Content-type</code>, doesn&rsquo;t want to display the <code>XML</code> at all:</li>
</ul>
<p><img src="https://nbr23.com/posts/rss-xsl/images/safari.png#center" alt="Safari dialog proposing to search the App Store for RSS reader apps instead of displaying the XML feed" width="886" height="246" loading="lazy" decoding="async">
</p>
<ul>
<li>Embedding the <code>xsl</code> file into the <code>xml</code> page is possible, and works on Firefox but not Chrome.</li>
</ul>
<p>On Firefox this can be achieve easily:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-xml"><span class="line"><span class="cl"><span class="cp">&lt;?xml-stylesheet type=&#34;text/xsl&#34; href=&#34;#rss-stylesheet&#34;?&gt;</span>
</span></span><span class="line"><span class="cl"><span class="nt">&lt;rss&gt;</span>
</span></span><span class="line"><span class="cl">  ...
</span></span><span class="line"><span class="cl">  <span class="nt">&lt;xsl:stylesheet</span> <span class="na">id=</span><span class="s">&#34;rss-stylesheet&#34;</span><span class="nt">&gt;</span>
</span></span><span class="line"><span class="cl">    ...
</span></span><span class="line"><span class="cl">  <span class="nt">&lt;/xsl:stylesheet&gt;</span>
</span></span><span class="line"><span class="cl"><span class="nt">&lt;/rss&gt;</span>
</span></span></code></pre></div><!-- /noTTS -->
<p>But on Chrome it will only show a white page. Some background on why <a href="https://stackoverflow.com/questions/4558160/xsl-not-working-in-google-chrome/6251807#6251807">here</a>.</p>
<ul>
<li>Firefox does not support <code>disable-output-escaping</code>:</li>
</ul>
<p>This flag should prevent escaping of <!-- tts say="angle bracket" --><code>&lt;&gt;</code><!-- /tts --> characters, allowing <code>HTML</code> from the feed&rsquo;s content to be rendered. Firefox does not seem to be supporting it, contrary to Chrome.</p>
<p>Note that if <code>disable-output-escaping</code> is <code>off</code>, <!-- tts say="script" --><code>&lt;script&gt;</code><!-- /tts --> tags won&rsquo;t get escaped either and Chrome will execute their content!</p>
<h2 id="links-and-references">Links and References</h2>
<ul>
<li><a href="https://darekkay.com/blog/rss-styling/">[0]</a> - Style your RSS feed</li>
<li><a href="https://en.wikipedia.org/wiki/XSLT">[1]</a> - Wikipedia - XSLT</li>
<li><a href="https://github.com/nbr23/rss-banquet/">[2]</a> - RSS Banquet - A Modular Atom/RSS Feed Generator</li>
<li><a href="https://github.com/nbr23/ydl-podcast">[3]</a> - Ydl-Podcast -  A simple tool to generate Podcast like RSS feeds from youtube (or other youtube-dl supported services) channels, using youtube-dl</li>
<li><a href="https://nbr23.com/posts/index.xml">[4]</a> - This blog&rsquo;s RSS Feed</li>
<li><a href="https://nbr23.com/style.xsl">[5]</a> - This blog&rsquo;s RSS Feed&rsquo;s XSLT template/stylesheet (which you will note is an XML file and could be, itself, styled&hellip;)</li>
</ul>
]]></content:encoded>
      </item>
    
      <item>
        <title>RSS/Atom feed of Docker image pushes to DockerHub</title>
        <link>https://nbr23.com/posts/dockerrss/?utm_source=rss</link>
        <pubDate>Tue, 07 Mar 2023 21:16:44 -0500</pubDate>
        <guid isPermaLink="false">https://wip.tf/posts/dockerrss/</guid>
        <description>Generating an RSS/Atom feed for DockerHub image pushes to trigger CI/CD deployments without Dependabot.</description>
        <content:encoded><![CDATA[<div class="text-to-speech-container">
    <span class="text-to-speech-label">Listen to this post:</span>
    <audio class="text-to-speech-audio" controls>
      <source src="https://nbr23.com/audio/tts/dockerrss.mp3" type="audio/mpeg">
      <a href="https://nbr23.com/audio/tts/dockerrss.mp3">Download the audio</a>
    </audio>
  </div>
  
<p>Some of my CI/CD deployments need to be triggered when a new docker image is pushed with a specific tag for a specific architecture, to stay up to date.</p>
<p>A lot of these image updates can be dealt with dependabot/renovate, creating a PR with the new release, or with tools like <a href="https://github.com/containrrr/watchtower">watchtower</a>.</p>
<p>In more &ldquo;complex&rdquo; cases however, I need my Jenkins instance to be aware of the new image being pushed to perform actions before and after pulling the image and recreating the container.</p>
<p>I built <a href="https://github.com/nbr23/dockerRSS" class="github-link"><span>DockerRSS</span></a> (now <a href="https://github.com/nbr23/rss-banquet" class="github-link"><span>rss-banquet</span></a>) for this, polling the Dockerhub API and formatting the image pushes data into an RSS feed. Its best use for me is in generating a feed for a specific tag (typically <code>latest</code>) and filtering for a specific platform (<code>linux/arm64</code> in my case), to only get the image pushes I am interested in.</p>
<p>Using the <a href="https://plugins.jenkins.io/urltrigger/">UrlTrigger</a> Jenkins plugin, my pipelines get triggered by new pushes to DockerHub:</p>
<!-- noTTS -->
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-groovy"><span class="line"><span class="cl"><span class="n">pipeline</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">agent</span> <span class="n">any</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="o">[...]</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">    <span class="n">triggers</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">        <span class="n">URLTrigger</span><span class="o">(</span>
</span></span><span class="line"><span class="cl">            <span class="nl">triggerLabel:</span> <span class="s1">&#39;my-agent&#39;</span><span class="o">,</span>
</span></span><span class="line"><span class="cl">            <span class="nl">labelRestriction:</span> <span class="kc">true</span><span class="o">,</span>
</span></span><span class="line"><span class="cl">            <span class="nl">cronTabSpec:</span> <span class="s1">&#39;H/15 * * * *&#39;</span><span class="o">,</span>
</span></span><span class="line"><span class="cl">            <span class="nl">entries:</span> <span class="o">[</span>
</span></span><span class="line"><span class="cl">                <span class="n">URLTriggerEntry</span><span class="o">(</span>
</span></span><span class="line"><span class="cl">                    <span class="nl">url:</span> <span class="s1">&#39;https://banquet/dockerhub/nbr23/rss-banquet:server-latest?platform=linux/arm64&#39;</span><span class="o">,</span>
</span></span><span class="line"><span class="cl">                    <span class="nl">requestHeaders:</span> <span class="o">[</span>
</span></span><span class="line"><span class="cl">                        <span class="n">RequestHeader</span><span class="o">(</span> <span class="nl">headerName:</span> <span class="s2">&#34;Accept&#34;</span> <span class="o">,</span> <span class="nl">headerValue:</span> <span class="s2">&#34;application/atom+xml&#34;</span> <span class="o">)</span>
</span></span><span class="line"><span class="cl">                    <span class="o">],</span>
</span></span><span class="line"><span class="cl">                    <span class="nl">contentTypes:</span> <span class="o">[</span>
</span></span><span class="line"><span class="cl">                        <span class="n">XMLContent</span><span class="o">(</span>
</span></span><span class="line"><span class="cl">                            <span class="o">[</span>
</span></span><span class="line"><span class="cl">                                <span class="n">XMLContentEntry</span><span class="o">(</span> <span class="nl">xPath:</span> <span class="s1">&#39;feed/entry[1]/id&#39;</span> <span class="o">)</span>
</span></span><span class="line"><span class="cl">                            <span class="o">])</span>
</span></span><span class="line"><span class="cl">                    <span class="o">]</span>
</span></span><span class="line"><span class="cl">                <span class="o">)</span>
</span></span><span class="line"><span class="cl">            <span class="o">]</span>
</span></span><span class="line"><span class="cl">        <span class="o">)</span>
</span></span><span class="line"><span class="cl">    <span class="o">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="o">[...]</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span></code></pre></div><!-- /noTTS -->
<p>I also enjoy having the feed of DockerHub image pushes in the &lsquo;Releases&rsquo; section of my RSS Reader, at least for now. This allows me to keep track of interesting images or images that I maintain.</p>
<h2 id="2024-02-01-update">2024-02-01 Update:</h2>
<p>I have consolidated dockerRSS and other RSS/Atom feed tools into <a href="https://github.com/nbr23/rss-banquet" class="github-link"><span>rss-banquet</span></a>, and archived dockerRSS.</p>
]]></content:encoded>
      </item>
    
      <item>
        <title>Bistrobot: orchestrating cat food dispensing with Raspberry Pies</title>
        <link>https://nbr23.com/posts/bistrobot-orchestrating-cat-foot-dispensing-raspberry-pi/?utm_source=rss</link>
        <pubDate>Wed, 01 Feb 2023 22:52:55 -0500</pubDate>
        <guid isPermaLink="false">https://wip.tf/posts/bistrobot-orchestrating-cat-foot-dispensing-raspberry-pi/</guid>
        <description>Building an automated cat food dispensing system with Raspberry Pis to synchronize my two cats&#39; feedings.</description>
        <content:encoded><![CDATA[<div class="text-to-speech-container">
    <span class="text-to-speech-label">Listen to this post:</span>
    <audio class="text-to-speech-audio" controls>
      <source src="https://nbr23.com/audio/tts/bistrobot-orchestrating-cat-foot-dispensing-raspberry-pi.mp3" type="audio/mpeg">
      <a href="https://nbr23.com/audio/tts/bistrobot-orchestrating-cat-foot-dispensing-raspberry-pi.mp3">Download the audio</a>
    </audio>
  </div>
  
<h2 id="problem">Problem</h2>
<p>I live with two cats:</p>
<ul>
<li><code>cat 1</code>, who has food anxiety and can meow for hours if his eating schedule is disrupted;</li>
<li><code>cat 2</code>, who eats faster than his own shadow.</li>
</ul>
<p>To fix <!-- tts say="cat one's" --><code>cat 1</code>&rsquo;s<!-- /tts --> food anxiety, we purchased two food dispensers online (each has a different branding but they are exactly the same product). These &ldquo;robots&rdquo; are simple, non-connected devices. Current time, meal sizes and schedules are manually configured through a <a href="https://nbr23.com/posts/bistrobot-orchestrating-cat-foot-dispensing-raspberry-pi/images/user_interface.jpg">rudimentary interface</a>.</p>
<p>As a result of this manual setup, it is near impossible to have them perfectly synced, and even if achieved, they get out of sync quickly.</p>
<p>This leads us to the second problem:</p>
<p><img src="https://nbr23.com/posts/bistrobot-orchestrating-cat-foot-dispensing-raspberry-pi/images/race_conditions.gif#center" alt="race conditions: cat 2 eats both meals while the cat 1 watches, dumbfounded" title="race conditions: cat 2 eats both meals while the cat 1 watches, dumbfounded" width="300" height="278" loading="lazy" decoding="async">
</p>
<ul>
<li>If both robots dispense the scheduled meal even just a second apart, <code>cat 2</code> will gulp the first dispensed meal <strong>and</strong> rush to the second robot to eat the other meal, leaving <code>cat 1</code> dumbfounded and hungry (bringing us back to <a href="https://nbr23.com/posts/bistrobot-orchestrating-cat-foot-dispensing-raspberry-pi/#problem">square 0</a>).</li>
</ul>
<h2 id="solution">Solution</h2>
<p>To perfectly synchronize the two robots, I gutted them and replaced the internals with a <strong><a href="https://www.raspberrypi.com/products/raspberry-pi-zero-w/">Raspberry Pi Zero W</a></strong> each.</p>
<p><img src="https://nbr23.com/posts/bistrobot-orchestrating-cat-foot-dispensing-raspberry-pi/images/peek.jpg#smaller" alt="cat 1 performing a sniff test" title="cat 1 performing a sniff test" width="2765" height="2074" loading="lazy" decoding="async">
</p>
<p>Both robots are now <strong><code>ntp</code> synchronized,</strong> and they pilot the motor for the dispensing mechanism through <strong>GPIO</strong>.</p>
<p>Scheduling is done through a <code>crontab</code> on each Raspberry Pi, which I push using <code>ansible</code>.</p>
<p>This solution also permits remote one-shot meals for emergency through <code>ssh</code>/<code>ansible</code>.</p>
<p>3 GPIO pins are used:</p>
<ul>
<li>One <code>input</code>: the <a href="https://nbr23.com/posts/bistrobot-orchestrating-cat-foot-dispensing-raspberry-pi/images/position_sensor.jpg">position trigger sensor</a> for the <a href="https://nbr23.com/posts/bistrobot-orchestrating-cat-foot-dispensing-raspberry-pi/images/dispenser_wheel.jpg">dispenser wheel</a>;</li>
<li>Two <code>outputs</code>:
<ul>
<li>one for the transistor triggering the <a href="https://nbr23.com/posts/bistrobot-orchestrating-cat-foot-dispensing-raspberry-pi/images/motor.jpg">motor</a> which rotates the dispenser wheel;</li>
<li>one for a buzzer to &ldquo;announce&rdquo; meals to the cats.</li>
</ul>
</li>
</ul>
<p><img src="https://nbr23.com/posts/bistrobot-orchestrating-cat-foot-dispensing-raspberry-pi/images/final_product.jpg#smaller" alt="bistrobot internals: the raspberry pi zero w, hooked up to the food dispenser&#39;s motor and sensors" title="bistrobot internals: the raspberry pi zero w, hooked up to the food dispenser&#39;s motor and sensors" width="2074" height="2765" loading="lazy" decoding="async">
</p>
<h2 id="side-effect">Side effect</h2>
<p>The python GPIO initialization appears to be driving a slight current during initialization, which is inaudible to me, but allows the cats to anticipate the actual buzzing: they now rush to their respective feeder <strong>before</strong> the buzzer even announces the upcoming meal.</p>
<h2 id="happy-ending">Happy Ending</h2>
<p>With both robots perfectly synced, <code>cat 1</code> and <code>cat 2</code> now enjoy their meals worry-free.</p>
<p><img src="https://nbr23.com/posts/bistrobot-orchestrating-cat-foot-dispensing-raspberry-pi/images/happy_meal.jpg#smaller" alt="cat 1 and 2 eating happily side by side" title="cat 1 and 2 eating happily side by side" width="2765" height="2074" loading="lazy" decoding="async">
</p>
<h2 id="links">Links</h2>
<ul>
<li><a href="https://github.com/nbr23/bistrobot">GPIO controller Bistrobot&rsquo;s github repository</a></li>
<li><a href="https://pinout.xyz/">Handy RbPi GPIO pins guide</a></li>
</ul>
]]></content:encoded>
      </item>
    
  </channel>
</rss>
