Home Assistant 接入 Lifesmart(云起智能)家居的途径。

技术路径

通过skyzhishui开发的lifesmart插件,将LifeSmart整合进Home Assistant(HASS)平台

下载地址

插件链接
使用ZIP下载或者

git clone https://github.com/skyzhishui/custom_components.git

获取

插件安装

将下载内容中的lifesmart文件夹放到HASS系统内的config/custom_component/内,前提是你的HASS系统打开了samba共享,具体打开方式见
samba和ssh的打开方法

配置

APPKEY和APPTOKEN获取

1.注册&审核,在http://www.ilifesmart.com/open/login内注册开发者账号,并新建一个应用,提交申请。
在这里插入图片描述
在这里插入图片描述

2.获取几日后,过审的应用信息内就包含你的AppKey和AppToken。
在这里插入图片描述

USERTOKEN和USERID获取

Login

通过以下Python代码模拟登录过程

import requests
import json

url = "https://api.ilifesmart.com/app/auth.login"

payload = json.dumps({
  "uid": "your_username", 
  "pwd": "your_password",
  "appkey": "appkey"
})
headers = {
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

如果返回的结果如果是以下格式,则获取UserID成功,请记好userid和token,下一段过程有用。

{
    "rgn": "cn",
    "userid": “xxxxxxxx",
    "code": "success",
    "token": "xxxxxxxxxxxxxxxxxxxxxxxxxx",
    "rgnid": "CN0"
}
授权

将上一组操作中获得的userid和token,以及之前获得的AppKey填入下一段Python代码,运行后则可以获取UserToken,并得到系统授权。

import requests
import json

url = "https://api.ilifesmart.com/app/auth.do_auth"

payload = json.dumps({
  "userid": "your_userid",
  "token": "your_token",
  "appkey": "your_appkey",
  "rgn": "cn"
})
headers = {
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

返回格式为

{
    "rgn": "cn",
    "svrurl": "https://api.cn0.ilifesmart.com/app",
    "code": "success",
    "expiredtime": xxxxxx,
    "svrrgnid": "CN0",
    "userid": "xxxxxx",
    "usertoken": "xxxxxxxxxxxxxxxxxxxxxxxx"
}

文件配置

1.在HASS系统内的config/configuration.yaml内添加如下内容。

lifesmart:
  appkey: "your_appkey" 
  apptoken: "your_apptoken"
  usertoken: "your_usertoken" 
  userid: "your_userid"
  exclude:
    - "0011" #需屏蔽设备的me值,这个暂时为必填项,可以填任意内容

2.重启HASS,Lifesmart的各类开关则会以实体的方式在HASS里存在。
在这里插入图片描述

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 22
    评论
评论 22
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值