mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-11-20 15:52:12 +01:00
The config a shade publishes for MQTT discovery moves to MqttDisco, with 11 unit tests: the topics, the device, which way each kind of shade opens, tilt, tilt only and dry contacts. A deleted group's retained sunSensor topic was never cleared: unpublish named it SunSensor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
1.1 KiB
C
29 lines
1.1 KiB
C
#ifndef MQTT_DISCO_H
|
|
#define MQTT_DISCO_H
|
|
#include <ArduinoJson.h>
|
|
#include "ShadeTypes.h"
|
|
|
|
// What Home Assistant's MQTT discovery needs to know about a shade. Kept
|
|
// free of the shade model and MQTT so the config it gets can be unit tested
|
|
// on the PC (pio test -e native).
|
|
struct shade_disco_t {
|
|
uint8_t shadeId = 0;
|
|
const char *name = "";
|
|
shade_types shadeType = shade_types::roller;
|
|
tilt_types tiltType = tilt_types::none;
|
|
bool flipPosition = false;
|
|
// From the MQTT and general settings.
|
|
const char *rootTopic = "";
|
|
const char *discoTopic = "";
|
|
const char *serverId = "";
|
|
const char *hostname = "";
|
|
const char *fwVersion = "";
|
|
};
|
|
// Dry contacts are switches, the rest covers.
|
|
bool isDiscoSwitch(shade_types type);
|
|
// Where the shade's config goes: <discoTopic>/cover/<id>/config or
|
|
// <discoTopic>/switch/<id>/config.
|
|
void shadeDiscoTopic(const char *discoTopic, uint8_t shadeId, bool isSwitch, char *topic, size_t len);
|
|
// Fills obj with the shade's config and topic with where it goes.
|
|
void shadeDisco(const shade_disco_t &shade, JsonObject obj, char *topic, size_t len);
|
|
#endif
|