Best way to marry Lutron RA2 Keypress with Musiccast (revised for clarity on Q's)

NOTE: Since no answers, I am assuming my questions are too vague/buried at the end. Many details below, but my questions are pretty simply and boil down to the following:

  1. In order to associate multiple keypads (pico) with multiple streaming devices (musiccast), what is the best approach? I have working a few rules that use the keypad item (points) as the trigger for rules, and the musiccast equipment items to do actions based on the triggers. This works, but I feel like I am not taking advantage of semantic classes, equipment abstraction models, metadata, etc. I am more than willing to do the work and write the code, but I do not understand the correct way to even model this relatively simple setup in OH. If someone can pseudocode a model for me that would be very helpful and I can probably figure out from there.

  2. Is it possible to write rules within the Paper UI that incorporate logic beyond when [x] do [y]? I see coding examples, but I do not see how to input code into a rule from the Paper UI. If I want something more complex that when [x] do [y], is there a way to add code (loops, variables, functions, etc.) to rules using the UI, or will I need to start over and just do text based configs? I saw a few posts that seem to imply there is some way to add code into the UI rules, and to add some kind of model for repeatedly used code … but I cannot figure out where/ how in the UI to do that.

  3. Once I have a working set of rules (or, as applicable, semantic models / templates, etc.) for a working pico + musiccast streamer, how can I replicate that for the other identical equipment in different rooms? I was hoping to create some kind of virtual class structure that could then be instantiated in each room, but I just don’t understand how I can do that (at least not from the UI).

  4. More generally, is there a language reference for rules files (whether or not just UI, I just want to see the semantics laid out). I am an old time C/C++ and Python programmer, with some java experience… but newer stuff like Ruby, XML and JSON I only know in concept so would be helpful for me to start from the language reference(s) that I need to know to write code for rules, which is always how I learned new programming langauges in years past…

ORIGINAL POST WITH DETAILS FOLLOWS …

  • Platform
    • Architecture: x64 Rpi 4 with 8gb ram, 64gb microsd
    • OS:Openhabian (raspian)
    • Java Runtime Environment: Not sure - latest openhabian
    • openHAB version: 4 (openhabian latest release as of last week)
  • Issue of the topic: What is the best way to use Lutron keypads and scenes to control Musiccast streamers using OH?

I am a control4 refugee (lots of reasons maybe for anither post some day), tried HA and couldnt make its limited yamaha and musiccast drivers work with my setup, so landed here and installed Openhabian on a brand new rpi 4 last week.

After some initial small annoyances (had to manually configure ethernet since it kept going to wifi and ignoring my eth0) got it all working and installed a bunch of bindings using the web UI Paper interface (maybe a mistake but wanted to get proof of concept quickly before spending days writing config files). I am a programmer (or was thirty years ago) and very fluent in Linux.

Relevant here, my hardware setup is already heavily dependant on Lutron RA2 (the full version, not select), and Yamaha AVR and streamers (in particular i have two qs5400 boxes in my rack that run music to eight rooms, plus additional WXA streamers for a couple of rooms, all via hard wire speakers and ethernet (not wifi), plus several Yamaha AVRs and other components). Luckily, bindings for Lutron and Musiccast were pretty easy to install and configure and i got that working as of yesterday.

As a simple test / proof of concept, i installed a lutron 3 button pico audio controller (really 5 buttons since it has raise/lower volume controls too).

I would like to use that to control speakers (each speaker set attached to its own musiccast streaming device). Here is how i tried to do it using 2 Rules, focusing on just one button the Play/Pause button 1, and for now just controlling one streamer / speaker set to power on and play using one button:
Power On: When play button is pressed (state change), turn power on, only if power is not on (working)
Play: when play button is pressed (state change), select streaming source, and play, only if power is on (working)

This requires 2 button presses to power on first, then play, but it works (the pico doesnt really have a good button for power so i am trying to overload that button1)

I still need to implement pause, volume up/down, mute, and next track but that is not the question for this post…

As you can see, i have 2 rules and will need at least one more just for button1 (pause). I will also need to make the rule trigger and exception conditions more complex to handle multiple states possible for two streamers from a single pico (one could be on, the other off; one might be joined to another room, etc)

Then there are the other 4 buttons to program. In all i think i will need at least 15 complex rules with lots of conditions per keypad… and then need to use that as a template for another 5 pico keypads in different locations.

While i can likely make all that work, i feel like there might be a better way so thought to ask here before going further.

  1. Should be using rules like this to link the Pico buttons with the musiccast streamers? Or, should i build a model of some kind using the pico and musiccast equipment as components? Or some other way?

  2. is there a way to create variables and custom functions that can be accessed from rules? For example., can i create a matrix to represent the state of the system (on or off, playing or paused, muted or not, linked rooms, source, playlist…) and use those variables in my rules globally and peristently? I realize there would need to be initialization and synching functions for that to work so would need all of that as well.

  3. once i have the first pico working, how can i “copy” that config to the next pico, and the next, etc., so i dont have to recreeate the whole rulebook?

  4. is the Paper UI really a mistake for me? I feel like the above issues might be more easily solved in config files but hate to start all over if i dont have to…

GENRATED CODE FOR PLAY:

configuration: {}
triggers:
  - id: "4"
    configuration:
      itemName: Coach_Road_Final_Master_Bath_Bath_Wall_Bathroom_Audio_Button_1
    type: core.ItemStateChangeTrigger
conditions:
  - inputs: {}
    id: "5"
    configuration:
      itemName: WXA50_Main_Zone_Power
      state: ON
      operator: =
    type: core.ItemStateCondition
  - inputs: {}
    id: "3"
    configuration:
      itemName: WXA50_Main_Zone_Playback_Control
      state: Play
      operator: "!="
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "1"
    configuration:
      itemName: WXA50_Main_Zone_Input_source
      command: TIDAL
    type: core.ItemCommandAction
  - inputs: {}
    id: "2"
    configuration:
      itemName: WXA50_Main_Zone_Playback_Control
      command: Play
    type: core.ItemCommandAction

GENERATED CODE FOR POWER ON (OVERLOADED BUTTON 1)

configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: Coach_Road_Final_Master_Bath_Bath_Wall_Bathroom_Audio_Button_1
    type: core.ItemStateChangeTrigger
conditions:
  - inputs: {}
    id: "3"
    configuration:
      itemName: WXA50_Main_Zone_Power
      state: OFF
      operator: =
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: WXA50_Main_Zone_Power
      command: ON
    type: core.ItemCommandAction