请选择 进入手机版 | 继续访问电脑版

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

 找回密码
 立即注册
查看: 218|回复: 11

[经验分享] 索尼家电TCP控制(使用NODERED实现),控制码及控制流程

[复制链接]

8

主题

105

帖子

300

积分

论坛分享达人

积分
300
金钱
195
HASS币
10
发表于 2020-3-18 14:36:26 | 显示全部楼层 |阅读模式
本帖最后由 zxlch 于 2020-3-18 17:10 编辑

我家有一台SONY BDV-N9200W(应该7200W等2013年之前的蓝光播放器都是一个意思),按照之前群里面大神的说法,官方有API和NR有对应的插件。但是具体我抓包以后发现,我这台播放器的数据格式和新款ONE SONY以后的设备有点区别。具体区别不详细说了,抓包对比找规则费了很多时间,而且他的验证方式也不同。
(刚才把家里另外一台功放也试了一下,是一样的,也就是说所有所有LINUX系统的设备应该都一样)

我把NR流程发上来,具体如何使用就要需要的人自己发挥了。

11.png

流程中由上往下表示控制码,获取验证PIN,输入验证PIN。
所有的控制码如下
N9200W的控制码

"Confirm"="AAAAAwAAAhAAAAB8Aw=="
"Up"="AAAAAwAAAhAAAAB4Aw=="
"Down"="AAAAAwAAAhAAAAB5Aw=="
"Right"="AAAAAwAAAhAAAAB7Aw=="
"Left"="AAAAAwAAAhAAAAB6Aw=="
"Home"="AAAAAgAAANAAAAAHAw=="
"Options"="AAAAAwAAAhAAAABzAw=="
"Return"="AAAAAwAAAhAAAAB9Aw=="
"Num1"="AAAAAwAAAhAAAAAAAw=="
"Num2"="AAAAAwAAAhAAAAABAw=="
"Num3"="AAAAAwAAAhAAAAACAw=="
"Num4"="AAAAAwAAAhAAAAADAw=="
"Num5"="AAAAAwAAAhAAAAAEAw=="
"Num6"="AAAAAwAAAhAAAAAFAw=="
"Num7"="AAAAAwAAAhAAAAAGAw=="
"Num8"="AAAAAwAAAhAAAAAHAw=="
"Num9"="AAAAAwAAAhAAAAAIAw=="
"Num0"="AAAAAwAAAhAAAAAJAw=="
"Power"="AAAAAgAAAFAAAAAVAw=="
"Display"="AAAAAwAAAhAAAAAYAw=="
"VolumeUp"="AAAAAgAAAFAAAAASAw=="
"VolumeDown"="AAAAAgAAAFAAAAATAw=="
"Mute"="AAAAAgAAAFAAAAAUAw=="
"Audio"="AAAAAwAAAhAAAAASAw=="
"SubTitle"="AAAAAwAAAhAAAAARAw=="
"Angle"="AAAAAwAAAhAAAAATAw=="
"Favorites"="AAAAAwAABhAAAABLAw=="
"Yellow"="AAAAAwAABhAAAAAHAw=="
"Blue"="AAAAAwAABhAAAAAEAw=="
"Red"="AAAAAwAABhAAAAAFAw=="
"Green"="AAAAAwAABhAAAAAGAw=="
"Play"="AAAAAgAAANAAAAACAw=="
"Stop"="AAAAAgAAANAAAAAAAw=="
"Pause"="AAAAAgAAANAAAAABAw=="
"Rewind"="AAAAAwAAAhAAAAAzAw=="
"Forward"="AAAAAwAAAhAAAAA0Aw=="
"Prev"="AAAAAwAAAhAAAAAwAw=="
"Next"="AAAAAwAAAhAAAAAxAw=="
"Replay"="AAAAAwAAAhAAAAAhAw=="
"Advance"="AAAAAwAAAhAAAAAgAw=="
"TopMenu"="AAAAAwAAAhAAAAAZAw=="
"PopUpMenu"="AAAAAwAAAhAAAAAaAw=="
"Eject"="AAAAAwAAAhAAAAA8Aw=="
"BDV:SoundOutput"="AAAAAwAABhAAAABFAw=="
"Dimmer"="AAAAAgAAAFAAAABNAw=="
"BDV:Sleep"="AAAAAgAAAFAAAABgAw=="
"BDV:Function"="AAAAAgAAANAAAABpAw=="
"BDV:SoundMode"="AAAAAgAAANAAAABuAw=="
"BDV:SoundModeDown"="AAAAAgAAANAAAABeAw=="
"BDV:SoundModeUp"="AAAAAgAAANAAAABLAw=="
"Enter"="AAAAAwAAAhAAAAAMAw=="
"SEN"="AAAAAwAADhAAAABQAw=="
"Netflix"="AAAAAwAADhAAAABRAw=="
"Mode3D"="AAAAAwAABhAAAABMAw=="
"BDV:KeyControl-"="AAAAAgAAANAAAAAXAw=="
"BDV:KeyControl+"="AAAAAgAAANAAAAAWAw=="
"BDV:Echo"="AAAAAgAAANAAAAAUAw=="
"BDV:MicVol+"="AAAAAgAAANAAAAASAw=="
"BDV:MicVol-"="AAAAAgAAANAAAAATAw=="
"BDV:Bluetooth"="AAAAAwAABhAAAABxAw=="
"BDV:MusicEQ"="AAAAAgAAANAAAABJAw=="
"BDV:SpeakerIllumination"="AAAAAwAABhAAAABgAw=="
"BDV:FootBall"="AAAAAwAADhAAAAAXAw=="

