OH3 - Virtual Blind item - do I need a rule at all?

In my current series of probable dumb questions I thought Id ask another…

I have a virtual blind (AKA rolershutter) item to allow up, stop, down commands which then sends a command to a broadlink RF device.

It is working with a simple rule:

  - id: "1"
      itemName: Bedroom1NightBlind
      command: DOWN
    type: core.ItemCommandTrigger
conditions: []
  - inputs: {}
    id: "2"
      itemName: BroadlinkRM2
      command: BR1_BLIND2_DOWN
    type: core.ItemCommandAction

but could I do this somehow on the item itself, rather than a rule - I am thinking I can probably create a widget but this seems like double handling if its possible?

Do you always send to the same ‘real’ Item?
Are commands always a one-to-one translation? A MAP transform is good at this.
Does the binding in use allow write transforms?

Is there an alternate approach -what’s the reason you are not using the ‘real’ device in UI with mappings etc., but using a virtual proxy?

Yes I always send a string command to the same item which is for a Broadlink RF transmitter using the broadlink binding. The binding receives the string and then uses a MAP file to translate to an RF code specific for the command to send to the blind.

I dont think I can use the ‘real’ device as that device isnt actually known by OH but does recieve the RF code at the end to do what it is supossed to.

Id love to come up with an alternative solution if there is one and feel like there should be? I have over a dozen of these blind controls to do as well as 20 or so Fan RF commands in the same way - i just feel like the UI rules would become - well unruly…

I misspoke really about 'real device’on your UI, I should expand to "openHAB Item linked to the real device " - in this case, BroadlinkRM2.

Anyway, now we know a bit more-you won’'t want BroadlinkRM2 on your UI because it is (going to) act as a portal to many devices, yes?
What binding are you using with this, is it the unreleased Broadlink binding?

I don’t know how that works - you send unique commands for many devices to one Item, or?

Thats correct the broadlink binding that I think will be merged into 3.1 but currently Jar based, but can confirm it works and the rule above is an example of how I send a DOWN command that is then interpreted via a MAP file into an RF command the broadlink device blasts out.

Yes I send a unique string which is mapped to a unique code but for many devices - it is basically a universal remote control

I didnt know f there was an equivilent custom (or otherwise) metadata item I could use that is similar to a widget “actionitem” “actioncommand”

Okay, got it.I think.
This is one-way traffic, no feedback from end devices.

For sanity if nothing else, you’ll want individual Items representing your blinds etc.
That in turn allows you to use standard UI widgets, seems desirable!

Standard widgets and Items will deal in standard OH commands,but we need to convert those to unique per Item + command strings (for your Broadlink MAP Item). Like your rule does now.

Your master MAP for all seems smart - much more manageable than many little maps.
There isn’t a shortcut for this, but the one rule can be made “universal” and handle all Items and commands, if you adopt an Item naming convention relating Items to your master MAP.

Example from your original -
Roller Item named Bedroom1NightBlind
Expect commands UP/DOWN/STOP from UI or rules.
So - name entries in your master MAP
Bedroom1NightBlind_UP = 1234
Bedroom1NightBlind_DOWN = 5678
Bedroom1NightBlind_STOP= abcd

Now the rule can trigger on any command, and in script build a string from triggering Item name and incoming command. Obviously, command that new string to master Item.

Then we can get clever; put all Broadlink Items into a Group.
Change the rule trigger to be a command to any member of the group.
The rule can find out the triggering Item’s name to build the new string together with the actual command, and send to master as before.
One rule for all devices.

So to add some new roller -
Create an Item, add to Group.
Add name_command=code entries to master MAP
Should be easy to manage.

I can’t give you a script example as I don’t work in UI, but this is all straightforward stuff.

There is undoubtedly a way to embed the individual IR codes in the actual Item’s metadata, and have a rule call those out for sending direct to broadlink, so avoiding the master MAP. Personally, Ilike the idea of allin one place though.

OK that sounds good, I have already got the MAP part done (all was working with lots of rules in 2.5 but thought there must be a better way)

So a single script based on group would be an excellent way forward
If you could provide me with a primer script that would be amazing and I rekon I’d be good to go!

As I said, I do not use UI rules yet.

In a DSL xxx.rules file, it’d look like

rule "do Broadlink commands"
   Member of myBroadlinks received command
   val newcomm = triggeringItem.name + "_" + receivedCommand.toString

Remember this relies on MAP names matching Item names.

OK thanks yes I am trying to use the UI where I can but can see my use cases will mean I need to flip in and out of them - I could probably do a hybrid UI rule that fires a script - thanks youve been enormously helpful.

Still a shame we couldnt just have up button on rollershutter item send actionitem = BroadlinkRM2 actionCommand = Bedroom1NightBlind_UP

Well you kinda can. A widget of some kind can command anything to any Item.

In BasicUI etc, a widget can only be linked to the one Item for its display part, so that probably rules that out.
But you can use a switch widget with mappings to send anything. It won’t look like a rollershutter widget.

In HABBpanel, I think you can construct a widget that displays one Item but commands another with whatever, by scripting. The problem you might have is what to display, the common Item state doesn’t help. Back to using individual proxy Items to represent each shutter etc.

Or you could I think script a kind of onscreen representation of a remote handset, just many buttons that do stuff without state display.

I know nothing about MainUI but it is certainly at least working towards similar capabilities to HABpanel,I expect similar things could be done now.

I reckon you’d make yourself a maintenance nightmare there though. Don’t underestimate the work needed when you come along to add something else in a year’s time, and everything is custom tweaked.

yes think i could emulate it in MainUI but that was why I wanted to do it on an item level - will get to it and see how I go thanks again for your help