[SOLVED] Multiple sub-directories/nesting

Tags: #<Tag:0x00007f2fc0582ab8>

Hi,

I’m trying to set up multiple sub-directories in my openhab setup. I can’t find any explanations that goes beyond a single sub-directory, it is possible to have more than one deep?

I’m specifically trying to have a top level that says “Temperatures”, once you click on that, you are shown temperatures for 10 different locations. That I can do.

From here I’d want to be able to click on the individual temperatures and be taken to a page that shows the battery level and RSSI for that temperature node. That I can’t do.

I’d also like it for the Temperatures to change colour if either the rssi or voltage drop to an unacceptable level.

What I have so far:-

My.sitemap

sitemap My label="My House"
{
Group item=Nodes label="Temperatures" icon="temperature"
Switch item=Act_Node50 label="Node50_Output"
}
}

My.items
//first half

Group Nodes (Network)

Number Temperature_Node50 "Temperature_Node50 [%.1f C]" <temperature> (Nodes) {mqtt="<[mosquitto:home/rfm_gw/nb/node50/dev50:state:default]"}
Number Temperature_Node51 "Temperature_Node51 [%.1f C]" <temperature> (Nodes) {mqtt="<[mosquitto:home/rfm_gw/nb/node51/dev50:state:default]"}
Number Temperature_Node52 "Temperature_Node52 [%.1f C]" <temperature> (Nodes) {mqtt="<[mosquitto:home/rfm_gw/nb/node52/dev50:state:default]"}
Number Temperature_Node53 "Temperature_Node53 [%.1f C]" <temperature> (Nodes) {mqtt="<[mosquitto:home/rfm_gw/nb/node53/dev50:state:default]"}
Number Temperature_Node54 "Temperature_Node54 [%.1f C]" <temperature> (Nodes) {mqtt="<[mosquitto:home/rfm_gw/nb/node54/dev50:state:default]"}
Number Temperature_Node55 "Temperature_Node55 [%.1f C]" <temperature> (Nodes) {mqtt="<[mosquitto:home/rfm_gw/nb/node55/dev50:state:default]"}
Number Temperature_Node56 "Temperature_Node56 [%.1f C]" <temperature> (Nodes) {mqtt="<[mosquitto:home/rfm_gw/nb/node56/dev50:state:default]"}
Number Temperature_Node57 "Temperature_Node57 [%.1f C]" <temperature> (Nodes) {mqtt="<[mosquitto:home/rfm_gw/nb/node57/dev50:state:default]"}
Number Temperature_Node58 "Temperature_Node58 [%.1f C]" <temperature> (Nodes) {mqtt="<[mosquitto:home/rfm_gw/nb/node58/dev50:state:default]"}
Number Temperature_Node59 "Temperature_Node59 [%.1f C]" <temperature> (Nodes) {mqtt="<[mosquitto:home/rfm_gw/nb/node59/dev50:state:default]"}

// second half

