mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-11-21 00:02:12 +01:00
test: Home Assistant discovery config on the PC
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>
This commit is contained in:
parent
8c59cf4903
commit
64f166490f
4 changed files with 326 additions and 128 deletions
29
src/MqttDisco.h
Normal file
29
src/MqttDisco.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#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
|
||||
Loading…
Add table
Add a link
Reference in a new issue