Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
401ad11
Write an ESPHome 101 guide
MarkParker5 Nov 30, 2026
c043438
Link the firmware README instead of repeating it
MarkParker5 Nov 30, 2026
43bcacf
Bump Pillow to 13 and refresh the lockfile
MarkParker5 Nov 30, 2026
8c4702b
Merge pull request #34 from MajorDom-Systems/chore/dependabot-alerts
MarkParker5 Nov 30, 2026
df9730f
Merge pull request #33 from MajorDom-Systems/docs/firmware-dedup
MarkParker5 Nov 30, 2026
909d417
Describe the self-contained feeds and fixed boards
MarkParker5 Dec 1, 2026
701e674
Merge pull request #35 from MajorDom-Systems/docs/firmware-channel
MarkParker5 Dec 1, 2026
ba53fab
Write an ESPHome 101 guide
MarkParker5 Nov 30, 2026
7c666f5
Cut the ESPHome overview to what MajorDom adds
MarkParker5 Nov 30, 2026
638f6b4
Add ESPHome entity options and a one-file ESPHome pack for AI
MarkParker5 Nov 30, 2026
e9e8920
Split the ESPHome page into what MajorDom adds and changes
MarkParker5 Dec 1, 2026
719677b
Point to the ESPHome docs after the quick start
MarkParker5 Dec 1, 2026
9ad4c44
Import the MajorDom components once in the template base
MarkParker5 Dec 1, 2026
1885d39
Build Hello world on the network packages
MarkParker5 Dec 1, 2026
4d59dc1
Set the package source once, make the setup code optional, add Reflas…
MarkParker5 Dec 1, 2026
166a306
Name the package line after its file
MarkParker5 Dec 1, 2026
8a4da04
Show the flash command with and without a setup code
MarkParker5 Dec 1, 2026
e6d77b6
Bring the ESPHome component pages up to date
MarkParker5 Dec 1, 2026
16eab68
Use the provision packages; flash without a code first
MarkParker5 Dec 1, 2026
82087f5
Trim the intro; note unrecognized entities keep working
MarkParker5 Dec 1, 2026
f108616
Merge the earlier push of docs/esphome-101
MarkParker5 Dec 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions docs/esphome/ble-provisioning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# BLE Provisioning

A node that ships without Wi-Fi gets its network from the MajorDom Hub over Bluetooth. The node side uses ESPHome's [Improv via BLE](https://www.improv-wifi.com/ble/). Three components in [esphome-components](https://github.com/MajorDom-Systems/esphome-components) make that exchange safe. For a Thread node, see [Thread Provisioning](thread-provisioning.md), which uses the same two safety parts.

ESPHome's stock `esp32_improv` sends the Wi-Fi password over a plain link. The Hub refuses that unless **Unencrypted Bluetooth setup** is on in the ESPHome integration settings. Turn it on only for such a device, and only as long as the setup takes: anyone in Bluetooth range could read the password.

## esp32_improv

The component overrides ESPHome's built-in `esp32_improv` (a copy of the one in ESPHome 2026.9.1) and adds `setup_code`. Everything else works as in ESPHome. ESPHome 2026.11 renamed the built-in to `improv_ble`, which this one doesn't override yet: build with ESPHome 2026.9.1.

```yaml
external_components:
- source: github://MajorDom-Systems/esphome-components@develop
components: [esp32_improv, ble_link_security, setup_code]

wifi: # no networks: the Hub sets them over Improv

esp32_improv:
authorizer: none # or the id of a binary sensor, e.g. boot_button
setup_code: ${setup_code} # optional
on_provisioned:
- delay: 10s # lets the Hub read the result first: removing a bond drops its link
- ble_link_security.clear_bonds:

esp32_ble:
auth_req_mode: sc_only
min_key_size: 16
max_key_size: 16

ble_link_security:
characteristics:
- service: 00467768-6228-2272-4663-277478268000 # Improv
characteristic: 00467768-6228-2272-4663-277478268003 # RPC command: carries the Wi-Fi password

api:
encryption: {}
```