String Node50Rssi "Node50 RSSI [%s db]" <network> (Node50) {mqtt="<[mosquitto:home/rfm_gw/nb/node50/dev02:state:default]", expire="3m,Offline?" }
Number Node50Voltage "Node50Voltage [%.2f Vdd]" <battery> (Node50) {mqtt="<[mosquitto:home/rfm_gw/nb/node50/dev04:state:default]"}
String Node50Rssi "Node51 RSSI [%s db]" <network> (Node51) {mqtt="<[mosquitto:home/rfm_gw/nb/node51/dev02:state:default]", expire="3m,Offline?" }
Number Node50Voltage "Node51Voltage [%.2f Vdd]" <battery> (Node51) {mqtt="<[mosquitto:home/rfm_gw/nb/node50/dev04:state:default]"}
String Node50Rssi "Node52 RSSI [%s db]" <network> (Node52) {mqtt="<[mosquitto:home/rfm_gw/nb/node52/dev02:state:default]", expire="3m,Offline?" }
Number Node50Voltage "Node52Voltage [%.2f Vdd]" <battery> (Node52) {mqtt="<[mosquitto:home/rfm_gw/nb/node50/dev04:state:default]"}
String Node50Rssi "Node53 RSSI [%s db]" <network> (Node53) {mqtt="<[mosquitto:home/rfm_gw/nb/node53/dev02:state:default]", expire="3m,Offline?" }
Number Node50Voltage "Node53Voltage [%.2f Vdd]" <battery> (Node53) {mqtt="<[mosquitto:home/rfm_gw/nb/node50/dev04:state:default]"}
String Node50Rssi "Node54 RSSI [%s db]" <network> (Node54) {mqtt="<[mosquitto:home/rfm_gw/nb/node54/dev02:state:default]", expire="3m,Offline?" }
Number Node50Voltage "Node54Voltage [%.2f Vdd]" <battery> (Node54) {mqtt="<[mosquitto:home/rfm_gw/nb/node50/dev04:state:default]"}
String Node50Rssi "Node55 RSSI [%s db]" <network> (Node55) {mqtt="<[mosquitto:home/rfm_gw/nb/node55/dev02:state:default]", expire="3m,Offline?" }
Number Node50Voltage "Node55Voltage [%.2f Vdd]" <battery> (Node55) {mqtt="<[mosquitto:home/rfm_gw/nb/node50/dev04:state:default]"}
String Node50Rssi "Node56 RSSI [%s db]" <network> (Node56) {mqtt="<[mosquitto:home/rfm_gw/nb/node56/dev02:state:default]", expire="3m,Offline?" }
Number Node50Voltage "Node56Voltage [%.2f Vdd]" <battery> (Node56) {mqtt="<[mosquitto:home/rfm_gw/nb/node50/dev04:state:default]"}
String Node50Rssi "Node57 RSSI [%s db]" <network> (Node57) {mqtt="<[mosquitto:home/rfm_gw/nb/node57/dev02:state:default]", expire="3m,Offline?" }
Number Node50Voltage "Node57Voltage [%.2f Vdd]" <battery> (Node57) {mqtt="<[mosquitto:home/rfm_gw/nb/node50/dev04:state:default]"}
String Node50Rssi "Node58 RSSI [%s db]" <network> (Node58) {mqtt="<[mosquitto:home/rfm_gw/nb/node58/dev02:state:default]", expire="3m,Offline?" }
Number Node50Voltage "Node58Voltage [%.2f Vdd]" <battery> (Node58) {mqtt="<[mosquitto:home/rfm_gw/nb/node50/dev04:state:default]"}
String Node50Rssi "Node59 RSSI [%s db]" <network> (Node59) {mqtt="<[mosquitto:home/rfm_gw/nb/node59/dev02:state:default]", expire="3m,Offline?" }
Number Node50Voltage "Node59Voltage [%.2f Vdd]" <battery> (Node59) {mqtt="<[mosquitto:home/rfm_gw/nb/node50/dev04:state:default]"}

I only added the second half to see if it would work, I didn’t have any luck. I’m not sure if I’m supposed to use frames into the sitemap or something like that.

Any help would be much appreciated.

I’m using OpenHAB2 on a Pine64.

Regards.

P.S. Fixed up the way the code way presented based on reply suggestion.

To do this, it’s easier if you don’t use a Group in your sitemap. (you can also do it with Groups, but you have more control with individual entries)
Use a Frame, then list each individual Item and make another nesting (using {}) to show more info when you click each entry.

something like:

Frame {
	Text	label="Temperatures" icon="temperature" {
			Text item=Temperature_Node50 valuecolor=[>35="red",>25="orange",>15="green",<=5="blue"] {
				Text item=Node50Voltage
				Text item=Node50Rssi
			}
			Text item=Temperature_Node51 valuecolor=[>35="red",>25="orange",>15="green",<=5="blue"] {
				Text item=Node51Voltage
				Text item=Node51Rssi
			}
	}
}

