极米投影进阶玩法及HomeKit电视接入方案

首先感谢一下这位大佬:[baisetiankong],两次提供了极米投影的控制API,本教程全程操作都是基于他分享的API,非常感谢下面是原贴地址,有需要的就去顶一下:
https://bbs.hassbian.com/thread-4998-1-1.html
https://bbs.hassbian.com/thread-8276-1-1.html

另外,有个重要的事情:请在投影上装好通电自启动插件,我的这个插件找不到了。

好了,骚操作开始了:HA接入篇:通过NR,发送上面的API指令,通过MQTT创建出实体按钮映射到HA,再通过Lovelace,呈现如下效果:

jpg三连(因为背景是动态的,所以三张图的背景不一样)

利用倾微大佬写的touchpad插件,盲操作简直不要太太爽,上下左右,滑动之间。这里也非常感谢倾微大佬,原贴如下,有需要的就去顶一下 https://bbs.hassbian.com/thread-8368-1-1.html
操作步骤:
1,导入下方NR的流程。(我把HA和HK两个的Flow写在一起了,在下面一起导入就好了)
2,把如下配置添加到configuration.yaml的switch下面。
3,下载倾微大佬的lovelace-card-touchpad插件,见上面原贴,我就不再介绍了

switch配置:

极米遥控

  • platform: mqtt
    name: “gimi_left”
    state_topic: “homeassistant/remote/status”
    command_topic: “homeassistant/remote/GIMI”
    qos: 2
    payload_on: “left”
    payload_off: “left”
    retain: true
  • platform: mqtt
    name: “gimi_right”
    state_topic: “homeassistant/remote/status”
    command_topic: “homeassistant/remote/GIMI”
    qos: 2
    payload_on: “right”
    payload_off: “right”
    retain: true
  • platform: mqtt
    name: “gimi_up”
    state_topic: “homeassistant/remote/status”
    command_topic: “homeassistant/remote/GIMI”
    qos: 2
    payload_on: “up”
    payload_off: “up”
    retain: true
  • platform: mqtt
    name: “gimi_down”
    state_topic: “homeassistant/remote/status”
    command_topic: “homeassistant/remote/GIMI”
    qos: 2
    payload_on: “down”
    payload_off: “down”
    retain: true
  • platform: mqtt
    name: “gimi_ok”
    state_topic: “homeassistant/remote/status”
    command_topic: “homeassistant/remote/GIMI”
    qos: 2
    payload_on: “pause&play”
    payload_off: “pause&play”
    retain: true
  • platform: mqtt
    name: “gimi_home”
    state_topic: “homeassistant/remote/status”
    command_topic: “homeassistant/remote/GIMI”
    qos: 2
    payload_on: “home”
    payload_off: “home”
    retain: true
  • platform: mqtt
    name: “gimi_vol-”
    state_topic: “homeassistant/remote/status”
    command_topic: “homeassistant/remote/GIMI”
    qos: 2
    payload_on: “vol-”
    payload_off: “vol-”
    retain: true
  • platform: mqtt
    name: “gimi_vol+”
    state_topic: “homeassistant/remote/status”
    command_topic: “homeassistant/remote/GIMI”
    qos: 2
    payload_on: “vol+”
    payload_off: “vol+”
    retain: true
  • platform: mqtt
    name: “gimi_back”
    state_topic: “homeassistant/remote/status”
    command_topic: “homeassistant/remote/GIMI”
    qos: 2
    payload_on: “back”
    payload_off: “back”
    retain: true
  • platform: mqtt
    name: “gimi_power”
    icon: mdi:power
    state_topic: “homeassistant/remote/status”
    command_topic: “homeassistant/remote/GIMI”
    qos: 2
    payload_on: “powerjimi”
    payload_off: “powerjimi”
    retain: true
  • platform: mqtt
    name: “gimi_mute”
    icon: mdi:speaker-off
    state_topic: “homeassistant/remote/status”
    command_topic: “homeassistant/remote/GIMI”
    qos: 2
    payload_on: “mute”
    payload_off: “mute”
    retain: true
  • platform: mqtt
    name: “gimi_menu”
    state_topic: “homeassistant/remote/status”
    command_topic: “homeassistant/remote/GIMI”
    qos: 2
    payload_on: “menu”
    payload_off: “menu”
    retain: true
  • platform: mqtt
    name: “gimi_cctv13”
    state_topic: “homeassistant/remote/status”
    command_topic: “homeassistant/remote/GIMI”
    qos: 2
    payload_on: “cctv13”
    payload_off: “cctv13”
    retain: true
  • platform: mqtt
    name: “gimi_qiyiguo”
    state_topic: “homeassistant/remote/status”
    command_topic: “homeassistant/remote/GIMI”
    qos: 2
    payload_on: “qiyiguo”
    payload_off: “qiyiguo”
    retain: true
  • platform: mqtt
    name: “gimi_txsp”
    state_topic: “homeassistant/remote/status”
    command_topic: “homeassistant/remote/GIMI”
    qos: 2
    payload_on: “txsp”
    payload_off: “txsp”
    retain: true
  • platform: mqtt
    name: “gimi_hdmi1”
    state_topic: “homeassistant/remote/status”
    command_topic: “homeassistant/remote/GIMI”
    qos: 2
    payload_on: “hdmi1”
    payload_off: “hdmi1”
    retain: true

4,编写Lovelace配置文件,把轻微大佬的滑动配置添加到ui-lovelace。
5,重启HA,然后就可以开始耍了

PS:

a,遥控下面的4个按钮是可以随意添加的,我接下来写了4个我自己常用的几个,然后需要一个个制作图标,我嫌麻烦。如果您需要可以把下面的小爱控制里面的指令复制过来,那个里面我写了25个电视台的指令,就是复制粘贴的事儿,主要是太懒,就没加到这个里面来,

b,由于投影关机以后就掉线了,就无法接受指令了,所以这边建议把投影电源控制起来,配合通电开机插件,完美自动化,可以在关机情况下,完美唤醒,并且播放你点播的电视台或者打开的应用程序,体验相当无缝

.C,流量里面有部分开关机的时候会有语音TTS播报,我这里用的是小爱,所以写的都是小爱的例程,可能引入进去后会 提示该做法,没有的话直接删除掉就好了,其他功能正

HK接篇
利用ABC大佬的homebridge插件,非常感谢大佬的无私奉献,目前就只能添加4个通道,要是哪天大佬心情好,把插件更新一下,提供更好了,GIT地址:homebridge-mqtt-television

通过MQTT把投影仪模拟成支持HomeKit的电视,直接连接到Home APP,可以使用苹果HomeKit电视的遥控器,操作起来非常顺滑,盲按无压力,我自己一个台Apple TV,通过这个,可以同时管理两个设备,简直不要太方便,遥控器可以扔掉了,其实主要还是装逼。

操作步骤:
1,安装homebridge
方法1,通过docker部署,参见Git部署方案,很简单,我就不多余述了,homebridge
方法2,通过iobroker的插件ham,直接参照,这个大佬的分享:iobroker-ham

2.编辑homebridge的配置,并启动HB,可参照代码如下:

[mw_shl_code=applescript,true]{
“bridge”: {
“name”: “JIMITV”,
“username”: “B1:07:FA:91:FA:7E”,
“port”: 52010,
“pin”: “123-11-678”
},
“accessories”:
{
“accessory”: “television”,
“name”: “XGIMI”,
“pinghost”: “192.168.2.000”,
“mqtt”: {
“server”: “192.168.2.000:1883”,
“prefix”: “lee”,
“username”: “00000”,
“password”: “0000000”
},
“input”: {
“screenName”: “home_screen”,
“home_screen”: “home”,
“HdmiName1”: “Hdmi 1”,
“hdmi1”: “hdmi1”,
“HdmiName2”: “Hdmi 2”,
“hdmi2”: “qiyiguo”,
“HdmiName3”: “Hdmi 3”,
“hdmi3”: “txsp”,
“HdmiName4”: “Hdmi 4”,
“hdmi4”: “cctv13”
},
“remote”: {
“on_off”: “powerjimi”,
“arrow_up”: “up”,
“arrow_right”: “right”,
“arrow_down”: “down”,
“arrow_left”: “left”,
“select”: “pause&play”,
“play_pause”: “pause&play”,
“back”: “back”,
“information”: “menu”,
“powerModeSelection”: “3,32A66897,32”
},
“volume”: {
“increment”: “vol+”,
“decrement”: “vol-”
}
}
]
}[/mw_shl_code]

3,注意 “ prefix”:“ lee”,这行代码,后面引号里面代表的是mqtt topic的替代,这里关系到能否成功发指令的问题,就像我的是lee,那么我的MQTT topic就是lee /发送。

[attach]1669[/attach]

4.在NR里面建立Mqtt节点来接受指令,

主题那里就按上面的填,就行了。具体的就把下面的流程,根据参数改就好了

。。5:导入下面的流程,部署,然后在首页App里面添加配件,就可以耍了

HA&HK的流程,

2019.11.14版,加入了是否在家检测,原理是通过检测手机在不在局域网内,如果在可以正常开机,如果不在,那么TTS主人不在,无法打开投影。
为什么要加入这个,主要是今天下班回来,投影自己打开了,查了一下日志,发现开了5个小时,卧槽,懵逼了,为了防止此类事件在发生,就做了一下调整,这里是我的个人情况,如果不需要这部分,就导入不带检测的那个Flow。如果需要实现在家检测,那么就要固定一下手机的IP。

带是否在家检测的flow