DN1080的控制码
"STR:PowerMain"="AAAAAgAAADAAAAAVAQ=="
"Mute"="AAAAAgAAADAAAAAUAQ=="
"Confirm"="AAAAAgAAADAAAAAMAQ=="
"Home"="AAAAAgAAADAAAABTAQ=="
"Display"="AAAAAgAAADAAAABLAQ=="
"Return"="AAAAAwAAARAAAAB9AQ=="
"Options"="AAAAAwAAARAAAABzAQ=="
"STR:FunctionPlus"="AAAAAgAAALAAAABpAQ=="
"STR:FunctionMinus"="AAAAAgAAALAAAABqAQ=="
"Play"="AAAAAwAAARAAAAAyAQ=="
"Pause"="AAAAAwAAARAAAAA5AQ=="
"Stop"="AAAAAwAAARAAAAA4AQ=="
"Next"="AAAAAwAAARAAAAAxAQ=="
"Prev"="AAAAAwAAARAAAAAwAQ=="
"STR:Shuffle"="AAAAAwAAARAAAAAqAQ=="
"STR:Repeat"="AAAAAwAAARAAAAAsAQ=="
"STR:FF"="AAAAAwAAARAAAAA0AQ=="
"STR:FR"="AAAAAwAAARAAAAAzAQ=="
"VolumeUp"="AAAAAgAAADAAAAASAQ=="
"VolumeDown"="AAAAAgAAADAAAAATAQ=="
"Up"="AAAAAgAAALAAAAB4AQ=="
"Down"="AAAAAgAAALAAAAB5AQ=="
"Left"="AAAAAgAAALAAAAB6AQ=="
"Right"="AAAAAgAAALAAAAB7AQ=="
"STR:Num1"="AAAAAgAAADAAAAAAAQ=="
"STR:Num2"="AAAAAgAAADAAAAABAQ=="
"STR:Num3"="AAAAAgAAADAAAAACAQ=="
"STR:Num4"="AAAAAgAAADAAAAADAQ=="
"STR:Num5"="AAAAAgAAADAAAAAEAQ=="
"STR:Num6"="AAAAAgAAADAAAAAFAQ=="
"STR:Num7"="AAAAAgAAADAAAAAGAQ=="
"STR:Num8"="AAAAAgAAADAAAAAHAQ=="
"STR:Num9"="AAAAAgAAADAAAAAIAQ=="
"STR:Num0"="AAAAAgAAADAAAAAJAQ=="
"STR:PureDirect"="AAAAAwAABRAAAAB5AQ=="



流程如下

