简体   繁体   English

如何使用 openHAB REST API 添加设备

[英]How to add devices using openHAB REST API

I am looking for a way to discover a USB zstick "/dev/ttyACM0" using OpenHab command line interface as I am not going to be using a GUI and I need to create a script to automate few things.我正在寻找一种使用 OpenHab 命令行界面发现 USB zstick“/dev/ttyACM0”的方法,因为我不打算使用 GUI,我需要创建一个脚本来自动化一些事情。

In their website here and here OpenHab have some documentation, and that's what I found for discovery:在他们的网站herehere OpenHab有一些文档,这就是我发现的内容:

GET /discovery POST /discovery/bindings/{bindingId}/scan GET /discovery POST /discovery/bindings/{bindingId}/scan

however I was unable to make that into a useful curl command.但是我无法将其变成有用的 curl 命令。 any idea on where to start?知道从哪里开始吗?

I would suggest to try out the REST Documentation, for finding the right endpoint/expression.我建议尝试使用 REST 文档,以找到正确的端点/表达式。

You can install it through paper ui:可以通过paper ui安装: 其余文档插件的纸质 ui 视图

It will then be available through <YOUR_OH_IP>:<PORT>/doc/index.html .然后它将通过<YOUR_OH_IP>:<PORT>/doc/index.html It provides some ui with explanations and examples for the endpoints and you can test them live through it.它提供了一些带有端点解释和示例的 ui,您可以通过它进行实时测试。 This should help you find the correct rest call to use with curl afterwards.这应该可以帮助您找到正确的 rest 调用,然后与 curl 一起使用。

休息文档插件页面概述

I don't know if adding devies through REST is possible.我不知道是否可以通过 REST 添加设备。 If so you can find it in the REST Documentation.如果是这样,您可以在 REST 文档中找到它。 If it doesn't work though the REST API you might want to write a small bash script which adds the things you want.如果它通过 REST API 不起作用,您可能需要编写一个小的 bash 脚本来添加您想要的东西。 Then you can call your script with executeCommandLine in a rule然后您可以在规则中使用executeCommandLine调用您的脚本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM