简体   繁体   English

如何在Openhab中仅允许对Switch项进行读取访问?

[英]How do I allow only read access to Switch item in Openhab?

I stumbled across this post while playing around with Openhab 2.4.0. 在使用Openhab 2.4.0时,我偶然发现了这篇文章。 I was trying to display the state of the switch item (for Hue Bulb) with only read access in the control tab of Paper UI. 我试图在Paper UI的“控制”选项卡中以只读访问权限显示开关项(对于Hue Bulb)的状态。 A simple solution would be to have a different item type with only read access to the switch state (similar to lockOnly capability in smartThings) but I couldn't find examples of someone using the "String" item type either. 一个简单的解决方案是使用仅对开关状态具有读取访问权限的其他项目类型(类似于smartThings中的lockOnly功能),但是我也找不到使用“字符串”项目类型的人的示例。

I think this is useful when someone just wants to share the state of the device while integrating 3rd party service or maybe allowing access to only one command on the device eg, only allowing lock but disabling unlock. 我认为这在有人只想在集成第三方服务时共享设备状态或仅允许访问设备上的一个命令(例如,仅允许锁定但禁用解锁)时很有用。

I'd appreciate if somebody posted a link to a tutorial which tries to implement similar functionality. 如果有人发布指向尝试实现类似功能的教程的链接,我将不胜感激。 I'm new to Openhab and I might be misunderstanding the architecture itself. 我是Openhab的新手,我可能会误解架构本身。

Maybe i am a bit late, but i will try to gice an answer anyway. 也许我来晚了,但是无论如何我都会尽量给出一个答案。 I don't think that there will be some kind of tutorial like you would like to see. 我认为不会像您希望的那样有某种教程。

The reason is very simple: Paper UI is not meant for being used in production as ui. 原因很简单:Paper UI并不打算在生产中用作ui。 It is meant to be used for configuration and administration and maintenance. 它旨在用于配置,管理和维护。 The control section is in there for testing out stuff without the ned to switch to a user ui, like basic ui or the android app. 控制部分用于测试内容,而无需切换到用户ui(如基本ui或android应用)。

For other uis like Basic UI or HABPanel you could solve your problem with a so called proxy-item . 对于其他UI,例如Basic UI或HABPanel,您可以使用所谓的proxy-item解决问题。

This has also been answered in an equivalent way in the openhab community thread you have linked in your question. 您在问题中链接的openhab社区线程中也以等效的方式回答了此问题。

Anyways, for others who may find this question, heres a tutorial/explanation for usage of proxy items. 无论如何,对于其他可能会发现此问题的人,这里是使用代理项目的教程/说明

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

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