Creating virtual device using standard capabilities

I am trying to create a device using standard capabilities. I am using the Thermostat Heating Setpoint capability. Upon initialization, I use this command to set initial values:

sendEvent(name: "heatingSetpoint", value: 3, unit:"F", maximum: 1000, minimum: -1000, title: "My title")

It sets the unit and the initial value OK but I don’t seem to be able to change the title (label) or the minimum/maximum values. What am I doing wrong? thanks.

What title are you trying to change cause that’s not done via sendEvent. Same for min/max. Here’s documentation on sendEvent usage:

https://docs.smartthings.com/en/latest/ref-docs/device-handler-ref.html?highlight=sendevent#sendevent

Min and Max need to be separate attributes if you want to change them, and depending on how you plan on using them, it may be better to set them in Preferences.

Can you provide more detail on what you’re trying to do?

Thanks, Preferences is where I was trying to get the values but then wasn’t sure how to get the preference value into the actual attribute. Appreciate the link.

No problem! Look at other code from developers for examples. That will help you a lot to learn this stuff. Here’s an example of one of mine using preferences maybe in a way you want to:

https://raw.githubusercontent.com/jsconstantelos/SmartThings/master/devicetypes/jsconstantelos/my-aeon-gen-1-home-energy-meter.src/my-aeon-gen-1-home-energy-meter.groovy

I’m wanting to change the text where it says ‘Heating temperature’ in the above picture.

Here is the definition of this capability from the documentation:

{
    "id": "thermostatHeatingSetpoint",
    "version": 1,
    "name": "Thermostat Heating Setpoint",
    "status": "live",
    "attributes": {
        "heatingSetpoint": {
            "schema": {
                "title": "Temperature",
                "type": "object",
                "additionalProperties": false,
                "properties": {
                    "value": {
                        "title": "TemperatureValue",
                        "type": "number",
                        "minimum": -460,
                        "maximum": 10000
                    },
                    "unit": {
                        "title": "TemperatureUnit",
                        "type": "string",
                        "enum": [
                            "F",
                            "C"
                        ]
                    },
                    "constraints": {
                        "title": "NumberConstraint",
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                            "min": {
                                "type": "number"
                            },
                            "max": {
                                "type": "number"
                            }
                        }
                    }
                },
                "required": [
                    "value",
                    "unit"
                ]
            }
        }
    },
    "commands": {
        "setHeatingSetpoint": {
            "arguments": [
                {
                    "name": "setpoint",
                    "schema": {
                        "title": "TemperatureValue",
                        "type": "number",
                        "minimum": -460,
                        "maximum": 10000
                    },
                    "required": true
                }
            ]
        }
    }
}

I guess what I really need to change the ‘constraints’ value min/max? Just trying to figure this all out before I have to move to the new app. thanks again.

Ah, cool. Glad to see you’re willing to develop on the new platform!

Trying. I have been searching for various examples to learn from but not many yet. In your example, you use ‘encap’ function to set the attributes after setting update. Is documentation for that function in the new API?

I’ve not gotten that far yet, but now that custom capabilities are back with CLI (see a separate post on that), I plan on working on a few of my DTH’s this weekend.

Your idea is a good one, but it would be helpful if ST provided a little more documentation for use too so we’re not guess on all this stuff.

Not that I know of. Technically 'encap" isn’t really needed, but since the DTH I used as my source was used for both newer Zwave devices supporting S2 security. Look at the section titled “secEncap” to see what I mean. In ST’s much older version f that DTH, encap didn’t exist at that time.

Look at the preference for watts limit as a good example of using a preference value starting at line 120:

def configWattsLimit = settings.wattsLimit as int

Yes, this uses the value. Unfortunately, ST has set limits internally so the adjustment won’t go above/below the internal min/max and I can’t figure out how to change those limits. Right now, I am limited to values 36-95 F which is fine for a thermostat but my ultimate purpose is more general.

I have these preferences:

 	preferences {
        input name: "minimump", type: "number", title: "Minimum value", description: "Minimum set point", required: true
        input name: "maximump", type: "number", title: "Maximum value", description: "Maximum set point", required: true
        input name: "Positivep", type: "boolean", title: "Positive value", description: "Is setpoint positive?", required: true, defaultValue: true
	}   // End of preferences   

And am trying to put them into the device using this:

def updated() {
    sendEvent(name: "minimum", value: minimump, displayed: true)
    sendEvent(name: "maximum", value: maximump, displayed: true)
	sendEvent(name: "Positive", value: Positivep, displayed: true)
    sendEvent(name: "GVstatus", value: "settings", displayed: false, isStateChange: true)
}

What happens when you code it as this:

sendEvent(name: “minimum”, value: settings.minimump as int, displayed: true)

It should allow you to Save and Publish, but what does Live Logging throw for an error, if anything, when that bit of code executes?

This wouldn’t compile. I got the following error:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
script_dth_metadata_111dfee4_ffe5_454b_94a6_e04c67db9815: 72: Invalid variable name. Must start with a letter but was: “minimum”
. At [72:18] @ line 72, column 18.
sendEvent(name: “minimum”, value: settings.minimump as int, displayed: true)
^

1 error

I know I should probably start a new topic but I have another question. I tried using ovenSetpoint instead of thermostat and it mostly works and would work better than the thermostat for my needs but every time I try to adjust the value, I get this error:

I noticed the status for this capability is “proposed” so maybe they didn’t finish it? Seems so close.

Looks like I will have to break down and create mh now custom capability. ugh.

1 Like

Ok, then I would do it like this:

def minValue = settings.minimump as int
sendEvent(name: “minimum”, value: minValue, displayed: true)

I already tried:

SendEvent(name: “minimum”, value: settings.minimump, displayed: true)

but that didn’t seem to work. You think the. intermediate variable will make a difference? Also, it is confusing because ‘value’ has a minimum and maximum but ‘constraints’ have min and max. Which do I need to change? I have tried both to no avail. Even in the preferences where I have an input for minimum and maximum, I am not allowed to go beyond 999 (anything with more than 3 digits, the save button is grayed out). Where is that constraint? this is all very confusing.

I am trying to solve the same problem, but no luck so far.
Any development on your side?