-
Notifications
You must be signed in to change notification settings - Fork 0
Networking and MQTT
Rewair operates in exactly one Wi-Fi role at a time:
- Station mode joins a saved home network.
- Setup mode hosts an access point for configuration.
With no stored network, the device boots directly into the open
rewair-setup-<xxxx> access point on channel 6 at 192.168.0.1/24. The suffix
is the final two bytes of the Wi-Fi MAC address. WICED supplies DHCP, DNS
redirection, and captive-portal redirects.
When saved networks exist, boot-time autojoin is attempted three times before falling back to the setup AP. A station link loss after a successful join does not enter setup mode; Rewair continues retrying the saved networks.
Submitting /api/join in setup mode stores the chosen credentials using the
scan cache, completes the HTTP response, and switches to station mode on the
network thread. /api/reset clears Wi-Fi, settings, and MQTT configuration and
reboots into setup mode.
The fallback AP retries saved networks about every five minutes. It delays a retry while a client is associated, preventing an active setup session from being interrupted.
In the device portal, open Settings → MQTT & Home Assistant → Configure. Enter the hostname or IP address and port of the broker used by Home Assistant. Username/password authentication is optional.
Rewair currently supports MQTT 3.1.1 over unencrypted TCP, normally port
1883. Use it only on a trusted local network; MQTT over TLS is not included.
Home Assistant discovery is enabled by default. Rewair creates seven entities:
- temperature
- humidity
- carbon dioxide
- VOC
- dust
- illuminance
- air-quality score
The device identifier is derived from the Wi-Fi MAC and remains stable across renames and reboots.
Retained telemetry is published to:
rewair/rewair_<12-hex-mac>/state
The adjacent availability topic carries retained online/offline state and
is configured as the last will. The portal allows custom state-topic and Home
Assistant discovery prefixes. Credentials and settings are stored in WICED
DCT. Factory reset removes retained discovery records when the broker is
reachable, then clears the local settings.
To inspect the broker:
mosquitto_sub -h <broker> -u <user> -P '<password>' -v \
-t 'rewair/#' -t 'homeassistant/sensor/#'