In case anyone is interested:
How to make the temperature and humidity sensor driver show temperature and humidity on the sensor tile
It would also be valid to show other attributes such as battery …

- Create a custom capability with an attribute of type text
- Create Capability presentation
Or you can use this capability
Capability: legendabsolute60149.infoPanel
- Create a VID presentation and on the dasboard I remove the Temperature capabilty and put the Custom Capability. In the detailView I do not put it, so that the custom Capability does not appear in the details view.
{
"mnmn": "SmartThingsCommunity",
"vid": "bcef4bd6-e6c2-3753-ab47-80470a09b972",
"version": "0.0.1",
"type": "profile",
"iconUrl": null,
"dashboard": {
"states": [
{
"component": "main",
"capability": "legendabsolute60149.infoPanel",
"version": 1,
"idx": 0,
"group": "main",
"values": [],
"composite": false
}
],
"actions": []
},
"detailView": [
{
"component": "main",
"capability": "temperatureMeasurement",
"version": 1,
"values": [],
"patch": []
},
{
"component": "main",
"capability": "relativeHumidityMeasurement",
"version": 1,
"values": [],
"patch": []
},
{
"component": "main",
"capability": "battery",
"version": 1,
"values": [],
"patch": []
},
{
"component": "main",
"capability": "refresh",
"version": 1,
"values": [],
"patch": []
}
],
"automation": {
"conditions": [
{
"component": "main",
"capability": "temperatureMeasurement",
"version": 1,
"values": [],
"patch": [],
"exclusion": []
},
{
"component": "main",
"capability": "relativeHumidityMeasurement",
"version": 1,
"values": [],
"patch": [],
"exclusion": []
},
{
"component": "main",
"capability": "battery",
"version": 1,
"values": [],
"patch": [],
"exclusion": []
}
],
"actions": []
},
"presentationId": "bcef4bd6-e6c2-3753-ab47-80470a09b972",
"manufacturerName": "SmartThingsCommunity"
}
- Add the custom capability and VID in the profile.yml file:
name: temp-humid-battery
components:
- id: main
capabilities:
- id: temperatureMeasurement
version: 1
- id: relativeHumidityMeasurement
version: 1
- id: battery
version: 1
- id: refresh
version: 1
- id: firmwareUpdate
version: 1
- id: legendabsolute60149.infoPanel
version: 1
categories:
- name: Thermostat
preferences:
- preferenceId: tempOffset
explicit: true
- preferenceId: humidityOffset
explicit: true
metadata:
deviceType: Thermostat
ocfDeviceType: oic.d.thermostat
deviceTypeId: Thermostat
mnmn: SmartThingsCommunity
vid: bcef4bd6-e6c2-3753-ab47-80470a09b972
- Declare Custom Capability in init.lua
-- Custom Capability declaration
local info_Panel = capabilities ["legendabsolute60149.infoPanel"]
- In the Temperature and Humidity Handler I add a code to give text value to the custom capability attribute and emit event when there is a change in temperature or humidity
--- temperature handler
local function temp_attr_handler(self, device, tempvalue, zb_rx)
device:set_field("last_temp_value", tempvalue.value / 100, {persist = true})
tempMeasurement_defaults.temp_attr_handler(self, device, tempvalue, zb_rx)
-- emit tile info
local temp = device:get_field("last_temp_value")
local humid = device:get_field("last_humid_value")
local text = string.format("%.1f",temp).."º".."C".." / "..humid.." % "
device:emit_event(info_Panel.infoPanel(text))
end
---humidity_attr_handler
local function humidity_attr_handler(driver, device, value, zb_rx)
device:set_field("last_humid_value", utils.round(value.value / 100.0), {persist = true})
device:emit_event_for_endpoint(zb_rx.address_header.src_endpoint.value, capabilities.relativeHumidityMeasurement.humidity(utils.round(value.value / 100.0)))
-- emit tile info
local humid = device:get_field("last_humid_value")
local temp = device:get_field("last_temp_value")
local text = string.format("%.1f",temp).."º".."C".." / "..humid.." % "
device:emit_event(info_Panel.infoPanel(text))
end
What if you need to see it in ºF you would have to write a code to convert it to ºF, since the automatic conversion will not be done