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