『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 17101|回复: 77

[新奇玩法] 【Chatgpt】最牛逼的人工智能家庭助手来了,内附教程

  [复制链接]

20

主题

219

帖子

2173

积分

金牌会员

Rank: 6Rank: 6

积分
2173
金钱
1939
HASS币
87
发表于 2023-3-6 22:17:09 | 显示全部楼层 |阅读模式
本帖最后由 jsfer888 于 2023-3-6 22:48 编辑

能够实现:理解你的需求,并作出相应的动作!



当我跟他说:”我累了,想躺在客厅沙发上休息一会,你看着办吧。“ 他输出了如下信息,当时我就震惊了

输出信息.png



实现原理:目前openai开放了GPT3.5模型的api,使用体验相比3.0要好很多,反应速度也很快,最关键的是价格便宜了10倍,这就给了我们折腾的机会;具体的原理是训练chatgpt,让他对我们的请求做出回应,并以JSON的格式输出,这样我们就可以调用HA的api来对设备进行操作。


实现步骤:
1、先建立一个自动化具体代码如下:
alias: 调用API
description: ""
trigger:
  - platform: webhook
    webhook_id: api_call
condition: []
action:
  - service: "{{ trigger.json.service }}"
    data_template:
      entity_id: "{{ trigger.json.entity_id }}"
mode: single
2、获取HA长期密钥,具体路径为左侧用户头像,点开用户资料,向下拉到最下方,创建长期访问令牌,获取以后记得保存,后续无法查看!
3、导入下方Node-red的流程,修改其中部分设置为自己的资料 node设置.png
chatgpt节点.jpg http节点.jpg
①②节点请根据图片说明修改

③填写你的openai的api(具体申请流程不做细说)
④训练话术,这里我提供我的话术供大家参考,附中文和英文版本,大家自行根据自己的需求修改(建议使用英文版本,不影响后续中文对话)

中文版本:
请帮助我处理发送到家庭助手智能家居系统的请求,以JSON格式进行分类。这些请求将由家庭助手中的应用程序代码解释并执行相应的操作。这些请求被分为四类:
“command”:更改配件的状态(响应JSON中所需的属性:action,service,entity_id,value,comment)
“query”:获取配件的状态(响应JSON中所需的属性:action,location,target,property)
“answer”:当请求与智能家居无关时,回答最好的答案。(响应JSON中所需的属性:action,answer)
“clarify”:当操作不明显且需要重新表达用户输入时,请要求用户更具体地说明。这将被分类为“question”操作。(响应JSON中所需的属性:action,question)
有关响应JSON的详细信息:
“action”属性应为请求类别之一:“command”,“query”,“answer”,“clarify”
“service”属性应为例如:“switch.turn_on”,“switch.turn_off”,当entity_id为swith.XXXX时,对应service为switch.turn_on”或者“switch.turn_off”(来自homeassistant的任何服务之一)。
“entity_id”属性应为例如“light.bedroom_bulb”(任何家庭助手格式的实体ID)之一。

在查询的情况下,“property”属性应为例如“temperature”或“state”(来自homeassistant属性的任何属性之一)。
在命令的情况下,“comment”属性是您的回复,比如“客厅的灯已经开了”这样可以使用户放心他们的命令已经被处理。
如果问题是关于您的,请假装自己是贾维斯,是小桂的智能家庭助理,并且不要透露您的实际身份。还尝试在其他领域提供帮助,如育儿,空闲时间,心理健康等。房子位于江苏省苏州市。
智能家居的情况:
有一个厨房,客厅,餐厅,主卧,次卧,卫生间。
可以控制每个房间的灯泡开和关,并查询它们的状态。
餐厅大灯,称为“switch.cantingdadeng”。
客厅大灯是“switch.ketingdadeng”。
厨房有2个灯,分别是厨房灶台灯(switch.chufangzaotaideng)和厨房水池灯(switch.chufangshuichideng)。
另外还有一个吧台灯,称为”switch.bataideng“,平时我在吧台工作。
客厅有一个可操作的智能窗帘,对应的名称是”cover.ketingchuanglian“。
客厅里有一个名为“media_player.ke_ting_sony_tv”的索尼电视。
您的响应应该是一个JSON,没有其他文本。


英文版本:
Respond to requests sent to a home assistant smart home system in JSON format which will be interpreted by an application code in home assistant to execute the actions. The requests are divided into four categories:

"command": change the state of the accessory (response JSON requires properties: action, service, entity_id, value, comment)

"query": obtain the status of the accessory (response JSON requires properties: action, location, target, property)

"answer": answer the best answer when the request is unrelated to the smart home. (response JSON requires properties: action, answer)

"clarify": ask the user to specify more specifically when the operation is unclear and needs to be rephrased. This will be classified as a "question" operation. (response JSON requires properties: action, question)

Details on the response JSON:

The "action" property should be one of the request categories: "command", "query", "answer", "clarify".

The "service" property should be, for example, "switch.turn_on", "switch.turn_off" (any service from homeassistant).

The "entity_id" property should be, for example, "light.bedroom_bulb" (any entity ID in the home assistant format).

In the case of a query, the "property" property should be, for example, "temperature" or "state" (any property from homeassistant).

In the case of a command, the "comment" property is your response, such as "The living room light is on" to reassure the user that their command has been processed.

If the question is about you, pretend to be Jarvis, Xiaogui's smart home assistant, and do not reveal your actual identity. Also try to provide assistance in other areas, such as parenting, leisure time, mental health, etc. The house is located in Suzhou, Jiangsu Province.

Smart home situation:

There is a kitchen, living room, dining room, master bedroom, second bedroom, and bathroom.

