[ST Edge] Device Preferences

You should be able to go the device details page in the mobile app and select Settings from the three dot menu, as you can with other devices.

1 Like

Do you mean ‘Edit’ ? So you’re saying any preferences I define for a device will show up on that Edit device page (along with Location and Room)? Would be nice if the documentation would just say that!

Thanks for the clarification.

Device Preferences act as parameters where you can enter a value (from the app) and use it in your Driver eg. to send configuration commands to your device. When you change a preference, the infoChanged lifecycle is called.

If we have this preference:

 - name: "garageSensor"
    title: "Use on garage door"
    required: false
    preferenceType: enumeration
    definition:
      options:
        "Yes" : "Yes"
        "No"  : "No"
      default: "No"

We can access its value using: device.preferences.useOnGarageDoor

Why do you want to include Room and Location?

Do you mean this documentation?

Thanks - I understand what they are and how they can be used by the driver, and how you define the metadata for them. But I wasn’t clear where and how the end-user actually sets their values. Yes, that documentation doesn’t say anything about that.

Can you confirm that it is supposed to be on the device edit page in the mobile app? So any preferences the driver defines for a device will be included on the device edit page?

It’s in Device details > Settings as Graham said. Here’s a example, if you don’t have any preferences in your device, this option is not shown.

Hello @nayelyz ,

I am going to bring here the topic of preferences that affect the configuration of the report intervals of temperature, battery … of zigbee devices, that we talked about yesterday, so that it is together in this thread of the device preferences topic.
As I mentioned to you, I don’t see a way to do it in driver as if it could be done in DTH.

I have copied post, if you can or want to move it from the other thread, I delete it.
Thanks

Thanks, i will wait.

The use of default configuration values ​​of the devices greatly facilitates the writing of drivers, but if they cannot be overwritten it will limit the options for using the devices.

To change the settings of the temperature report intervals for the smartthings multisensor is not a whim, it is a matter of excessive battery consumption.
These have a CR2450 battery and with the default values:

  • minimum interval: 30 sec
  • Maximum interval: 300 sec
  • Reportable change: 0.1º
    In practice, it sends a report for every 0.1º change or every 5 minutes, whichever occurs first if temperature change.
    Whoever designed this device with this battery, I don’t think they thought it was going to be used by default with a precision of 0.1º. Temperature sensors on doors and windows are not suitable for use as thermostats. They do not give usable and reliable information unless they are posted on interior doors of the house.

I use the modified dth to save battery with values since 9 month:

  • minimum interval: 30 sec
  • Maximum interval: 3600 sec
  • Reportable change: 1º
    With these values, it sends a report every 1º change or every 1 hour, whichever occurs first if temperature change.
    The battery has consumed 17% from the end of Nov 2020 until yesterday August 30, 2021, when I installed the edge driver.

When I installed the edge driver the battery showed the same level as with the DTH, 83%.
In just 24 hours with the default values ​​it has consumed 4% (79%)

UPDATED:

In 3 days the battery has already consumed 15%, it shows 68%

I have three smartthings sensors, now aeotec, and I use them for door and automation control and the temperature only as statistical information. If they can’t be modified I’ll have to throw them away when groovy disappears. I do not plan to change batteries every 20 days or put a glob of AA batteries attached to the sensor, hahaha …

On the other hand, another “Health poll” seems to be another default value, which is seen in the logcat every 30 sec. I don’t know what impact this will have on the devices with battery. With DTH I am not aware of this being the case on all devices.

Thanks - I don’t have any devices that show the Settings option. Can you post an example image of the settings screen itself please?

Thank you.

You said you had a multipurpose smartthings, right?
That one has temperature and garage door use preferences.

3 Likes

Ahhhhh you are right! THANK YOU!!

2 Likes

Please, take a look at my post here:

Nayely - I would recommend that in that documentation, there needs to be some clarification to this sentence:

Users are then able to change the Preference to customize their Device.

You should add further clarification like:

Users are then able to change the Preference to customize their Device by selecting the Settings option from the device details menu.

This will avoid others having the same confusion that I had.

2 Likes

Thank you for the feedback, @TAustin. I’ll share it with the corresponding team :smiley:

A bit more feedback after I’ve gotten the preferences (Embedded directly into the Device Profile of the Device) mostly working:

