Air Conditioner control via Apple HomeKit and desktop app

Summer is a good time to work a bit on DIY smart-home air conditioner (AC) controls.

If you happen to have WiFi enabled Cooper&Hunter and/or Gree ACs – you’re lucky, because those support an easy to integrate with protocol, details of which one can find here:

In order to do so using Java I’ve implemented my own library:

And using that library I’ve created two solutions for AC control – a desktop app that works great, and a HomeKit automation that is in a Proof-of-Concept state right now because of limitations and connectivity issues I’ve encountered using HAP (HomeKit Accessory Protocol).

Here’s how they look:

ACControl on macOS.png
Continue reading

launchd tip of the day

I have a launchd service that fetches me some data from a website and sends them to an email. It uses password from keychain to do so. A week ago that password has expired and I had to update it. Aaand…

I was using security find-generic-password/add-generic-password, I’ve added security to the list of apps that don’t require password entry, done all that. It was all working fine before, but not this time. I’ve tried everything and just couldn’t figure it out.
Continue reading

New laptop? Check your hosts. /etc/hosts

I’ve just run into a weird problem where RabbitMQ server was running EXTREMELY slow on my laptop for no apparent reason.

After trying a bunch of things and googlig for a while I’ve found out that possible reason for that might be slow host resolution. But everything was running on a localhost!

I’ve checked my /etc/hosts and found out… Well, when I’ve upgraded my MacBook Pro laptop I’ve imported all stuff from previous one (using Apple’s migration assistant), but also did change the new laptop’s network name to avoid conflicts with the old laptop being on the same network. But I did not update /etc/hosts accordingly – it only had associated with the old network name.

Apparently, this is a big deal for RabbitMQ. I’ve been running it like that for more than a month and had no issues with any software whatsoever so far – but RabbitMQ (or possibly the underlying Erlang VM) was doing some special name resolution using my computer network name apparently, and that just didn’t work. Causing it not to report any errors though, but just run EXTREMELY (I mean it!) slow.

OS X (macOS) Migration Assistant disk space bug

Hi all,

Have you ever encountered an issue with OS X (AKA macOS) Migration Assistant being stuck on restart and/or starting up screen? I know I have, and I know other people have too.


If you don’t even know what Migration Assistant is, chances are you’ve used it anyway – because it’s run as an option on macOS installation – the one where you choose to import files from another drive/mac/etc. FYI.

The solution to the issue turned out to be rather simple in my case, but figuring it out took a couple of retries which all took several hours, so in total I’ve spent a few days (well, evenings) resolving the issue – and with this post I hope I can spare some people from repeating my fate.

Long story short, the issue was caused by a lack of disk space. Basically, if you choose not to import some files/folders in order to fit your data onto the target drive – Migration Assistant ignores that choice and tries to import everything. And when it runs out of disk space – it does not show any error or anything like that. Instead, import stops just as if all files were copied, installation proceeds to restart step (in case you’ve been doing it during macOS install like I did) – which gets stuck BTW. And on boot (by force reboot in my case) it was stuck on “Starting up” step. All because of lack of disk space.

The fix for me was to offload a particularly big folder to an external HDD, and then do the import.

That’s about it. Hope this helps.

RAM disk on OS X High Sierra

Here’s a code for creating RAM disk that works for me under OS X High Sierra.
One can change FS from HFS+ to something else (say, APSE, or case-sensitive/journaled FSs), but for me HFS+ is the one I want.

ramdiskSizeMB=$(osascript -e 'return text returned of (display dialog "RAM disk size in MB" default answer "1024")')
echo Creating RAM disk of size $ramdiskSizeMB MB
hdidOutput=$(hdid -nomount ram://$((2048*ramdiskSizeMB)) | cut -d ' ' -f 1) && diskutil erasedisk "HFS+" ramdisk $hdidOutput

To free the RAM one can simply unmount it in finder or DiskUtility.

P.S. Updated version with FS type selection:


choiceScript='return choose from list {';
while read -r fsType 
done <<EOT
$(diskutil listFilesystems -plist | grep Personality -A 1 | grep -F "<string>" | grep -E -o ">[^<]+<" | grep -o -E "[^><]+" | sort)
choiceScript="${choiceScript}\"\"} with prompt \"Choose filesystem type\" "

ramdiskSizeMB=$(osascript -e 'return text returned of (display dialog "RAM disk size in MB" default answer "1024")')
if [ "$ramdiskSizeMB" != "" ]
  fsType=$(osascript -e "$choiceScript")

  if [ "$fsType" != "false" ]
    export ramdiskName=$(osascript -e 'return text returned of (display dialog "RAM disk name" default answer "ramdisk")')
    if [ "$ramdiskName" == "" ] 
    echo Creating RAM disk $ramdiskName of size $ramdiskSizeMB MB with FS type $fsType
    hdidOutput=$(hdid -nomount ram://$((2048*ramdiskSizeMB)) | cut -d ' ' -f 1) && diskutil erasedisk "$fsType" "$ramdiskName" $hdidOutput


MySensors on Raspberry Pi with nRF24L01+

Recently I’ve learned that nRF24L01+ radio module can be connected directly to Raspberry Pi via GPIO pins in order for this Raspberry Pi to be used as MySensors library “gateway”.

I’ve successfully installed MySensors on Raspberry Pi using official instruction, but one thing wasn’t exactly clear – how do I specify channel for nRF24L01+? Without specifying proper channel, the “gateway” won’t be able to see other nodes.

It turned out to be quite simple actually – before doing make / sudo make install one has to run configure with these parameters:

./configure --my-transport=nrf24 --my-rf24-channel=123

The 123 is the number of channel to be used.

P.S. Remember to enable SPI via raspi-config.

DSLR focus control with gphoto2

If you read the documentation on gphoto2 regarding the focus control (“manual” focus as they call it) it mentions that focus control only works while liveview mode is on, and that seemed to be sufficient for Canon, but it turned out that for Nikon cameras there was more to it than just liveview.

First the necessary disclaimer though: I’ve only tried the Nikon D5100 here and Canon 550D and 600D, so YMMV.

But let’s start with liveview (or preview) mode itself first – this one is controlled by “/main/actions/viewfinder” setting in both Nikon and Canon. Continue reading