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

 找回密码
 立即注册
12
返回列表 发新帖
楼主: chiunownow

[经验分享] Awtrix2 mqtt控制

[复制链接]

2

主题

123

帖子

589

积分

高级会员

Rank: 4

积分
589
金钱
466
HASS币
10
发表于 2021-1-16 22:39:49 | 显示全部楼层

搞定状态了

automation:
  - id: '1610802646971'
    alias: Get PowerState
    description: ''
    trigger:
    - platform: state
      entity_id: sensor.awtrix_activeapp
    condition: []
    action:
    - service: mqtt.publish
      data:
        topic: awtrix/basics
        payload: '{"get":"powerState"}'
    mode: single
回复

使用道具 举报

2

主题

123

帖子

589

积分

高级会员

Rank: 4

积分
589
金钱
466
HASS币
10
发表于 2021-1-17 14:49:19 | 显示全部楼层
根据各位大佬的实例,修改了一下,增加了按钮的控制,实际效果:

awtrix.jpg

本来想把App切换和暂停弄成播放器形式的,但是无奈试了好多次都不行,求助大佬帮助,现在的代码如下:

light:
  - platform: template
    lights:
      awtrix_lights:
        value_template: '{{ states.sensor.awtrix_powerstate.state }}'
        turn_on: 
          - service: mqtt.publish
            data:
              topic: awtrix/basics
              payload: '{"power": true}'
          - service: mqtt.publish
            data:
              topic: awtrix/basics
              payload: '{"get":"powerState"}'
        turn_off: 
          - service: mqtt.publish
            data:
              topic: awtrix/basics
              payload: '{"power":false}'
          - service: mqtt.publish
            data:
              topic: awtrix/basics
              payload: '{"get":"powerState"}'

switch:
  - platform: template
    switches:
      awtirx_apploop:
        friendly_name: "Back/Next"
        turn_on:
          - service: mqtt.publish
            data:
              topic: "awtrix/basics"
              payload: '{"app": "next"}'
        turn_off: 
          - service: mqtt.publish
            data:
              topic: awtrix/basics
              payload: '{"app": "back"}'
      awtirx_switching:
        friendly_name: "Hold/Pause"
        turn_on:
          - service: mqtt.publish
            data:
              topic: "awtrix/basics"
              payload: '{"app": "pause"}'
        turn_off: 
          - service: mqtt.publish
            data:
              topic: awtrix/basics
              payload: '{"app": "hold"}'

input_text:
  awtrix_notify:
    name: Awtrix Notify
    initial: Hello, World!
    icon: mdi:form-textarea

script:
  awtrix_notify:
    sequence:
      - service: mqtt.publish
        data:
          topic: awtrix/notify
          payload: '{"name":"HASS Notify", "force":true, "duration":5, "repeat":2, "icon":1208, "text":"{{states.input_text.awtrix_notify.state}}"}'
    mode: single

sensor:
  - platform: mqtt
    name: 'awtrix_activeApp'
    state_topic: 'awtrix/activeApp'
  - platform: mqtt
    name: 'awtrix_powerState'
    state_topic: 'awtrix/response'
    value_template: '{{ value_json.powerState }}'

automation:
  - id: '1610802646971'
    alias: Get Power State
    description: ''
    trigger:
    - platform: state
      entity_id: sensor.awtrix_activeapp
    condition: []
    action:
    - service: mqtt.publish
      data:
        topic: awtrix/basics
        payload: '{"get":"powerState"}'
    mode: single



回复

使用道具 举报

10

主题

181

帖子

2584

积分

金牌会员

Rank: 6Rank: 6

积分
2584
金钱
2398
HASS币
60
发表于 2021-1-17 15:19:28 | 显示全部楼层
这玩意不知会不会出HA的官方支持?
大佬: 请勿咨询任何问题,所有问题都能 Google 到答案
回复

使用道具 举报

2

主题

123

帖子

589

积分

高级会员

Rank: 4

积分
589
金钱
466
HASS币
10
发表于 2021-1-17 16:41:47 | 显示全部楼层
lyfff 发表于 2021-1-17 15:19
这玩意不知会不会出HA的官方支持?

看了作者的论坛 基本不太会的 只能自己弄了
回复

使用道具 举报

0

主题

13

帖子

85

积分

注册会员

Rank: 2

积分
85
金钱
72
HASS币
0
发表于 2021-7-26 07:57:08 | 显示全部楼层
请问这个mqtt填写什么? iShot2021-07-26 07.56.25.png



回复

使用道具 举报

2

主题

65

帖子

1075

积分

金牌会员

Rank: 6Rank: 6

积分
1075
金钱
1010
HASS币
0
发表于 2022-1-20 17:49:09 | 显示全部楼层
毛毛卷 发表于 2021-1-17 14:49
根据各位大佬的实例,修改了一下,增加了按钮的控制,实际效果:

可以用 网格卡做按钮,直接调用mqtt
,就不用创建switch了。
type: grid
cards:
  - type: button
    entity: light.awtrix_lights
    theme: ios-dark-mode-dark-blue
    name: '矩阵 '
    icon: mdi:view-comfy
  - type: button
    entity: sensor.awtrix_activeapp
    icon: mdi:play-protected-content
    show_state: true
    show_name: false
    tap_action:
      action: more-info
    theme: ios-dark-mode-dark-blue
  - type: button
    tap_action:
      action: call-service
      service: mqtt.publish
      service_data:
        topic: awtrix/basics
        payload: '{"app": "next"}'
      target: {}
    entity: automation.get_power_state
    name: '切换 '
    show_state: false
    hold_action:
      action: call-service
      service: mqtt.publish
      service_data:
        topic: awtrix/basics
        payload: '{"app": "back"}'
      target: {}
    icon: mdi:arrow-split-vertical
    theme: ios-dark-mode-dark-blue
  - type: button
    entity: input_text.awtrix_notify
    show_name: false
    show_state: true
    tap_action:
      action: more-info
    hold_action:
      action: call-service
      service: script.awtrix_notify
      service_data: {}
      target: {}
    theme: ios-dark-mode-dark-blue
columns: 5
回复

使用道具 举报

1

主题

42

帖子

122

积分

注册会员

Rank: 2

积分
122
金钱
80
HASS币
0
发表于 2022-11-6 17:17:25 | 显示全部楼层
本帖最后由 yymeme345 于 2022-12-30 14:10 编辑

好贴顶一下
















活字印刷術和現代的印刷術一樣,都需要經過程序把文字印刷出來,當中最大的分別,應該就是古代主要以人手操作,現代則多以機器處理








回复

使用道具 举报

0

主题

30

帖子

580

积分

高级会员

Rank: 4

积分
580
金钱
550
HASS币
0
发表于 2024-1-3 18:42:56 | 显示全部楼层
瞌睡缺枕头,正好前辈的用上了。感谢感谢!最新版本mqtt的格式需要调整下,否则总是报错。具体看homeassistant community的指引。
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-5-9 07:54 , Processed in 0.072864 second(s), 30 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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