本帖最后由 lidicn 于 2019-1-24 00:41 编辑
孔乙己显出极高兴的样子,将两个指头的长指甲敲着柜台,点头说,“对呀对呀!……回字有四样写法⑸,你知道么?”我愈不耐烦了,努着嘴走远。孔乙己刚用指甲蘸了酒,想在柜上写字,见我毫不热心,便又叹一口气,显出极惋惜的样子。 Taker联动HA
方法一 webhooks
设置自动化
automation:
- alias: 'Webhook Call Service'
initial_state: 'on'
trigger:
platform: webhook
webhook_id: call_service
action:
service_template: '{{ trigger.json.service }}'
data_template:
entity_id: '{{ trigger.json.entity_id }}'
- alias: 'miai_tts'
initial_state: 'on'
trigger:
platform: webhook
webhook_id: hellomiai
action:
- service: hello_miai.add2msgqueue
data_template:
message: '{{ trigger.json.message }}'
miai_num: '{{ trigger.json.miai_num }}'
设置Taker
Server: Port = https://[HA URL]
Path = /api/webhook/call_service
Data / File = { "service": "light.turn_on", "entity_id": "light.living_room" }
Content Type: application/json
Server: Port = https://[HA URL]
Path = /api/webhook/hellomiai
Data / File = { "message": "我是小爱,您的智能家居助理", "miai_num": 0 }
Content Type: application/json
- webhook_id 可以根据个人喜好随意设置
- 可以传递各种参数
- 没有鉴权,安全性较差
- HA版本需要大于0.80
方法二 长期令牌
- 手机安装RESTaker for tasker
- 设置任务 > 操作插件 >RESTask
- 从HA获取长期令牌
设置RESTask
- Setings 请求方式为 Post
- Host设置完整附带服务带不带api_password的url 例如: http://192.168.2.200:8123/api/services/switch/toggle
- 勾选Enable custom body 并在Custom body里填写请求内容 例如: {"entity_id":"switch.wall_switch_ln_left_158d000239c546"}
- 设置Headers 字段为Authorization 内容为 Bearer然后空一格接上你的长期令牌
HA联动Tasker待续
参考文档:
1. https://community.home-assistant ... st-new-auth/66303/5
2. https://community.home-assistant ... cess-tokens/69253/4
|