<font style="background-color: rgb(255, 255, 255);">[{"id":"17cde06d.7e62f","type":"http request","z":"d63a2914.0f51b8","name":"IRCC(BDV-N9200W)","method":"POST","ret":"txt","paytoqs":false,"url":"http://10.0.0.21:50001/upnp/control/IRCC","tls":"","persist":false,"proxy":"","authType":"","x":720,"y":920,"wires":[["94254bd7.3db428"]]},{"id":"fe79d7ef.a83548","type":"function","z":"d63a2914.0f51b8","name":"format","func":"msg.headers = {\n    "soapaction": "\\"urn:schemas-sony-com:service:IRCC:1#X_SendIRCC\\"",\n    "content-type": "text/xml; charset=utf-8",\n    "Connection": "close"\n}\n\nvar str = "<s:Envelope xmlns:s=\\"http://schemas.xmlsoap.org/soap/envelope/\\" s:encodingStyle=\\"http://schemas.xmlsoap.org/soap/encoding/\\"><s:Body><u:X_SendIRCC xmlns:u=\\"urn:schemas-sony-com:service:IRCC:1\\"><IRCCCode>" + msg.payload + "</IRCCCode></u:X_SendIRCC></s:Body></s:Envelope>"\nmsg.payload = str;\n\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":920,"wires":[["17cde06d.7e62f"]]},{"id":"5f09eecf.bcb9e","type":"debug","z":"d63a2914.0f51b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":890,"y":1080,"wires":[]},{"id":"359eb9a9.151586","type":"http request","z":"d63a2914.0f51b8","name":"Register(BDV-N9200W)","method":"GET","ret":"txt","paytoqs":false,"url":"http://10.0.0.21:50002/register?name=debian®istrationType=initial&deviceId=Nodered%3A11-22-33-44-55-66&wolSupport=true","tls":"","persist":false,"proxy":"","authType":"","x":710,"y":1080,"wires":[["5f09eecf.bcb9e"]]},{"id":"d0a22545.434458","type":"inject","z":"d63a2914.0f51b8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":1040,"wires":[["6e97d50f.ed5a0c"]]},{"id":"6e97d50f.ed5a0c","type":"function","z":"d63a2914.0f51b8","name":"GetPinCode","func":"msg.headers = {\n    "X-CERS-DEVICE-ID": "Nodered:11-22-33-44-55-66",\n    "X-CERS-DEVICE-INFO": "debian/Noderedforlinux/nodered",\n    "Connection": "close",\n}\n\nmsg.payload = null;\n\nreturn msg;","outputs":1,"noerr":0,"x":490,"y":1040,"wires":[["359eb9a9.151586"]]},{"id":"94254bd7.3db428","type":"debug","z":"d63a2914.0f51b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":890,"y":920,"wires":[]},{"id":"e67fb75f.06fb08","type":"inject","z":"d63a2914.0f51b8","name":"","topic":"","payload":"AAAAAwAAAhAAAAB4Aw==","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":920,"wires":[["fe79d7ef.a83548"]]},{"id":"1781c5a6.3809ca","type":"base64","z":"d63a2914.0f51b8","name":"","action":"str","property":"payload","x":340,"y":1120,"wires":[["c4ef5196.62ee3"]]},{"id":"da4138b2.557518","type":"inject","z":"d63a2914.0f51b8","name":"","topic":"","payload":"6096","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":1120,"wires":[["267d4a19.3949c6"]]},{"id":"267d4a19.3949c6","type":"function","z":"d63a2914.0f51b8","name":"format","func":"var srt = ":" + msg.payload;\nmsg.payload = srt;\nreturn msg;","outputs":1,"noerr":0,"x":210,"y":1120,"wires":[["1781c5a6.3809ca"]]},{"id":"c4ef5196.62ee3","type":"function","z":"d63a2914.0f51b8","name":"SetPinCode","func":"msg.headers = {\n    "Authorization": "Basic " + msg.payload,\n    "X-CERS-DEVICE-ID": "Nodered:11-22-33-44-55-66",\n    "X-CERS-DEVICE-INFO": "debian/Noderedforlinux/nodered",\n    "Connection": "close"\n}\n\nmsg.payload = null;\n\nreturn msg;","outputs":1,"noerr":0,"x":490,"y":1120,"wires":[["359eb9a9.151586"]]}]</font>





