I seem to be missing the need of setting the contacts to UNDEF?
Because @rlkoshak rightfully says:
âI now know that I have no idea what state the garage doors are inâ
So that would indeed be the perfect case where you would want a contactâs state to be UNDEF.
And subsequently you could do all kinds of things with that state, like stopping a rule that would turn on sprinklers (as you donât want to risk watering the inside of your garage), or anything like that. Iâm just making something up right now, but you could imagine a whole range of uses.
Perhaps another way to look at it is that Kim wants a new Item type, maybe we could call it ChannelFollower, that links to one (and only one, no more no less) channel and so can only do what a binding tells it.
I imagine you might still be allowed to edit label, or transform state, etc.
I think that idea would be a âhard sellâ, as any existing Item type can do this by the simple method of choosing not to provide any tool (rules, UI, other bindings) to amend it.
@rlkoshak Thank you for making what I consider a âseriousâ answer, which much have taken some time. I appreciate it.
Iâll start by addressing your âdisclaimerâ. I understand that thereâs no guarantees, and that goes beyond OH as well (computer/OS, the uncertainty of the wireless transfer (z-wave) itself, the network and not the least whatever method you use to be notified). The smoke detectors I use have built-in sirens and work as âregular fire alarmsâ without involving z-wave/OH at all. This is just an added layer that lets me do additional warning to locations where the siren isnât audible, so it is indeed just an extension/a compliment. That said, I want it to be as reliable as I can within these limits.
Itâs useful for me to read your description of the event bus mechanism because it will hopefully make me able to be more precise when I describe my suggestion. To reiterate, Iâve never meant to suggest that the events themselves should have any kind of âwrite protectionâ enforcement. When Iâve said âwrite protected from the UI perspectiveâ, I simply mean that unless you make a conscious effort to enable changing a âread-onlyâ itemâs state, it will not be manipulable from any UI.
My idea that this should be some kind of property of an item, which can be read by involved parties. UIâs and other âcontrol interfacesâ would then respect this property. If we think of a switch and a sitemap, this would mean that when using Default
or Switch
, it would either render this a Text
or as a ânon-clickableâ Switch
(whatever was deemed to be most appropriate). In the same way, a Slider
for such an item wouldnât be possible to move and would only display the state it received from update events.
A Contact
item would always have this property set since it can never receive commands, but for example Switch
items or Dimmer
items would not have this set by default.
Ideally I would prefer if this property could be âset automaticallyâ by the binding in those cases where the binding knows that the channel doesnât accept commands. But, I would also like for this to be possible to define in .items
files, so that it is possible to âdowngradeâ an item from how the binding (or channel) defines it. While I donât quite see when this would be useful, for the sake of keeping things generic, I guess it should be possible to âupgradeâ an item in .items
files as well.
As I understand it, this property could then be used by all âcontrol interfacesâ whether weâre talking about a sitemap, HABPanel, a voice interface or any other interface. Iâm not talking about enforcement, merely information. HABPanel for example, have a checkbox on the Knob
widget that âwrite protectsâ the widget. This would be a typical use case, where the item property automatically âwrite protectedâ widgets when appropriate. When using a Knob
to display the temperature from a temperature sensor for example, itâs equally âunhelpfulâ that the UI allows you to SET the temperature as it is that you can SET the status of a fire alarm.
I understand perfectly well that you already can implement all these âwrite protectionsâ in the individual UIâs (with some exceptions like Group
items), but I see this as a âfragileâ way to build a system. For me, the correct âlevelâ to define this is on the item, and once set there, it would automatically be handled correctly in all âcontrol interfacesâ.
So, in a sense, Contact
/Switch
is a red herring after all, because my interpretation of the logic was that a contact was merely a Switch
with an âimplicit read-only propertyâ (not enforcement). But, I think itâs easier if we all disregard this, the above explanation is hopefully easier to understand/clearer.
As I see it, my suggestion would make the whole Switch/Contact issue much less of an annoyance for everybody, especially when the binding knew that the channels were âread-onlyâ aka didnât support commands.
Itâs not that I canât manage without it. I just see this as an issue that a lot of people will have to face in one way or another, and that could be handled much more intuitively and consistently. It would also allow sitemaps and other âUI configurationsâ to be much cleaner with less use of proxies, rules and other workarounds.
I understand that, and I think I have already explained what I mean in this post. If you agree or not is another matter, Iâm simply trying to explain what I think would be an improvement.
I donât understand what you try to say with this, I donât think Iâve raised any concerns that is relatedâŠ? If it was a metaphor, I clearly failed to understand it.
My PaperUI reference ; new OH users will complain about Switch Items where they cannot hide the clickable user action. (or other manipulations, e.g text colour)
Thereâs no provision in PaperUI to do that because it is an admin interface, not for end users.
Sometimes it comes as a revelation that there are separate âproperâ UIs which can be tailored.
You should give some thought to how youâd like your âread onlyâ designation to work in that situation.
There is no need to ever implement rules or proxies to make a display-only item in any of the user facing UIs.
@rossko57 Ah, I didnât even think about UI configured items - but I donât see why the same âread-onlyâ property couldnât be configured from the UI. Likewise, when displaying items in PaperUI, it should be easy to show designated items as âunclickableâ when showing their state - or am I missing something?
I donât know if youâre missing anything, I only observe that users often get in a twist thinking that PaperUi is what they (and their family) should use everyday.
@rossko57 Ok, I guess I was there at one stage when I first looked at openHAB as well, but Iâm way past that point
What is the practical advantage between setting a property on the Item to dictate what UIs can allow versus choosing a read only element to present your Item on the UI in the first place. Youâve already said this is a property that only impacts the UI. Itâs a UI concern. Why force users to define a UI restriction outside of the UI?
Contact, String, and Number Items (IIRC) are already presented on the sitemap as Text which is read only. If you want to present some other Item on the sitemap to be read only, choose Text as the element.
I still fail to see how adding a property to the Item and all the complexities required to cause the UIs to read that property actually solves the problem any better than what exists. In fact, IMHO it solves the problem in a less clear manner because you are mixing UI and Model in the MVC architecture, you are imposing a great deal of additional complexity on the UIs with some fundamental changes to the assumptions for how the UIs work, and itâs strictly speaking unenforceable. At best OH can say âwill you please follow this setting, pretty please?â because the UIs all work through the REST API. If you can do it through the REST API you can do it from a UI.
What problem does this really solve? Why add all of this complexity and enforce some sort of contract on the UIs when you can just choose a read only element on the UI in the first place? It still just seems like a much more complicated (from an implementation perspective) way to achieve what is already achievable much more simply in the current approach.
I strongly disagree. It is strictly a UI concern and therefore belongs in the View part of the Model View Controller design.
And I fail to see how it is any more fragile than setting it in the UI as you build it. You know what the Item is. You know what it represents (if you donât you need to go back and figure out your own model again). You know whether it makes sense for it to be read only or not on the UI. So you have both the knowledge and the power to choose the correct way to display that element as read only or not as you build your UI.
And the bindings have that power too. They can choose to use a Contact Item for binary sensors. Problem solved and OH already supports this. The fact that many bindings choose incorrectly (e.g Network) is a different argument.
Once could argue that there should be a âread onlyâ Number Item equivalent, something akin to Contact which doesnât accept commands. Similarly one could argue that there should be a String Item equivalent that does accept commands to provide symmetry. I could be convinced of that. I donât think I can be convinced that there should be a setting on Items that independently controls whether an Item can receive a command from a UI. Thatâs a UI concern and there are already ways to manage this.
Except it makes the model much more complex. Weâve gone from two options: Switch/Contact to four. And it introduces two ways to implement the same thing. And there is a way to deal with this that could be implemented that doesnât require this breaking of the current model. The Profiles could be updated to allow for the translation between Item Types so, for example, one could map the ON/OFF from the Channel to OPEN/CLOSED required by the Contact Item. Or one could leverage Groups and a very simple Rule:
rule "Convert Switch to Contact"
when
Member of SwitchToContact changed
then
postUpdate(triggeringItem.name+"_Contact", if(triggeringItem.state == ON) "OPEN" else "CLOSED")
end
In Python
from core.rules import rule
from core.triggers import when
@rule("Convert Switch to Contact")
@when("Member of SwitchToContact changed")
def sw_to-cont(event):
events.postUpdate("{}_Contact".format(events.itemName),
"OPEN" if event.itemState == ON else "CLOSED")
Or, I can just use a Text element on my sitemap to display them, as I do now. The issue is annoying because it is not consistent across all OH bindings. Itâs annoying when two bindings choose differently and you are trying to use the two together (e.g. in a Group that aggregates all the states). Your proposal would not address that. Your proposal only addresses how they get displayed on the sitemap by default.
But there are no Rules required. There are no work arounds required. If you donât want an Item to be changed from the UI, donât choose a UI element that allows changing the Item. The Rules and work arounds are only required if you need to combine Switches and Contacts into the same Group (for example) and your proposal doesnât address that problem.
Ultimately, you seem to be pushing towards being lazy about creating your sitemap so you donât have to define every element. And I agree that defining a sitemap can be easier. But I just donât see that the benefit of being able to use Default
instead of Text
when you define your sitemap provides any real benefit. There is a tiny bit of benefit in being able to use the Group
sitemap element, but there are so many other limitations to using Group
(canât use stuff like visibility, color, control order, etc.) that I donât see how this proposal would be worth it.
This is just my own opinion. You are free to open an issue on the UIs and the core repos to implement something like this. But I do not think it will be well received. The amount of work required to make it work is huge, it really doesnât add anything that canât be done now, and it mixes a View concern with the Model which isnât supposed to happen.