I’m excited to share my latest project, a custom integration that brings the power of OpenAI’s ChatGPT directly into your Home Assistant setup. With this integration, you can harness the potential of AI-driven conversations and automations to make your smart home even more intelligent and versatile. From incorporating ChatGPT into dashboard views to triggering automations based on AI-generated responses, the possibilities are endless.
Great to see the interest of GPT among the community. I just came in to see if anyone thought about incorporating it into Home Assistant but not just to have chat prompt somewhere in lovelace but to be able to command my system from chat. For example I imagine it would be amazing if i could open my ChatGPT instance and ask it to turn on the lights today if i will not come home before 6pm. Without implementing an automation. I’m not even sure it’s doable at this stage of ChatGPT development but i’m sure some day it will be and it will be great to have it in place.
Not possible to action this without an automation (at the moment).
For a start, chatgpt cant keep track of time.
Home Assistant does have a built in openai tool, this declares certain home assistant entities and allows chatgpt to read the state of certain devices.
I created this so us as a community have a starting point on discovering what is indeed possible.
It’s an alt. Which would be banned if used for sock-puppeting (supporting your own posts with alt accounts), however as the other account makes no attempt to hide that they are the same person I see no reason to suspend it.
This is the first integration I’ve made.
This is by no means a ChatGPT replacement, Including chat history significantly increased the cost of usage due to the current OpenAI pricing model, so I aborted that idea for now.
OK, so I decided to give it a try and get some practical application of this integration. Here is what I got; ‘roon style’ media dashboard, that pulls information about album from OpenAI:
automation:
- id: 'update_media_info'
alias: Update Media Info
trigger:
- platform: state
entity_id: media_player.marantz_sacd30n
attribute: media_album_name
condition: []
action:
- service: input_text.set_value
data_template:
entity_id: input_text.gpt_input
value: >-
Tell me about {{state_attr('media_player.marantz_sacd30n', 'media_artist')}}'s album {{state_attr('media_player.marantz_sacd30n', 'media_album_name')}}"
initial_state: true
So far I’m using this only for media info, so there is no distinguishing regarding source of question. Not sure if with simple input/output model this would be possible to distinguish what process/automation asked the question and redirect answer to specific destination. This might be possible with asking question/blocking another question/waiting for answer/storing the answer wherever appropriate/ unblocking asking another question sort of flow.
BTW. I checked that you can also use song title to get more detailed info about any specific song. Pretty interesting answer you can get for this!
After working with the UI for a while, then checking entities, services, documentation and here, then going back and repeating, I was able to determine the only proper docs are on your GitHub. Please improve the docs.
Hmm I just tried to put this together but couldn’t get it to work. I followed all the steps via the GitHub link. Do you need a premium account for the API key to work? As it’s not generating a response
Thanks, working perfect in Lovelace UI!
Any Chance to get an Automation working with the Telegram Bot? I just can’t update the input_text.gpt_input entity …
Here is my code:
It gets triggered, but doesn’t fill in my text behind the /chatgpt command, the input_text.gpt_input doesn’t update.
I’ve tried nearly everything at the trigger.event.data.text part.
ChatGPT itself said I should try it with trigger.message.text.split(' ', 1)[1] but this still doesn’t work. Dunno whats the correct trigger data.
Maybe someone knows the correct way?
The Part of sending the response_text is working fine standalone!