<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>datenzwerg on foosel.net</title><link>https://foosel.net/tags/datenzwerg/</link><description>Recent content in datenzwerg on foosel.net</description><generator>Hugo</generator><language>en-us</language><copyright>Gina Häußge (foosel)</copyright><lastBuildDate>Thu, 26 Dec 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://foosel.net/tags/datenzwerg/feed.xml" rel="self" type="application/rss+xml"/><item><title>TIL: How to fetch additional data for a flux query from a json file</title><link>https://foosel.net/til/2024-12-26-how-to-fetch-additional-data-for-a-flux-query-from-a-json-file/</link><pubDate>Thu, 26 Dec 2024 00:00:00 +0000</pubDate><guid>https://foosel.net/til/2024-12-26-how-to-fetch-additional-data-for-a-flux-query-from-a-json-file/</guid><description>&lt;p&gt;My buddy Romses is currently taking care of the &lt;a href="https://datagnome.de"&gt;Datenzwerg deployment&lt;/a&gt; at 38c3, and like at every event where we deploy them I&amp;rsquo;m updating our page and &lt;a href="https://grafana.datagnome.de"&gt;Grafana dashboard&lt;/a&gt; with the locations of the gnomes.&lt;/p&gt;
&lt;p&gt;So far the latter was always quite annoying: We have only the names of the gnomes in our influx data, and adding the location/deployment status to the graph thus meant having something like this for every single graph:&lt;/p&gt;</description><content:encoded><![CDATA[<p>My buddy Romses is currently taking care of the <a href="https://datagnome.de">Datenzwerg deployment</a> at 38c3, and like at every event where we deploy them I&rsquo;m updating our page and <a href="https://grafana.datagnome.de">Grafana dashboard</a> with the locations of the gnomes.</p>
<p>So far the latter was always quite annoying: We have only the names of the gnomes in our influx data, and adding the location/deployment status to the graph thus meant having something like this for every single graph:</p>
<pre tabindex="0"><code class="language-flux" data-lang="flux">import &#34;strings&#34;
import &#34;dict&#34;

locations = [
    &#34;Bashful&#34;: &#34;Uptime Bar&#34;,
    &#34;Dopey&#34;: &#34;c3cat&#34;,
    &#34;Grumpy&#34;: &#34;Späti&#34;,
    &#34;Happy&#34;: &#34;Kidspace&#34;,
    &#34;Hefty&#34;: &#34;HASS Assembly&#34;,
    &#34;Moopsy&#34;: &#34;Chaospost&#34;,
    &#34;Kinky&#34;: &#34;Eventphone&#34;,
    &#34;Nerdy&#34;: &#34;House of Tea&#34;,
    &#34;Sleepy&#34;: &#34;DDOS Bar&#34;,
    &#34;Sneezy&#34;: &#34;Wohnzimmer&#34;
]

from(bucket: &#34;datagnome&#34;)
  [...]
  |&gt; map(fn: (r) =&gt; ({r with device: r.device + &#34; (&#34; + dict.get(dict: locations, key: r.device, default: &#34;?&#34;) + &#34;)&#34;}))
</code></pre><p>Which of course means that I had to update this <code>locations</code> dict for every single panel, on every single deployment, at least twice (start and end of the event).</p>
<p>I finally decided I had to solve this differently and just now figured out how to keep the deployment info in <a href="https://github.com/romses/Datenzwerg/blob/main/docs/deployment.json">a JSON file on our git repo</a> and then querying <em>that</em> from the graphs, instead of manually keeping the lookup data updated in more than one place:</p>
<pre tabindex="0"><code class="language-flux" data-lang="flux">import &#34;strings&#34;
import &#34;dict&#34;
import &#34;http/requests&#34;
import &#34;experimental/json&#34;

response = requests.get(url: &#34;https://raw.githubusercontent.com/romses/Datenzwerg/refs/heads/main/docs/deployment.json&#34;)
data = json.parse(data: response.body)
locations = dict.fromList(pairs: data)

from(bucket: &#34;datagnome&#34;)
  [...]
  |&gt; map(fn: (r) =&gt; ({r with device: r.device + &#34; (&#34; + dict.get(dict: locations, key: r.device, default: &#34;?&#34;) + &#34;)&#34;}))
</code></pre><p>So far seems to work well, and I&rsquo;m very happy to be able to do this faster now (and also more easily from my phone, should I need to).</p>
<p>Next step: Figuring out how to use that JSON file to also keep the event box on the home page updated. But that&rsquo;s for another day :)</p>
]]></content:encoded></item><item><title>TIL: Why ESPHome might fail compiling a custom component with 'fatal error: string: No such file or directory'</title><link>https://foosel.net/til/2023-07-14-why-esphome-might-fail-compiling-a-custom-component/</link><pubDate>Fri, 14 Jul 2023 00:00:00 +0000</pubDate><guid>https://foosel.net/til/2023-07-14-why-esphome-might-fail-compiling-a-custom-component/</guid><description>&lt;p&gt;I just spent several hours trying to figure out why ESPHome refused to compile a custom component I was working on. The error message I got was&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;Compiling .pioenvs/datenzwerg-sleepy/src/esphome/components/sound_pressure/sound_pressure_sensor.c.o
In file included from src/esphome/components/sound_pressure/sound_pressure_sensor.h:3,
from src/esphome/components/sound_pressure/sound_pressure_sensor.c:1:
src/esphome/core/component.h:3:10: fatal error: string: No such file or directory
3 | #include &amp;lt;string&amp;gt;
| ^~~~~~~~
compilation terminated.
Compiling .pioenvs/datenzwerg-sleepy/src/main.cpp.o
*** [.pioenvs/datenzwerg-sleepy/src/esphome/components/sound_pressure/sound_pressure_sensor.c.o] Error 1
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Other external and internal components compiled just fine, so that was quite a head scratcher, until I just &lt;em&gt;finally&lt;/em&gt; noticed something in my source tree: my custom component&amp;rsquo;s source file had the file ending &lt;code&gt;.c&lt;/code&gt; instead of &lt;code&gt;.cpp&lt;/code&gt;. And that caused all of this, a quick rename from &lt;code&gt;sound_pressure_sensor.c&lt;/code&gt; to &lt;code&gt;sound_pressure_sensor.cpp&lt;/code&gt; resolved the compilation error 🤦‍♀️&lt;/p&gt;</description><content:encoded><![CDATA[<p>I just spent several hours trying to figure out why ESPHome refused to compile a custom component I was working on. The error message I got was</p>
<pre tabindex="0"><code>Compiling .pioenvs/datenzwerg-sleepy/src/esphome/components/sound_pressure/sound_pressure_sensor.c.o
In file included from src/esphome/components/sound_pressure/sound_pressure_sensor.h:3,
                 from src/esphome/components/sound_pressure/sound_pressure_sensor.c:1:
src/esphome/core/component.h:3:10: fatal error: string: No such file or directory
    3 | #include &lt;string&gt;
      |          ^~~~~~~~
compilation terminated.
Compiling .pioenvs/datenzwerg-sleepy/src/main.cpp.o
*** [.pioenvs/datenzwerg-sleepy/src/esphome/components/sound_pressure/sound_pressure_sensor.c.o] Error 1
</code></pre><p>Other external and internal components compiled just fine, so that was quite a head scratcher, until I just <em>finally</em> noticed something in my source tree: my custom component&rsquo;s source file had the file ending <code>.c</code> instead of <code>.cpp</code>. And that caused all of this, a quick rename from <code>sound_pressure_sensor.c</code> to <code>sound_pressure_sensor.cpp</code> resolved the compilation error 🤦‍♀️</p>
<p>And since it was utterly impossible for me to find anything about this particular problem online, I decided to share my mishap with all of you here, so that in the future someone else doing an internet search for this will have more luck than me today and not waste hours on this 😅</p>
]]></content:encoded></item></channel></rss>