P.S 我在国外的论坛翻遍了,索尼功放除了我这种的还有一种不需要验证的,包括使用Renderer控制的,在我这台设备上面不是很方便,IRCC包含了所有遥控器上的功能,比较方便一些。


另外有个问题,HA如何输入字符然后通过MQTT传递给NR,或者用其他方式传递给NR。现在这个输入PIN码不知道在HA中如何做交互。。

评分

参与人数 1金钱 +20 HASS币 +10 收起 理由
+ 20 + 10 厉害了word楼主!

查看全部评分

回复

使用道具 举报

8

主题

105

帖子

300

积分

论坛分享达人

积分
300
金钱
195
HASS币
10
 楼主| 发表于 2020-3-18 14:38:19 | 显示全部楼层
本帖最后由 zxlch 于 2020-3-18 14:39 编辑

记得把HTTP节点中的IP地址改一下,或者导入的时候,替换两个10.0.0.21成自己设备的IP
回复

使用道具 举报

8

主题

105

帖子

300

积分

论坛分享达人

积分
300
金钱
195
HASS币
10
 楼主| 发表于 2020-3-18 15:19:45 | 显示全部楼层
刚才试了一下家里的SONY DN1080,跟我这个控制码一样的,估计AV功放系列的都是这样操作的
回复

使用道具 举报

8

主题

105

帖子

300

积分

论坛分享达人

积分
300
金钱
195
HASS币
10
 楼主| 发表于 2020-3-18 16:01:57 | 显示全部楼层
本帖最后由 zxlch 于 2020-3-18 17:01 编辑

电视部分

电视的控制码比较统一,可以参照官方这个(官方的控制码不全,如果有需要可以留言,我发全的)
https://pro-bravia.sony.net/zhs/develop/integrate/ircc-ip/ircc-codes/index.html



