Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT isn't connected? #4

Open
formatBCE opened this issue Mar 30, 2023 · 13 comments
Open

MQTT isn't connected? #4

formatBCE opened this issue Mar 30, 2023 · 13 comments

Comments

@formatBCE
Copy link

I'm using HA setup.
Tried to remove all commands to check if MQTT is working, but commands weren't deleted (no log in serial mon, commands still are being recognized.
Is it because i use non-rhasspi setup? Or there's bug?

@formatBCE
Copy link
Author

It's literally in the code
void app_hass_init(void)
{
#if NLU_MODE == NLU_RHASSPY

ESP_LOGI(TAG, "Starting up");
app_api_mqtt_start();

#elif NLU_MODE == NLU_HASS

ESP_LOGI(TAG, "Starting up");
xTaskCreate(&app_api_rest_test, "rest_test_task", 8192, NULL, 5, NULL);

#endif
}

However, it means there's no way to add/delete commands with HA - only pre-compiled stuff.

@justinhunt1223
Copy link

justinhunt1223 commented Mar 30, 2023

MQTT is not enabled if you set NLU_MODE to 1 0. Open up the file app/app_hass.c and add app_api_mqtt_start(); between lines 137 and 138. This will start up mqtt for ha. I think this is a bug and mqtt should be enabled for both modes.

@formatBCE
Copy link
Author

Yeah that's exactly what I did, and it works. Thanks.

Now basically one would able to create integration for HA, to be able to add commands from interface. Would be neat.

@formatBCE
Copy link
Author

formatBCE commented Mar 30, 2023

@justinhunt1223 the only thing is - is there any online thing to make phonetics from text? Or should i use that python lib exclusively?

@justinhunt1223
Copy link

Open up the script mentioned in the readme, it's very simple and you can repurpose the code. I'm almost done with a python script for making commands and pushing them to esp32 nodes. Just remember, there's a 200 command limit.

@formatBCE
Copy link
Author

Well, it seems to be not working - device reports in log about removing commands, and adding command from MQTT - so it's connected - but it doesn't affect actual set of commands on device itself.
Will dig more into, when have more time.

@christian-nils
Copy link
Contributor

MQTT is not enabled if you set NLU_MODE to 1. Open up the file app/app_hass.c and add app_api_mqtt_start(); between lines 137 and 138. This will start up mqtt for ha. I think this is a bug and mqtt should be enabled for both modes.

You meant if NLU_MODE == 0 (NLU_HASS), MQTT is not enabled. Right? Which may make sense since using HASS means not using MQTT but using a REST API (see

ESP_LOGI(TAG, "Sending command to Home Assistant");
char response[MAX_HTTP_OUTPUT_BUFFER] = {0};
char *message = malloc(strlen(cmd) + 100);
sprintf(message, "{\"text\": \"%s\"}", cmd);
app_api_rest_post("/api/conversation/process", response, message);
and https://developers.home-assistant.io/docs/intent_conversation_api/)

@formatBCE
Copy link
Author

MQTT is not enabled if you set NLU_MODE to 1. Open up the file app/app_hass.c and add app_api_mqtt_start(); between lines 137 and 138. This will start up mqtt for ha. I think this is a bug and mqtt should be enabled for both modes.

You meant if NLU_MODE == 0 (NLU_HASS), MQTT is not enabled. Right? Which may make sense since using HASS means not using MQTT but using a REST API (see

ESP_LOGI(TAG, "Sending command to Home Assistant");
char response[MAX_HTTP_OUTPUT_BUFFER] = {0};
char *message = malloc(strlen(cmd) + 100);
sprintf(message, "{\"text\": \"%s\"}", cmd);
app_api_rest_post("/api/conversation/process", response, message);
and https://developers.home-assistant.io/docs/intent_conversation_api/)

Yeah I found that already, and turned it on for HA too (there's no way to edit/add commands for REST, and I don't want to recompile each time I want to add something). But it doesn't work still - see my comments above.

@justinhunt1223
Copy link

justinhunt1223 commented Mar 30, 2023

MQTT is not enabled if you set NLU_MODE to 1. Open up the file app/app_hass.c and add app_api_mqtt_start(); between lines 137 and 138. This will start up mqtt for ha. I think this is a bug and mqtt should be enabled for both modes.

You meant if NLU_MODE == 0 (NLU_HASS), MQTT is not enabled. Right? Which may make sense since using HASS means not using MQTT but using a REST API (see

ESP_LOGI(TAG, "Sending command to Home Assistant");
char response[MAX_HTTP_OUTPUT_BUFFER] = {0};
char *message = malloc(strlen(cmd) + 100);
sprintf(message, "{\"text\": \"%s\"}", cmd);
app_api_rest_post("/api/conversation/process", response, message);

and https://developers.home-assistant.io/docs/intent_conversation_api/)

Correct, it will use hass to process the commands but you can't use mqtt to add/remove commands as the readme states because mqtt is not enabled.

I write a python script to send commands over mqtt for anyone interested. I modified app/app_api_mqtt.c line 144 to listen on esp-ha/config/add_cmd/MQTT_SITE_ID so the device will receive location-specific commands.

@formatBCE
Copy link
Author

I would actually write some integration for HA, that allows adding commands from UI.

@justinhunt1223
Copy link

I would actually write some integration for HA, that allows adding commands from UI.

This would be great!

@christian-nils
Copy link
Contributor

MQTT is not enabled if you set NLU_MODE to 1. Open up the file app/app_hass.c and add app_api_mqtt_start(); between lines 137 and 138. This will start up mqtt for ha. I think this is a bug and mqtt should be enabled for both modes.

You meant if NLU_MODE == 0 (NLU_HASS), MQTT is not enabled. Right? Which may make sense since using HASS means not using MQTT but using a REST API (see

ESP_LOGI(TAG, "Sending command to Home Assistant");
char response[MAX_HTTP_OUTPUT_BUFFER] = {0};
char *message = malloc(strlen(cmd) + 100);
sprintf(message, "{\"text\": \"%s\"}", cmd);
app_api_rest_post("/api/conversation/process", response, message);

and https://developers.home-assistant.io/docs/intent_conversation_api/)

Correct, it will use hass to process the commands but you can't use mqtt to add/remove commands as the readme states because mqtt is not enabled.

I write a python script to send commands over mqtt for anyone interested. I modified app/app_api_mqtt.c line 144 to listen on esp-ha/config/add_cmd/MQTT_SITE_ID so the device will receive location-specific commands.

Alright, I understand! Thanks for sharing your work!

@formatBCE
Copy link
Author

formatBCE commented Mar 30, 2023

I would actually write some integration for HA, that allows adding commands from UI.

This would be great!

Well, it would require MQTT to work :)
Also, for supporting multiple devices root topic should be adjustable (easy to do though).
P.S. I see you've done that topic extension already. Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants