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

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

 找回密码
 立即注册
查看: 4055|回复: 42

[进阶教程] 任意安卓机顶盒不用AndroidTV接入HA的通用方法

  [复制链接]

5

主题

598

帖子

3297

积分

论坛元老

Rank: 8Rank: 8

积分
3297
金钱
2694
HASS币
20
发表于 2021-2-24 16:46:08 | 显示全部楼层 |阅读模式
先上图:
无标题1.png
方法如下:

  在安卓盒子上安装 121.png ,HA通过rest_command直接用post方式直接访问盒子9978端口,进行遥控器的各种操作,和各种功能的调用。
  下面分享我的代码:
  rest_command.yaml:(遥控按键和应用直接调用)
  
atv_233_app_setup:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/runSystem
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: "packageName=android.settings.SETTINGS" 
atv_233_app_aiqiyi:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/run
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'packageName=com.gitvdemo.video'
atv_233_app_cctvnews:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/run
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'packageName=cn.cntvnews.tv'
atv_233_app_mxplayer:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/run
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'packageName=com.mxtech.videoplayer.pro'
atv_233_app_cjiptv:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/run
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'packageName=com.aesq.iptv'
atv_233_app_xiguashipin:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/run
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'packageName=com.ixigua.android.tv.wasu'
atv_233_app_hdp:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/run
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'packageName=hdpfans.com'
atv_233_app_dangbeishichang:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/run
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'packageName=com.dangbeimarket'
atv_233_app_youkushipin:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/run
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'packageName=com.cibn.tv'
atv_233_app_tengxunshipin:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/run
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'packageName=com.ktcp.video'

atv_233_ok:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/key
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'code=23'
atv_233_home:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/key
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'code=3'
atv_233_menu:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/key
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'code=82'
atv_233_back:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/key
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'code=4'
atv_233_power:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/key
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'code=26'
atv_233_valume_mute:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/key
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'code=164'
atv_233_valume_up:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/key
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'code=24'
atv_233_valume_down:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/key
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'code=25'
atv_233_dpad_up:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/key
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'code=19'
atv_233_dpad_down:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/key
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'code=20'
atv_233_dpad_left:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/key
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'code=21'
atv_233_dpad_right:
  url: http://{{states('input_select.an_zhuo_tv')}}:9978/key
  method: POST
  content_type: "application/x-www-form-urlencoded"
  payload: 'code=22'
    我的多个盒子加入了input_select进行选择(entity_id: input_select.an_zhuo_tv),如果你只有一个盒子,可以直接写入IP地址。
  然后在configuration.yaml加入引用:rest_command:   !includeconfig/rest_command.yaml
  lovelace配置放下一楼。

评分

参与人数 2金钱 +40 HASS币 +20 收起 理由
jyz_0501 + 20 厉害了 哥,佩服佩服!!!
+ 20 + 20 厉害了word楼主!

查看全部评分

回复

使用道具 举报

5

主题

598

帖子

3297

积分

论坛元老

Rank: 8Rank: 8

积分
3297
金钱
2694
HASS币
20
 楼主| 发表于 2021-2-24 16:51:44 | 显示全部楼层
左侧应用控制部分:全部用button-card
type: vertical-stack
cards:
  - type: horizontal-stack
    cards:
      - color: 'rgb(6, 180, 97)'
        color_type: card
        entity_picture: /local/app/xiguashipin.png
        icon: 'mdi:power'
        name: 西瓜视频
        show_entity_picture: true
        show_icon: true
        show_name: true
        styles:
          card:
            - height: 88px
            - border-radius: 8px
        tap_action:
          action: call-service
          service: rest_command.atv_233_app_xiguashipin
        type: 'custom:button-card'
      - color: 'rgb(116, 100, 19)'
        color_type: card
        entity_picture: /local/app/youkushipin.png
        icon: 'mdi:power'
        name: 优酷视频
        show_entity_picture: true
        show_icon: true
        show_name: true
        styles:
          card:
            - height: 88px
            - border-radius: 8px
        tap_action:
          action: call-service
          service: rest_command.atv_233_app_youkushipin
        type: 'custom:button-card'
  - type: horizontal-stack
    cards:
      - color: 'rgb(46, 80, 197)'
        color_type: card
        entity_picture: /local/app/hdp.png
        icon: 'mdi:power'
        name: HDP
        show_entity_picture: true
        show_icon: true
        show_name: true
        styles:
          card:
            - height: 88px
            - border-radius: 8px
        tap_action:
          action: call-service
          service: rest_command.atv_233_app_hdp
        type: 'custom:button-card'
      - color: 'rgb(6, 108, 97)'
        color_type: card
        entity_picture: /local/app/aiqiyi.png
        icon: 'mdi:power'
        name: 爱奇艺
        show_entity_picture: true
        show_icon: true
        show_name: true
        styles:
          card:
            - height: 88px
            - border-radius: 8px
        tap_action:
          action: call-service
          service: rest_command.atv_233_app_aiqiyi
        type: 'custom:button-card'
  - type: horizontal-stack
    cards:
      - color: 'rgb(46, 80, 7)'
        color_type: card
        entity_picture: /local/app/tengxunshipin.png
        icon: 'mdi:power'
        name: 腾讯视频
        show_entity_picture: true
        show_icon: true
        show_name: true
        styles:
          card:
            - height: 88px
            - border-radius: 8px
        tap_action:
          action: call-service
          service: rest_command.atv_233_app_tengxunshipin
        type: 'custom:button-card'
      - color: 'rgb(146, 18, 19)'
        color_type: card
        entity_picture: /local/app/dangbeishichang.png
        icon: 'mdi:power'
        name: 当贝市场
        show_entity_picture: true
        show_icon: true
        show_name: true
        styles:
          card:
            - height: 88px
            - border-radius: 8px
        tap_action:
          action: call-service
          service: rest_command.atv_233_app_dangbeishichang
        type: 'custom:button-card'
  - type: horizontal-stack
    cards:
      - color: 'rgb(146, 80, 7)'
        color_type: card
        entity_picture: /local/app/cjiptv.png
        icon: 'mdi:power'
        name: 超级IPTV
        show_entity_picture: true
        show_icon: true
        show_name: true
        styles:
          card:
            - height: 88px
            - border-radius: 8px
        tap_action:
          action: call-service
          service: rest_command.atv_233_app_cjiptv
        type: 'custom:button-card'
      - color: 'rgb(146, 18, 219)'
        color_type: card
        entity_picture: /local/app/cctvnews.png
        icon: 'mdi:power'
        name: CCTV新闻
        show_entity_picture: true
        show_icon: true
        show_name: true
        styles:
          card:
            - height: 88px
            - border-radius: 8px
        tap_action:
          action: call-service
          service: rest_command.atv_233_app_cctvnews
        type: 'custom:button-card'
  - type: horizontal-stack
    cards:
      - color: 'rgb(46, 180, 87)'
        color_type: card
        entity_picture: /local/app/mxplayer.png
        icon: 'mdi:power'
        name: MX Player
        show_entity_picture: true
        show_icon: true
        show_name: true
        styles:
          card:
            - height: 88px
            - border-radius: 8px
        tap_action:
          action: call-service
          service: rest_command.atv_233_app_mxplayer
        type: 'custom:button-card'
      - color: 'rgb(26, 20, 157)'
        color_type: card
        entity_picture: /local/app/setup.png
        icon: 'mdi:power'
        name: 设置
        show_entity_picture: true
        show_icon: true
        show_name: true
        styles:
          card:
            - height: 88px
            - border-radius: 8px
        tap_action:
          action: call-service
          service: rest_command.atv_233_app_setup
        type: 'custom:button-card'


