家庭助理:Command_line&休息开关
我试图通过 HA 解锁我的门,这是一个简单的 HTTPS 链接,但在链接“date=”的最后一个变量中,我们需要分配当前日期,我认为这是导致我的以下代码出现问题的日期:
switch:
- platform: command_line
switches:
home_door_four:
command_on: "curl -k https://api.ttlock.com/v3/lock/unlock?clientId=xxxxx&accessToken=xxxxx&lockId=xxxxx&date={{ (now().timestamp() | int * 1000 ) }}"
command_off: "curl -k https://api.ttlock.com/v3/lock/lock?clientId=xxxxx&accessToken=xxxxx&lockId=xxxxx&date={{ (now().timestamp() | int * 1000 ) }}"
I am trying to unlock my door through HA, it's a straightforward HTTPS link but in the last variable of the link "date=" we need to assign the current date, which I think is the one that is causing issues with my below code:
switch:
- platform: command_line
switches:
home_door_four:
command_on: "curl -k https://api.ttlock.com/v3/lock/unlock?clientId=xxxxx&accessToken=xxxxx&lockId=xxxxx&date={{ (now().timestamp() | int * 1000 ) }}"
command_off: "curl -k https://api.ttlock.com/v3/lock/lock?clientId=xxxxx&accessToken=xxxxx&lockId=xxxxx&date={{ (now().timestamp() | int * 1000 ) }}"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用rest_command和模板锁集成来完成此工作。
注意:这只是我的代码片段,我相信您可以填写空白,我还使用门传感器并从 API 获取锁状态。
然后创建锁:
I got this working using the rest_command and template lock integration.
NB: This is just a snippet of my code, I'm sure you can fill in the blanks, I also use a door sensor and also get the lock status from the API.
Then create the lock: