SmartThings Community

Device handler tiles, text wrapping


(Richard Southward) #1

I have a thermometer device, which is also a humidity and pressure sensor. I am using a device handler I downloaded from the internet, but I want to modify the text that appears in the main tile, so that I can see the temperature, humidity and pressure on the same tile.

I have got this working, but I’m unable to force it to show on multiple lines, and it will show in a very small font in the format

12º 97% 1024

I’ve tried arranging the string in the device handler to include \r \n etc… but I can’t get it to appear like

12º
97%
1024

The code I’m using for this is…

sendEvent(name: “combined”, value: “{currentTemp}° \r\n {currentHumidity}% \r\n ${currentPressure}”, displayed: false)

Has anyone got any ideas?


#2

The thread below might help:


(Richard Southward) #3

Thanks for your suggestion, but this doesn’t work. I’ve tried viewing on both my Samsung Galaxy S9 phone and also on an iPad, but both just display the word ‘BATTERY’ in the example given.


#4

Based on what they figured out in that other thread, it looks like the key is using a valueTile. This is what I get:

Using this:

/**
 *  Multi Line Example
 *
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 */
metadata {
	definition (name: "Multi Line Example", namespace: "smartthings", author: "smartthings") {
		capability "Contact Sensor"

		attribute "display1", "string"
		attribute "display2", "string"
        
		command "changeDisplay"
		command "resetCount"
	}

	tiles(scale: 2) {
		valueTile("firstThing", "device.display1", inactiveLabel: false, width: 6, height: 4, decoration: "flat") { state "default", label: '${currentValue}', action: "changeDisplay" }
		valueTile("secondThing", "device.display2", inactiveLabel: false, width: 2, height: 2, decoration: "flat") { state "default", label: '${currentValue}', action: "resetCount" }
		main (["firstThing"])
		details(["firstThing", "secondThing"])

	}
}

def parse(String description) {
	log.debug "Parsing '${description}'"
}

def installed() {
	state.val1 = 1
	state.val2 = 10
	state.val3 = 100
	sendEvent(name: "display1", value:"${state.val1}\n${state.val2}\n${state.val3}")
	sendEvent(name: "display2", value:"${state.val3}\n${state.val2}\n${state.val1}")
	log.debug "Installed: ${state.val1} ${state.val2} ${state.val3}"
}

def resetCount() {
	state.val1 = 1
	state.val2 = 10
	state.val3 = 100
	sendEvent(name: "display1", value:"${state.val1}\n${state.val2}\n${state.val3}")
	sendEvent(name: "display2", value:"${state.val3}\n${state.val2}\n${state.val1}")
	log.debug "Reset: ${state.val1} ${state.val2} ${state.val3}"
}

def changeDisplay() {
	if (state.val1) {
		state.val1 = state.val1 + 1
		state.val2 = state.val2 + 10
		state.val3 = state.val3 + 100
	} else {
		resetCount()
	}
	sendEvent(name: "display1", value:"${state.val1}\n${state.val2}\n${state.val3}")
	sendEvent(name: "display2", value:"${state.val3}\n${state.val2}\n${state.val1}")
	log.debug "Increased: ${state.val1} ${state.val2} ${state.val3}"
}

(Richard Southward) #5

Thanks for your detailed explanation.

I have added your device handler, and created a device that uses that device - it displays exactly that same as your screenshot.

However, the main place I wanted to see my devices was the favourites area on the dashboard, but this just displays at “1” in the example above. I’m guessing that it uses different code to render that particular tile.

Apologies that I wasn’t clear in my original message.


#6

Ah. I don’t know if that’s possible. It seems like the dashboard and the device list just show the first line of the main tile. The only way I can think of doing that is to spawn child devices for each attribute so you can add each separately to your favorites.

Or… ActionTiles will let you add multiple attributes of a single device as separate tiles on a dashboard.