Uploading a Snapshot to a Fresh Home Assistant OS Instance
Hi!
After finding that my previously running Home Assistant OS instance was no longer working let alone starting properly, I decided to wipe it and simply install from a fresh image today. In order to pick up where I left off, I wanted to restore from a snapshot that I made a short while ago.
Out of the box, Home Assistant OS does not seem to come with any way to upload snapshots (or any other kind of files) onto the instance. Usually, this would not be a problem, because I had previously used the Samba share add-on from the official add-on repository, but since updating it to the new repository website, the Samba share add-on seems to have disappeared.
My first alternate approach using the SSH access did not work either, as I could not use SFTP because it is not effectively using proper SSH/SFTP but an intermediate wrapper for the Home Assistant console.
The quickest way I found that had minimal impact on the system in terms of creating a mess was to use Docker and download my latest snapshot from a web server hosted somewhere else via cURL. In this case I was using a self-hosted Nextcloud instance with a shared file link, but your mileage may of course vary.
Prerequisites / Assumptions
- You are using the Home Assistant OS official image on a device in headless mode, so you have a minimal system without neat tools like curl or wget pre-installed.
- You have uploaded the snapshot file to a web server that is accessible from the Home Assistant OS system (in terms of network connectivity).
Steps
- Enable SSH access by following the official documentation on how to enable SSH access to the host.
- Update from 2020-05-21: They seem to have restructured the documentation and the original instructions are no longer on that page. It used to say:
Use a USB drive formatted with FAT, ext4, or NTFS and name it CONFIG (case sensitive). Create an "authorized_keys" file (no extension) containing your public key, and place it in the root of the USB drive. File needs to be ANSI encoded (not UTF-8) and must have Unix line ends (LF), not Windows (CR LF). [...] From the UI, navigate to the Supervisor system page and choose "Import from USB". You can now access your device as root over SSH on port 22222. Alternatively, the file will be imported from the USB when the Home Assistant OS device is rebooted.
- Update from 2020-05-21: They seem to have restructured the documentation and the original instructions are no longer on that page. It used to say:
- Log into the Home Assistance OS instance via SSH.
- Type the command "login" to enter the actual shell.
- Use the following command to download the snapshot file:
docker run --rm curlimages/curl https://my.server.local/a1b2c3d4.tar > /mnt/data/supervisor/backup/a1b2c3d4.tar
(Change URL and file names of course. The destination directory should be fine.) - You might want to check file integrity for the file via md5sum or sha512sum etc.
- If you want to be extra tidy, you can remove the cURL Docker image again by executing
docker image rm curlimages/curl
- Close the SSH session and open a new one.
- Do not enter the actual shell but instead execute this command to get Home Assistant to notice the newly uploaded snapshot:
snapshots reload
- Now log into the Home Assistant web interface or just keep using the console and restore what you need.
- Done!
I hope this saved you a bunch of research because I myself could not find anything quick and practical on this topic.
Thanks for reading!
Fix GNOME GUI Login After Upgrade to Debian 10 Buster (VirtualBox VM)
Hello!
Yesterday I upgraded my old Debian VirtualBox VM from Debian 9 stretch to Debian 10 buster.
After going through all the usual upgrade steps from the official documentation and rebooting, I found myself waiting for the GNOME user selection in order to log in. Except that it was stuck with the gray background and nothing except the mouse cursor was showing up or working.
I switched to a text-only terminal (Ctrl+Alt+F5) and logged in via command line. Looking at /var/log/syslog I found the following messages repeating over and over:
gnome-shell[1281]: Failed to set CRTC mode 1448x953: Invalid argument kernel: [ 192.917346] [drm:drm_crtc_helper_set_config [drm_kms_helper]] ERROR failed to set mode on [CRTC:29:crtc-0]
1448x953 is the resolution I am using for the VM.
This current VM was created back when Debian 7 wheezy was still current, and I knew that a more recently created VM (originally with Debian 9 stretch) was working fine after upgrading to 10, so I figured that the info about the resolution from gnome-shell might have something to do with the VM's settings.
Sure enough, I found out that there were about a handful of settings that were different, most likely because over time VirtualBox defaulted to slightly different settings depending on my hardware, the template for the OS I selected (different Debian major releases) and the VirtualBox release itself. A couple of VM starts and configuration changes later I narrowed the problem down to the following VM setting:
Display => Screen => Video Memory
I raised the original 12 MB to 16 MB and thankfully the next boot showed the GNOME login mask as per usual!
Surely this is a very edge case kind of scenario, but I am hoping that this might help you in case you come across the same problem. All the other search results I found regarding roughly the same error message in the logs were about different things.
Thanks for reading!
Disable Autoplay For Videos in Firefox 63
Hi!
Just after updating to Mozilla Firefox 63 (on Windows), I found that my setting to disable autoplaying media / videos was no longer effective - at least for HTML5 videos.
Apparently one of the changes for this release was to include an autoplay video blocker, but I could not find anything definitive about this in the settings.
I decided to disable autoplay for all videos (which is my preferred setting anyway) once again by doing the following:
- Open the config editor by entering about:config in the navigation bar.
- Enter the "autoplay" as a filter.
- Find the entry "media.autoplay.default", double-click it and set it to "1" to disable media autoplay browser-wide.
I just left the old setting "media.autoplay.enabled" as "false", even though it does not seem to be relevant any more.
After reloading the website with the video (in this case YouTube), once more it showed the play icon on top of the video instead automatically starting playback.
I hope this was helpful.
Thanks for reading!
Using Git Bash With Custom Installation Of GPG / GnuPG
Hi!
You have probably noticed that Git for Windows comes with MinGW64, which enables you to use programs (or to be more precise: Windows versions of these programs) that are usually only available to Linux users. One of the programs that MinGW64 / Git for Windows ships with is GPG / GnuPG. The current version of Git for Windows (2.17.1) for example comes with GPG version 1.4.22.
If you prefer using a custom installation of GPG / GnuPG by default, which is probably much more current than the one you installed manually (2.x), you can achieve this by doing the following:
- Install GPG as you normally would
- Make sure it is executable in the command line / PowerShell (as in: make sure the bin/ subdirectory of the GPG program directory is included in the PATH environment variable)
- Go to the Git for Windows program directory (e.g. C:\Program Files\Git\)
- Navigate to the usr/bin/ subdirectory and rename gpg.exe to something else (like gpg_disabled.exe)
- Close any open Git Bash instances and start a fresh one
- Check the GPG version via
gpg --version
The way that Git Bash works is that is has its own set of directories which have a higher priority when looking for executable files than the ones in Windows' PATH environment variable. So in order to have your own GPG executable working as the "gpg" command, you have to get the included gpg.exe out of the way so it keeps looking in Windows' PATH environment variable.
You can still access the old GPG executable by using the new name (e.g. "gpg_disabled").
Unfortunately you have to do these steps every time you install or update Git for Windows, but at least now you know where to look!
The upside is that now Git (executed from the Git Bash) also uses your own version of GPG for its GPG-related operations.
I hope this was helpful.
Thanks for reading!
Using OpenVPN For All Network Traffic Except For LAN
Hi!
Recently I noticed that my Android smartphone was not able to connect to YouTube via third-party apps. I narrowed it down to the issue with it being able to resolve hostnames to the correct IPv6 addresses but not being able to connect to them (somehow the IPv6 part of my internet connection is broken. A problem for a different time).
In order to work around the problem I am using an OpenVPN connection which automatically forces all outgoing connections to use IPv4, not IPv6. The only problem was that internal LAN connections did not work any more.
In the .ovpn configuration file I am using
redirect-gateway local def1
(because it is a WiFi connection), but I was also using
redirect-gateway def1
before that, which did not make any difference in that regard.
If add a route directive like the following one after the redirect-gateway directive, you can add a route to the routing table, directing all traffic for the specified route to the WiFi connection instead of the VPN connection:
redirect-gateway local def1 route 192.168.0.0 255.255.255.0 net_gateway
You will probably have to adjust the network address and maybe even the subnet mask to match your network.
The routing table is basically a prioritized table which lets the operating system decide which network adapter it should use for a specific connection. With the above entry you add a rule with a higher priority, overriding the generic one(s) from the OpenVPN connection configuration. These ones are added because of redirect-gateway def1 and tell the operating system to send all traffic via the virtual VPN network adapter, effectively sending it all over the VPN.
If you are configuring this from the OpenVPN server side, of course you can still use these directives, but in the context of the push directive. I am not doing that, however, so I saved both directives in the client configuration.
Now I can watch / listen to YouTube videos with third-party apps AND connect to LAN devices!
I hope this was helpful to you.
Thank you for reading!
Rewrite MySQL / MariaDB Database Dump Create View Statements For Current User
Hi!
If you would like to import a database dump file created by MySQL's or MariaDB's mysqldump executable, but it contains statements to create views, the import process may abort with an error when it comes to creating views.
When creating a view, MySQL wants to know who created it, and for that it needs a username and the host. If the user who is executing the import does not have sufficient privileges or the original user referenced in the dump does not exist (for example when importing the dump into a fresh database for a migration), this leads to an error.
Usually when I import a dump, I don't care so much about the "SQL Security Definer", so I just want to set it to the importing user.
You can generate a new, modified SQL dump file very easily with the following shell command:
$ sed -r 's#^(/\*!50013 DEFINER=).+?( SQL SECURITY DEFINER \*/)$#\1CURRENT_USER\2#' input_file.sql > output_file.sql
This command simply scans through the entire dump, looking for the statement created by mysqldump which triggers the database to create the view if it doesn't exist already. It then sets the user information to CURRENT_USER which refers to the user that is currently executing the import.
Please note that because the search pattern is so specific, it will probably require some modification in the future, depending on the version of mysqldump you're using and if / how they change this particular statement. On the upside the chance that it will accidentally modify something it shouldn't is pretty low.
I hope this is helpful to you!
Thanks for reading!
Fixing Low Stereo Out Sound Volume For the Yamaha MG12XU / MG16XU / MG20XU Audio Mixer
Hi!
I recently got my hands on a Yamaha MG12XU audio mixer and dove right into the world of amateur analog audio mixing.
Everything went fine until it came to the USB interface. When trying to record the sound that was output via USB to my computer (basically STEREO OUT without the master stereo fader), it did arrive, but the volume was really, really low. Audacity barely showed any change in the graphs displaying the signal volume (went from a one pixel thick line to an occasionally 2-3 pixel thick line).
Additionally, the audio that went into the mixer via USB (channel 11/12 on the MG12XU) was considerably louder than all my other channels. In fact, if I used the USB attenuator function (press the PROGRAM dial/button 5x, turn the dial to adjust between -24 to 0 dB and confirm by pressing it once more) to set it to -24 dB, the lowest setting, only then was it as loud as all my other channels. That should have been the first indication as to what was wrong.
This was after installing the YAMAHA Steinberg USB driver from the official Yamaha Professional Audio website, which I strongly recommend. The default one that Windows 10 installed when it first detected the mixer somehow resulted in CPU usage skyrocketting due to svchost.exe. Not sure what that was about.
I tried installing the ASIO4ALL driver, but it didn't appear to make any difference, so I called the technical support hotline.
The very friendly and competent person on the other end explained to me that the signal strength the mixer was working with from the input all the way to STEREO OUT was simply too low. I had intentionally kept everything just as low as I could with the channel sliders on the 0 positions because I didn't want the gain settings to distort my signals. Turns out that mixers work best with the highest volume levels possible without distortion or constant peaking which does make sense - if you have more data for the signals, you can do more with them in terms of EQ, FX or anything really. Another clue was the monitor level display on the right side. For normal signals it only went up to a strength of about -25 to -30, which is basically the two bottom indicators of a total of twelve. They should be around the 0 level (5th from the top).
Once I realized that, it was only a matter of increasing the gain levels for the different input channels and lowering the master stereo slider as well as the phones level knob (and the AUX1 level knob in the SEND MASTER section) accordingly because the signal was now very strong. The monitor level now usually filled up to the 4-6 bottom-most lights (-15 to -6).
One test recording confirmed that the STEREO OUT USB signal was now as loud as what I heard on my headphones.
This was loud enough for me (the phones dial being set to 1 / the first "notch"), and translated to a gain level at 8 out of 10 "notches" (3 o'clock position) for all my sound cards (which were set to 100% volume in Windows for input as well as output) as well as my XLR microphone. Luckily, at this point there was no noticeable distortion yet.
Oh, and the volume in the USB input (channel 11/12) was now as loud as the other ones even without any attenuation set.
That's it!
I hope that helps you.
PS: Sorry if that is a bit of an obvious "hint", but as a beginner in the audio space myself, the advice from the Yamaha customer service representative made a light bulb switch on in my head. I thought I would share it in case you are having the same experience.
PPS: Even though I can only speak of the MG12XU, I am pretty certain that this applies to the sister models MG16XU and MG20XU, too, and maybe even the entire range of Yamaha audio mixers.