Sitemap - repeat items

Hi,

There is a specific subsection of my sitemap, that I want to copy-paste in multiple frames.

This is the part:

	Text label="Airco" icon="climate" {		
		Switch item=KNX_Airco_AanUit_14_0_0
		Switch item=KNX_Airco_AanUit_7_0_0
		Setpoint item=KNX_Airco_TargetTemperature_7_0_1 step=1 minValue=15 maxValue=30
		Selection item=KNX_Airco_Mode_7_0_2 mappings=[ 0="Auto", 1="Verwarmen", 3="Koelen", 14="Ontvochtigen" ]
		Selection item=KNX_Airco_Fan_7_0_3 mappings=[ 0="0%", 25="25%", 50="50%", 100="100%" ]
		}

Obviously, I could just copy-paste that part 10 times and I’m done. However, if I need to make some changes later, I need to repeat those changes as well.

So what is the best way to minimize redundant repeating in my sitemap?

My editor (emacs) support regular expressions.
Take a look at this Online RegExr maybe this is what you`r looking for.

Hi BrutalBirdie,

Thank you for your reply. I use Notepad++, so I could maintain my sitemap using smart search-replace options if that is what you are saying.

This implies that is not possible to define this sitemap-section only once and refer to it multiple times?

I know in rules you could refer to scripts if you need the same code over and over again. I guess that does not exist for sitemaps?

As far as I know, I say no this is not. But I summon some guys who might know better @Dim @sihui

That’s true. However, one workaround (which I use) is to use a text template language or macro preprocessor for the sitemap and then generate the final site map using the tool. If you also use a tool to run commands when files change, you can just save the template and the sitemap will be automatically regenerated.

Duplicating sections of the sitemap in various locations would be one use case. I also use this technique to define macros for sections of the site map and then instantiate those sections for specific devices. For example, I have a relatively complex subpage for detailed information related to each of my network security cameras. With a macro, I can add a single line to the sitemap template with the parameter for a specific camera and the details frame is automatically generated. If I want to add some details to all the cameras, I only need to change the macro. I also use templates to generate sections that include multiperiod charting for numeric items, The pattern for defining these charts is the same across the items and it was tedious and error-prone to hand-maintain the mostly duplicated content.

I would say that you are correct…
I am not aware of any method that could allow you to “re-use” code within a sitemap file…

Hi all,

Thanks! Too bad it is not possible, but I expected the answer.

Search-and-replace (using regular expressions) is a good alternative. A macro preprocessor might be even better, but is overkill in my case.

hmm, i was looking for the same thing.

i have my house set up where one item is for example in a seperate window section, where you can check the states of all windows, but these windows are also in the section where i have the house and all the rooms and i put it into the room it is in …

woulde be great if you could just define a kind of function that is used … like

code function window state 1


end

then you would just put the window state 1 function call into the places you need …

I’m just reviving this thread to ask if there is a way in 2023 or still not?
I’m not aware of one, but would be super useful to have that ability.

But one never knows, so worth to ask.

Is there a way how to reuse bit of sitemap on multiple places in the sitemap so it’s not duplicating same Frame on multiple places?

Nothing in the current sitemap syntax allows that.