hugobloem / esp-ha-speech

Local speech recognition on an ESP32 for Home Assistant
141 stars 10 forks source link

MQTT isn't connected? #4

Open formatBCE opened 1 year ago

formatBCE commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

justinhunt1223 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 https://github.com/hugobloem/esp-ha-speech/blob/e03d22ee03369fceacd7ce55a96cb0b3c9074295/main/app/app_hass.c#L61-L65 and https://developers.home-assistant.io/docs/intent_conversation_api/)

formatBCE commented 1 year ago

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 https://github.com/hugobloem/esp-ha-speech/blob/e03d22ee03369fceacd7ce55a96cb0b3c9074295/main/app/app_hass.c#L61-L65 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 commented 1 year ago

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

https://github.com/hugobloem/esp-ha-speech/blob/e03d22ee03369fceacd7ce55a96cb0b3c9074295/main/app/app_hass.c#L61-L65

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 commented 1 year ago

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

justinhunt1223 commented 1 year ago

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

This would be great!

christian-nils commented 1 year ago

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 https://github.com/hugobloem/esp-ha-speech/blob/e03d22ee03369fceacd7ce55a96cb0b3c9074295/main/app/app_hass.c#L61-L65

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 commented 1 year ago

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!