Following is observed on iOS version of mobile app…

  1. The order of the preferences displayed on the settings screen is not what I put in my profile. They’re not in alphabetical order either, so seems kind of random. I’d much prefer them in the order I put them in the preferences section of the device profile.
  2. For string fields , it seems to want to capitalize the first letter of the value displayed (not necessarily desired). However when you tap on the field to edit it, the first letter is not capitalized.
  3. For string fields of type=password, I expected the display and input to be ‘*****’ to hide it, but that is not the case. So what is the purpose of defining a field as type=password?
  4. It seems there is no way to delete the contents of a field that has a default value defined for it. If you edit the field and delete all the characters and hit ‘done’, and then go back in again, the default value is back in there. Any recommendations here? If you want the user to optionally provide an empty field - and have that passed back to the driver, does that mean you can’t have a default value?
  5. The changes made in the Settings screen invoke immediate lifecycle updates to the driver as soon as the user presses the done button on a field. So if a user is going back and forth and changing various fields multiple times, it results in multiple lifecycle calls to the driver. (This is a warning to anyone writing a driver that handles these!) I think I would prefer not to get the lifecycle update until the user exits the settings screen after they’re satisfied with their changes. Getting them realtime can cause an awful lot of (possibly harmful) churn in the driver. Think of an IP address field that gets rapidly edited multiple times for whatever reason (people are funny…): every time you receive that lifecycle update you’re going to go try and reconnect to the device at that IP address. You can see where this could cause trouble…

EDIT regarding #5 above. I think the most logical thing to do if possible, is change the ‘Save’ button for each individual field to ‘OK’, and put a new Save button on settings screen.

Thanks for listening!

6 Likes

I have an integer type field defined with a 5-digit maximum but the settings screen in the (iOS) app only lets you tap ‘Save’ if you enter 3 digits or less. You can type more than 3 digits, but as soon as you do, the ‘Save’ button disappears as if it’s an invalid value. Even the default value can’t be saved!

Here the profile definition:

- title: "Port Number"
    name: portNumber
    description: "Port number of Envisalink"
    required: true
    preferenceType: integer
    definition:
      minimum: 1
      maximum: 65535
      default: 4025

Please let me know if I’ve done something wrong!

p.s. Any comments on my prior post??

1 Like

@TAustin

Indeed, there’s an issue with integer ranges because they’re only supporting -999 to 999 by default, even if you define smaller references. This has been already documented and the engineers will apply the corresponding patch as soon as possible.

Some of these issues had been already documented and for others, we’re still gathering the proper information to keep track of them properly.

2 Likes

Modification of the “edge Driver st Multiporpuse Sensor” to add in the preferences the custom configuration settings for Temperature Reports:

-There are two preference settings:

UPDATE
To prevent the limit of integer preferences, -999 to 999 had changed the maximum interval to minutes instead of seconds.

I have increased the rabgo of the 2 preferences

  • maxTime”: Maximum interval of the temperature report, between (5 sec and 240min)
  • changeRep”: Reportable temperature change, between 10 (0.1º) and 600 (6º)
    categories:
      - name: MultiFunctionalSensor
preferences:
  - preferenceId: tempOffset
    explicit: true
  - name: "maxTime"
    title: "Temp Rep Max Interval(5..240 min)"
    required: false
    preferenceType: integer
    definition:
      minimum: 5
      maximum: 240
      default: 5   
  - name: "changeRep"
    title: "Rep Temp Change 0.1 to 6(10..600)"
    required: false
    preferenceType: integer
    definition:
      minimum: 10
      maximum: 600
      default: 10    
  - name: "garageSensor"
    title: "Use on garage door"
    required: false
    preferenceType: enumeration
    definition:
      options:
        "Yes" : "Yes"
        "No"  : "No"
      default: "No"

When installed it is configured with the default values (30, 300, 10) in samjin subdriver

local function do_configure(self,device)
  print ("subdriver do_configure")
  local maxTime = device.preferences.maxTime * 60
  local changeRep = device.preferences.changeRep
  print ("maxTime y changeRep: ",maxTime, changeRep )
    device:send(device_management.build_bind_request(device, tempMeasurement.ID, self.environment_info.hub_zigbee_eui))
    device:send(tempMeasurement.attributes.MeasuredValue:configure_reporting(device, 30, maxTime, changeRep))
    device:configure()
end

When a setting is changed or the drivers are changed by other in the app, the lifecycle handler “infoChanged” will be executed, which has been assigned a function that reconfigures the reports on the device.