回复

使用道具 举报

5

主题

598

帖子

3297

积分

论坛元老

Rank: 8Rank: 8

积分
3297
金钱
2694
HASS币
20
 楼主| 发表于 2021-2-24 16:52:53 | 显示全部楼层
本帖最后由 mitu 于 2021-2-24 16:58 编辑

右侧的遥控部分,用firetv-card,电源的直接写
type: 'custom:firetv-card'
tv: false
entity: sensor.date
name: Phicomm N1
power:
  service: rest_connand.atv_233_power
back:
  service: rest_command.atv_233_back
home:
  service: rest_command.atv_233_home
up:
  service: rest_command.atv_233_dpad_up
down:
  service: rest_command.atv_233_dpad_down
left:
  service: rest_command.atv_233_dpad_left
right:
  service: rest_command.atv_233_dpad_right
select:
  service: rest_command.atv_233_ok
reverse:
  service: rest.reload
pauseplay:
  service: rest.reload
forward:
  service: rest.reload
menu:
  service: rest_command.atv_233_menu
volume_up:
  service: rest_command.atv_233_valume_up
volume_down:
  service: rest_command.atv_233_valume_down
volume_mute:
  service: rest_command.atv_233_valume_mute
小盒精灵app大小11M压缩后也无法上传,有需要的自行寻找。

回复

使用道具 举报

8

主题

131

帖子

596

积分

高级会员

Rank: 4

积分
596
金钱
465
HASS币
20
发表于 2021-2-24 17:02:28 | 显示全部楼层
mark一下                                       
回复

使用道具 举报

8

主题

420

帖子

1183

积分

金牌会员

Rank: 6Rank: 6

积分
1183
金钱
763
HASS币
10
QQ
发表于 2021-2-24 17:42:47 | 显示全部楼层
膜拜大佬。
我不生产技术,我只是技术的搬运工。
回复

使用道具 举报

2

主题

57

帖子

194

积分

注册会员

Rank: 2

积分
194
金钱
137
HASS币
0
发表于 2021-2-24 20:47:04 | 显示全部楼层
膜拜大神,感谢分享
回复

使用道具 举报

9

主题

247

帖子

2190

积分

论坛技术达人

积分
2190
金钱
1928
HASS币
100
发表于 2021-2-24 22:06:31 | 显示全部楼层
感谢大佬分享,很实用!!!
E5-2650L-V2+华南X79+16GB*2
回复

使用道具 举报

1

主题

32

帖子

264

积分

中级会员

Rank: 3Rank: 3

积分
264
金钱
232
HASS币
0
发表于 2021-2-25 09:33:39 | 显示全部楼层
电视能直接安装吗
回复

使用道具 举报

5

主题

598

帖子

3297

积分

论坛元老

Rank: 8Rank: 8

积分
3297
金钱
2694
HASS币
20
 楼主| 发表于 2021-2-25 09:55:46 | 显示全部楼层
sdfd 发表于 2021-2-25 09:33
电视能直接安装吗

安卓系统的电视应该没问题
回复

使用道具 举报

5

主题

203

帖子

1707

积分

金牌会员

Rank: 6Rank: 6

积分
1707
金钱
1494
HASS币
45
发表于 2021-2-25 10:03:39 | 显示全部楼层
软件后台工作的吗?会不会出现被杀的情况?
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2021-4-15 02:11 , Processed in 0.107083 second(s), 37 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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