Stephan van Rooij

Software architect with a passion for home automation.

Developing a typescript library

D

I’ve been building node libraries for home automation purposes for a while now, see my repositories. I decided that it was time to try out the strong-type goodness you get when using Typescript.

Node-sonos (a library to control your sonos device, from you guessed it, node) was a good candidate. I’m one of the main contributors at this point. In the last two months I spend a lot of hours developing a comparable library in typescript. The result node-sonos-ts is now at version 1.1.1 so it’s a good moment to look back on the bumps in the road.

Setup project

Setting up the project correctly is important. Before you can run (or debug) your typescript code it has to be compiled to JavaScript by tsc. You’ll need to do some setup stuff, someone make a great tutorial. You can also have a look at the package.json and the tsconfig.json files in my new repository. In node-sonos-ts the files live in the src folder, and the get compiled (and released) from the lib folder.

Debugging

Getting your library to compile automatically is one thing, but debugging is might be as important! In node-sonos-ts is a special VSCode launch.json file. What it does is compiling the library to javascript (with source maps). And that way you can debug the typescript files really easy. You can set breakpoints and they are hit. You can even inspect all the current values.

Sonos goodness

S

I’m a big fan of the sonos devices, but I’m not a big fan of the Sonos app (mac/windows/android/ios), it just isn’t that good. At least the following points should be fixed before I would consider changing my mind:

  1. Android/iOS -> Alarm settings are hidden to far in the application. (two clicks, a long scroll and another click).
  2. Slowly startup, they do device discovery even though all my speakers have a semi-static (dhcp reservation) ip.
  3. The playbar should rejoin the previous group after watching tv.
  4. Memory usage on mac
  5. No integration with other systems

Like what you're seeing? Consider Sharing on Twitter or Sponsoring me