Manually editing sitemap created through UI

Is it possible to edit the sitemap file directly for a sitemap that has been created through the UI? I really like the UI experience, but have built a very big sitemap for mobile use over time. I need to rejig some items into sub-groups and frames, but that’s not something that the UI allows you to retrofit.

I tried clicking on the code tab in the UI and editing directly in there, but even after cleaning out all the syntax errors that it doesn’t like with the UI generated code, it doesn’t seem to save, and when I return into the sitemap any changes have been lost.

  • Platform information:
    • Hardware: amd64/Oodles
    • OS: Linux 5.14.21-150500.55.73-default
    • Java Runtime Environment: OpenJDK 17.0.12
    • openHAB version: 4.2.1

This is likely a bug then. You should be able to edit the sitemap directly from the code tab without error.

However, there should be any syntax errors in the code tab with the generated code. Please proviode more details on the steps you took and what syntax errors you saw.

Outside of the code tab, the only other place to edit a managed sitemap would be to stop OH and edit the JSONDB file manually. Though be careful, it’s easy to mess up the JSON.

1 Like

I went through all the errors in the code editor and once I fixed those, it was happy to save changes, which is great. Though when I switch back to the design and then back again, a bunch of the errors are reintroduced. I think I’ve boiled them down to mostly the iconify icons.

Error: Syntax error at line 85 col 35:

83      }
84      Text item=TimeOfDay label="Current Cycle [%s]" labelcolor=["grey"] valuecolor=["grey"]
85  }
                                      ^
Unexpected number token: "2".

Which despite the error is sourced from:

Group icon=iconify:solar:sofa-2-linear item=Lounge label="Lounge" labelcolor=[LoungeSmoke_Smoke==ON="red", Motion2_Occupancy==ON="teal", LoungeTV_Online==ON="teal", Iris1_State==ON="orange"] {

Putting quotes around the icon attribute resolves the error until switching back to the Design tab, which reverts the change. Putting quotes in the UI breaks the icon resolution. A variation on the theme:

Error: Syntax error at line 174 col 41:

172      }
173      Text item=TimeOfDay label="Current Cycle [%s]" labelcolor=["grey"] valuecolor=["grey"]
174  }
                                             ^
Unexpected colon token: ":".

Actual source:

Group icon=iconify:icon-park-outline:girl-two item=Bed2 label="Myka's Room" {

It is evident above that the line reporting also is wrong, while the line numbers are correct, each error message displays the same line of code from the end of the file.

There were a few other things that caused problems, but could be worked around with new labels:

  • Unicode characters, e.g. ▲▼
  • Slashes in values label maps e.g. 1=This / That
  • Other special characters in label maps, e.g. the @ sign

OK, that’s pretty clearly a bug. The sitemap parser can’t handle the “-” in the icon name unless you put quotes around it. Please file an issue on the webuis repo with this information and a recommended solution to put quotes around the icon name all the time.

Both - and : are meaningful tokens (apparently) so when the parser encounters them without knowing they are part of a string it gets confused.

The reason it reverts is that what you see in the code tab gets rewritten by what you’ve configured in the design tab. The design tab takes precidence.

That’s not all that unexpected. The same thing happens when you forget a closing } or ) or something like that. When you have a stray token like that the parser continues on it’s merry way and often doesn’t know something’s wrong until it encounters something unexpected further down in the file.

You might want to try this with a 4.3 milestone version of OH. There have been a number of improvements in this area. But there is no guarantee I catched everything.

2 Likes