-- preferences update
local function do_preferences(self, device)
    local maxTime = device.preferences.maxTime * 60
    local changeRep = device.preferences.changeRep
    print ("maxTime y changeRep: ", maxTime, changeRep)
      device:send(device_management.build_bind_request(device, tempMeasurement.ID, self.environment_info.hub_zigbee_eui))
      device:send(tempMeasurement.attributes.MeasuredValue:configure_reporting(device, 30, maxTime, changeRep))
      device:configure()
  end

  local zigbee_multipurpose_driver_template = {
    supported_capabilities = {
        capabilities.contactSensor,
        capabilities.battery,
        capabilities.threeAxis,
        capabilities.accelerationSensor,
        capabilities.refresh
    },
    zigbee_handlers = handlers,
    lifecycle_handlers = {
        added = added,
        infoChanged = do_preferences
    },
    ias_zone_configuration_method = constants.IAS_ZONE_CONFIGURE_TYPE.AUTO_ENROLL_RESPONSE,
    sub_drivers = { require("smartthings"), require("samjin") }
}

--Run driver
defaults.register_for_default_handlers(zigbee_multipurpose_driver_template, zigbee_multipurpose_driver_template.supported_capabilities)
local zigbee_multipurpose = ZigbeeDriver("smartthingsMultipurposeSensor", zigbee_multipurpose_driver_template)
zigbee_multipurpose:run()

The title of the preference is limited to 36 characters and the explanatory text in the app settings is not very clear.

With the code that @nayelyz created to modify the default configuration during the installation of the device, has been able to modify the driver to change the configuration of the reports through the preferences in a zigbee device, just as it can be done in the zwave devices.
It’s a big step Thank you @nayelyz !!!

It is working well
I will update you if there is any change or malfunction.
Thanks again

1 Like

Great job, @Mariano_Colmenarejo. Thank you for sharing your solution. In this case, I noticed only one issue pending to report:

Is this correct?

Yeah that’s right.
When performing the package driver it gave the error because the preference title was greater than 36 characters and must be between 3 and 36 according to the log

PS C:\Users\Mariano\smartthings> .\smartthings edge:drivers:package C:\Users\Mariano\Documents\Mariano\VSC\SampleDrivers\st-multipurpose-sensor-pref
(node:8768) UnhandledPromiseRejectionWarning: Error: Request failed with status code 422: {"requestId":"EF72B156-2D5A-4E61-86A4-A3EB25E6CEB0","error":{"code":"ConstraintViolationError","message":"Invalid device profile specification for st-multipurpose","details":[{"code":"SizeError","target":"title","message":"title must have a length between 3 and 36.","details":[]}]}}
    at createError (C:\snapshot\smartthings-cli\node_modules\axios\lib\core\createError.js:16:15)
    at settle (C:\snapshot\smartthings-cli\node_modules\axios\lib\core\settle.js:17:12)
    at IncomingMessage.handleStreamEnd (C:\snapshot\smartthings-cli\node_modules\axios\lib\adapters\http.js:260:11)
    at IncomingMessage.emit (events.js:327:22)
    at IncomingMessage.EventEmitter.emit (domain.js:482:12)
    at endReadableNT (_stream_readable.js:1221:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:8768) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:8768) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will

@nayelyz,

I have installed two multipurpose sensors on the same driver with different temperature report setting preferences for each sensor and it works fine. Each sensor sends the reports according to the selected preferences.
I had to test it to see if it worked well, since the preferences must be in a table linked to the device.
A single driver with different preferences for each device is fine.

@nayelyz,

The preferences title also does not support the degree character " º ".
It is not that it is very important, but if can add this character to the filter pattern.

Can’t write this:

  title: "Rep Temp Change 0.1º to 6º(10..600)"
PS C:\Users\Mariano\smartthings> .\smartthings edge:drivers:package C:\Users\Mariano\Documents\Mariano\VSC\SampleDrivers\st-multipurpose-sensor-pref
(node:20012) UnhandledPromiseRejectionWarning: Error: Request failed with status code 422: {"requestId":"6130DA66-6DBC-4C0A-9E31-C64CEB61D321","error":{"code":"ConstraintViolationError","message":"Invalid device profile specification for st-multipurpose","details":[{"code":"PatternError","target":"title","message":"title does not match the pattern ^[A-Za-z][\\w()\\\\/.?,~!@#$%^\\&*()_+ ]+$.","details":[]}]}}