Use GPT to report device status

This automation relies on GPT to run business logic and determine if a device status requires attention. To connect my automation to GPT, I use AI-Intent which allows me to tell GPT what I care about. Below is an automation that highlights this capability.Click here (AI-Intent) to see how to install this plugin into Node-Red


Battery Status Automation

This automation uses the Home assistant render node to query for all devices with "battery" in it's name. The result along with their states are passed to GPT

[{"id":"d37ae37aa0591137","type":"inject","z":"b9203c19c137b9ca","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":200,"y":1060,"wires":[["02c68fb18029a2db"]]},{"id":"02c68fb18029a2db","type":"api-render-template","z":"b9203c19c137b9ca","name":"get battery states","server":"228d3d53.df8e02","version":0,"template":"{ \n  {% for state in states.sensor | sort(attribute='entity_id') | selectattr('entity_id', 'contains', 'battery' ) %}\n    \"{{state_attr(state.entity_id, 'friendly_name')}}\" :\"{{ state.state }}\",\n  {% endfor %}\n}","resultsLocation":"payload","resultsLocationType":"msg","templateLocation":"template","templateLocationType":"msg","x":250,"y":1120,"wires":[["8b5af06dd9359d63"]]},{"id":"8b5af06dd9359d63","type":"OpenAI System","z":"b9203c19c137b9ca","name":"","instruction":"You are an very polite AI Home assistant that\ncan give me insights into my home. Only report on devices\nthat are 10% and lower. Always greet me good night.\n\nBelow is a JSON of the device and the battery percentage:\n{payload}","x":260,"y":1160,"wires":[["edb94b83fc41a616"]]},{"id":"edb94b83fc41a616","type":"OpenAI User","z":"b9203c19c137b9ca","name":"","content":"Concisely tell me which devices have low batteries?","x":270,"y":1200,"wires":[["fa563fd5dbaab3d9"]]},{"id":"8afc878c80f309de","type":"OpenAI Response","z":"b9203c19c137b9ca","name":"","x":250,"y":1280,"wires":[["a21095e9c883e3d3"]]},{"id":"fa563fd5dbaab3d9","type":"OpenAI Chat","z":"b9203c19c137b9ca","name":"","tool_choice":"none","token":"","model":"gpt-4-1106-preview","temperature":0.7,"max_tokens":1200,"top_p":1,"frequency_penalty":0,"presence_penalty":0,"x":270,"y":1240,"wires":[["8afc878c80f309de"]]},{"id":"a21095e9c883e3d3","type":"debug","z":"b9203c19c137b9ca","name":"debug 137","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":450,"y":1280,"wires":[]},{"id":"13deade548e34b5e","type":"comment","z":"b9203c19c137b9ca","name":"Connect the response to your preferred output","info":"","x":560,"y":1240,"wires":[]},{"id":"228d3d53.df8e02","type":"server","name":"Home Assistant","addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"","statusSeparator":"","enableGlobalContextStore":false}]
Previous
Previous

Save Anything... Temporarily

Next
Next

Easily Use GPT in your automations with this plugin