Update virtual temperature sensor

Hi,

I have tried with several ways to update a virtual temperature sensor

Have created a device with DTH “Temperature Sensor” or “Temperature Measurement Capability” or “simulated Temperature Sensor” - and all of them I could not update.
Not via CLI command and not via MQTT

Switches are working fine, read temperature value from real sensors is also working.

What may I do wrong?

(question about MQTT to @Tech_GFam :wink: )

Thanks!

Hi, there! How are you trying to update the temperature value?
Is this one of the DTHs you used?

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

Hi, let me see if I understand.

  • You created a device using another DTH (device type) using the IDE tool.
  • Then you edited the device and selected the Temperature sensor DTH but the view wasn’t updated in the app.

It could happen that the previous configuration of your device was cached in the app (to reduce the refreshing time, make sure you have enabled the developer mode in the ST app)
Verify your device configuration by getting the device list from the SmartThings API:

  • A device uses a presentationID also known as VID that defines how the capabilities are displayed.
  • In that list, you can see the capabilities used by your device.
    • Verify their current value from the device status, the values shown in IDE are taken from the DTH but they’re not always saved correctly.

@nayelyz I have tried different DTH - from templates and your listed.
Have added a command for updating
(used sendEvent(name:“temperature”, value: temp, unit: unitString()) for this)
got the right lines in log.

But I must correct my question…

I had an issue before in code - then later have only checked the label at the tile and was waiting for updates. Today have seen that value will be updated in element (see it in events and history) and in second level tile (after open the main tile) - but level will not be changed in main tile - here is all the time a like “checking” (not sure because I have German version with “Wird überprüft…”)

I have now about 8 different virtual temperature elements with different versions of DTH - and only at TWO of them the label will be changed after value updating. On one sensor I see the battery value instead of temperature on second the temperature (without updating battery).

So something is not right with the DTH in the tile section, I think so.

Can you tell me how to build a DTH with an updating temperature (or humidity) value at main tile and an additional battery value in second level? Something I do wrong, I feel it… :slight_smile:

Thanks!

Sure, no problem.
For those devices that should show the temperature on the dashboard view (main tile), you need to make sure they send the unit in all the temperature events. This is because, in the dashboard, the value shown is the concatenated values of {{temperature.value}} {{temperature.unit}}. The accepted units are “F”, “C” and “K”.

You can create a custom device presentation to change which capabilities are displayed in each view. If the VID property is not included, capabilities are displayed according to the default presentation assigned to the device.

To start working on this, you should install the SmartThings CLI, in the post below, you’ll find the steps for the installation and the device presentation creation.

As a reference, this post has more details about the Views. The tiles config in the DTH is no longer used.

Let me know if you have any questions.

Ok, I thought so, but cannot understand it.

I’m using as sample the “Xiaomi Temperature Humidity Sensor” DTH - here is no vid included.
Using other DTH without vid it will not work in most cases as described.

If I include a vid,mnmn,namespace from working DTH - it does not help - is this right?
I send all the time the temperature vale with unit - it is working for this (modified) DTH stable (in this time) https://github.com/SmartThingsCommunity/SmartThingsPublic/blob/master/devicetypes/smartthings/child-temperature-sensor.src/child-temperature-sensor.groovy

I do not see any system here - when it is working and why…

I already have used cli, but because of ready DTH templates I thought it could be used, but many seems to be useless because of such problems.
A main question for me is - how we can give “ready made” custom DTH to normal customers for integration? If I use cli for create individual vid - will it work for other users?

Can you share your DTH, please? I’d like to see its configuration (since you made some modifications to the child-temperature-sensor DTH) and the VID you generated. It can be through a private repository, my Github user is nayelyzarazua-bluetrail

Yes, the generated VID is not available only from your account. If other users install your DTH, it will use that VID without problems.

Thanks, will do. Only want to check before if there is again any cache problem…

The cache problem is only device related or also DTH related?
Does it help to remove / add a new device to be sure to work without cache?

Is “°C” and “°F” also accepted? I see it in ready DTH and working devices (Zigbee) in label.

Thanks!

It’s also DTH related, in that case, you need to create a new DTH with the same config but a different name.

No, the values of “F”, “C”, and “K” are compared in the alternatives of the capability (Key > the current attribute value, is replaced by the text in Value). If you send a different value for the unit, the “checking…” message will show again.

:+1: This maybe one of the problems of some of my DTH … Sometimes I have used “°C” as I have seen…

From where I can get this states json ? And can it be modified ?

It belongs to the presentation of the temperatureMeasurement capability, you can see it using the command:

smartthings capabilities:presentation temperatureMeasurement -j

Up to now, the presentation of the stock capabilities cannot be modified.

Oh, sorry for the confusion. I just meant that you can make a REST request to the API to get the Device list, for example, using Postman, this would be the request:

You just need to replace “PersonalAccessToken” by the actual value.

I thought about custom capabilities.
Could it be possible to define a label like
"{{temperature.value}} {{temperature.unit}} / {{humidity.value}} {{humidity.unit}}"
for combined sensors - if make a combined capability tempHum as sample?

BTW: my DTH are working stable now - seems the °C was final the problem in some codes…
Will mark it as solution if stable until tomorrow :wink: THANKS!

No, the label is defined in each capability presentation, if you include the attribute of another capability, it won’t work.
If you want to show two capabilities values in the dashboard, you can use the “group” property in your custom capability presentation. There’s an example in this post:

But this does not work inside the label, right?
I can not display temperature AND humidity value at the line , if I understand it right…

You’re right, it doesn’t work in the capability presentation label. You can copy the Temperature and Humidity capabilities configuration into a custom capability (each) and add the “group” property. For example:

{
    "dashboard": {
        "states": [
            {
                "label": "{{temperature.value}} {{temperature.unit}}",
                "alternatives": [
                    {
                        "key": "C",
                        "value": "°C",
                        "type": "active"
                    },
                    {
                        "key": "K",
                        "value": "°K",
                        "type": "active"
                    },
                    {
                        "key": "F",
                        "value": "°F",
                        "type": "active"
                    }
                ],
                "group": "main"
            }
        ]
    ...