<feedxmlns="http://www.w3.org/2005/Atom"><title>balkian.com - misc</title><linkhref="http://balkian.com/"rel="alternate"></link><linkhref="http://balkian.com/feeds/misc.atom.xml"rel="self"></link><id>http://balkian.com/</id><updated>2019-01-06T10:00:00+01:00</updated><entry><title>Controlling Zigbee devices with MQTT</title><linkhref="http://balkian.com/controlling-zigbee-devices-with-mqtt.html"rel="alternate"></link><published>2019-01-06T10:00:00+01:00</published><updated>2019-01-06T10:00:00+01:00</updated><author><name>J. Fernando Sánchez</name></author><id>tag:balkian.com,2019-01-06:/controlling-zigbee-devices-with-mqtt.html</id><summarytype="html"><p>This is a short tutorial on connecting a zigbee device (an Aqara cube) to an MQTT server, so you can control your zigbee devices from the network.</p>
<p>If you're anything like me, you're probably a sucker for IoT devices.
For a long time, I've been using WiFi-enabled lights, and Amazon …</p></summary><contenttype="html"><p>This is a short tutorial on connecting a zigbee device (an Aqara cube) to an MQTT server, so you can control your zigbee devices from the network.</p>
<p>If you're anything like me, you're probably a sucker for IoT devices.
For a long time, I've been using WiFi-enabled lights, and Amazon dash buttons to control them.
To keep these (cheap Chinese) internet enabled devices away from your network and their respective cloud services, you'll probably want to set up a dedicated network in your router (more on this on a future post, maybe).
Another disadvantage of WiFi devices is that they're relatively power hungry.</p>
<p>A popular alternative is using ZigBee for communication.
It is a dedicated protocol similar to bluetooth (BLE), with lower power requirements and bitrate.</p>
<p>Take the (super cute) aqara cube as an example.
It is a small cube that detects rotation on all of its axes, and tapping events.
Here's a video:</p>
<div class="youtube youtube-16x9"><iframe src="https://www.youtube.com/embed/5YtqG1wEnng" allowfullscreen seamless frameBorder="0"></iframe></div><p>To connect to zigbee devices you will need a zigbee enabled gateway (a.k.a. hub), which connects to your WiFi network and your zigbee devices.
Once again, this means adding an internet-enabled device to your home, and probably a couple of cloud services.</p>
<p>As an alternative, you can set up your own zigbee gateway, and control it to your home automation platform of choice (e.g. home assistant).
We will cover how to set up a zigbee2mqtt gateway that is also connected to an MQTT server, so you can use MQTT to control your devices and get notifications.</p>
For that, you only need to follow the instructions from the <a class="reference external" href="https://koenkk.github.io/zigbee2mqtt/">zigbee2mqtt documentation</a>.</p>
<p>Once you're done flashing, you're ready to set up the zigbee2mqtt server.
For convenience, I wrote a simple docker-compose to deploy a zigbee2mqtt server and a test mosquitto server:</p>
</td></tr></table><p>zigbee2mqtt supports the following events for the aqara cube: shake, wakeup, fall, tap, slide, flip180, flip90, rotate_left and rotate_right.
Every event has additional information, such as the sides involved, or the degrees turned.</p>
<p>Now you are ready to set up home assistant support in zigbee2mqtt following <a class="reference external" href="https://koenkk.github.io/zigbee2mqtt/integration/home_assistant.html">this guide</a>.</p>
</content><categoryterm="mqtt"></category><categoryterm="iot"></category><categoryterm="zigbee"></category></entry><entry><title>Progress bars in python</title><linkhref="http://balkian.com/progress-bars-in-python.html"rel="alternate"></link><published>2016-09-28T18:47:00+02:00</published><updated>2016-09-28T18:47:00+02:00</updated><author><name>J. Fernando Sánchez</name></author><id>tag:balkian.com,2016-09-28:/progress-bars-in-python.html</id><summarytype="html"><p><a class="reference external" href="https://github.com/noamraph/tqdm">tqdm</a> is a nice way to add progress bars in the command line or in a jupyter notebook.</p>
</td></tr></table></summary><contenttype="html"><p><a class="reference external" href="https://github.com/noamraph/tqdm">tqdm</a> is a nice way to add progress bars in the command line or in a jupyter notebook.</p>
</td></tr></table></content><categoryterm="python"></category></entry><entry><title>Sharing dotfiles</title><linkhref="http://balkian.com/sharing-dotfiles.html"rel="alternate"></link><published>2015-04-10T17:47:00+02:00</published><updated>2015-04-10T17:47:00+02:00</updated><author><name>J. Fernando Sánchez</name></author><id>tag:balkian.com,2015-04-10:/sharing-dotfiles.html</id><summarytype="html"><p>Today's post is half a quick note, half public shaming. In other words, it is a reminder to be very careful with OAuth tokens and passwords.</p>
<p>As part of moving to emacs, I starting using the incredibly useful <a class="reference external" href="https://github.com/defunkt/gist.el">gh.el</a>.
When you first use it, the extension saves either your …</p></summary><contenttype="html"><p>Today's post is half a quick note, half public shaming. In other words, it is a reminder to be very careful with OAuth tokens and passwords.</p>
<p>As part of moving to emacs, I starting using the incredibly useful <a class="reference external" href="https://github.com/defunkt/gist.el">gh.el</a>.
When you first use it, the extension saves either your password or an OAuth token in your .gitconfig file.
This is cool and convenient, unless you <a class="reference external" href="https://github.com/balkian/dotfiles">happen to be publishing your .gitconfig file in a public repo</a>.</p>
<p>So, how can you still share your gitconfig without sharing your password/token with the rest of the world?
Since Git 1.7.0, you can <a class="reference external" href="http://stackoverflow.com/questions/1557183/is-it-possible-to-include-a-file-in-your-gitconfig">include other files in your gitconfig</a>.</p>
</td></tr></table></content><categoryterm="github"></category><categoryterm="git"></category><categoryterm="dotfiles"></category></entry><entry><title>Zotero</title><linkhref="http://balkian.com/zotero.html"rel="alternate"></link><published>2014-12-09T12:12:12+01:00</published><updated>2014-12-09T12:12:12+01:00</updated><author><name>J. Fernando Sánchez</name></author><id>tag:balkian.com,2014-12-09:/zotero.html</id><summarytype="html"><p><a class="reference external" href="https://www.zotero.org/">Zotero</a> is an Open Source tool that lets
you organise your bibliography, syncing it with the cloud. Unlike other
alternatives such as <a class="reference external" href="http://www.mendeley.com">Mendeley</a>, Zotero can
upload the attachments and data to a private cloud via WebDav.</p>
<p>If you use nginx as your web server, know that even though it provides …</p></summary><contenttype="html"><p><a class="reference external" href="https://www.zotero.org/">Zotero</a> is an Open Source tool that lets
</content><categoryterm="zotero"></category><categoryterm="webdav"></category><categoryterm="nginx"></category><categoryterm="apache"></category></entry><entry><title>Proxies with Apache and python</title><linkhref="http://balkian.com/proxies-with-apache-and-python.html"rel="alternate"></link><published>2014-10-09T10:00:00+02:00</published><updated>2014-10-09T10:00:00+02:00</updated><author><name>J. Fernando Sánchez</name></author><id>tag:balkian.com,2014-10-09:/proxies-with-apache-and-python.html</id><summarytype="html"><p>This is a quick note on proxying a local python application (e.g. flask)
to a subdirectory in Apache. This assumes that the file wsgi.py contains
a WSGI application with the name <em>application</em>. Hence, wsgi:application.</p>
<span class="nb">ProxyPass</span> http://127.0.0 …</pre></div></td></tr></table></div></summary><contenttype="html"><p>This is a quick note on proxying a local python application (e.g. flask)
</td></tr></table><p><strong>Important</strong>: <em>SCRIPT_NAME</em> and the end of <em>ProxyPass</em> URL <strong>MUST BE
THE SAME</strong>. Otherwise, Gunicorn will fail miserably.</p>
<span class="na">file</span><span class="o">=</span><span class="s">/tmp/myapp.sock ; path to your socket file</span>
<span class="na">serverurl</span><span class="o">=</span><span class="s">unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket</span>
</content><categoryterm="python"></category><categoryterm="apache"></category><categoryterm="proxy"></category><categoryterm="gunicorn"></category><categoryterm="uwsgi"></category></entry><entry><title>Publishing on PyPi</title><linkhref="http://balkian.com/publishing-on-pypi.html"rel="alternate"></link><published>2014-09-27T10:00:00+02:00</published><updated>2014-09-27T10:00:00+02:00</updated><author><name>J. Fernando Sánchez</name></author><id>tag:balkian.com,2014-09-27:/publishing-on-pypi.html</id><summarytype="html"><p>Developing a python module and publishing it on Github is cool, but most
of the times you want others to download and use it easily. That is the
role of PyPi, the python package repository. In this post I show you how
to publish your package in less than 10 …</p></summary><contenttype="html"><p>Developing a python module and publishing it on Github is cool, but most
13</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="na">[distutils] # this tells distutils what package indexes you can push to</span>
</td></tr></table><p>As you can see, you need to register both in the <a class="reference external" href="https://pypi.python.org/pypi?%3Aaction=register_form">main pypi
<span class="n">packages</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;mypackage&#39;</span><span class="p">],</span><span class="c1"># this must be the same as the name above</span>
<span class="n">version</span><span class="o">=</span><span class="s1">&#39;{ version }&#39;</span><span class="p">,</span>
<span class="n">keywords</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;websockets&#39;</span><span class="p">,</span><span class="s1">&#39;display&#39;</span><span class="p">,</span><span class="s1">&#39;d3&#39;</span><span class="p">],</span><span class="c1"># list of keywords that represent your package</span>
2</pre></div></td><td class="code"><div class="highlight"><pre><span></span>git tag <span class="o">{</span>version<span class="o">}</span> -m <span class="s2">&quot;{ Description of this tag/version}&quot;</span>
</content><categoryterm="github"></category><categoryterm="python"></category><categoryterm="pypi"></category></entry><entry><title>Updating EuroLoveMap</title><linkhref="http://balkian.com/updating-eurolovemap.html"rel="alternate"></link><published>2014-03-27T14:00:00+01:00</published><updated>2014-03-27T14:00:00+01:00</updated><author><name>J. Fernando Sánchez</name></author><id>tag:balkian.com,2014-03-27:/updating-eurolovemap.html</id><summarytype="html"><p>As part of the <a class="reference external" href="http://www.opener-project.org/2013/07/18/opener-hackathon-in-amsterdam/">OpeNER
hackathon</a>
we decided to build a prototype that would allow us to compare how
different countries feel about several topics. We used the OpeNER
pipeline to get the sentiment from a set of newspaper articles we
gathered from media in several languages. Then we aggregated …</p></summary><contenttype="html"><p>As part of the <a class="reference external" href="http://www.opener-project.org/2013/07/18/opener-hackathon-in-amsterdam/">OpeNER
we decided to build a prototype that would allow us to compare how
different countries feel about several topics. We used the OpeNER
pipeline to get the sentiment from a set of newspaper articles we
gathered from media in several languages. Then we aggregated those
articles by category and country (using the source of the article or the
language it was written in), obtaining the &quot;overall feeling&quot; of each
country about each topic. Then, we used some fancy JavaScript to make
sense out of the raw information.</p>
<p>It didn't go too bad, it turns out <a class="reference external" href="http://eurosentiment.eu/wp-content/uploads/2013/07/BOLv9qnCIAAJEek.jpg">we
won</a>.</p>
<p>Now, it was time for a face-lift. I used this opportunity to play with
new technologies and improve it:</p>
<ul class="simple">
<li>Using Flask, this time using python 3.3 and Bootstrap 3.0</li>
</content><categoryterm="javascript"></category><categoryterm="python"></category><categoryterm="heroku"></category></entry><entry><title>Remove git files with globbing</title><linkhref="http://balkian.com/remove-git-files-with-globbing.html"rel="alternate"></link><published>2013-08-22T23:14:00+02:00</published><updated>2013-08-22T23:14:00+02:00</updated><author><name>J. Fernando Sánchez</name></author><id>tag:balkian.com,2013-08-22:/remove-git-files-with-globbing.html</id><summarytype="html"><p>A simple trick. If you want to remove all the '.swp' files from a git
</td></tr></table></content><categoryterm="git"></category></entry><entry><title>Creating my web</title><linkhref="http://balkian.com/creating-my-web.html"rel="alternate"></link><published>2013-08-22T14:14:22+02:00</published><updated>2013-08-22T14:14:22+02:00</updated><author><name>J. Fernando Sánchez</name></author><id>tag:balkian.com,2013-08-22:/creating-my-web.html</id><summarytype="html"><p>Finally, I've decided to set up a decent personal page. I have settled
for github-pages because I like the idea of keeping my site in a
repository and having someone else host and deploy it for me. The site
will be really simple, mostly static files. Thanks to Github,
<a class="reference external" href="http://jekyllrb.com">Jekyll …</a></p></summary><contenttype="html"><p>Finally, I've decided to set up a decent personal page. I have settled
for github-pages because I like the idea of keeping my site in a
repository and having someone else host and deploy it for me. The site
will be really simple, mostly static files. Thanks to Github,
<a class="reference external" href="http://jekyllrb.com">Jekyll</a> will automatically generate static
pages for my posts every time I commit anything new to this repository.</p>
<p>But Jekyll can be used independently, so if I ever choose to host the
site myself, I can do it quite easily. Another thing that I liked about
this approach is that the generated html files can be used in the
future, and I will not need Jekyll to serve it. Jekyll is really simple
and most of the things are written in plain html. That means that
everything could be easily reused if I ever choose to change to another
blogging framework (e.g. pelical). But, for the time being, I like the
fact that Github takes care of the compilation as well, so I can simply
modify or add files through the web interface should I need to.</p>
<p>I hadn't played with HTML and CSS for a while now, so I also wanted to
use this site as a playground. At some point, I realised I was doing
mostly everything in plain HTML and CSS, and decided to keep it like
that for as long as possible. As of this writing, I haven't included any
Javascript code in the page. Probably I will use some to add my
<a class="reference external" href="http://gist.github.com/balkian">gists</a> and
<a class="reference external" href="http://github.com/balkian">repositories</a>, but we will see about
that.</p>
<p>I think the code speaks for itself, so you can check out <a class="reference external" href="http://github.com/balkian/balkian.github.com">my repository