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