- **authorizer** (*Required*, ID or `none`): A binary sensor, usually a button. When set, Wi-Fi settings are accepted only within `authorized_duration` after it turns on. With `none`, and without a `setup_code`, they are accepted at any time.
- **setup_code** (*Optional*, string): The 8-digit [setup code](#setup-code). An empty string is no code.
- **authorized_duration** (*Optional*, Time): How long a press authorizes. Defaults to `1min`.
- **identify_duration** (*Optional*, Time): How long the status indicator blinks after an Improv identify request. Defaults to `10s`.
- **wifi_timeout** (*Optional*, Time): How long the node tries a new network before it goes back to waiting. Defaults to `90s`.
- **status_indicator**, **on_start**, **on_state**, **on_provisioning**, **on_provisioned**, **on_stop**: as in ESPHome's [`esp32_improv`](https://esphome.io/components/esp32_improv/).

A complete example (ESP32-C3, also a Bluetooth proxy once on Wi-Fi) is in the repository: [`examples/esp32c3_improv_secure.yaml`](https://github.com/MajorDom-Systems/esphome-components/blob/develop/examples/esp32c3_improv_secure.yaml).

## Encrypted link

`ble_link_security` makes the characteristics you list accept a write only over an encrypted link. The Hub pairs first, then writes, so the Wi-Fi password never crosses the air in clear text.

- **characteristics** (*Optional*, list): Each item has a `service` and a `characteristic`, both 128-bit UUIDs. `thread_provisioning` protects its own without being listed.

The build fails unless `esp32_ble:` sets `auth_req_mode` to `sc_only` or `sc_bond` and `min_key_size` to `16`.

Pairing is "Just Works": it stops passive sniffing, but it does not check who is on the other end. With `sc_only`, nothing is bonded, so no key is stored on either side. With `sc_bond`, bonds are dropped once the node is provisioned. The `ble_link_security.clear_bonds` action does it by hand.

## Setup code

A setup code is 8 digits, printed on the device. The Hub proves it knows the code, and then every command travels sealed by that session. This is the design proposed for Improv via BLE revision 2.5 ([improv-wifi/website#70](https://github.com/improv-wifi/website/pull/70)), using SPAKE2+ as Matter does. The code itself never crosses the air.

Give every device its own random code and print it on the device. Pass it at build time, so it is not in the YAML:

```yaml
esp32_improv:
authorizer: none
setup_code: ${setup_code}
```

```sh
esphome -s setup_code <your code> compile device.yaml
```

Without `-s setup_code`, the [network packages](components.md#use) build with no code: they default it to an empty string, which the command line overrides.

Only a verifier is compiled in (a random salt, the iteration count and two derived values), so the code cannot be read back from the firmware except by guessing. Codes that repeat a digit eight times, `12345678` and `87654321` are refused at build time.

With a `setup_code` and `authorizer: none`, only a client that knows the code can set the node up. The Hub asks for the code in the app when it pairs.
33 changes: 33 additions & 0 deletions docs/esphome/components.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# ESPHome Components

[MajorDom-Systems/esphome-components](https://github.com/MajorDom-Systems/esphome-components) holds the [ESPHome](https://esphome.io) external components MajorDom devices are built with. They add what ESPHome does not have (yet); each is meant to go upstream, and is kept here until it does.

| Component | What it does |
|---|---|
| [`thread_provisioning`](thread-provisioning.md) | Gives a Thread node its network over BLE at runtime, so one image ships without one. |
| [`esp32_improv`](ble-provisioning.md) | ESPHome's own `esp32_improv`, plus setup code authentication. Gives a node its Wi-Fi over BLE. |
| [`ble_link_security`](ble-provisioning.md#encrypted-link) | Accepts secrets over BLE only on an encrypted link. |
| [`setup_code`](ble-provisioning.md#setup-code) | The 8-digit setup code. A library for the two provisioning components. |

## Use

The quickest way is a network package: it brings the components with the rest of the device's network part. See [Hello world](index.md#hello-world).

| Package | For |
|---|---|
| [`wifi-provision.yaml`](https://github.com/MajorDom-Systems/esphome-components/blob/develop/packages/wifi-provision.yaml) | Wi-Fi provisioned over Bluetooth by the Hub or the app, any ESP32 |
| [`thread-provision.yaml`](https://github.com/MajorDom-Systems/esphome-components/blob/develop/packages/thread-provision.yaml) | Thread provisioned over Bluetooth by the Hub or the app, ESP32-C6, C5, H2 |

To use the components on their own, add the repository as an [external component source](https://esphome.io/components/external_components/):

```yaml
external_components:
- source: github://MajorDom-Systems/esphome-components@develop
components: [esp32_improv, ble_link_security, setup_code] # Wi-Fi; Thread: thread_provisioning in place of esp32_improv
```

The configs in these docs use `@develop` until the next release: the only tag, `v0.1.0`, has `thread_provisioning` alone, without the encrypted link and the setup code.

The repository's CI compiles every change against the ESPHome version pinned in its `requirements.txt` (`2026.9.1` today), and checks that the packages build with and without a setup code. Newer ESPHome releases are picked up by Dependabot and compile-checked before they are merged.

ESPHome 2026.11 renamed `esp32_improv` to `improv_ble`, which this repository's `esp32_improv` doesn't override yet: build Wi-Fi devices with ESPHome 2026.9.1 until it does.
168 changes: 157 additions & 11 deletions docs/esphome/index.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,165 @@
# ESPHome Components
# ESPHome

[MajorDom-Systems/esphome-components](https://github.com/MajorDom-Systems/esphome-components) holds the [ESPHome](https://esphome.io) external components MajorDom devices are built with. They add what ESPHome does not have (yet); each is meant to go upstream, and is kept here until it does.
[ESPHome](https://esphome.io) turns an ESP32 into a smart device from a short YAML file. MajorDom's ESPHome is a superset of it: every ESPHome config works as it is, and MajorDom adds encrypted pairing and secure provisioning on top.

| Component | What it does |
|---|---|
| [`thread_provisioning`](thread-provisioning.md) | Gives a Thread node its network over BLE at runtime, so one image ships without one. |
## Let an AI assistant write the config

Give an AI assistant this prompt; the link is every ESPHome page of these docs in one file:

```text
Write an ESPHome config for a MajorDom device.
Follow https://docs.majordom.io/esphome/llms.txt: use the MajorDom components, and the entity options for the app.
Board: <your board>. Network: <Wi-Fi provisioned over Bluetooth, Wi-Fi from secrets.yaml, or Thread>.
It should: <what the device does, on which pins>.
```

## What MajorDom adds

- **Encrypted pairing and secure provisioning.** The Hub finds a new device over Bluetooth, pairs over an encrypted link, and hands it its Wi-Fi or Thread network, then sets the device's API key. The network credentials and the API key never need to be in the firmware. This is an option, not a rule: Wi-Fi from your `secrets.yaml` works as usual.
- **A setup code, optional.** An 8-digit code built into the device. With one, the app asks for it, and only a Hub that knows it can set the device up; the code never crosses the air. Without one, the handover is still encrypted, but any Hub in Bluetooth range can take the device, unless an `authorizer` button guards it. The code is passed at build time, never written in the YAML.
- **Thread provisioning.** An ESP32-C6, C5 or H2 joins the Hub's Thread network, handed over the same way as Wi-Fi.
- **Discovery.** The Hub finds new devices over Bluetooth, and devices already on its network over mDNS.

These come from the [MajorDom components](components.md).

## What is different

- **`api:` is required.** The Hub talks to the device over the ESPHome native API only. `encryption: {}` leaves the key to the Hub. A key of your own (`encryption: key:`) works too: the app then asks for it.
- **Factory reset returns the device to setup.** A [`factory_reset`](https://esphome.io/components/button/factory_reset/) button erases the network and the key, and the device can be set up again.
- **Almost every entity is supported by MajorDom:** lights, switches, sensors, covers, fans, climate, locks, valves, water heaters, alarm panels, numbers, selects, text, dates and times, buttons and more. Firmware updates are hidden from the device screen. The others, such as cameras and images, sound and streams, events, raw infrared and radio frames, keep working on the device; MajorDom just doesn't recognize them yet.

## Choose a network

| Network | Boards | What to add | The Hub needs |
|---|---|---|---|
| Wi-Fi, provisioned over Bluetooth | any ESP32 | package [`wifi-provision.yaml`](https://github.com/MajorDom-Systems/esphome-components/blob/develop/packages/wifi-provision.yaml), [`esp32_improv`](ble-provisioning.md) inside | a Wi-Fi network in its settings |
| Wi-Fi, from `secrets.yaml` | any ESP32 | ESPHome's [`wifi`](https://esphome.io/components/wifi/) | the same network, nothing to hand over |
| Thread, provisioned over Bluetooth | ESP32-C6, C5, H2 | package [`thread-provision.yaml`](https://github.com/MajorDom-Systems/esphome-components/blob/develop/packages/thread-provision.yaml), [`thread_provisioning`](thread-provisioning.md) inside | its Thread border router |
| Ethernet | boards with an Ethernet port | ESPHome's [`ethernet`](https://esphome.io/components/ethernet/) | the same LAN, nothing to hand over |

## Hello world

The simplest way to a working device: one switch. You need an ESP32 with a USB cable, and Python 3.11 or newer.

1. Install ESPHome 2026.9.1, the version the MajorDom components are built for:

```sh
pip install esphome==2026.9.1
```
2. Save this as `hello.yaml`. Set `board` to [yours](https://registry.platformio.org/platforms/platformio/espressif32/boards).

```yaml
esphome:
name: hello-majordom

esp32:
board: esp32-c3-devkitm-1
framework:
type: esp-idf

packages: # the network: keep one
wifi-provision: github://MajorDom-Systems/esphome-components/packages/wifi-provision.yaml@develop
# thread-provision: github://MajorDom-Systems/esphome-components/packages/thread-provision.yaml@develop # ESP32-C6, C5, H2

switch:
- platform: template
name: "Hello Switch"
optimistic: true

button:
- platform: factory_reset
name: "Factory Reset"
```

## Use
The package is the network part of the device: the MajorDom components, `api:` with the key left to the Hub, and the Bluetooth handover. See [`wifi-provision.yaml`](https://github.com/MajorDom-Systems/esphome-components/blob/develop/packages/wifi-provision.yaml) and [`thread-provision.yaml`](https://github.com/MajorDom-Systems/esphome-components/blob/develop/packages/thread-provision.yaml). Anything you set in your own file overrides it, for example `logger: level: DEBUG`.

Add the repository as an [external component source](https://esphome.io/components/external_components/), pinned to a release tag:
3. Plug the board in over USB, then build and flash it. Pick the USB port when asked.

Without a setup code, any Hub in Bluetooth range can set the device up:

```sh
esphome run hello.yaml
```

With a setup code, only a Hub that knows it can. Make one, write it on the board, and build with it:

```sh
python3 -c "import secrets; c = f'{secrets.randbelow(10**8):08d}'; print(c[:4] + '-' + c[4:])"
esphome -s setup_code <your code> run hello.yaml
```

4. In the MajorDom app, add a device. `hello-majordom` appears; select it and enter the setup code if it has one. The Hub hands it the network, and then pairs it.

Later updates go over the network with the same command.

## Reflashing

A reflash, over the network or USB, keeps the device paired: the network the Hub handed over, the API key it set, and the device's place in the app, even after you edit the YAML or rename the device. Pairing is lost only when:

- **The flash is erased**, for example by a web flasher's "erase" option. It's the same as a factory reset: remove the device in the app, then set it up again.
- **The API key changes:** a key of your own replaces `encryption: {}`, or your key is edited. The app asks for the new key.
- **The network changes:** Wi-Fi provisioned over Bluetooth, from `secrets.yaml`, or Thread. Remove the device in the app and set it up again.

Renaming an entity keeps the pairing, but creates a new parameter: automations using the old one stop working.

For more components, other ways to flash, and the finer details of the YAML, see the [ESPHome docs](https://esphome.io/components/).

## Entities that look right in the app

Each entity becomes a parameter of the device. These options decide where it shows and how it behaves:

| ESPHome option | In the app |
|---|---|
| `name` | The parameter's name. Its id comes from the name, so a rename creates a new parameter and breaks the automations using the old one. |
| `entity_category: config` or `diagnostic` | Under the device's **Settings**, off the main screen. For calibration, intervals, restart buttons, signal strength, uptime. |
| `disabled_by_default: true` | Hidden. |
| `internal: true` | Not sent to the Hub at all. For helpers that only other entities use. |
| `unit_of_measurement` | The unit: `°C`, `K`, `%`, `Pa`, `lx`, `W`, `kWh`, `J`, `A`, `V`, `Hz`, `ppm`, `µg/m³`, `m`, `m/s`, `s`, `kg` or `rpm`. Any other unit, `°F` included, shows a plain number. |
| `device_class` | The unit, when `unit_of_measurement` is not set. |
| `min_value`, `max_value`, `step` (number) | The slider's range and step. |
| `options` (select) | The choices. |
| `visual:` `min_temperature`, `max_temperature`, `temperature_step` (climate) | The target temperature's range and step. |

```yaml
external_components:
- source: github://MajorDom-Systems/esphome-components@v0.1.0
components: [thread_provisioning]
switch:
- platform: gpio
pin: GPIO5
name: "Relay" # the everyday control, on the main screen
- platform: template
name: "Child Lock"
entity_category: config # under Settings
optimistic: true

sensor:
- platform: dht
pin: GPIO4
temperature:
name: "Temperature" # a reading on the main screen, in °C
humidity:
name: "Humidity"
- platform: wifi_signal
name: "Wi-Fi Signal"
entity_category: diagnostic # under Settings

number:
- platform: template
name: "Report Interval"
entity_category: config
unit_of_measurement: s
min_value: 10
max_value: 600
step: 10
optimistic: true
```

Each release is compiled in CI against the ESPHome version pinned in the repository's `requirements.txt`; newer ESPHome releases are picked up by Dependabot and compile-checked before they are merged.
!!! tip "Pro tip"
A tap on the device's tile runs one everyday control: a switch, light, fan, button or select. Keep only one of them on the main screen, so the tap does what you expect, and move the rest under `entity_category: config`. Above, a tap toggles the relay.

See [Parameter UX](../integrations/parameter-ux.md) for how the app places parameters.

## Troubleshooting

- **The device is not listed.** Bring it within Bluetooth range of the Hub. Once it is on the network, check that mDNS is not blocked between it and the Hub.
- **"The setup code is wrong".** Check the code you built it with. After too many wrong codes, wait a minute.
- **The device could not join the Wi-Fi.** Most ESP32 chips support only 2.4 GHz networks.
- **Pairing asks for a key and rejects it.** The config has a key of its own: enter that key, or reflash with `encryption: {}`.
Loading