@vandubois/homebridge-virtual-switch
Version:
Creation of virtual switches, triggered independently and by keywords appearing in the Homebridge log file.
261 lines (259 loc) • 10.8 kB
JSON
{
"pluginAlias": "HomebridgeVirtualSwitches",
"pluginType": "platform",
"singular": true,
"schema": {
"type": "object",
"properties": {
"name": {
"title": "Name",
"type": "string",
"required": true,
"default": "HomebridgeVirtualSwitches",
"description": "This name is shown in as child bridge name and in logs."
},
"platform": {
"type": "string",
"title": "Platform Name",
"default": "HomebridgeVirtualSwitches",
"description": "Do not change Platform name!"
},
"devices": {
"type": "array",
"title": "Virtual Switches",
"items": {
"type": "object",
"title": "Switch Configuration",
"properties": {
"Name": {
"type": "string",
"title": "Switch Name",
"required": true
},
"NormallyClosed": {
"type": "boolean",
"title": "Normally Closed switch",
"default": false,
"description": "Sets switch to ON (closed) by default and to turn OFF (open) when triggered."
},
"SwitchStayOn": {
"type": "boolean",
"title": "Stateful",
"default": false,
"description": "When selected the switch will remain in triggered state until switched off manually or by automation (i.e., it is not be controlled by a timer)."
},
"Time": {
"type": "integer",
"title": "Timer (in ms)",
"default": 0,
"description": "Time (in milliseconds) the switch stays triggered.",
"condition": {
"functionBody": "return model.devices[arrayIndices[0]].SwitchStayOn === false && model.devices[arrayIndices[0]].UseCustomTime === false;"
}
},
"UseCustomTime": {
"type": "boolean",
"title": "Set timer time in days/hours/minutes/seconds instead of milliseconds.",
"default": false,
"description": "Total time cannot exceed ~47 days (46 days + 24 hours + 60 minutes + 60 seconds",
"condition": { "functionBody": "return model.devices[arrayIndices[0]].SwitchStayOn === false;" }
},
"TimeDays": {
"type": "integer",
"title": "Days",
"default": 0,
"minimum": 0,
"maximum": 47,
"condition": { "functionBody": "return model.devices[arrayIndices[0]].SwitchStayOn === false && model.devices[arrayIndices[0]].UseCustomTime === true;" }
},
"TimeHours": {
"type": "integer",
"title": "Hours",
"default": 0,
"minimum": 0,
"maximum": 24,
"condition": { "functionBody": "return model.devices[arrayIndices[0]].SwitchStayOn === false && model.devices[arrayIndices[0]].UseCustomTime === true;" }
},
"TimeMinutes": {
"type": "integer",
"title": "Minutes",
"default": 0,
"minimum": 0,
"maximum": 60,
"condition": { "functionBody": "return model.devices[arrayIndices[0]].SwitchStayOn === false && model.devices[arrayIndices[0]].UseCustomTime === true;" }
},
"TimeSeconds": {
"type": "integer",
"title": "Seconds",
"default": 0,
"minimum": 0,
"maximum": 60,
"condition": { "functionBody": "return model.devices[arrayIndices[0]].SwitchStayOn === false && model.devices[arrayIndices[0]].UseCustomTime === true;" }
},
"TimerPersistent": {
"type": "boolean",
"title": "Persistent Timer",
"default": false,
"description": "Keeps timer active through Homebridge restarts.",
"condition": { "functionBody": "return model.devices[arrayIndices[0]].SwitchStayOn === false;" }
},
"OneShotTimer": {
"title": "One Shot Timer",
"type": "boolean",
"required": false,
"default": false,
"description": "Prevent timer from restarting when the switch is triggered while the timer is still running",
"condition": { "functionBody": "return model.devices[arrayIndices[0]].SwitchStayOn === false;" }
},
"UseLogFile": {
"type": "boolean",
"title": "Trigger switch by keywords appearing in the Homebridge Log File",
"default": false,
"description": "Trigger switch based on keywords / keyphrases in the Homebridge log."
},
"LogFilePath": {
"type": "string",
"title": "Log File Path",
"default": "/var/lib/homebridge/homebridge.log",
"description": "Full path to the log file.",
"condition": { "functionBody": "return model.devices[arrayIndices[0]].UseLogFile === true;" }
},
"Keywords": {
"type": "array",
"title": "Keywords",
"description": "Keywords / Keyphrases that will trigger the switch when they appear in the log file (case insensitive).",
"condition": { "functionBody": "return model.devices && model.devices[arrayIndices[0]] && model.devices[arrayIndices[0]].UseLogFile === true;" },
"items": {
"type": "string",
"title": "Keyword"
},
"default": [""],
"uniqueItems": true
},
"EnableStartupDelay": {
"type": "boolean",
"title": "Delay switch start",
"default": false,
"description": "Delay switch activation after Homebridge restarts.For log monitoring switches only!"
},
"UseCustomStartupDelay": {
"type": "boolean",
"title": "Set the switch start up delay in days, hours, minutes and seconds instead of milliseconds.",
"default": false,
"description": "Total time cannot exceed ~47 days (46 days + 24 hours + 60 minutes + 60 seconds).",
"condition": { "functionBody": "return model.devices[arrayIndices[0]].EnableStartupDelay === true;" }
},
"StartupDelay": {
"type": "integer",
"title": "Startup Delay (in ms)",
"description": "Startup delay in milliseconds.",
"condition": {
"functionBody": "return model.devices[arrayIndices[0]].EnableStartupDelay === true && model.devices[arrayIndices[0]].UseCustomStartupDelay === false;"
}
},
"StartupDelayDays": {
"type": "integer",
"title": "Startup Delay Days",
"default": 0,
"minimum": 0,
"maximum": 46,
"condition": { "functionBody": "return model.devices[arrayIndices[0]].EnableStartupDelay === true && model.devices[arrayIndices[0]].UseCustomStartupDelay === true;" }
},
"StartupDelayHours": {
"type": "integer",
"title": "Startup Delay Hours",
"default": 0,
"minimum": 0,
"maximum": 24,
"condition": { "functionBody": "return model.devices[arrayIndices[0]].EnableStartupDelay === true && model.devices[arrayIndices[0]].UseCustomStartupDelay === true;" }
},
"StartupDelayMinutes": {
"type": "integer",
"title": "Startup Delay Minutes",
"default": 0,
"minimum": 0,
"maximum": 60,
"condition": { "functionBody": "return model.devices[arrayIndices[0]].EnableStartupDelay === true && model.devices[arrayIndices[0]].UseCustomStartupDelay === true;" }
},
"StartupDelaySeconds": {
"type": "integer",
"title": "Startup Delay Seconds",
"default": 0,
"minimum": 0,
"maximum": 60,
"condition": { "functionBody": "return model.devices[arrayIndices[0]].EnableStartupDelay === true && model.devices[arrayIndices[0]].UseCustomStartupDelay === true;" }
},
"RememberState": {
"type": "boolean",
"title": "Restart the switch in its last known state",
"default": false,
"description": "Retain last state after restart (non-log-monitoring stateful switches only).",
"condition": { "functionBody": "return model.devices[arrayIndices[0]].SwitchStayOn === true && model.devices[arrayIndices[0]].UseLogFile === false;" }
}
},
"required": ["Name"]
}
}
},
"required": ["name", "platform", "devices"]
},
"layout": [
{
"type": "array",
"key": "devices",
"title": "Devices",
"buttonText": "Add Another Switch",
"expandable": true,
"expanded": true,
"items": [
{
"type": "fieldset",
"items": [
"devices[].Name",
"devices[].SwitchStayOn",
"devices[].NormallyClosed",
"devices[].Time",
"devices[].UseCustomTime",
"devices[].TimeDays",
"devices[].TimeHours",
"devices[].TimeMinutes",
"devices[].TimeSeconds",
"devices[].OneShotTimer",
"devices[].TimerPersistent",
"devices[].UseLogFile",
"devices[].LogFilePath",
{
"key": "devices[].Keywords",
"type": "array",
"title": "Keywords",
"buttonText": "Add Keyword",
"startEmpty": false,
"items": [
{
"key": "devices[].Keywords[]",
"title": "Keyword",
"type": "string"
}
]
},
"devices[].EnableStartupDelay",
"devices[].UseCustomStartupDelay",
"devices[].StartupDelay",
"devices[].StartupDelayDays",
"devices[].StartupDelayHours",
"devices[].StartupDelayMinutes",
"devices[].StartupDelaySeconds",
"devices[].RememberState"
]
}
]
},
{
"type": "fieldset",
"title": "Plugin config",
"expandable": true,
"expanded": false,
"items": ["name"]
}
]
}