Health Spa
Charly's Column – XMLStarlet
![](/var/linux_magazin/storage/images/issues/2017/199/charly-s-column-xmlstarlet/kuehnast_charly_2.png/700185-1-eng-US/Kuehnast_Charly_2.png1_medium.png)
Charly and XML have never been best friends. However, because it was vital for him to have an excellent climate indoors, he plucked up his courage and considered XMLStarlet.
A few smart home components from the HomeMatic system are permanent guests in my bathroom – they are for controlling the temperature in the room. A radiator thermostat and three sensors detect whether doors and windows are open. I use a central unit called CCU2 to set the climate I want and in which scenario. Their web interface seriously tests my patience. If, for example, I name a window contact Bathroom_Window_North
instead of NEQ1651969
– because that's what it's called – I can't rely on the web interface to use the new name in all views (Figure 1).
![](/var/linux_magazin/storage/images/issues/2017/199/charly-s-column-xmlstarlet/figure-1/700188-1-eng-US/Figure-11_large.png)
The issue of security is another low point: The user interface is not password protected by default. I may be able to set one, but because CCU2 does not speak HTTPS, the password would fall into the clutches of the next sniffer anyway. Access to the script engine on port 8181 is also completely insecure. Nevertheless, the benefit is great because it allows me to use HTTP requests to read out the status of HomeMatic components and even set values.
Given this information, however, it should be clear that nobody is allowed to simply put the CCU2 onto the Internet via port forwarding, at least not anyone who doesn't want to invite all hackers to play poltergeist in their own home. Anyone wanting to view their home heating system from Jamaica will need a good VPN.
XML Instead of a GUI
So, I have a tool at hand for operating the CCU2 without its web interface. To receive the status of a window contact, I type the following into the console:
wget http://10.0.0.231:/x.exe?Response=dom.GetObject(%27BidCos-RF.NEQ1651559:1.STATE%27).Value()
The CCU2 responds very quickly with (brrr!) XML:
<xml> <exec>/x.exe</exec> <sessionId/> <httpUserAgent> User Agent: wget </httpUserAgent> <Response>true</Response> </xml>
I will suppress my XML aversion to help machines communicate with other machines – because that's just what XML is designed for. The true
between the Response
tags means that the window is closed. I can also retrieve the thermostat using similar commands and then set new temperature values. This means I can set up my own CCU2 GUI-free control using a few Bash scripts. Now I'm still missing an XML parser for the command line – with which I can finally angle for the XMLStarlet [1].
I previously had the output of the wget
command above written to the bathwindow.xml
file. In this way,
xmlstarlet sel -T -t -m xml -v Response $WDIR/bathwindow.xml
I now get the value between the Response
tags. Fancy a ride through the hell of parameters? Just read the 17-page (!) PDF document [2].
Charly Kühnast
Charly Kühnast manages Unix systems in the data center in the Lower Rhine region of Germany. His responsibilities include ensuring the security and availability of firewalls and the DMZ.
Infos
- XML Starlet: http://xmlstar.sourceforge.net
- Documentation: http://xmlstar.sourceforge.net/docs.php
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
NVIDIA Released Driver for Upcoming NVIDIA 560 GPU for Linux
Not only has NVIDIA released the driver for its upcoming CPU series, it's the first release that defaults to using open-source GPU kernel modules.
-
OpenMandriva Lx 24.07 Released
If you’re into rolling release Linux distributions, OpenMandriva ROME has a new snapshot with a new kernel.
-
Kernel 6.10 Available for General Usage
Linus Torvalds has released the 6.10 kernel and it includes significant performance increases for Intel Core hybrid systems and more.
-
TUXEDO Computers Releases InfinityBook Pro 14 Gen9 Laptop
Sporting either AMD or Intel CPUs, the TUXEDO InfinityBook Pro 14 is an extremely compact, lightweight, sturdy powerhouse.
-
Google Extends Support for Linux Kernels Used for Android
Because the LTS Linux kernel releases are so important to Android, Google has decided to extend the support period beyond that offered by the kernel development team.
-
Linux Mint 22 Stable Delayed
If you're anxious about getting your hands on the stable release of Linux Mint 22, it looks as if you're going to have to wait a bit longer.
-
Nitrux 3.5.1 Available for Install
The latest version of the immutable, systemd-free distribution includes an updated kernel and NVIDIA driver.
-
Debian 12.6 Released with Plenty of Bug Fixes and Updates
The sixth update to Debian "Bookworm" is all about security mitigations and making adjustments for some "serious problems."
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.