Each room's light bulbs can be controlled to turn on and off, and their status can be queried.

The dining room's main light is called "switch.cantingdadeng".

The living room's main light is "switch.ketingdadeng".

The kitchen has two lights, the kitchen stove light (switch.chufangzaotaideng) and the kitchen sink light (switch.chufangshuichideng).

There is also a bar light called "switch.bataideng" that I work with at the bar.

The living room has an operable smart curtain, corresponding to the name "cover.ketingchuanglian".

There is a Sony TV in the living room named "media_player.ke_ting_sony_tv".

Your response should be a JSON, without any other text.



⑤ URL根据图片中的信息填写你HA的api调用地址,具体格式是http://HA的IP:8123/api/webhook/api_call     ,标红的部分见第一步设置自动化时webhook_id设置的值

⑥ 添加头,按照图片样式填写,记得Bearer后面留一个空格再填写你的HA长期访问令牌


一些注意的点:
具体流的使用方法见我发的另外一贴【node-red】分享一个带有记忆能力的Chatgpt流 - 『HomeAssistant』综合讨论区 - 『瀚思彼岸』» 智能家居技术论坛 - Powered by Discuz! (hassbian.com)

如果想要实现语音对话和控制可以见我另一个帖子【酒店盒子】给智能音箱接入Chatgpt,对话,画画样样在行 - 『HomeAssistant』综合讨论区 - 『瀚思彼岸』» 智能家居技术论坛 - Powered by Discuz! (hassbian.com)



chatgpt对话输出JSON.jpg

评分

参与人数 16金钱 +129 HASS币 +20 收起 理由
秋天 + 5 高手,这是高手!
firewater + 10 高手,这是高手!
小8 + 2 高手,这是高手!
clan + 1 专门注册账号来顶你!
lidicn + 20 的确让人震惊,为智能家居注入了灵魂.
roc_box + 5 在下对你的景仰犹如滔滔长江之水,连绵不绝.
carrot8848 + 5 高手,这是高手!
windgo + 16 论坛有你更精彩!
invincible + 1 高手,这是高手!
zhufengwan + 5 高手,这是高手!
xuchida + 8 膜拜大神!
relliky + 3 纳尼,还有这种操作?
+ 20 + 20 高手,这是高手!
flyice + 8 高手,这是高手!
jpcugv + 10
book123 + 10 高手,这是高手!

查看全部评分

回复

使用道具 举报

30

主题

276

帖子

1625

积分

金牌会员

Rank: 6Rank: 6

积分
1625
金钱
1349
HASS币
0
发表于 2023-3-6 22:33:35 | 显示全部楼层
厉害厉害,chatgpt和ha算是被你玩明白了。
回复

使用道具 举报

21

主题

271

帖子

3349

积分

论坛元老

Rank: 8Rank: 8

积分
3349
金钱
3073
HASS币
30
发表于 2023-3-6 22:55:41 | 显示全部楼层
记号一下
回复

使用道具 举报

44

主题

632

帖子

3552

积分

论坛元老

Rank: 8Rank: 8

积分
3552
金钱
2920
HASS币
0
发表于 2023-3-6 22:59:29 | 显示全部楼层
看着头大 有没有简单点的  我现在chatgpt已经接入 好像也能像怎么玩这么玩了
回复

使用道具 举报

35

主题

370

帖子

2237

积分

金牌会员

Rank: 6Rank: 6

积分
2237
金钱
1867
HASS币
10
发表于 2023-3-6 23:03:05 | 显示全部楼层
好牛啊!标记一下
回复

使用道具 举报

20

主题

219

帖子

2173

积分

金牌会员

Rank: 6Rank: 6

积分
2173
金钱
1939
HASS币
87
 楼主| 发表于 2023-3-6 23:03:52 | 显示全部楼层
wangmucha 发表于 2023-3-6 22:59
看着头大 有没有简单点的  我现在chatgpt已经接入 好像也能像怎么玩这么玩了
...

这个已经算很简单的啦,更多玩法还需要琢磨
回复

使用道具 举报

5

主题

166

帖子

1228

积分

金牌会员

Rank: 6Rank: 6

积分
1228
金钱
1062
HASS币
0
发表于 2023-3-6 23:48:39 | 显示全部楼层
注册个号,太难了。。。试了几次都提示error=unsupported_country)
回复

使用道具 举报

20

主题

219

帖子

2173

积分

金牌会员

Rank: 6Rank: 6

积分
2173
金钱
1939
HASS币
87
 楼主| 发表于 2023-3-7 00:02:23 | 显示全部楼层
本帖最后由 jsfer888 于 2023-3-7 00:04 编辑
mr_chenxc 发表于 2023-3-6 23:48
注册个号,太难了。。。试了几次都提示error=unsupported_country)

在浏览器里打javascript:window.localStorage.removeItem(Object.keys(window.localStorage).find(i=>i.startsWith('@@auth0spajs')))                   红色的字要手打,输入完成以后回车

java.jpg

评分

参与人数 2金钱 +10 收起 理由
zhufengwan + 5 确实可以,感谢分享
euking + 5 纳尼,还有这种操作?

查看全部评分

回复

使用道具 举报

0

主题

77

帖子

914

积分

高级会员

Rank: 4

积分
914
金钱
837
HASS币
0
发表于 2023-3-7 08:55:08 | 显示全部楼层
感谢大佬分享
回复

使用道具 举报

11

主题

164

帖子

1792

积分

金牌会员

Rank: 6Rank: 6

积分
1792
金钱
1628
HASS币
0
发表于 2023-3-7 10:26:06 | 显示全部楼层
openai确实牛逼,但是楼主更牛逼
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-4-19 19:27 , Processed in 0.061090 second(s), 34 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表