SOLVED - by workaround. How to tell a template which variable of a device to edit and display

I have some devices that have several time variables.(.time1, .time2, time3 I have a time editor template common to multiple devices and am struggling to link the bits of functionality

When I jump to the template I need it to act on @device - and one of the multiple time variables.
This means the template must know which device (it does @device - perfect) but also which time variable to display and send adjust commands (by mqtt).

Plan A. Have three copies of the template identical except hardcoded to work on @device.time1 @device.time2 etc
Messy but at least easier to understand. Prone to error if I change anything

Plan B. Use virtual variables to tell the edit template which time variable (time1,time2,time 3) to operate on. I have two problems here.

  1. For every display and field in the template it needs to choose between time1,time2.time3 based on the virtualvariable. Not sure how to do this cleanly - or even at all

  2. In the plugin script I need to read a virtual variable to construct the mqtt publish message so the far end knows which of the three times to change. I couldn’t get at the virtual devices in the plugin so not sure if this is possible?

Plan C - something totally different… any suggestions?

SOLVED. Workaround. I have built a totally different way of achieving this functionality.

To recap I have a common time/date editor page. Some devices have more than one timer so I need to distinguish between them - both for the current display of value in the editor and also how to direct the actions that change the time.

The timeeditor:
It shows the time value based on @Device.timecommon
It sends any time commands back to @Device.MQTT (my common way of unusual mqtt requests to node red)

Onsynchronise:
I create attributes time1, time2,…,timen and a common one called timecommon
I also create an attribute called choice which I use to point at the chosen timer.

I also create an attribute called MQTT which i use for sending generic commands back to node red. I use this for all devices that have other control commands other than standard level or switch commands - not just timers.

Onpoll:
gets any new value for time1 … time2 etc it checks the content of the attribute choice. If it is set to time1 or time2 it copies the value into timecommon.

Jump to time editor button actions:
a) sets @Device.choice to time1 or time2 so any resultant commands back to node red have a target set.
b) Copies @device.time1 or @device.time2 into @device.timecommon so the first time the timeeditor shows it has the correct starting time.
c) Pushes the timeeditor page template

The timeeditor buttons send an appropriate payload to the MQTT attribute
EG hitting the time+10mins button in the time editor will send MQTT payload of time/60000
EG hitting the time-10mins button in the time editor will send MQTT payload of time/-60000

onChangeRequest:
If it gets an MQTT action it appends any content of the choice to the payload.
onChange Request appends the current choice - eg time2 so the mqtt payload is time/60000/time2

Node red:
gets mqtt payload of time/60000/time2 to apply to a given device
knows to apply a timevalue of +60000 to the device but also, if it has more than one timer, apply it to timern in that device

This does work well and is easily extendable to time3, timer4 etc or other types of function arrays within one device. I do suspect there is a cleaner, easier way of doing this though