/*
* UnifiNetworkChild-USPPDUP
*
* Description:
* This Hubitat driver provides a spot to put data from USPPDUP device(s).
*
* Instructions for using Tile method:
* 1) In "Preferences -> Tile Template" enter your template (example below) and click "Save Preferences"
* Ex: "[b]Temperature:[/b] @temperature@°@location.getTemperatureScale()@[/br]"
* 2) In a Hubitat dashboard, add a new tile, and select the child/sensor, in the center select "Attribute", and on the right select the "Tile" attribute
* 3) Select the Add Tile button and the tile should appear
* NOTE1: Put a @ before and after variable names
* NOTE2: Should accept most HTML formatting commands with [] instead of <>
*
* Features List:
* Control USB Ports for on/off/toggle individually (1 to 4)
* Control Outlets for on/off/toggle individually (5 to 20)
* Report the power, voltage, and current values returned per AC outlet and a combined total for the device
* Ability to check a website (mine) to notify user if there is a newer version of the driver available
* Ability to start/stop device location signaling
* Ability to turn on/off device LEDs
* Ability to restart device
* Holds a variety of data as attributes for use by other areas of Hubitat hub
*
* Licensing:
* Copyright 2025 David Snell
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
* Version Control:
* 0.1.9 - Updated state, event, & tile handling
* 0.1.8 - Removed "Driver Status", added RestartDevice command, and LCM Preferences
* 0.1.7 - Correction to ProcessEvent function and removal of old driver-specific attributes when Preferences are saved
* 0.1.6 - Fix for errors with update checking
* 0.1.5 - Added Uptime as an attribute and updates to various functions
* 0.1.4 - Rework of USB & outlet handling and addition of power monitoring
* 0.1.3 - Correction to Tile Template preference
* 0.1.2 - Added refresh capability to get device specific information and revised HTML to Tile Template
* 0.1.1 - Correction for how USB ports can be controlled in pairs
* 0.1.0 - Initial version
*
* Thank you(s):
* @Cobra for inspiration of how I perform driver version checking
* @mircolino for original concept of HTML Template method
*/
// Returns the driver name
def DriverName(){
return "UnifiNetworkChild-USPPDUP"
}
// Returns the driver version
def DriverVersion(){
return "0.1.9"
}
// Driver Metadata
metadata{
definition( name: "UnifiNetworkChild-USPPDUP", namespace: "Snell", author: "David Snell", importUrl: "https://www.drdsnell.com/projects/hubitat/drivers/UnifiNetworkChild-USPPDUP.groovy" ) {
capability "PresenceSensor" // Adds an attribute "presence" with possible values of "present" or "not present"
capability "Actuator"
capability "Refresh"
capability "PowerMeter"
capability "CurrentMeter"
capability "VoltageMeasurement"
// Commands
//command "DoSomething"
command "OutletOn", [
[ name: "Outlet", type: "ENUM", constraints: [ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ], description: "Enter Outlet # (ex: 5, 6, 7 ... 20)" ]
] // Power on a specific outlet
command "OutletOff", [
[ name: "Outlet", type: "ENUM", constraints: [ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ], description: "Enter Outlet # (ex: 5, 6, 7 ... 20)" ]
] // Power off a specific outlet
command "ToggleOutlet", [
[ name: "Outlet", type: "ENUM", constraints: [ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ], description: "Enter Outlet # (ex: 5, 6, 7 ... 20)" ]
] // Toggle a specific outlet
command "PowerCycleOutlet", [
[ name: "Outlet", type: "ENUM", constraints: [ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ], description: "Enter Outlet # (ex: 5, 6, 7 ... 20)" ]
] // Power cycles a specific outlet
command "USB_On", [
[ name: "USBPort", type: "ENUM", constraints: [ 1, 2, 3, 4 ], description: "Enter USB Port # ( 1, 2, 3, or 4 )" ]
] // Power on a USB Port
command "USB_Off", [
[ name: "USBPort", type: "ENUM", constraints: [ 1, 2, 3, 4 ], description: "Enter USB Port # ( 1, 2, 3, or 4 )" ]
] // Power off a USB Port
command "ToggleUSBPort", [
[ name: "USBPort", type: "ENUM", constraints: [ 1, 2, 3, 4 ], description: "Enter USB Port # ( 1, 2, 3, or 4 )" ]
] // Toggle a USB Port
command "PowerCycleUSB", [
[ name: "USBPort", type: "ENUM", constraints: [ 1, 2, 3, 4 ], description: "Enter USB Port # ( 1, 2, 3, or 4 )" ]
] // Power cycles a USB Port
command "RestartDevice"
// Attributes - Driver Related
attribute "DriverName", "string" // Identifies the driver being used for update purposes
attribute "DriverVersion", "string" // Handles version for driver
attribute "DriverStatus", "string" // Handles version notices for driver
// Attributes - Device Related
attribute "LastSeen", "string" // Date/Time the device was last seen by the Unifi controller
attribute "Satisfaction", "number"
attribute "Model LTS", "string"
attribute "Model EOL", "string"
attribute "LED Override", "string"
attribute "LED OnOff", "string"
attribute "power", "number" // Reported directly by the PDU Pro
attribute "current", "number" // Total of the individual outlet currents
attribute "voltage", "number" // Last voltage value reported (typically Outlet 20)
attribute "AC Power Consumption", "number"
attribute "USB Port 1", "enum", [ "on", "off", "Unknown" ]
attribute "USB Port 2", "enum", [ "on", "off", "Unknown" ]
attribute "USB Port 3", "enum", [ "on", "off", "Unknown" ]
attribute "USB Port 4", "enum", [ "on", "off", "Unknown" ]
attribute "Outlet 5", "enum", [ "on", "off", "Unknown" ]
attribute "Outlet 6", "enum", [ "on", "off", "Unknown" ]
attribute "Outlet 7", "enum", [ "on", "off", "Unknown" ]
attribute "Outlet 8", "enum", [ "on", "off", "Unknown" ]
attribute "Outlet 9", "enum", [ "on", "off", "Unknown" ]
attribute "Outlet 10", "enum", [ "on", "off", "Unknown" ]
attribute "Outlet 11", "enum", [ "on", "off", "Unknown" ]
attribute "Outlet 12", "enum", [ "on", "off", "Unknown" ]
attribute "Outlet 13", "enum", [ "on", "off", "Unknown" ]
attribute "Outlet 14", "enum", [ "on", "off", "Unknown" ]
attribute "Outlet 15", "enum", [ "on", "off", "Unknown" ]
attribute "Outlet 16", "enum", [ "on", "off", "Unknown" ]
attribute "Outlet 17", "enum", [ "on", "off", "Unknown" ]
attribute "Outlet 18", "enum", [ "on", "off", "Unknown" ]
attribute "Outlet 19", "enum", [ "on", "off", "Unknown" ]
attribute "Outlet 20", "enum", [ "on", "off", "Unknown" ]
attribute "USB Port 1 Enabled", "string"
attribute "USB Port 2 Enabled", "string"
attribute "USB Port 3 Enabled", "string"
attribute "USB Port 4 Enabled", "string"
attribute "Outlet 5 Enabled", "string"
attribute "Outlet 6 Enabled", "string"
attribute "Outlet 7 Enabled", "string"
attribute "Outlet 8 Enabled", "string"
attribute "Outlet 9 Enabled", "string"
attribute "Outlet 10 Enabled", "string"
attribute "Outlet 11 Enabled", "string"
attribute "Outlet 12 Enabled", "string"
attribute "Outlet 13 Enabled", "string"
attribute "Outlet 14 Enabled", "string"
attribute "Outlet 15 Enabled", "string"
attribute "Outlet 16 Enabled", "string"
attribute "Outlet 17 Enabled", "string"
attribute "Outlet 18 Enabled", "string"
attribute "Outlet 19 Enabled", "string"
attribute "Outlet 20 Enabled", "string"
attribute "Outlet 5 Power", "number"
attribute "Outlet 6 Power", "number"
attribute "Outlet 7 Power", "number"
attribute "Outlet 8 Power", "number"
attribute "Outlet 9 Power", "number"
attribute "Outlet 10 Power", "number"
attribute "Outlet 11 Power", "number"
attribute "Outlet 12 Power", "number"
attribute "Outlet 13 Power", "number"
attribute "Outlet 14 Power", "number"
attribute "Outlet 15 Power", "number"
attribute "Outlet 16 Power", "number"
attribute "Outlet 17 Power", "number"
attribute "Outlet 18 Power", "number"
attribute "Outlet 19 Power", "number"
attribute "Outlet 20 Power", "number"
attribute "Outlet 5 Voltage", "number"
attribute "Outlet 6 Voltage", "number"
attribute "Outlet 7 Voltage", "number"
attribute "Outlet 8 Voltage", "number"
attribute "Outlet 9 Voltage", "number"
attribute "Outlet 10 Voltage", "number"
attribute "Outlet 11 Voltage", "number"
attribute "Outlet 12 Voltage", "number"
attribute "Outlet 13 Voltage", "number"
attribute "Outlet 14 Voltage", "number"
attribute "Outlet 15 Voltage", "number"
attribute "Outlet 16 Voltage", "number"
attribute "Outlet 17 Voltage", "number"
attribute "Outlet 18 Voltage", "number"
attribute "Outlet 19 Voltage", "number"
attribute "Outlet 20 Voltage", "number"
attribute "Outlet 5 Current", "number"
attribute "Outlet 6 Current", "number"
attribute "Outlet 7 Current", "number"
attribute "Outlet 8 Current", "number"
attribute "Outlet 9 Current", "number"
attribute "Outlet 10 Current", "number"
attribute "Outlet 11 Current", "number"
attribute "Outlet 12 Current", "number"
attribute "Outlet 13 Current", "number"
attribute "Outlet 14 Current", "number"
attribute "Outlet 15 Current", "number"
attribute "Outlet 16 Current", "number"
attribute "Outlet 17 Current", "number"
attribute "Outlet 18 Current", "number"
attribute "Outlet 19 Current", "number"
attribute "Outlet 20 Current", "number"
attribute "Uptime", "string"
// Tile attribute
attribute "Tile", "string"; // Ex: "[b]Temperature:[/b] @temperature@°@location.getTemperatureScale()@[/br]"
}
preferences{
//section{
if( ShowAllPreferences ){
if( state.DeviceName != null ){
input( type: "string", name: "DeviceName", title: "Device Name", description: "If set it will change the device's name on the controller.", defaultValue: "${ state.DeviceName }" )
} else {
input( type: "string", name: "DeviceName", title: "Device Name", description: "If set it will change the device's name on the controller.", defaultValue: "" )
}
if( state.LCMBrightness != null ){
input( type: "number", name: "LCMBrightness", title: "LCD Brightness", description: "Sets the brightness of the LCD display.", defaultValue: state.LCMBrightness, minValue: 10, maxValue: 100, required: false )
} else {
input( type: "number", name: "LCMBrightness", title: "LCD Brightness", description: "Sets the brightness of the LCD display.", defaultValue: 75, minValue: 10, maxValue: 100, required: false )
}
if( state.LCMNightStart != null ){
input( type: "string", name: "LCMNightStart", title: "LCD Night Mode Start", description: "When the LCD should start night mode. Formatted as 22:00 = 10pm", defaultValue: "${ state.LCMNightStart }", required: false )
} else {
input( type: "string", name: "LCMNightStart", title: "LCD Night Mode Start", description: "When the LCD should start night mode. Formatted as 22:00 = 10pm", defaultValue: "22:00", required: false )
}
if( state.LCMNightEnd != null ){
input( type: "string", name: "LCMNightEnd", title: "LCD Night Mode End", description: "When the LCD should end night mode. Formatted as 08:00 = 8am", defaultValue: "${ state.LCMNightEnd }", required: false )
} else {
input( type: "string", name: "LCMNightEnd", title: "LCD Night Mode End", description: "When the LCD should end night mode. Formatted as 08:00 = 8am", defaultValue: "08:00", required: false )
}
input( name: "TileTemplate", type: "string", title: "Tile Template", description: "Ex: [b]Temperature:[/b] @temperature@°@location.getTemperatureScale()@[/br]", defaultValue: "");
input( type: "enum", name: "LogType", title: "Enable Logging?", required: false, multiple: false, options: [ "None", "Info", "Debug", "Trace" ], defaultValue: "Info" )
input( type: "bool", name: "ShowAllPreferences", title: "Show All Preferences?", defaultValue: true )
} else {
input( type: "bool", name: "ShowAllPreferences", title: "Show All Preferences?", defaultValue: true )
}
//}
}
}
// DoSomething is for testing purposes and should be disabled by commenting the command before publishing
def DoSomething(){
CheckForUpdate()
}
// SetDefaults sets "unknown" as initial value for some attributes of the device
def SetDefaults(){
for( int x = 5; x <= 20; x++ ){
ProcessEvent( "Outlet ${ x }", "Unknown" )
ProcessState( "Outlet ${ x } Status", [ Index: x, Relay_State: "unknown", Cycle_Enabled: "unknown", Name: "Outlet ${ x }", Voltage: "unknown", Current: "unknown", Power: "unknown", Power_Factor: "unknown" ] )
}
for( int x = 1; x <= 4; x++ ){
ProcessState( "USB Port ${ x } Status", [ Index: x, Relay_State: "unknown", Cycle_Enabled: "unknown", Name: "USB Port ${ x }" ] )
}
ProcessEvent( "LastSeen", "Unknown" )
ProcessEvent( "Model LTS", "Unknown" )
ProcessEvent( "Model EOL", "Unknown" )
ProcessEvent( "LED Override", "Unknown" )
}
// updated
def updated( boolean NewDevice = false ){
if( state."Driver Status" != null ){
state.remove( "Driver Name" )
state.remove( "Driver Version" )
state.remove( "Driver Status" )
device.deleteCurrentState( "Driver Status" )
device.deleteCurrentState( "Driver Name" )
device.deleteCurrentState( "Driver Version" )
}
ProcessEvent( "DriverName", DriverName(), true )
ProcessEvent( "DriverVersion", DriverVersion(), true )
ProcessEvent( "DriverStatus", null )
if( LogType == null ){
LogType = "Info"
}
if( NewDevice != true ){
if( ( DeviceName != state.DeviceName ) || ( LCMBrightness != state.LCMBrightness ) || ( LCMNightStart != state.LCMNightStart ) || ( LCMNightEnd != state.LCMNightEnd ) ){
SendSettings()
}
}
def Hour = ( new Date().format( "h" ) as int )
def Minute = ( new Date().format( "m" ) as int )
def Second = ( new Date().format( "s" ) as int )
// Schedule checks that are only performed once a day
schedule( "${ Second } ${ Minute } ${ Hour } ? * *", "CheckForUpdate" )
Logging( "Updated", 2 )
}
// Configure device settings based on Preferences
def SendSettings(){
if( state.ID != null ){
def Settings = ""
if( ( LCMBrightness != state.LCMBrightness ) || ( LCMNightStart != state.LCMNightStart ) || ( LCMNightEnd != state.LCMNightEnd ) ){
if( LCMBrightness != null ){
Settings = Settings + ",\"lcm_brightness\":${ LCMBrightness }"
} else if( state.LCMBrightness != null ){
Settings = Settings + ",\"lcm_brightness\":${ state.LCMBrightness }"
}
Settings = Settings + ",\"lcm_brightness_override\":true"
if( LCMNightStart != null ){
Settings = Settings + ",\"lcm_night_mode_begins\":\"${ LCMNightStart }\""
} else if( state.LCMNightStart != null ){
Settings = Settings + ",\"lcm_night_mode_begins\":\"${ state.LCMNightStart }\""
}
if( LCMNightEnd != null ){
Settings = Settings + ",\"lcm_night_mode_ends\":\"${ LCMNightEnd }\""
} else if( state.LCMNightEnd != null ){
Settings = Settings + ",\"lcm_night_mode_ends\":\"${ state.LCMNightEnd }\""
}
}
if( DeviceName != null && DeviceName != device.label ){
if( DeviceName != "null" ){
parent.SendChildSettings( device.getDeviceNetworkId(), state.ID, "{\"name\":\"${ DeviceName }\"${ Settings } }" )
} else {
parent.SendChildSettings( device.getDeviceNetworkId(), state.ID, "${ Settings } }" )
}
} else {
parent.SendChildSettings( device.getDeviceNetworkId(), state.ID, "{\"name\":\"${ device.label }\"${ Settings } }" )
}
} else {
Logging( "No ID for ${ device.getDeviceNetworkId() }, cannot send settings", 5 )
}
}
// RestartDevice attempts to restart device
def RestartDevice(){
if( state.MAC != null ){
parent.RestartDevice( state.MAC )
} else {
Logging( "No MAC known for ${ device.getDeviceNetworkId() }, cannot restart.", 5 )
}
}
// Refresh the specific device's information
def refresh(){
if( state.MAC != null ){
parent.RefreshSpecificUnifiDevice( state.MAC )
} else {
Logging( "No MAC for ${ device.getDeviceNetworkId() }, cannot refresh.", 5 )
}
}
// Turn on a specific outlet
def OutletOn( Outlet ){
if( state.MAC != null && state.ID != null ){
parent.PowerOutlet( device.getDeviceNetworkId(), state.ID, state.MAC, Outlet as int, "On" )
} else {
Logging( "No ID or MAC for ${ device.getDeviceNetworkId() }, cannot power on outlet ${ Outlet }.", 5 )
}
}
//Turn off a specific outlet
def OutletOff( Outlet ){
if( state.MAC != null && state.ID != null ){
parent.PowerOutlet( device.getDeviceNetworkId(), state.ID, state.MAC, Outlet as int, "Off" )
} else {
Logging( "No ID or MAC for ${ device.getDeviceNetworkId() }, cannot power off outlet ${ Outlet }.", 5 )
}
}
// Turn on USB port
def USB_On( Outlet ){
if( state.MAC != null && state.ID != null ){
parent.PowerOutlet( device.getDeviceNetworkId(), state.ID, state.MAC, Outlet as int, "On" )
} else {
Logging( "No ID or MAC for ${ device.getDeviceNetworkId() }, cannot power on USB Port ${ Outlet }.", 5 )
}
}
//Turn off USB port
def USB_Off( Outlet ){
if( state.MAC != null && state.ID != null ){
parent.PowerOutlet( device.getDeviceNetworkId(), state.ID, state.MAC, Outlet as int, "Off" )
} else {
Logging( "No ID or MAC for ${ device.getDeviceNetworkId() }, cannot power off USB Port ${ Outlet }.", 5 )
}
}
// Power cycle a specific Outlet
def PowerCycleOutlet( Outlet ){
if( state.MAC != null ){
parent.PowerCycleOutlet( state.MAC, Outlet as int )
} else {
Logging( "No MAC for ${ device.getDeviceNetworkId() }, cannot power cycle the outlet.", 5 )
}
}
// Power cycle a USB port
def PowerCycleUSB( Outlet ){
if( state.MAC != null ){
parent.PowerCycleOutlet( state.MAC, Outlet as int )
} else {
Logging( "No MAC for ${ device.getDeviceNetworkId() }, cannot power cycle the USB port.", 5 )
}
}
// Toggle power of an Outlet
def ToggleOutlet( Outlet ){
if( state.ID != null && state.MAC != null ){
if( state."Outlet ${ Outlet }" == "off" ){
OutletOn( Outlet as int )
} else {
OutletOff( Outlet as int )
}
} else {
Logging( "No ID or MAC for ${ device.getDeviceNetworkId() }, cannot toggle the outlet.", 5 )
}
}
// Toggle power of a USB port
def ToggleUSBPort( Outlet ){
if( state.ID != null && state.MAC != null ){
if( state."USB Port ${ Outlet }" == "off" ){
USB_On( Outlet )
} else {
USB_Off( Outlet )
}
} else {
Logging( "No ID or MAC for ${ device.getDeviceNetworkId() }, cannot toggle USB port ${ Outlet }.", 5 )
}
}
// installed is called when the device is installed, all it really does is run updated
def installed(){
Logging( "Installed", 2 )
SetDefaults()
updated( true )
}
// initialize is called when the device is initialized, all it really does is run updated
def initialize(){
Logging( "Initialized", 2 )
updated( true )
}
// Return a state value
def ReturnState( Variable ){
return state."${ Variable }"
}
// Tile method to produce HTML formatted string for dashboard use
private void UpdateTile( String val ){
if( TileTemplate != null ){
def TempString = ""
Parsing = TileTemplate
Parsing = Parsing.replaceAll( "\\[", "<" )
Parsing = Parsing.replaceAll( "\\]", ">" )
Count = Parsing.count( "@" )
if( Count >= 1 ){
def x = 1
while( x <= Count ){
TempName = Parsing.split( "@" )[ x ]
switch( TempName ){
case "location.latitude":
Value = location.latitude
break
case "location.longitude":
Value = location.longitude
break
case "location.getTemperatureScale()":
Value = location.getTemperatureScale()
break
default:
Value = ReturnState( "${ TempName }" )
break
}
TempString = TempString + Parsing.split( "@" )[ ( x - 1 ) ] + Value
x = ( x + 2 )
}
if( Parsing.split( "@" ).last() != Parsing.split( "@" )[ Count - 1 ] ){
TempString = TempString + Parsing.split( "@" ).last()
}
} else if( Count == 1 ){
TempName = Parsing.split( "@" )[ 1 ]
switch( TempName ){
case "location.latitude":
Value = location.latitude
break
case "location.longitude":
Value = location.longitude
break
case "location.getTemperatureScale()":
Value = location.getTemperatureScale()
break
default:
Value = ReturnState( "${ TempName }" )
break
}
TempString = TempString + Parsing.split( "@" )[ 0 ] + Value
} else {
TempString = TileTemplate
}
Logging( "Tile = ${ TempString }", 4 )
sendEvent( name: "Tile", value: TempString )
}
}
// Process data to check against current state value and then send an event if it has changed
def ProcessEvent( Variable, Value, Unit = null, ForceEvent = false, Description = null ){
if( ForceEvent ){
sendEvent( name: Variable, value: Value, unit: Unit, isStateChange: true, descriptionText: Description )
} else {
sendEvent( name: Variable, value: Value, unit: Unit, descriptionText: Description )
}
Logging( "Event: ${ Variable } = ${ Value } Unit = ${ Unit } Forced = ${ ForceEvent }", 4 )
ProcessState( Variable, Value )
UpdateTile( "${ Value }" )
}
// Set a state variable to a value
def ProcessState( Variable, Value ){
Logging( "State: ${ Variable } = ${ Value }", 4 )
state."${ Variable }" = Value
UpdateTile( "${ Value }" )
}
// Handles whether logging is enabled and thus what to put there.
def Logging( LogMessage, LogLevel ){
// Add all messages as info logging
if( ( LogLevel == 2 ) && ( LogType != "None" ) ){
log.info( "${ device.displayName } - ${ LogMessage }" )
} else if( ( LogLevel == 3 ) && ( ( LogType == "Debug" ) || ( LogType == "Trace" ) ) ){
log.debug( "${ device.displayName } - ${ LogMessage }" )
} else if( ( LogLevel == 4 ) && ( LogType == "Trace" ) ){
log.trace( "${ device.displayName } - ${ LogMessage }" )
} else if( LogLevel == 5 ){
log.error( "${ device.displayName } - ${ LogMessage }" )
}
}
// Checks drdsnell.com for the latest version of the driver
// Original inspiration from @cobra's version checking
def CheckForUpdate(){
ProcessEvent( "DriverName", DriverName() )
ProcessEvent( "DriverVersion", DriverVersion() )
httpGet( uri: "https://www.drdsnell.com/projects/hubitat/drivers/versions.json", contentType: "application/json" ){ resp ->
switch( resp.status ){
case 200:
if( resp.data."${ DriverName() }" ){
CurrentVersion = DriverVersion().split( /\./ )
if( resp.data."${ DriverName() }".version == "REPLACED" ){
ProcessEvent( "DriverStatus", "Driver replaced, please use ${ resp.data."${ state.DriverName }".file }" )
} else if( resp.data."${ DriverName() }".version == "REMOVED" ){
ProcessEvent( "DriverStatus", "Driver removed and no longer supported." )
} else {
SiteVersion = resp.data."${ DriverName() }".version.split( /\./ )
if( CurrentVersion == SiteVersion ){
Logging( "Driver version up to date", 3 )
ProcessEvent( "DriverStatus", "Up to date" )
} else if( ( CurrentVersion[ 0 ] as int ) > ( SiteVersion [ 0 ] as int ) ){
Logging( "Major development ${ CurrentVersion[ 0 ] }.${ CurrentVersion[ 1 ] }.${ CurrentVersion[ 2 ] } version", 3 )
ProcessEvent( "DriverStatus", "Major development ${ CurrentVersion[ 0 ] }.${ CurrentVersion[ 1 ] }.${ CurrentVersion[ 2 ] } version" )
} else if( ( CurrentVersion[ 1 ] as int ) > ( SiteVersion [ 1 ] as int ) ){
Logging( "Minor development ${ CurrentVersion[ 0 ] }.${ CurrentVersion[ 1 ] }.${ CurrentVersion[ 2 ] } version", 3 )
ProcessEvent( "DriverStatus", "Minor development ${ CurrentVersion[ 0 ] }.${ CurrentVersion[ 1 ] }.${ CurrentVersion[ 2 ] } version" )
} else if( ( CurrentVersion[ 2 ] as int ) > ( SiteVersion [ 2 ] as int ) ){
Logging( "Patch development ${ CurrentVersion[ 0 ] }.${ CurrentVersion[ 1 ] }.${ CurrentVersion[ 2 ] } version", 3 )
ProcessEvent( "DriverStatus", "Patch development ${ CurrentVersion[ 0 ] }.${ CurrentVersion[ 1 ] }.${ CurrentVersion[ 2 ] } version" )
} else if( ( SiteVersion[ 0 ] as int ) > ( CurrentVersion[ 0 ] as int ) ){
Logging( "New major release ${ SiteVersion[ 0 ] }.${ SiteVersion[ 1 ] }.${ SiteVersion[ 2 ] } available", 2 )
ProcessEvent( "DriverStatus", "New major release ${ SiteVersion[ 0 ] }.${ SiteVersion[ 1 ] }.${ SiteVersion[ 2 ] } available" )
} else if( ( SiteVersion[ 1 ] as int ) > ( CurrentVersion[ 1 ] as int ) ){
Logging( "New minor release ${ SiteVersion[ 0 ] }.${ SiteVersion[ 1 ] }.${ SiteVersion[ 2 ] } available", 2 )
ProcessEvent( "DriverStatus", "New minor release ${ SiteVersion[ 0 ] }.${ SiteVersion[ 1 ] }.${ SiteVersion[ 2 ] } available" )
} else if( ( SiteVersion[ 2 ] as int ) > ( CurrentVersion[ 2 ] as int ) ){
Logging( "New patch ${ SiteVersion[ 0 ] }.${ SiteVersion[ 1 ] }.${ SiteVersion[ 2 ] } available", 2 )
ProcessEvent( "DriverStatus", "New patch ${ SiteVersion[ 0 ] }.${ SiteVersion[ 1 ] }.${ SiteVersion[ 2 ] } available" )
}
}
} else {
Logging( "${ DriverName() } is not published on drdsnell.com", 2 )
ProcessEvent( "DriverStatus", "${ DriverName() } is not published on drdsnell.com" )
}
break
default:
Logging( "Unable to check drdsnell.com for ${ DriverName() } driver updates.", 2 )
break
}
}
}