My relationship with Javascript hasn’t been a great one. I like JavaScript in the context of what it was created for: a client language for web pages. It beats the idea of mixing and matching Javascript and VBScript. I’ve had quite a lot of issues with JavaScript, its weird frameworks, and over-exerted JavaScript engines. For example, the fact that it’s trying to be a desktop application (via Electron) or a full-on highly asynchronous backend server (NodeJS) just feels wrong to me. It makes it even worse when there’s a full on package manager (yarn, npm) and non-structured packages. (To me Maven and the package management surrounding it is fairly well-thought-out).

It’s not just Javascript: I take issue when Python is overextended as well. My stance is: Languages are great in the context they’re meant for. Abusing them out of the context brings some bad things. For example: Python is great for short run scripts and proof of concepts, but it really struggles on long-running or high demand web services.

However, I must give credit to where credit is due: I really like what Web-serial has turned out to be. I had strong opinions about standboxing javascript to stay in the browser and not reaching out to interact with the system that the browser runs on. However, after seeing how web serial enables users to easily upload firmware to USB devices, I become pretty excited. Web-serial is an extension, mostly supported on Chrome, that came from standards body to help build up support for talking to serial devices.

How did this happen?

I’ve been playing around with Home Assistant and the Zigbee devices. Some of the devices I’ve worked with are:

  1. ESP32 devices flashed with ESPHome
  2. RATGDO - (Revenge of the garage door opener)- Flashed to support my network and the garage door operations
  3. Sonoff Zigbee Router (It needed a new firmware that was compatible with Zigbee2MQTT)
  4. Meshtastic device

In all of these cases, firmware was custom-built, and then flashed in a browser. Historically, you had to have a full toolchain and special permissions to flash devices. Now it’s a matter of navigating to a trusted web page, using Chrome, and hooking up the USB Serial between the two. Things are much easier, and I’m happy about it. (Ignoring the potential for nafarious attacks between a website and a client computer)

With web serial, when you make a connection to the device, the browser gives you an option of which device you wish to connect to, and then the web page performs the actions that it needs to. In the case of flashing, it’s writing and updating the storage on the device.

See the video for an example of this:

Even better, this is becoming the norm for flashing embedded devices which means no more half-baked sketchy software that quickly becomes out of date on your local machine.

The upside (or downside if you see it that way) to going about this is that it is only allowable from sites that have encryption enabled. This is another case for having a Certificate Authority if ESPHome is configured to remain on your local network.

OK. This is our little secret. I don’t completely hate Javascript…but I mostly do.