Skip to main content

MQTT 集成

folotoy 服务器内的 MQTT 功能允许将有用的值发布到 MQTT 代理或订阅主题以修改 folotoy 服务器的配置。这对于其他自动化平台从 folotoy 服务器消费数据或进行交流非常有用。

MQTT Topics

在使用 MQTT 集成功能之前,需要在设置 INTEGRATION_MQTT 为 true,参考环境变量设置查看

以下是可用的主题和权限描述。

TopicPermissionsDescriptionPayload
/sys/folotoy/$sn/thing/event/postSubscribe发送玩具的事件消息,identifier 包括: voice_generated,recording_transcribed{"msgId": 174, "identifier": "voice_generated", "inputParams": {"recordingId": 31, "order": 4, "voiceText": " What's your first question?", "voiceUrl": "http://192.168.52.164:8082/voice-58fa4289fcc04d89bfee38aa038a904a.mp3", "role": 7}}
/sys/folotoy/$sn/thing/command/callPublish发送命令到玩具,identifier: iwantplay,identifier: updatecommonconfig使用角色1播放文字:
{"msgId": 100,"identifier": "iwantplay","inputParams": {"role": 1,"text": "这是一个播放文字转语音的测试123 hi good 朋友"}}
播放链接:
{"msgId" : 1, "identifier" : "iwantplay", "inputParams" : { "url" : "http://192.168.52.81:9001/speech-11.mp3" }}
当 url 和 text 同时存在时,优先播放 url
修改通用配置:
{"msgId" : 1, "identifier" : "updatecommonconfig", "inputParams" : { "record_type" : 1,"open_tip_type" : 1,"voltage_alarm" : 3.7,"sleep_trigger_time" : 600,"volume" : 100,"volume_control_type" : 1 }}
record_type: 1-点击录音按键对话,2-按压录音按键对话,3-连续对话模式
open_tip_type: 0-关闭开机提示音,1-启用开机提示应
voltage_alarm: 电压预警值配置,默认为3.7V
sleep_trigger_time: 休眠触发时间配置,默认为0,最小为30,单位为秒,为0时不启用
volume: 音量配置,默认为100,范围为0-100
volume_control_type: 音量设置类型配置;1-旋钮控制,2-指令控制,默认为1
/sys/folotoy/+/thing/command/callAckSubscribe接受命令的执行结果. identifier: iwantplay{"identifier": "iwantplay", "msgId": 1, "result": 1}, If result is 0 when command failed
/sys/configPublish在线调整系统配置,identifier 包括:load_roles_config , 如果发送的消息中有 msgId,回复的消息中也会有 msgId{"msgId": 174, "identifier": "load_roles_config"}
/sys/configAckSubscribe在线调整系统配置的回复{"msgId": 174, "identifier": "load_roles_config", "result": 1}
note

$sn通常可以在您的玩具包装盒或者tool.folotoy.com的控制台中找到。