节点(切记修改PIN码,pin码在X-Auth-PSK后面,我设定的是123456,电视使用的是cookie验证,根据群内的说法是这种验证方法容易验证失败,所以直接在电视上设置固定PIN码后使用较为稳妥
[{"id":"19711bfb.1dfcd4","type":"http request","z":"d63a2914.0f51b8","name":"IRCC(KD-55)","method":"POST","ret":"txt","paytoqs":false,"url":"http://10.0.0.8:80/sony/IRCC","tls":"","persist":false,"proxy":"","authType":"","x":700,"y":840,"wires":[[]]},{"id":"e64fb3a2.bddd3","type":"function","z":"d63a2914.0f51b8","name":"format","func":"msg.headers = {\n    "SOAPACTION": "\\"urn:schemas-sony-com:service:IRCC:1#X_SendIRCC\\"",\n    "content-type": "text/xml; charset=utf-8",\n    "Connection": "close",\n    "X-Auth-PSK": "123456"\n}\n\nvar str = "<s:Envelope xmlns:s=\\"http://schemas.xmlsoap.org/soap/envelope/\\" s:encodingStyle=\\"http://schemas.xmlsoap.org/soap/encoding/\\"><s:Body><u:X_SendIRCC xmlns:u=\\"urn:schemas-sony-com:service:IRCC:1\\"><IRCCCode>" + msg.payload + "</IRCCCode></u:X_SendIRCC></s:Body></s:Envelope>"\nmsg.payload = str;\n\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":840,"wires":[["19711bfb.1dfcd4"]]},{"id":"cd13eedf.06382","type":"inject","z":"d63a2914.0f51b8","name":"","topic":"","payload":"AAAAAQAAAAEAAAB0Aw==","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":840,"wires":[["e64fb3a2.bddd3"]]}]



回复

使用道具 举报

8

主题

105

帖子

300

积分

论坛分享达人

积分
300
金钱
195
HASS币
10
 楼主| 发表于 2020-3-18 16:03:09 | 显示全部楼层
本帖最后由 zxlch 于 2020-3-18 17:09 编辑

投影部分


投影控制码:
"STANDBY"="[2,10,83,79,78,89,0,23,47,0]"
"ON"="[2,10,83,79,78,89,0,23,46,0]"
"Menu"="[2,10,83,79,78,89,0,23,41,0]"
"Enter"="[2,10,83,79,78,89,0,23,90,0]"
"Return"="[2,10,83,79,78,89,0,27,111,0]"
"Reset"="[2,10,83,79,78,89,0,23,123,0]"
"Inupt"="[2,10,83,79,78,89,0,23,87,0]"
"Up"="[2,10,83,79,78,89,0,23,53,0]"
"Down"="[2,10,83,79,78,89,0,23,54,0]"
"Lift"="[2,10,83,79,78,89,0,23,52,0]"
"Right"="[2,10,83,79,78,89,0,23,51,0]"

投影节点(使用方法,发送控制码倒数第二个数组给格式化单元,例如打开菜单发送41即可)
<font style="background-color: rgb(255, 255, 255);">[{"id":"425a507e.36f3f","type":"function","z":"d63a2914.0f51b8","name":"format","func":"var tmp = new Buffer([2,10,83,79,78,89,0,23,0,0]);\nif(msg.payload == 111)tmp[7] = 27;\ntmp[8] = msg.payload;\nmsg.payload = tmp;\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":640,"wires":[["22889306.37602c"]]},{"id":"134c9e00.b90162","type":"inject","z":"d63a2914.0f51b8","name":"","topic":"","payload":"87","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":640,"wires":[["425a507e.36f3f"]]},{"id":"22889306.37602c","type":"tcp request","z":"d63a2914.0f51b8","server":"10.0.0.4","port":"53484","out":"time","splitc":"0","name":"TCP(VPL)","x":690,"y":640,"wires":[[]]}]</font>



回复

使用道具 举报

9

主题

174

帖子

1179

积分

论坛技术达人

积分
1179
金钱
1005
HASS币
0
发表于 2020-3-19 19:50:04 | 显示全部楼层

投影机直接开启pjlink和网络待机就完事了。
回复

使用道具 举报

8

主题

105

帖子

300

积分

论坛分享达人

积分
300
金钱
195
HASS币
10
 楼主| 发表于 2020-3-19 21:01:37 | 显示全部楼层
kenlau 发表于 2020-3-19 19:50
投影机直接开启pjlink和网络待机就完事了。

也只能这样了,其他的做不到
回复

使用道具 举报

9

主题

174

帖子

1179

积分

论坛技术达人

积分
1179
金钱
1005
HASS币
0
发表于 2020-3-19 23:11:04 | 显示全部楼层
zxlch 发表于 2020-3-19 21:01
也只能这样了,其他的做不到

用PJLINK直接搞定了,什么关机开机切换信号那些足够了,还有状态反馈,上下左右按键那些我觉得根本没啥必要
回复

使用道具 举报

8

主题

105

帖子

300

积分

论坛分享达人

积分
300
金钱
195
HASS币
10
 楼主| 发表于 2020-3-19 23:35:17 | 显示全部楼层
本帖最后由 zxlch 于 2020-3-20 18:27 编辑
kenlau 发表于 2020-3-19 23:11
用PJLINK直接搞定了,什么关机开机切换信号那些足够了,还有状态反馈,上下左右按键那些我觉得根本没啥必 ...

PJLINK是个插件?

用插件不如我这样,做出的按钮可以不需要实体
Screenshot_20200319_233305_com.android.chrome.png


Screenshot_20200319_232756_com.android.chrome.png

我用实体写了一个,按钮太多了,实体列表里面一大堆菜单。。
回复

使用道具 举报

9

主题

174

帖子

1179

积分

论坛技术达人

积分
1179
金钱
1005
HASS币
0
发表于 2020-3-20 00:44:45 | 显示全部楼层
zxlch 发表于 2020-3-19 23:35
PJLINK是个插件?

用插件不如我这样,做出的按钮可以不需要实体

media_player
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2020-4-3 16:44 , Processed in 0.102198 second(s), 25 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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