[mw_shl_code = applescript,true] {“ id”:“ fc975f4.b4289a”,“ type”:“ tab”,“ label”:“极米投影控制”,“ disabled”:false,“ info”:“” },{“ id”:“ 6ba8ca5.c4a7534”,“ type”:“ mqtt in”,“ z”:“ fc975f4.b4289a”,“ name”:“极米遥控输入HK”,“ topic”:“ lee /send",“qos”:“0”,“datatype”:“auto”,“broker”:“8de150fb.a895b”,“x”:100,“y”:240,“wires”:""a6c02528 .cf1968“,” 53689625.ec33b8“,” 9df9622a.423c8“]]},{” id“:” 34405c34.259c24“,” type“:” udp out“,” z“:” fc975f4.b4289a“,”名称”:“极米控制指令广播”,“地址”:“ 192.168.2.109”,“ iface”:“”,“ port”:“ 16735”,“ ipv”:“ udp4”,“ outport”:“”,“ base64”:false,“ multicast”:“ false”,“ x”:1210, “ y”:180,“ wires”:]},{“ id”:“ a6c02528.cf1968”,“ type”:“ function”,“ z”:“ fc975f4.b4289a”,“ name”:“组装指令“,” func“:” if(msg.payload == \“ home \”){\ n msg.payload = \“ KEYPRESSES:35 \” \ n返回msg; \ n} \ nelse if(msg.payload = = \“静音\”){\ n msg.payload = \“ KEYPRESSES:113 \” \ n返回msg; \ n} \ nelse if(msg.payload == \“ set_up \”){\ n msg.payload = \“ KEYPRESSES:251 \” \ n返回msg; \ n} \ nelse if(msg.payload == \“ vol + \”){\ n msg.payload = \“ KEYPRESSES:115 \“ \ n return msg; \ n} \ nelse if(msg.payload == \” vol- \“){\ n msg.payload = \” KEYPRESSES:114 \“ \ n返回msg; \ n} \ nelse if(msg.payload == \“ menu \”){\ n msg.payload = \“ KEYPRESSES:139 \” \ n return msg; \ n} \ nelse if(msg.payload == \“ back \” ){\ n msg.payload = \“ KEYPRESSES:48 \” \ n返回msg; \ n} \ nelse if(msg.payload == \“ pause&play \”){\ n msg.payload = \“ KEYPRESSES:49 \“ \ n return msg; \ n} \ nelse if(msg.payload == \” down \“){\ n msg.payload = \” KEYPRESSES:38 \“ \ n返回msg; \ n} \ nelse如果(msg.payload == \“ up \”){\ n msg.payload = \“ KEYPRESSES:36 \” \ n返回msg; \ n} \ nelse if(msg.payload == \“ left \”){ \ n msg.payload = \“ KEYPRESSES:50 \” \ n返回msg; \ n} \ nelse if(msg。有效负载== \“正确\”){\ n msg.payload = \“ KEYPRESSES:37 \” \ n返回msg; \ n} \ n“,”输出“:1,” noerr“:0,” x“ :360,“ y”:140,“ wires”:“ dfce9c8f.e5b99”]]},{“ id”:“ 2764d3db.dd8a5c”,“ type”:“ udp out”,“ z”:“ fc975f4 .b4289a“,” name“:”极米控制指令广播“,” addr“:” 192.168.2.109“,” iface“:”“,” port“:” 16750“,” ipv“:” udp4“,” outport“:”“,” base64“:false,” multicast“:” false“,” x“:1210,” y“:120,” wires“:]},{” id“:” 53689625.ec33b8“ ,“ type”:“函数”,“ z”:“ fc975f4.b4289a”,“ name”:“组装指令”,“func“:” if(msg.payload == \“ cctv13 \”){\ n msg.payload = {\“ action \”:20000,\“ controlCmd \”:{\“ data \”:\“中央十三台\“,\” delayTime \“:0,\” mode \“:5,\” time \“:0,\” type \“:0},\” msgid \“:\” 2 \“} \ n return msg; \ n} \ nelse if(msg.payload == \“ qiyiguo \”){\ n msg.payload = {\“ action \”:20000,\“ controlCmd \”:{\“ data \ “:\” com.gitvjimi.video \“,\” delayTime \“:0,\” mode \“:7,\” time \“:0,\” type \“:1},\” msgid \“ :\“ 2 \”} \ n返回msg; \ n} \ nelse if(msg.payload == \“ txsp \”){\ n msg.payload = {\“ action \”:20000,\“ controlCmd \ “:{\” data \“:\” com.ktcp.tvvideo \“,\” delayTime \“:0,\” mode \“:7,\“ time \”:0,\“ type \”:1},\“ msgid \”:\“ 2 \”} \ n返回msg; \ n} \ nelse if(msg.payload == \“ hdmi1 \ “){\ n msg.payload = {\” action \“:20000,\” controlCmd \“:{\” data \“:\” HDMI2 \“,\” delayTime \“:0,\” mode \“ :5,\“ time \”:0,\“ type \”:0},\“ msgid \”:\“ 2 \”} \ n返回味精; \ n} \ n返回null; \ n \ n“, “输出”:1,“ noerr”:0,“ x”:360,“ y”:200,“电线”:“” dfce9c8f.e5b99“]]} , {” id“:” bfa182d3.b8f07“, “ type”:“ json”,“ z”:“ fc975f4.b4289a”,“ name”:“”,“ property”:“有效载荷”,“ action”:“ str”,“ pretty”:false,“ x” :810,“ y”:120,“电线”:“” 2764d3db.dd8a5c“]]}},{” id“:” dfce9c8f.e5b99“,” type“:” switch“,” z“:” fc975f4.b4289a“,” name“:”“,”属性“:”有效载荷“,” propertyType“:” msg“,”规则“:{” t“:” istype“,” v“:”对象“,” vt“:”对象“},{” t“: “ istype”,“ v”:“字符串”,“ vt”:“字符串”}]],“ checkall”:“ true”,“修复”:false,“输出”:2,“ x”:610,“ y “:180,” wires“:”“ bfa182d3.b8f07”],“ 34405c34.259c24”]]}},{“ id”:“ 8a2ff2dd.0d802”,“ type”:“注释”,“ z”: “ fc975f4.b4289a”,“名称”:“ HomeKit”,“info“:”“,” x“:80,” y“:200,” wires“:]},{” id“:” 4844588a.675cc8“,” type“:” function“,” z“:” fc975f4.b4289a“,” name“:”组装指令“,” func“:” if(msg.payload == \“ home \”){\ n msg.payload = \“ KEYPRESSES:35 \” \ n返回msg ; \ n} \ nelse if(msg.payload == \“静音\”){\ n msg.payload = \“ KEYPRESSES:113 \” \ n返回msg; \ n} \ nelse if(msg.payload == \“ set_up \”){\ n msg.payload = \“ KEYPRESSES:251 \” \ n返回msg; \ n} \ nelse if(msg.payload == \“ vol + \”){\ n msg.payload = \“ KEYPRESSES:115 \” \ n返回msg; \ n} \ nelse if(msg.payload == \“ vol- \”){\ n msg.payload = \“ KEYPRESSES:114 \” \ n返回msg; \ n} \ nelse if(msg.payload == \“菜单\“){\ n msg.payload = \” KEYPRESSES:139 \“ \ n返回msg; \ n} \ nelse if(msg.payload == \” back \“){\ n msg.payload = \” KEYPRESSES:48 \“ \ n返回msg; \ n} \ nelse if(msg.payload == \” pause&play \“){\ n msg.payload = \” KEYPRESSES:49 \“ \ n返回msg; \ n} \ nelse if(msg.payload == \“ down \”){\ n msg.payload = \“ KEYPRESSES:38 \” \ n return msg; \ n} \ nelse if(msg.payload == \“ up \ “){\ n msg.payload = \” KEYPRESSES:36 \“ \ n返回msg; \ n} \ nelse if(msg.payload == \” left \“){\ n msg.payload = \” KEYPRESSES: 50 \“ \ n return msg; \ n} \ nelse if(msg.payload == \” right \“){\ n msg.payload = \” KEYPRESSES:37 \“ \ n返回msg; \ n} \ n “,”输出“:1,” noerr“:0,” x“:360,” y“:540,“ wires”:“” 7c102a03.e8de54“]]},{” id“:” f1bc217c.7a20d“,” type“:” mqtt in“,” z“:” fc975f4.b4289a“,” name“:”极米遥控输入HA“,” topic“:” homeassantant / remote / GIMI“,” qos“:” 1“,” datatype“:” auto“,” broker“:” 8de150fb.a895b“,” x“:100 ,“ y”:580,“电线”:“” 4844588a.675cc8“,” d1fb339.92cefd“,” 3a12c418.69654c“,” d3cfc827.843658“]]}},{” id“:” 5625dc5d.980c04“ ,“ type”:“评论”,“ z”:“ fc975f4.b4289a”,“名称”:“ HA”,“信息”:“”,“ x”:72,“ y”:540,“电线”: ]},{“ id”:“ 9df9622a.423c8”,“类型”:“switch“,” z“:” fc975f4.b4289a“,” name“:”“,” property“:” payload“,” propertyType“:” msg“,” rules“:{” t“:” eq“, “ v”:“ powerjimi”,“ vt”:“ str”},{“ t”:“ eq”,“ v”:“ home”,“ vt”:“ str”},{“ t”:“ eq “,” v“:” cctv13“,” vt“:” str“},{” t“:” eq“,” v“:” qiyiguo“,” vt“:” str“},{” t“: “ eq”,“ v”:“ txsp”,“ vt”:“ str”},{“ t”:“ eq”,“ v”:“ hdmi1”,“ vt”:“ str”}]],“ checkall “:” true“,”修复“:false,”输出“:6,” x“:350,“ y”:360,“电线”:“ a8ef15c0.e7d2a8”],“ 2090dfb2.fb011”],“ 2090dfb2.fb011”],“ 2090dfb2.fb011”],“ 2090dfb2.fb011”] ,“ 39db352.54729ca”]]}},{“ id”:“ 39db352.54729ca”,“ type”:“ api-call-service”,“ z”:“ fc975f4.b4289a”,“ name”:“ ATV电源开“,”服务器“:” 3fefe449.e70c1c“,”版本“:1,” debugenabled“:false,” service_domain“:” switch“,” service“:” turn_on“,” entityId“:” switch.bookroom_switch_2 “,” data“:”“,” dataType“:” json“,” mergecontext“:”“,” output_location“:”“,” output_location_type“:” none“,” mustacheAltTags“:false,“ x”:550,“ y”:420,“电线”:“” e4db2fa1.5d90d“]]},{” id“:” 655ba9ef.d78b48“,” type“:” api-call-service“, “ z”:“ fc975f4.b4289a”,“名称”:“ ATV电源关闭”,“服务器”:“ 3fefe449.e70c1c”,“版本”:1,“ debugenabled”:false,“ service_domain”:“ switch”, “ service”:“ turn_off”,“ entityId”:“ switch.bookroom_switch_2”,“ data”:“”,“ dataType”:“ json”,“ mergecontext”:“”,“ output_location”:“”,“ output_location_type” :“ none”,“ mustacheAltTags”:false,“ x”:730,“ y”:360,“ wires”:“” ffc343e6.07939“]]},{” id“:” 2090dfb2.fb011“,“ type”:“ delay”,“ z”:“ fc975f4.b4289a”,“ name”:“”,“ pauseType”:“ delay”,“ timeout”:“ 5”,“ timeoutUnits”:“ seconds”,“ rate“:” 1“,” nbRateUnits“:” 1“,” rateUnits“:” second“,” randomFirst“:” 1“,” randomLast“:” 5“,” randomUnits“:” seconds“,” drop“ :false,“ x”:540,“ y”:360,“ wires”:“” 655ba9ef.d78b48“]]},{” id“:” a8ef15c0.e7d2a8“,” type“:” exec“,” z“:” fc975f4.b4289a“,”命令“:” ping 192.168.2.109 -c 1> / dev / null 2>&1“,” addpay“:false,” append“:”“,” useSpawn“:”false“,” timer“:”“,” oldrc“:false,” name“:”检测投影是否在线“,” x“:570,” y“:300,”电线“:],], “ 45e7866d.e29168”]]},{“ id”:“ a69b82db.bec81”,“ type”:“ api-call-service”,“ z”:“ fc975f4.b4289a”,“ name”:“投影仪电源关”,“服务器”:“ 3fefe449.e70c1c”,“版本”:1,“已启用调试”:false,“ service_domain”:“ switch”,“服务”:“ turn_off”,“ entityId”:“ switch.bookroom_switch_1 “,” data“:”“,” dataType“:” json“,” mergecontext“:”“,” output_location“:”“,” output_location_type“:” none“,” mustacheAltTags“:false,” x“:1200 ,“ y”:300,“ wires”:“” 57cb661.572d398“]]},{” id“:” 6cc5da28.8407a4“,” type“:” delay“,” z“:” fc975f4.b4289a“, “ name”:“”,“ pauseType”:“ delay”,“ timeout”:“ 10”,“ timeoutUnits”:“ seconds”,“ rate”:“ 1”,“ nbRateUnits”:“ 1”,“ rateUnits” :“ second”,“ randomFirst”:“ 1”,“ randomLast”:“ 5”,“ randomUnits”:“ seconds”,“ drop”:false,“ x”:1000,“ y”:300,“ wires” :“” a69b82db.bec81“]]},{” id“:” 9987b09.172275“,” type“:” change“,” z“:” fc975f4.b4289a“,” name“:”转换指令“, “规则”:{t“:” set“,” p“:”有效载荷“,” pt“:” msg“,” to“:” KEYPRESSES:30“,” tot“:” str“}]],” action“:”“, “ property”:“”,“ from”:“”,“ to”:“”,“ reg”:false,“ x”:1000,“ y”:240,“ wires”:“” 34405c34.259c24“ ]]},{“ id”:“ c009f2e5.72225”,“ type”:“ udp out”,“ z”:“ fc975f4.b4289a”,“ name”:“极米控制指令广播”,“ addr”: “ 192.168.2.109”,“ iface”:“”,“ port”:“ 16735”,“ ipv”:“ udp4”,“ outport”:“”,“ base64”:false,“ multicast”:“ false”, “ x”:1210,“ y”:580,“电线”:]},{“ id”:“ 1bc928a3.97ed57”,“ type”:“ udp out”,“ z”:“ fc975f4.b4289a”,“ name”:“极米控制指令广播”,“ addr”:“ 192.168.2.109 “,” iface“:”“,”端口“:” 16750“,” ipv“:” udp4“,”输出“:”“,” base64“:false,”多播“:” false“,” x“: 1210,“ y”:535,“ wires”:]},{“ id”:“ d1fb339.92cefd”,“ type”:“ function”,“ z”:“ fc975f4.b4289a”,“ name”:“组装指令“,” func“:” if(msg.payload == \“ cctv13 \”){\ n msg.payload = {\“ action \”:20000,\“ controlCmd \”:{\“ data \” :\“中央十三台\”,\“ delayTime \”:0,\“ mode \”:5,\“ time \”:0,\“ type \”:0},\“ msgid \”:\“ 2 \”} \ n返回msg; \ n} \ nelse if(msg.payload == \“ qiyiguo \”){\ n msg.payload = {\“ action \”:20000,\“ controlCmd \”:{\“ data \”:\“ com.gitvjimi.video \”,\“ delayTime \”:0,\“ mode \”:7,\ “ time \”:0,\“ type \”:1},\“ msgid \”:\“ 2 \”} \ n返回msg; \ n} \ nelse if(msg.payload == \“ txsp \” ){\ n msg.payload = {\“ action \”:20000,\“ controlCmd \”:{\“ data \”:\“ com.ktcp.tvvideo \”,\“ delayTime \”:0,\“模式\“:7,\”时间\“:0,\”类型\“:1},\” msgid \“:\” 2 \“} \ n返回msg; \ n} \ nelse if(msg.payload == \“ hdmi1 \”){\ n msg.payload = {\“ action \”:20000,\“ controlCmd \”:{\“ data \”:\“ HDMI2 \”,\“ delayTime \”:0,\“ mode \”:5,\“ time \”:0,\“ type \”:0},\“ msgid \”:\“ 2 \” } \ n return msg; \ n} \ n返回null; \ n \ n“,”输出“:1,” noerr“:0,” x“:360,” y“:620,”电线“:” 7c102a03.e8de54“]]}},{” id“:” 14e63605.4c67aa“,” type“:” json“,” z“:” fc975f4.b4289a“,” name“:”“,” property“:”有效载荷“,” action“:” str“,” pretty“:false,” x“:810,” y“:540,” wires“:”“ 1bc928a3.97ed57”]]} , {“ id”:“ 7c102a03 .e8de54“,”类型“:”开关“,” z“:” fc975f4.b4289a“,”名称“:”“,”属性“:”有效载荷“,”propertyType“:” msg“,”规则“:{” t“:” istype“,” v“:”对象“,” vt“:”对象“},{” t“:” istype“,” v“ :“字符串”,“ vt”:“字符串”}]],“ checkall”:“ true”,“修复”:false,“输出”:2,“ x”:610,“ y”:580,“电线” :“” 14e63605.4c67aa“],” c009f2e5.72225“]]},{” id“:” e1a9d073.55dfd“,” type“:” exec“,” z“:” fc975f4.b4289a“,”命令“:” ping 192.168.2.109 -c 1> / dev / null 2>&1“,” addpay“:false,” append“:”“,” useSpawn“:” false“,” timer“:”“,” oldrc“:false,” name“:”检测投影是否在线“,”x“:550,” y“:760,” wires“:],],” f24d38bf.055d28“]]}},{” id“:” ed29899f.2b50e8“,” type“:” api-呼叫服务”,“ z”:“ fc975f4.b4289a”,“名称”:“投影仪电源关”,“服务器”:“ 3fefe449.e70c1c”,“版本”:1,“已启用调试”:false,“ service_domain” “:” switch“,” service“:” turn_off“,” entityId“:” switch.bookroom_switch_1“,” data“:”“,” dataType“:” json“,” mergecontext“:”“,” output_location“: “”,“ output_location_type”:“ none”,“ mustacheAltTags”:false,“ x”:1180,“ y”:680,“ wires”:“ ceabea0.7d28018”]]}},{“ id”:“ 401f3299。febadc“,” type“:” delay“,” z“:” fc975f4.b4289a“,” name“:”“,” pauseType“:” delay“,” timeout“:” 10“,” timeoutUnits“:” seconds “,” rate“:” 1“,” nbRateUnits“:” 1“,” rateUnits“:” second“,” randomFirst“:” 1“,” randomLast“:” 5“,” randomUnits“:” seconds“, “ drop”:false,“ x”:980,“ y”:680,“ wires”:“ ed29899f.2b50e8”]]}},{“ id”:“ f24d38bf.055d28”,“ type”:“开关“,” z“:” fc975f4.b4289a“,”名称“:”“,”属性“:”有效载荷代码“,”属性类型“:” msg“,”规则“:{” t“:”eq“,” v“:” 0“,” vt“:” str“},{” t“:” eq“,” v“:” 1“,” vt“:” str“}]],” checkall“ :“ true”,“修复”:false,“输出”:2,“ x”:770,“ y”:700,“电线”:“” 401f3299.febadc“,” 63ca80d2.374cf“],” aaa3d893.767048“]]},{” id“:” 63ca80d2.374cf“,” type“:” change“,” z“:” fc975f4.b4289a“,” name“:”转换指令“,”规则“: {“ t”:“ set”,“ p”:“有效载荷”,“ pt”:“ msg”,“至”:“ KEYPRESSES:30”,“ tot”:“ str”}]],“动作”: “”,“属性”:“”,“从”:“”,“到”:“”,“ reg”:false,“ x”:980,“ y”:640,“ wires”:“ c009f2e5.72225”]]}},{“ id”:“ a06022bb.af90d”,“ type”:“ api -call-service“,” z“:” fc975f4.b4289a“,” name“:”投影仪电源开“,” server“:” 3fefe449.e70c1c“,” version“:1,” debugenabled“:false,” service_domain“:” switch“,” service“:” turn_on“,” entityId“:” switch.bookroom_switch_1“,” data“:”“,” dataType“:” json“,” mergecontext“:”“,” output_location“ :“”,“ output_location_type”:“ none”,“ mustacheAltTags”:false,“ x”:1380,“ y”:740,“ wires”:“” 9b7dad3c.9f0b5“]]},{” id“: ”9b7dad3c.9f0b5“,”类型“:” xiaoai-tts“,” z“:” fc975f4.b4289a“,”名称“:”“,” xiaoai“:” 8c10e069.13221“,” tts“:”你的投影仪已打开,不要看太久了,对眼睛不好哦“,” device“:”“,” x“:1570,” y“:740,” wires“:],]]},{ “ id”:“ ceabea0.7d28018”,“ type”:“ xiaoai-tts”,“ z”:“ fc975f4.b4289a”,“ name”:“,” xiaoai“:” 8c10e069.13221“,” tts“ :“您的投影仪已关闭,早点休息哦”,“设备”:“”,“ x”:1390,“ y”:680,“电线”:],]]},{“ id” :“ 57cb661.572d398”,“类型”:“ xiaoai-tts”,“ z”:“ fc975f4.b4289a”,“名称”:“”,“ xiaoai”:“ 8c10e069”。13221“,” tts“:”您的投影仪已关闭,早点休息哦“,” device“:”“,” x“:1390,” y“:300,”电线“:],]] },{“ id”:“ e4db2fa1.5d90d”,“ type”:“ xiaoai-tts”,“ z”:“ fc975f4.b4289a”,“ name”:“”,“ xiaoai”:“ 8c10e069.13221”, “ tts”:“ AppleTV立即打开,忙了一天了,好好享受电影时光吧。”,“ device”:“”,“ x”:730,“ y”:420,“ wires”:], ]]},{“ id”:“ 3a12c418.69654c”,“ type”:“ switch”,“ z”:“ fc975f4.b4289a”,“ name”:“”,“ property”:“ payload”,“ propertyType “:” msg“,”规则“:{” t“:” eq“,” v“:” powerjimi“,” vt“:” str“},{”t“:” eq“,” v“:” home“,” vt“:” str“},{” t“:” eq“,” v“:” cctv13“,” vt“:” str“}, {“ t”:“ eq”,“ v”:“ qiyiguo”,“ vt”:“ str”},{“ t”:“ eq”,“ v”:“ txsp”,“ vt”:“ str” },{“ t”:“ eq”,“ v”:“ hdmi1”,“ vt”:“ str”}]],“ checkall”:“ true”,“修复”:false,“输出”:6,“ x“:350,” y“:820,”电线“:”“ e1a9d073.55dfd”],“ 9a28bfac.2f7c7”],“ 9a28bfac.2f7c7”],“ 9a28bfac.2f7c7”],“ 9a28bfac.2f7c7“],” 5aeffe24.9b576“]]},{” id“:” 5aeffe24.9b576“,” type“:”api-call-service“,” z“:” fc975f4.b4289a“,” name“:” ATV电源开“,” server“:” 3fefe449.e70c1c“,” version“:1,” debugenabled“:false,” service_domain“:” switch“,” service“:” turn_on“,” entityId“:” switch.bookroom_switch_2“,” data“:”“,” dataType“:” json“,” mergecontext“:”“,” output_location“ :“”,“ output_location_type”:“ none”,“ mustacheAltTags”:false,“ x”:530,“ y”:880,“ wires”:“” 6971d37a.252d4c“]]}},{” id“: “ 1523b4f8.0f70fb”,“类型”:“ api-call-service”,“ z”:“ fc975f4.b4289a”,“名称”:“ ATV电源关闭”,“服务器”:“3fefe449.e70c1c“,”版本“:1,”启用调试“:false,” service_domain“:” switch“,” service“:” turn_off“,” entityId“:” switch.bookroom_switch_2“,” data“:”“ “ dataType”:“ json”,“ mergecontext”:“”,“ output_location”:“”,“ output_location_type”:“ none”,“ mustacheAltTags”:false,“ x”:710,“ y”:820,“ wires “:”“ 168cae50.e1a672”]]},{“ id”:“ 9a28bfac.2f7c7”,“ type”:“ delay”,“ z”:“ fc975f4.b4289a”,“ name”:“”,“ pauseType“:” delay“,” timeout“:” 5“,” timeoutUnits“:” seconds“,” rate“:” 1“,” nbRateUnits“:“ 1”,“ rateUnits”:“ second”,“ randomFirst”:“ 1”,“ randomLast”:“ 5”,“ randomUnits”:“ seconds”,“ drop”:false,“ x”:520,“ y“:820,” wires“:”“ 1523b4f8.0f70fb”]]},{“ id”:“ 168cae50.e1a672”,“ type”:“ xiaoai-tts”,“ z”:“ fc975f4.b4289a” ,“ name”:“”,“ xiaoai”:“ 8c10e069.13221”,“ tts”:“您的投影仪已关闭,早点休息哦”,“ device”:“”,“ x”:890,“ y “:820,” wires“:],]]},{” id“:” 6971d37a.252d4c“,” type“:” xiaoai-tts“,” z“:” fc975f4.b4289a“,”名称“:”“,” xiaoai“:” 8c10e069.13221“,” tts“:”你的投影仪已打开,不要看太久了,对眼睛不好哦“,” device“:”“,” x“:710,” y“:880,” wires“:],]] },{“ id”:“ ffc343e6.07939”,“ type”:“ xiaoai-tts”,“ z”:“ fc975f4.b4289a”,“ name”:“”,“ xiaoai”:“ 8c10e069.13221”, “ tts”:“检测到你已切换到其他通道,已经帮你关闭了Apple TV的电源”,“ device”:“”,“ x”:910,“ y”:360,“电线”: ],]]},{“ id”:“ aaa3d893.767048”,“ type”:“ exec”,“ z”:“ fc975f4.b4289a”,“ command”:“ ping 192.168.2.27 -c 1> / dev / null 2>&1“,” addpay“:false,” append“:”“,” useSpawn“:” false“,” timer“:”“,” oldrc“:false,” name“:”检测投影是否在线“,” x“:1010,” y“:740,”电线“:],],” bfef7417.4ffb08“]]}},{” id“:” bfef7417.4ffb08“, “ type”:“ switch”,“ z”:“ fc975f4.b4289a”,“ name”:“”,“ property”:“ payload.code”,“ propertyType”:“ msg”,“ rules”:{“ t“:” eq“,” v“:” 0“,” vt“:” str“},{” t“:” eq“,” v“:” 1“,” vt“:” str“}] ,“ checkall”:“ true”,“ repair”:false,“ outputs”:2,“ x”:1190,“ y”:740,“ wires”:“ a06022bb.af90d”],“ 1cc699f0。 680046“]]},{” id“:” 1cc699f0.680046“,” type“:” xiaoai-tts“,” z“:”fc975f4.b4289a“,” name“:”“,” xiaoai“:” 8c10e069.13221“,” tts“:”主人不在家,不能开启投影哦“,” device“:”“,” x“:1350, “ y”:780,“ wires”:],]]},{“ id”:“ 45e7866d.e29168”,“ type”:“ switch”,“ z”:“ fc975f4.b4289a”,“名称“:”“,” property“:” payload.code“,” propertyType“:” msg“,” rules“:{” t“:” eq“,” v“:” 0“,” vt“:” str“},{” t“:” eq“,” v“:” 1“,” vt“:” str“}],” checkall“:” true“,”修复“:false,”输出“:2 ,“ x”:790,“ y”:300,“导线”:“ 6cc5da28.8407a4”,“ 9987b09。172275“],” 4666089d.ce3f88“]]},{” id“:” 4666089d.ce3f88“,” type“:” exec“,” z“:” fc975f4.b4289a“,” command“:” ping 192.168 .2.27 -c 1> / dev / null 2>&1“,” addpay“:false,” append“:”“,” useSpawn“:” false“,” timer“:”“,” oldrc“:false,” name“:”检测投影是否在线“,” x“:1210,” y“:360,”电线“:],],” f6640e15.dd5f8“]]},{” id“:” a194e528 .b9bd18“,”类型“:” api-call-service“,” z“:” fc975f4.b4289a“,”名称“:”投影仪电源开“,”服务器“:” 3fefe449.e70c1c“,”版本“ :1,“ debugenabled”:false,“ service_domain”:“ switch”,“服务”:“ turn_on”,“ entityId”:“ switch.bookroom_switch_1”,“数据”:“”,“数据类型”:“ json”,“合并上下文”:“”,“输出位置”:“”,“输出位置类型”: “ none”,“ mustacheAltTags”:false,“ x”:1580,“ y”:380,“ wires”:“” 5d1974a1.ec076c“]]},{” id“:” 5d1974a1.ec076c“,” type “:” xiaoai-tts“,” z“:” fc975f4.b4289a“,” name“:”“,” xiaoai“:” 8c10e069.13221“,” tts“:”您的投影仪已打开,不要看太久了,对眼睛不好哦“,” device“:”“,” x“:1770,” y“:380,” wires“:],]]},{” id“:” f6640e15。 dd5f8“,” type“:”开关“,” z“:”fc975f4.b4289a“,” name“:”“,” property“:” payload.code“,” propertyType“:” msg“,” rules“:{” t“:” eq“,” v“:” 0 “,” vt“:” str“},{” t“:” eq“,” v“:” 1“,” vt“:” str“}],” checkall“:” true“,”修复“: false,“输出”:2,“ x”:1390,“ y”:380,“电线”:“” a194e528.b9bd18“],” ff6852a8.2b92e“]]}},{” id“:” ff6852a8 .2b92e“,” type“:” xiaoai-tts“,” z“:” fc975f4.b4289a“,” name“:”“,” xiaoai“:” 8c10e069.13221“,” tts“:”主人不在家,不能开启投影哦“,” device“:”“,” x“:1550,” y“:420,”wire“:],]]},{” id“:” d3cfc827.843658“,” type“:” debug“,” z“:” fc975f4.b4289a“,” name“:”“,” active “:true,” tosidebar“:true,”控制台“:false,” tostatus“:false,” complete“:” false“,” x“:320,” y“:700,”电线“:]}, {“ id”:“ 8de150fb.a895b”,“ type”:“ mqtt-broker”,“ z”:“”,“ name”:“ mqtt”,“ broker”:“ 192.168.2.88”,“ port”: “ 1883”,“ clientid”:“”,“ usetls”:false,“ compatmode”:true,“ keepalive”:“ 60”,“ cleansession”:true,“ birthTopic”:“”,“ birthQos”:“ 0 “,” birthPayload“:”“,“ closeTopic”:“”,“ closeQos”:“ 0”,“ closePayload”:“”,“ willTopic”:“”,“ willQos”:“ 0”,“ willPayload”:“”},{“ id”: “ 3fefe449.e70c1c”,“类型”:“服务器”,“ z”:“”,“名称”:“家庭助理星期日”,“旧版”:false,“ hassio”:true,“ rejectUnauthorizedCerts”:true,“ ha_boolean“:” y | yes | true | on | home | open“,” connectionDelay“:true,” cacheJson“:true},{” id“:” 8c10e069.13221“,” type“:” xiaoai-tts- configurator“,” z“:”“,”名称“:”“,”用户名“:” 123456“,”密码“:” 78910120。“}] / mw_shl_code]“”,“ closeQos”:“ 0”,“ closePayload”:“”,“ willTopic”:“”,“ willQos”:“ 0”,“ willPayload”:“”},{“ id”:“ 3fefe449.e70c1c “,” type“:”服务器“,” z“:”“,”名称“:”家庭助理周日“,”旧版“:false,” hassio“:true,” rejectUnauthorizedCerts“:true,” ha_boolean“:” y | yes | true | on | home | open“,” connectionDelay“:true,” cacheJson“:true},{” id“:” 8c10e069.13221“,” type“:” xiaoai-tts-configurator“,” z“:”“,”名称“:”“,”用户名“:” 123456“,”密码“:” 78910120。“}] / mw_shl_code]“”,“ closeQos”:“ 0”,“ closePayload”:“”,“ willTopic”:“”,“ willQos”:“ 0”,“ willPayload”:“”},{“ id”:“ 3fefe449.e70c1c “,” type“:”服务器“,” z“:”“,”名称“:”家庭助理周日“,”旧版“:false,” hassio“:true,” rejectUnauthorizedCerts“:true,” ha_boolean“:” y | yes | true | on | home | open“,” connectionDelay“:true,” cacheJson“:true},{” id“:” 8c10e069.13221“,” type“:” xiaoai-tts-configurator“,” z“:”“,”名称“:”“,”用户名“:” 123456“,”密码“:” 78910120。“}] / mw_shl_code]“ closePayload”:“”,“ willTopic”:“”,“ willQos”:“ 0”,“ willPayload”:“”},{“ id”:“ 3fefe449.e70c1c”,“ type”:“服务器”,“ z“:”“,”名称“:”家庭助理星期天“,”旧版“:false,” hassio“:true,” rejectUnauthorizedCerts“:true,” ha_boolean“:” y | yes | true | on | home | open “,” connectionDelay“:true,” cacheJson“:true},{” id“:” 8c10e069.13221“,” type“:” xiaoai-tts-configurator“,” z“:”“,” name“:” “,”用户名“:” 123456“,”密码“:” 78910120。“}] / mw_shl_code]“ closePayload”:“”,“ willTopic”:“”,“ willQos”:“ 0”,“ willPayload”:“”},{“ id”:“ 3fefe449.e70c1c”,“ type”:“服务器”,“ z“:”“,”名称“:”家庭助理星期天“,”旧版“:false,” hassio“:true,” rejectUnauthorizedCerts“:true,” ha_boolean“:” y | yes | true | on | home | open “,” connectionDelay“:true,” cacheJson“:true},{” id“:” 8c10e069.13221“,” type“:” xiaoai-tts-configurator“,” z“:”“,” name“:” “,”用户名“:” 123456“,”密码“:” 78910120。“}] / mw_shl_code]0“,” willPayload“:”“},{” id“:” 3fefe449.e70c1c“,” type“:”服务器“,” z“:”“,”名称“:”家庭助理周日“,”旧版“ :false,“ hassio”:true,“ rejectUnauthorizedCerts”:true,“ ha_boolean”:“ y | yes | true | on | home | open”,“ connectionDelay”:true,“ cacheJson”:true},{“ id” :“ 8c10e069.13221”,“类型”:“ xiaoai-tts-configurator”,“ z”:“”,“名称”:“”,“用户名”:“ 123456”,“密码”:“ 78910120。”} ] / mw_shl_code]0“,” willPayload“:”“},{” id“:” 3fefe449.e70c1c“,” type“:”服务器“,” z“:”“,”名称“:”家庭助理周日“,”旧版“ :false,“ hassio”:true,“ rejectUnauthorizedCerts”:true,“ ha_boolean”:“ y | yes | true | on | home | open”,“ connectionDelay”:true,“ cacheJson”:true},{“ id” :“ 8c10e069.13221”,“类型”:“ xiaoai-tts-configurator”,“ z”:“”,“名称”:“”,“用户名”:“ 123456”,“密码”:“ 78910120。”} ] / mw_shl_code]家庭助理周日”,“旧版”:false,“ hassio”:true,“ rejectUnauthorizedCerts”:true,“ ha_boolean”:“ y | yes | true | on | home | open”,“ connectionDelay”:true,“ cacheJson” :true},{“ id”:“ 8c10e069.13221”,“ type”:“ xiaoai-tts-configurator”,“ z”:“”,“ name”:“”,“ username”:“ 123456”,“密码”:“ 78910120。”}] / mw_shl_code]家庭助理周日”,“旧版”:false,“ hassio”:true,“ rejectUnauthorizedCerts”:true,“ ha_boolean”:“ y | yes | true | on | home | open”,“ connectionDelay”:true,“ cacheJson” :true},{“ id”:“ 8c10e069.13221”,“ type”:“ xiaoai-tts-configurator”,“ z”:“”,“ name”:“”,“ username”:“ 123456”,“密码”:“ 78910120。”}] / mw_shl_code]“用户名”:“ 123456”,“密码”:“ 78910120。”}] / mw_shl_code]“用户名”:“ 123456”,“密码”:“ 78910120。”}] / mw_shl_code]

不带在家检测的流量,帖子字数限制贴不下了
移步:https

://bbs.hassbian.com/forum.php?mod=viewthread&tid=8623&page=1&extra=** # ** pid277083PS:这两个部分都涉及到了,开关机检测的问题,主要是靠Ping投影的地址,所以需要固定投影的IP,同样的,这里面也涉及到TTS播报的问题,不需要的删除掉就好了

** NR小爱同学语音控制篇
**
jpg二连同样这边也提供两个版本****带是否在家检测的流程

分割\ nconst列表= \ n ‘播放北京卫视’,‘我要看北京卫视’,‘打开北京卫视’,‘北京卫视’],\ n ‘播放湖南卫视’,‘我要看湖南卫视’,‘打开湖南卫视’,‘湖南卫视’],\ n ‘播放浙江卫视’,‘我要看浙江卫视’,‘打开浙江卫视’,‘浙江卫视’],\ n ‘播放东方卫视’,‘我要看东方卫视’,‘打开东方卫视’,‘东方卫视’],\ n ‘播放江苏卫视’,‘我要看江苏卫视’,‘打开江苏卫视’,‘江苏卫视’] ,\ n ‘播放安徽卫视’,‘我要看安徽卫视’,‘打开安徽卫视’,‘安徽卫视’],\ n ‘播放湖北卫视’,‘我要看湖北卫视’,‘打开湖北卫视’,‘湖北卫视’],\ n ‘播放天津卫视’,‘我要看天津卫视’,‘打开天津卫视’,‘天津卫视’],\ n ‘播放山东卫视’,‘我要看山东卫视’,‘打开山东卫视’,‘山东卫视’],\ n ‘播放广东卫视’,‘我要看广东卫视’,‘打开广东卫视’,‘广东卫视’],\ n ‘播放中央一台’,‘我要看中央一台’,‘打开中央一台’,‘中央一台’],\ n ‘播放中央二 台’,‘我要看中央二台’ ,‘打开中央二台’,‘中央二台’],\ n ‘播放中央三台’,‘我要看综艺频道’,‘打开综艺频道’,‘综艺频道’],\ n ‘播放中央四台’,‘我要看中央四台’,‘打开中央四台’,‘中央四台’],\ n ‘播放中央五台’,‘我要看体育频道’,‘打开体育频道’,‘体育频道’],\ n ‘播放中央六台’,‘我要看电影频道’,‘打开电影频道’,‘电影频道’],\ n ‘播放中央六台’,‘我要看中央七台’,‘打开中央七台’,‘中央七台’],\ n ‘播放中央八台’,‘我要看中央八台’,‘打开中央八台’,‘中央八台’],\ n ‘播放中央九台’,‘我要看中央九台’,‘打开中央九台’,‘中央九台’],\ n ‘播放中央十台’,'我要看科教频道”,“打开科教频道”,“科教频道”],\ n ‘播放中央十一台’,‘我要看中央十一台’,‘打开中央十一台’,‘中央十一台’],\ n ‘播放中央十二台’,‘我要看中央十二台’,‘打开中央十二台’,‘中央十二台’],\ n ‘播放中央十二台’,‘我要看新闻频道’,'打开新闻 道 ’ ‘新闻频道’],\ n ’

不带在家检测版本
请移步HA论坛,帖子有字数限制,贴不了了, https: //bbs.hassbian.com/forum.php ? mod = viewthread & tid = 8623 & page =1& extra = #pid277083在突出一遍,投影的IP要固定一下,这里的IP检测有自动化,可以直接对小爱说播放北京卫视,投影可以从关机状态直接跳到某个频道的。这个功能其实是给家里的爸妈准备,,不会用,,为了搞简单点,就让他们直接说就好了。。另外,这个电视频道的指令信息可以直接套到第一步HA里面使用,这样就可以直接在HA的遥控上选频道了。**在这里也算是做个抛砖引玉,其他同类型的,电视,盒子其实都可以套用这三种方案,类似小米电视,论坛有大佬发过API,那么就可以参照这个,红外的学到红外码也可以遵循这几个方案搞。**好了教程到这里就此结束,的英文分享一种美德!!! 对了,接入HA的同学,别忘了下载WWW文件。 附] 1668 / ATTAC H]加粗示例

lee大佬能不能排一下版 谢谢分享

非常棒,家里有两个极米投影