找回密码
 立即注册
查看: 2384|回复: 6

[技术探讨] 小白求问,http开关怎么接入hass

[复制链接]

6

主题

18

回帖

210

积分

中级会员

积分
210
金钱
186
HASS币
0
发表于 2022-11-7 23:07:22 | 显示全部楼层 |阅读模式
我这个开关,本地浏览器输入a地址=关,b地址=开,c地址会返回一个status,值为0表示现在开关是关着的,1表示是开着的,请问如何接入hass呢?
回复

使用道具 举报

4

主题

170

回帖

1409

积分

金牌会员

积分
1409
金钱
1235
HASS币
0
发表于 2022-11-8 10:10:00 | 显示全部楼层
我能想到的方案是用NodeRed的http组件来控制和获取状态,然后再接入hass。不知道有没有直接接入HASS的方案,我会的不多
回复

使用道具 举报

7

主题

346

回帖

3454

积分

论坛元老

积分
3454
金钱
3101
HASS币
0
发表于 2022-11-8 16:32:50 | 显示全部楼层
可以用command line switch集成配合curl命令
https://www.home-assistant.io/integrations/switch.command_line/
回复

使用道具 举报

7

主题

107

回帖

1096

积分

论坛DIY达人

积分
1096
金钱
972
HASS币
60
发表于 2022-11-8 18:41:38 | 显示全部楼层
rest_command:
  shuffle_on:
    url: "http://YOUR_ITUNES-API_SERVER_IP:8181/shuffle"
    method: put
    content_type: "application/x-www-form-urlencoded"
    payload: "mode=songs"
  shuffle_off:
    url: "http://YOUR_ITUNES-API_SERVER_IP:8181/shuffle"
    method: put
    content_type: "application/x-www-form-urlencoded"
    payload: "mode=off"


https://www.home-assistant.io/integrations/rest_command/

评分

参与人数 1金钱 +8 收起 理由
sorrypqa + 8 大神666!

查看全部评分

回复

使用道具 举报

6

主题

18

回帖

210

积分

中级会员

积分
210
金钱
186
HASS币
0
 楼主| 发表于 2022-11-8 22:21:13 | 显示全部楼层
yuyuye 发表于 2022-11-8 16:32
可以用command line switch集成配合curl命令
https://www.home-assistant.io/integrations/switch.command_ ...

判断状态的返回值为:
{"response":[{"index":0,"status":1}],"led":1,"def_st":2,"result":0}

status为1就是开,为0就是关,请问怎么判断呢,我现在是这样的,ha不能识别开关状态
command_state: 'curl -X GET "my_url"'
value_template: '{{ status == "1" }}'
回复

使用道具 举报

6

主题

18

回帖

210

积分

中级会员

积分
210
金钱
186
HASS币
0
 楼主| 发表于 2022-11-9 00:52:32 | 显示全部楼层
dianxin11 发表于 2022-11-8 18:41
https://www.home-assistant.io/integrations/rest_command/

dalao你好,这个能实现开关,请问状态怎么监测呢
回复

使用道具 举报

7

主题

107

回帖

1096

积分

论坛DIY达人

积分
1096
金钱
972
HASS币
60
发表于 2022-11-9 18:55:11 | 显示全部楼层
d1178775534 发表于 2022-11-9 00:52
dalao你好,这个能实现开关,请问状态怎么监测呢

状态监测看这里:
switch:
  - platform: rest
    resource: http://IP_ADDRESS/led_endpoint
    body_on: '{"active": "true"}'
    body_off: '{"active": "false"}'
    is_on_template: "{{ value_json.is_active }}"
    headers:
      Content-Type: application/json
      X-Custom-Header: '{{ states("input_text.the_custom_header") }}'
    verify_ssl: true


https://www.home-assistant.io/integrations/switch.rest/
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian ( 晋ICP备17001384号-1 )

GMT+8, 2025-5-18 13:00 , Processed in 0.167532 second(s), 24 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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