-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from bitfocus/chore/libs
Refactor for new upstream library
- Loading branch information
Showing
11 changed files
with
1,179 additions
and
1,196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ node_modules/ | |
package-lock.json | ||
.DS_Store | ||
/pkg | ||
/pkg.tz | ||
/pkg.tgz | ||
DEBUG-INSPECT | ||
DEBUG-PACKAGED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,83 @@ | ||
module.exports = { | ||
initActions: function () { | ||
let self = this | ||
let actions = {} | ||
export function initActions() { | ||
let self = this | ||
let actions = {} | ||
|
||
if (self.SINGLEPLUGMODE) { | ||
actions.on = { | ||
name: 'Power On', | ||
options: [], | ||
callback: async function (action) { | ||
await self.power(1, 1) | ||
}, | ||
} | ||
if (self.SINGLEPLUGMODE) { | ||
actions.on = { | ||
name: 'Power On', | ||
options: [], | ||
callback: async function (action) { | ||
await self.power(1, 1) | ||
}, | ||
} | ||
|
||
actions.off = { | ||
name: 'Power Off', | ||
options: [], | ||
callback: async function (action) { | ||
await self.power(1, 0) | ||
}, | ||
} | ||
actions.off = { | ||
name: 'Power Off', | ||
options: [], | ||
callback: async function (action) { | ||
await self.power(1, 0) | ||
}, | ||
} | ||
|
||
actions.toggle = { | ||
name: 'Power Toggle', | ||
options: [], | ||
callback: async function (action) { | ||
await self.powerToggle(1) | ||
}, | ||
} | ||
} else { | ||
actions.powerOn = { | ||
name: 'Power On', | ||
options: [ | ||
{ | ||
type: 'dropdown', | ||
label: 'Plug', | ||
id: 'plug', | ||
default: self.CHOICES_PLUGS[0].id, | ||
choices: self.CHOICES_PLUGS, | ||
tooltip: 'The plug on the device to control', | ||
}, | ||
], | ||
callback: async function (action) { | ||
await self.power(action.options.plug, 1) | ||
actions.toggle = { | ||
name: 'Power Toggle', | ||
options: [], | ||
callback: async function (action) { | ||
await self.powerToggle(1) | ||
}, | ||
} | ||
} else { | ||
actions.powerOn = { | ||
name: 'Power On', | ||
options: [ | ||
{ | ||
type: 'dropdown', | ||
label: 'Plug', | ||
id: 'plug', | ||
default: self.CHOICES_PLUGS[0].id, | ||
choices: self.CHOICES_PLUGS, | ||
tooltip: 'The plug on the device to control', | ||
}, | ||
} | ||
], | ||
callback: async function (action) { | ||
await self.power(action.options.plug, 1) | ||
}, | ||
} | ||
|
||
actions.powerOff = { | ||
name: 'Power Off', | ||
options: [ | ||
{ | ||
type: 'dropdown', | ||
label: 'Plug', | ||
id: 'plug', | ||
default: self.CHOICES_PLUGS[0].id, | ||
choices: self.CHOICES_PLUGS, | ||
tooltip: 'The plug on the device to control', | ||
}, | ||
], | ||
callback: async function (action) { | ||
await self.power(action.options.plug, 0) | ||
actions.powerOff = { | ||
name: 'Power Off', | ||
options: [ | ||
{ | ||
type: 'dropdown', | ||
label: 'Plug', | ||
id: 'plug', | ||
default: self.CHOICES_PLUGS[0].id, | ||
choices: self.CHOICES_PLUGS, | ||
tooltip: 'The plug on the device to control', | ||
}, | ||
} | ||
], | ||
callback: async function (action) { | ||
await self.power(action.options.plug, 0) | ||
}, | ||
} | ||
|
||
actions.powerToggle = { | ||
name: 'Power Toggle', | ||
options: [ | ||
{ | ||
type: 'dropdown', | ||
label: 'Plug', | ||
id: 'plug', | ||
default: self.CHOICES_PLUGS[0].id, | ||
choices: self.CHOICES_PLUGS, | ||
tooltip: 'The plug on the device to control', | ||
}, | ||
], | ||
callback: async function (action) { | ||
await self.powerToggle(action.options.plug) | ||
actions.powerToggle = { | ||
name: 'Power Toggle', | ||
options: [ | ||
{ | ||
type: 'dropdown', | ||
label: 'Plug', | ||
id: 'plug', | ||
default: self.CHOICES_PLUGS[0].id, | ||
choices: self.CHOICES_PLUGS, | ||
tooltip: 'The plug on the device to control', | ||
}, | ||
} | ||
], | ||
callback: async function (action) { | ||
await self.powerToggle(action.options.plug) | ||
}, | ||
} | ||
} | ||
|
||
self.setActionDefinitions(actions) | ||
}, | ||
self.setActionDefinitions(actions) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,45 @@ | ||
const { Regex } = require('@companion-module/base') | ||
import { Regex } from '@companion-module/base' | ||
|
||
module.exports = { | ||
getConfigFields() { | ||
return [ | ||
{ | ||
type: 'static-text', | ||
id: 'info', | ||
width: 12, | ||
label: 'Information', | ||
value: 'This module controls TP-Link Kasa Smart Plugs. It supports both single plug and multi plug devices.', | ||
}, | ||
{ | ||
type: 'textinput', | ||
id: 'host', | ||
label: 'Plug IP', | ||
default: '192.168.0.5', | ||
width: 4, | ||
regex: Regex.IP, | ||
}, | ||
{ | ||
type: 'checkbox', | ||
id: 'polling', | ||
label: 'Enable Polling', | ||
default: false, | ||
width: 12, | ||
}, | ||
{ | ||
type: 'static-text', | ||
id: 'intervalInfo', | ||
width: 12, | ||
label: 'Update Interval', | ||
value: | ||
'Please enter the amount of time in milliseconds to request new information from the device. Set to 0 to disable. Do not use an interval less than 2000 or the device may stop responding.', | ||
isVisible: (configValues) => configValues.polling === true, | ||
}, | ||
{ | ||
type: 'textinput', | ||
id: 'interval', | ||
label: 'Update Interval', | ||
width: 3, | ||
default: 2000, | ||
isVisible: (configValues) => configValues.polling === true, | ||
}, | ||
] | ||
}, | ||
export function getConfigFields() { | ||
return [ | ||
{ | ||
type: 'static-text', | ||
id: 'info', | ||
width: 12, | ||
label: 'Information', | ||
value: 'This module controls TP-Link Kasa Smart Plugs. It supports both single plug and multi plug devices.', | ||
}, | ||
{ | ||
type: 'textinput', | ||
id: 'host', | ||
label: 'Plug IP', | ||
default: '192.168.0.5', | ||
width: 4, | ||
regex: Regex.IP, | ||
}, | ||
{ | ||
type: 'checkbox', | ||
id: 'polling', | ||
label: 'Enable Polling', | ||
default: false, | ||
width: 12, | ||
}, | ||
{ | ||
type: 'static-text', | ||
id: 'intervalInfo', | ||
width: 12, | ||
label: 'Update Interval', | ||
value: 'Please enter the amount of time in milliseconds to request new information from the device. Set to 0 to disable. Less than 2000 will overrun the device.', | ||
isVisible: (configValues) => configValues.polling === true, | ||
}, | ||
{ | ||
type: 'textinput', | ||
id: 'interval', | ||
label: 'Update Interval', | ||
width: 3, | ||
default: 2000, | ||
min: 2000, | ||
isVisible: (configValues) => configValues.polling === true, | ||
}, | ||
] | ||
} |
Oops, something went wrong.