├── .github └── workflows │ └── companion-module-checks.yaml ├── .gitignore ├── .prettierignore ├── .yarnrc.yml ├── LICENSE ├── README.md ├── actions.js ├── companion ├── HELP.md └── manifest.json ├── feedbacks.js ├── main.js ├── package.json ├── upgrades.js └── variables.js /.github/workflows/companion-module-checks.yaml: -------------------------------------------------------------------------------- 1 | name: Companion Module Checks 2 | 3 | on: 4 | push: 5 | 6 | jobs: 7 | check: 8 | name: Check module 9 | 10 | if: ${{ !contains(github.repository, 'companion-module-template-') }} 11 | 12 | permissions: 13 | packages: read 14 | 15 | uses: bitfocus/actions/.github/workflows/module-checks.yaml@main 16 | # with: 17 | # upload-artifact: true # uncomment this to upload the built package as an artifact to this workflow that you can download and share with others 18 | 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | package-lock.json 3 | /pkg 4 | /*.tgz 5 | DEBUG-* 6 | /.yarn 7 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | package.json 2 | /LICENSE.md -------------------------------------------------------------------------------- /.yarnrc.yml: -------------------------------------------------------------------------------- 1 | nodeLinker: node-modules 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Bitfocus AS - Open Source 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # companion-module-[replace with module name] 2 | 3 | See [HELP.md](./companion/HELP.md) and [LICENSE](./LICENSE) 4 | -------------------------------------------------------------------------------- /actions.js: -------------------------------------------------------------------------------- 1 | module.exports = function (self) { 2 | self.setActionDefinitions({ 3 | sample_action: { 4 | name: 'My First Action', 5 | options: [ 6 | { 7 | id: 'num', 8 | type: 'number', 9 | label: 'Test', 10 | default: 5, 11 | min: 0, 12 | max: 100, 13 | }, 14 | ], 15 | callback: async (event) => { 16 | console.log('Hello world!', event.options.num) 17 | }, 18 | }, 19 | }) 20 | } 21 | -------------------------------------------------------------------------------- /companion/HELP.md: -------------------------------------------------------------------------------- 1 | ## Your module 2 | 3 | Write some help for your users here! 4 | -------------------------------------------------------------------------------- /companion/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "your-module-name", 3 | "name": "your-module-name", 4 | "shortname": "module-shortname", 5 | "description": "A short one line description of your module", 6 | "version": "0.0.0", 7 | "license": "MIT", 8 | "repository": "git+https://github.com/bitfocus/companion-module-your-module-name.git", 9 | "bugs": "https://github.com/bitfocus/companion-module-your-module-name/issues", 10 | "maintainers": [ 11 | { 12 | "name": "Your name", 13 | "email": "Your email" 14 | } 15 | ], 16 | "runtime": { 17 | "type": "node22", 18 | "api": "nodejs-ipc", 19 | "apiVersion": "0.0.0", 20 | "entrypoint": "../main.js" 21 | }, 22 | "legacyIds": [], 23 | "manufacturer": "Your company", 24 | "products": ["Your product"], 25 | "keywords": [] 26 | } 27 | -------------------------------------------------------------------------------- /feedbacks.js: -------------------------------------------------------------------------------- 1 | const { combineRgb } = require('@companion-module/base') 2 | 3 | module.exports = async function (self) { 4 | self.setFeedbackDefinitions({ 5 | ChannelState: { 6 | name: 'Example Feedback', 7 | type: 'boolean', 8 | label: 'Channel State', 9 | defaultStyle: { 10 | bgcolor: combineRgb(255, 0, 0), 11 | color: combineRgb(0, 0, 0), 12 | }, 13 | options: [ 14 | { 15 | id: 'num', 16 | type: 'number', 17 | label: 'Test', 18 | default: 5, 19 | min: 0, 20 | max: 10, 21 | }, 22 | ], 23 | callback: (feedback) => { 24 | console.log('Hello world!', feedback.options.num) 25 | if (feedback.options.num > 5) { 26 | return true 27 | } else { 28 | return false 29 | } 30 | }, 31 | }, 32 | }) 33 | } 34 | -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | const { InstanceBase, Regex, runEntrypoint, InstanceStatus } = require('@companion-module/base') 2 | const UpgradeScripts = require('./upgrades') 3 | const UpdateActions = require('./actions') 4 | const UpdateFeedbacks = require('./feedbacks') 5 | const UpdateVariableDefinitions = require('./variables') 6 | 7 | class ModuleInstance extends InstanceBase { 8 | constructor(internal) { 9 | super(internal) 10 | } 11 | 12 | async init(config) { 13 | this.config = config 14 | 15 | this.updateStatus(InstanceStatus.Ok) 16 | 17 | this.updateActions() // export actions 18 | this.updateFeedbacks() // export feedbacks 19 | this.updateVariableDefinitions() // export variable definitions 20 | } 21 | // When module gets deleted 22 | async destroy() { 23 | this.log('debug', 'destroy') 24 | } 25 | 26 | async configUpdated(config) { 27 | this.config = config 28 | } 29 | 30 | // Return config fields for web config 31 | getConfigFields() { 32 | return [ 33 | { 34 | type: 'textinput', 35 | id: 'host', 36 | label: 'Target IP', 37 | width: 8, 38 | regex: Regex.IP, 39 | }, 40 | { 41 | type: 'textinput', 42 | id: 'port', 43 | label: 'Target Port', 44 | width: 4, 45 | regex: Regex.PORT, 46 | }, 47 | ] 48 | } 49 | 50 | updateActions() { 51 | UpdateActions(this) 52 | } 53 | 54 | updateFeedbacks() { 55 | UpdateFeedbacks(this) 56 | } 57 | 58 | updateVariableDefinitions() { 59 | UpdateVariableDefinitions(this) 60 | } 61 | } 62 | 63 | runEntrypoint(ModuleInstance, UpgradeScripts) 64 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "your-module-name", 3 | "version": "0.1.0", 4 | "main": "main.js", 5 | "scripts": { 6 | "format": "prettier -w .", 7 | "package": "companion-module-build" 8 | }, 9 | "license": "MIT", 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/bitfocus/companion-module-your-module-name.git" 13 | }, 14 | "dependencies": { 15 | "@companion-module/base": "~1.11.3" 16 | }, 17 | "devDependencies": { 18 | "@companion-module/tools": "^2.3.0", 19 | "prettier": "^3.5.3" 20 | }, 21 | "prettier": "@companion-module/tools/.prettierrc.json", 22 | "packageManager": "yarn@4.9.1" 23 | } 24 | -------------------------------------------------------------------------------- /upgrades.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | /* 3 | * Place your upgrade scripts here 4 | * Remember that once it has been added it cannot be removed! 5 | */ 6 | // function (context, props) { 7 | // return { 8 | // updatedConfig: null, 9 | // updatedActions: [], 10 | // updatedFeedbacks: [], 11 | // } 12 | // }, 13 | ] 14 | -------------------------------------------------------------------------------- /variables.js: -------------------------------------------------------------------------------- 1 | module.exports = function (self) { 2 | self.setVariableDefinitions([ 3 | { variableId: 'variable1', name: 'My first variable' }, 4 | { variableId: 'variable2', name: 'My second variable' }, 5 | { variableId: 'variable3', name: 'Another variable' }, 6 | ]) 7 | } 8 | --------------------------------------------------------------------------------