Notes:

  1. Use Code Fences
  2. Use VSCode
  3. Your second half of the items file has duplicate Item names (e.g. Node50Rssi is used 10 times)
  4. Why not a Number type for the RSSI Items?
  5. I don’t think that you can do this:

You can change the colour based on the Item value that you display (not based on another Item)
You can use valuecolor for your RSSI and Voltage Items in the sitemap.
You could try to use a rule that notifies you if these 2 values drop below a defined threshold

Thanks for the reply and example Angelos.

So is my understanding correct your example show a top level of 'Temperature", click that will show Temperature_Node50 and 51, then choose one of those and it will show the voltage and Rssi for the chosen temperature?
It looks very logical :).

I did the following, My.items:-

Number Temperature_Node50 "Temperature_Node50 [%.1f C]" <temperature> {mqtt="<[mosquitto:home/rfm_gw/nb/node50/dev50:state:default]"}
Number Node50Rssi "Node50 RSSI [%s db]" <network> {mqtt="<[mosquitto:home/rfm_gw/nb/node50/dev02:state:default]", expire=“3m,Offline?” }
Number Node50Voltage "Node50Voltage [%.2f Vdd]" <battery> {mqtt="<[mosquitto:home/rfm_gw/nb/node50/dev04:state:default]"}
Number Node51Rssi "Node51 RSSI [%s db]" <network> {mqtt="<[mosquitto:home/rfm_gw/nb/node51/dev02:state:default]", expire=“3m,Offline?” }
Number Node51Voltage "Node51Voltage [%.2f Vdd]" <battery> {mqtt="<[mosquitto:home/rfm_gw/nb/node51/dev04:state:default]"}
Number Temperature_Node51 "Temperature_Node51 [%.1f C]" <temperature> {mqtt="<[mosquitto:home/rfm_gw/nb/node51/dev50:state:default]"}
Number Distance_Node51 "Distance_Node51 [%.1f cm]" <cistern> {mqtt="<[mosquitto:home/rfm_gw/nb/node51/dev51:state:default]"}

My.sitemap:-

sitemap My label="My House"
Frame {
   Text label="Temperatures" icon="temperature" {
      Text item=Temperature_Node50 valuecolor=[>35="red",>25="orange",>15="green",<=5="blue"] {
         Text item=Node50Voltage
	 Text item=Node50Rssi
      }
      Text item=Temperature_Node51 valuecolor=[>35="red",>25="orange",>15="green",<=5="blue"] {
         Text item=Node51Voltage
         Text item=Node51Rssi
      }
   }
   Text label="Distance" icon="cistern"
}

All working well, thank you.

  1. Use Code Fences - Thanks will do that in future (now :slight_smile:).
  2. Use VSCode - Thanks, I’m not seen that before, it looks like a lot easier/tidier way to code :slight_smile:.
  3. Your second half of the items file has duplicate Item names (e.g. Node50Rssi is used 10 times) - Sorry I had fixed that up the numbering, it was just so show the concept of where I was trying to go with it.
  4. Why not a Number type for the RSSI Items? - I hadn’t thought of that, it was an example I got from another source.
  5. I don’t think that you can do this: - No worries.
1 Like

I think you may be able to…

Frame {
	Text	label="Temperatures" icon="temperature" {
			Text item=Temperature_Node50 valuecolor=[>35="red",>25="orange",>15="green",<=5="blue", Node50Voltage<3="white", Node50Rssi<20="white"] {
				Text item=Node50Voltage
				Text item=Node50Rssi
			}
			Text item=Temperature_Node51 valuecolor=[>35="red",>25="orange",>15="green",<=5="blue"] {
				Text item=Node51Voltage
				Text item=Node51Rssi
			}
	}
}
1 Like

Thanks Vincent, I’ll give it a try.

From the docs:

Note that expressions are evaluated from left to right; the first matching expression determines the color. If the order of the expressions was reversed, the color assignment would not work properly.

Great thanks for giving me a head up on that.
I just added your previous suggestion and played with the values and the temperature values change colour; perfect!