No, YAML ain't, but what is it?

YAML is said to stand for "YAML Ain't a Markup Language". This unhelpful acronym (and brazen use of the old "GNU = GNU is Not Unix" joke) doesn't really help in understanding YAML as it pertains to Home Assistant.

Well, in this context, YAML is a way of defining the hierarchical configuration settings that drive Home Assistant. So, suppose we have some settings such as:

  • Lights:
    • Left:
      • Brightness: 4
      • Colour: "Red"
    • Right:
      • Brightness: 6
      • Colour: "Green"
  • Fans:
    • Extractor: 2

YAML is just the thing to define such a hierarchical structure. For the moment, don't worry too much what these might represent. Consider, however, that we might want the actual settings (such as 4 or "Red") to be controlled by some variable quantity derived from something else within the system. In this case it would be useful to be able to replace the settings with snippets of Python code.

And this is, effectively, what Home Assistant does.

So, strictly speaking, it is not accurate to say "Home Assistant is programmed in YAML". As far as I can make out (with my limited knowledge of what is going on) Home Assistant is written in Python and it is configured using a YAML file (or files) containing constants and snippets of Python.

This approach is made possible because Python is an interpetreted language. You don't "compile" or "link" a program before you run it like you do for C or C++. So code snippets such as those found in the YAML configuration can be evaluated at run-time.

Is that clear? Probably not, but it is the best I can do at the moment!

Comments

Popular posts from this blog

Automation tasks underway

A new strategy, a new approach to automation