mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-24 11:46:34 +00:00
Add discovery
This commit is contained in:
parent
8017be47db
commit
40c905687d
@ -42,8 +42,8 @@ extern uint8_t hasp_sleep_state;
|
||||
|
||||
dispatch_conf_t dispatch_setings = {.teleperiod = 300};
|
||||
|
||||
uint32_t dispatchLastMillis;
|
||||
uint8_t nCommands = 0;
|
||||
uint32_t dispatchLastMillis = -3000000; // force discovery
|
||||
uint8_t nCommands = 0;
|
||||
haspCommand_t commands[18];
|
||||
|
||||
struct moodlight_t
|
||||
|
@ -253,6 +253,13 @@ int mqtt_send_state(const __FlashStringHelper* subtopic, const char* payload)
|
||||
return mqttPublish(tmp_topic, payload, strlen(payload), false);
|
||||
}
|
||||
|
||||
int mqtt_send_discovery(const char* payload)
|
||||
{
|
||||
char tmp_topic[20];
|
||||
snprintf_P(tmp_topic, sizeof(tmp_topic), PSTR(MQTT_PREFIX "/discovery"));
|
||||
return mqttPublish(tmp_topic, payload, strlen(payload), false);
|
||||
}
|
||||
|
||||
int mqtt_send_object_state(uint8_t pageid, uint8_t btnid, const char* payload)
|
||||
{
|
||||
char tmp_topic[strlen(mqttNodeTopic) + 20];
|
||||
@ -268,6 +275,7 @@ static void onConnect(void* context)
|
||||
printf("Successful connection\n");
|
||||
|
||||
mqtt_subscribe(mqtt_client, TOPIC "command/#");
|
||||
mqtt_subscribe(mqtt_client, TOPIC "config/#");
|
||||
// mqtt_subscribe(mqtt_client, TOPIC "command");
|
||||
mqtt_subscribe(mqtt_client, TOPIC "light/#");
|
||||
mqtt_subscribe(mqtt_client, TOPIC "brightness/#");
|
||||
|
Loading…
x
Reference in New Issue
Block a user