I’ve successfully managed to set up a Custom GPT which can query entities and call services in your home.
Current issues:
GPTs don’t work in the Android App yet when you add a custom API
The Custom GPT seems to have an issue with saving and publishing changes to API specs, current workaround is deleting the GPT and recreating a new one if you want to add additional services.
Pre-reqs:
You will need a Plus account
You will need an internet facing address for your Home Assistant.
Steps:
GPT Initialization:
Create a new GPT named ‘Home Assistant’.
Use the following prompt, updating it with your entity list: Prompt Link
Action Integration:
Add Actions using the provided OpenAPI Spec. Ensure to replace the URL with your public address: API Spec Link
Authentication:
Add an API Bearer Token for authentication. This token should be a long-lived token generated from your user page in the Home Assistant API.
Finalizing GPT Setup:
In your GPT settings, turn off “Use conversation data in your GPT to improve our models” for privacy.
Test the setup in the preview.
Publication:
When ready, publish the GPT. It’s recommended to set it as Private for security.
And now if all has gone well, you should be able to ask to turn lights on and off, ask for weather report, or run automations, depending which entities you added in the list in the prompt. I’m going to add more entities/services over time as I think of them and test them. Wanted to try the Todo list but I’m having trouble querying the current state of the list, so that’s one for the later Todo list
I went down the route of making a specific OpenAPI spec and adding individual service calls rather than using the /domain/service endpoint so that the specific parameters for each service can be described, so the GPT knows what it can send in. Planning on adding a lot more services in the future, and I’ll make a GitHub repo for this at some point.
I hope this is useful to someone, and that the current limitations can be overcome.
Ah, just noticed in the developer docs it mentions enabling the REST API in configuration.yaml by adding api:, which I probably a long time ago and forgot.
I’ll update the pre-reqs on the github readme, but let me know if you try it and it makes a difference.
One of the things that it does really well that I’ve discovered is that even though I only told it about my light groups, it’s able to infer the other lights from the result of the first call to the group of lights and set them all to different colours without specifically listing the entity names.
You could try adding the /api/entities endpoint or giving a knowledge base item with the list in for a wider list, but I found on my system there’s too many and it gets a request too large to query them, and by putting the limited list in the prompt it avoided an extra step checking the knowledge base when you give a command.
I was running into a similar problem and getting a 404, and just solved it for me.
In the GPT schema, check the URL you pasted in from nabu.casa. Mine had a trailing ‘/’ at the end of the URL by default. I had to remove that slash to get it to work.
I’ve posted over on GitHub on the issue raised, it’s still working for me at the moment, however it has just broken again for me in the Android app. Although only broken for some calls but not others (light and automation calls work, but check API doesn’t).
The check API called is saying “Stopped talking to …” and clicking that pops up a review privacy action. I didn’t set up a privacy statement, being a private GPT, but perhaps the android app is stopping messages due to that. I will try adding one tomorrow and see that gets it working there again.
There have been a fair few ChatGPT outages and issues recently, so it might be worth giving it a try later, FSZJ. Is it just check API, or do the other service calls also break for you?