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

 找回密码
 立即注册
查看: 180530|回复: 90

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

  [复制链接]

6

主题

743

帖子

5960

积分

论坛元老

Rank: 8Rank: 8

积分
5960
金钱
5212
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配置放下一楼。

评分

参与人数 3金钱 +45 HASS币 +20 收起 理由
aivi + 5 在下对你的景仰犹如滔滔长江之水,连绵不绝.
jyz_0501 + 20 厉害了 哥,佩服佩服!!!
+ 20 + 20 厉害了word楼主!

查看全部评分

回复

使用道具 举报

6

主题

743

帖子

5960

积分

论坛元老

Rank: 8Rank: 8

积分
5960
金钱
5212
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'


回复

使用道具 举报

6

主题

743

帖子

5960

积分

论坛元老

Rank: 8Rank: 8

积分
5960
金钱
5212
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压缩后也无法上传,有需要的自行寻找。

回复

使用道具 举报

17

主题

320

帖子

2497

积分

金牌会员

Rank: 6Rank: 6

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

使用道具 举报

33

主题

2196

帖子

5838

积分

论坛元老

Rank: 8Rank: 8

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

使用道具 举报

2

主题

57

帖子

350

积分

中级会员

Rank: 3Rank: 3

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

使用道具 举报

9

主题

251

帖子

4380

积分

元老级技术达人

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

使用道具 举报

1

主题

79

帖子

1006

积分

金牌会员

Rank: 6Rank: 6

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

使用道具 举报

6

主题

743

帖子

5960

积分

论坛元老

Rank: 8Rank: 8

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

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

使用道具 举报

5

主题

209

帖子

2014

积分

金牌会员

Rank: 6Rank: 6

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

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-26 08:35 , Processed in 0.074447 second(s), 36 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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