Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

213 migration to eslint 9 and iobrokereslint config #223

Merged
merged 2 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .eslintrc.json

This file was deleted.

32 changes: 32 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// ioBroker eslint template configuration file for js and ts files
// Please note that esm or react based modules need additional modules loaded.
import config from '@iobroker/eslint-config';

export default [
...config,

{
// specify files to exclude from linting here
ignores: [
'.dev-server/',
'.vscode/',
'*.test.js',
'test/**/*.js',
'*.config.mjs',
'build',
'admin/build',
'admin/words.js',
'admin/admin.d.ts',
'**/adapter-config.d.ts'
]
},

{
// you may disable some 'jsdoc' warnings - but using jsdoc is highly recommended
// as this improves maintainability. jsdoc warnings will not block buiuld process.
rules: {
// 'jsdoc/require-jsdoc': 'off',
},
},

];
296 changes: 221 additions & 75 deletions lib/gatebox.js
Original file line number Diff line number Diff line change
@@ -1,112 +1,258 @@
const datapoints = {
"gatebox#command.move": {
path: "command.move", type: "state", common: { name: "primary action (p), secondary action (s), open (o), close (c)", type: "string", role: "text", read: true, write: true, states: { p: "Primary", s: "Secondary", o: "Open", c: "Close" } }
'gatebox#command.move': {
path: 'command.move',
type: 'state',
common: {
name: 'primary action (p), secondary action (s), open (o), close (c)',
type: 'string',
role: 'text',
read: true,
write: true,
states: { p: 'Primary', s: 'Secondary', o: 'Open', c: 'Close' },
},
},
"gatebox#device.deviceName": {
path: "device.deviceName", type: "state", common: { name: "Devicename", type: "string", role: "text", read: true, write: false }
'gatebox#device.deviceName': {
path: 'device.deviceName',
type: 'state',
common: { name: 'Devicename', type: 'string', role: 'text', read: true, write: false },
},
"gatebox#device.type": {
path: "device.type", type: "state", common: { name: "Type", type: "string", role: "text", read: true, write: false }
'gatebox#device.type': {
path: 'device.type',
type: 'state',
common: { name: 'Type', type: 'string', role: 'text', read: true, write: false },
},
"gatebox#device.product": {
path: "device.product", type: "state", common: { name: "Product", type: "string", role: "text", read: true, write: false }
'gatebox#device.product': {
path: 'device.product',
type: 'state',
common: { name: 'Product', type: 'string', role: 'text', read: true, write: false },
},
"gatebox#device.fv": {
path: "device.fv", type: "state", common: { name: "Firmwareversion", type: "string", role: "text", read: true, write: false }
'gatebox#device.fv': {
path: 'device.fv',
type: 'state',
common: { name: 'Firmwareversion', type: 'string', role: 'text', read: true, write: false },
},
"gatebox#device.hv": {
path: "device.hv", type: "state", common: { name: "Hardwareversion", type: "string", role: "text", read: true, write: false }
'gatebox#device.hv': {
path: 'device.hv',
type: 'state',
common: { name: 'Hardwareversion', type: 'string', role: 'text', read: true, write: false },
},
"gatebox#device.apiLevel": {
path: "device.apiLevel", type: "state", common: { name: "ApiLevel", type: "string", role: "text", read: true, write: false }
'gatebox#device.apiLevel': {
path: 'device.apiLevel',
type: 'state',
common: { name: 'ApiLevel', type: 'string', role: 'text', read: true, write: false },
},
"gatebox#device.id": {
path: "device.id", type: "state", common: { name: "ID", type: "string", role: "text", read: true, write: false }
'gatebox#device.id': {
path: 'device.id',
type: 'state',
common: { name: 'ID', type: 'string', role: 'text', read: true, write: false },
},
"gatebox#device.ip": {
path: "device.ip", type: "state", common: { name: "IP-Adress", type: "string", role: "text", read: true, write: false }
'gatebox#device.ip': {
path: 'device.ip',
type: 'state',
common: { name: 'IP-Adress', type: 'string', role: 'text', read: true, write: false },
},
"gatebox#upTimeS": {
path: "uptimeS", type: "state", common: { name: "Uptime in seconds", type: "number", role: "value", read: true, write: false }
'gatebox#upTimeS': {
path: 'uptimeS',
type: 'state',
common: { name: 'Uptime in seconds', type: 'number', role: 'value', read: true, write: false },
},
"gatebox#settings.deviceName": {
path: "settings.deviceName", type: "state", common: { name: "Device name.", type: "string", role: "text", read: true, write: false }
'gatebox#settings.deviceName': {
path: 'settings.deviceName',
type: 'state',
common: { name: 'Device name.', type: 'string', role: 'text', read: true, write: false },
},
"gatebox#settings.statusLed.enabled": {
path: "settings.statusLed.enabled", type: "state", common: { name: "Status led enabled (0 - disabled, 1 - enabled)", type: "number", role: "value", read: true, write: false }
'gatebox#settings.statusLed.enabled': {
path: 'settings.statusLed.enabled',
type: 'state',
common: {
name: 'Status led enabled (0 - disabled, 1 - enabled)',
type: 'number',
role: 'value',
read: true,
write: false,
},
},
"gatebox#settings.tunnel.enabled": {
path: "settings.tunnel.enabled", type: "state", common: { name: "Tunnel enabled (0 - disabled, 1 - enabled)", type: "number", role: "value", read: true, write: false }
'gatebox#settings.tunnel.enabled': {
path: 'settings.tunnel.enabled',
type: 'state',
common: {
name: 'Tunnel enabled (0 - disabled, 1 - enabled)',
type: 'number',
role: 'value',
read: true,
write: false,
},
},
"gatebox#settings.gate.gateType": {
path: "settings.gate.gateType", type: "state", common: { name: "Type of controlled appliance. Where: 0 - sliding door, 1 - garage door, 2 - over door, 3 - door.", type: "number", role: "value", read: true, write: false }
'gatebox#settings.gate.gateType': {
path: 'settings.gate.gateType',
type: 'state',
common: {
name: 'Type of controlled appliance. Where: 0 - sliding door, 1 - garage door, 2 - over door, 3 - door.',
type: 'number',
role: 'value',
read: true,
write: false,
},
},
"gatebox#settings.gate.gatePulseTimeMs": {
path: "settings.gate.gatePulseTimeMs", type: "state", common: { name: "Gate output pulse time in ms.", type: "number", role: "value", read: true, write: false }
'gatebox#settings.gate.gatePulseTimeMs': {
path: 'settings.gate.gatePulseTimeMs',
type: 'state',
common: { name: 'Gate output pulse time in ms.', type: 'number', role: 'value', read: true, write: false },
},
"gatebox#settings.gate.gateRelayNumber": {
path: "settings.gate.gateRelayNumber", type: "state", common: { name: "Gate relay number, where: 0 - O1, 1 - O2.", type: "number", role: "value", read: true, write: false }
'gatebox#settings.gate.gateRelayNumber': {
path: 'settings.gate.gateRelayNumber',
type: 'state',
common: {
name: 'Gate relay number, where: 0 - O1, 1 - O2.',
type: 'number',
role: 'value',
read: true,
write: false,
},
},
"gatebox#settings.gate.gateInvert": {
path: "settings.gate.gateInvert", type: "state", common: { name: "Inputs swap. Where: 0 - non-invert, 1 - invert.", type: "number", role: "value", read: true, write: false }
'gatebox#settings.gate.gateInvert': {
path: 'settings.gate.gateInvert',
type: 'state',
common: {
name: 'Inputs swap. Where: 0 - non-invert, 1 - invert.',
type: 'number',
role: 'value',
read: true,
write: false,
},
},
"gatebox#settings.gate.extraButtonType": {
path: "settings.gate.gateInvert", type: "state", common: { name: "Type of extra button, where: 0 - disabled, 1 - stop, 2 - walk-in, 3 - other.", type: "number", role: "value", read: true, write: false }
'gatebox#settings.gate.extraButtonType': {
path: 'settings.gate.gateInvert',
type: 'state',
common: {
name: 'Type of extra button, where: 0 - disabled, 1 - stop, 2 - walk-in, 3 - other.',
type: 'number',
role: 'value',
read: true,
write: false,
},
},
"gatebox#settings.gate.extraButtonPulseTimeMs": {
path: "settings.gate.extraButtonPulseTimeMs", type: "state", common: { name: "Extra button output pulse time in ms", type: "number", role: "value", read: true, write: false }
'gatebox#settings.gate.extraButtonPulseTimeMs': {
path: 'settings.gate.extraButtonPulseTimeMs',
type: 'state',
common: {
name: 'Extra button output pulse time in ms',
type: 'number',
role: 'value',
read: true,
write: false,
},
},
"gatebox#settings.gate.extraButtonInvert": {
path: "settings.gate.extraButtonInvert", type: "state", common: { name: "Invert output signal on gate output. Where: 0 - non-invert, 1 - invert.", type: "number", role: "value", read: true, write: false }
'gatebox#settings.gate.extraButtonInvert': {
path: 'settings.gate.extraButtonInvert',
type: 'state',
common: {
name: 'Invert output signal on gate output. Where: 0 - non-invert, 1 - invert.',
type: 'number',
role: 'value',
read: true,
write: false,
},
},
"gatebox#settings.gate.extraButtonRelayNumber": {
path: "settings.gate.extraButtonRelayNumber", type: "state", common: { name: "Extra button relay number, where: 0 - O1, 1 - O2.", type: "number", role: "value", read: true, write: false }
'gatebox#settings.gate.extraButtonRelayNumber': {
path: 'settings.gate.extraButtonRelayNumber',
type: 'state',
common: {
name: 'Extra button relay number, where: 0 - O1, 1 - O2.',
type: 'number',
role: 'value',
read: true,
write: false,
},
},
"gatebox#settings.gate.inputsType": {
path: "settings.gate.inputsType", type: "state", common: { name: "Inputs type. Where: 0 - Method 1, 1 - Method 2, 2 - Method 3.", type: "number", role: "value", read: true, write: false }
'gatebox#settings.gate.inputsType': {
path: 'settings.gate.inputsType',
type: 'state',
common: {
name: 'Inputs type. Where: 0 - Method 1, 1 - Method 2, 2 - Method 3.',
type: 'number',
role: 'value',
read: true,
write: false,
},
},
"gatebox#settings.gate.openLimitSwitchInputNumber": {
path: "settings.gate.openLimitSwitchInputNumber", type: "state", common: { name: "Open input number, where: 0 - IN1, 1 - IN2.", type: "number", role: "value", read: true, write: false }
'gatebox#settings.gate.openLimitSwitchInputNumber': {
path: 'settings.gate.openLimitSwitchInputNumber',
type: 'state',
common: {
name: 'Open input number, where: 0 - IN1, 1 - IN2.',
type: 'number',
role: 'value',
read: true,
write: false,
},
},
"gatebox#settings.gate.closeLimitSwitchInputNumber": {
path: "settings.gate.closeLimitSwitchInputNumber", type: "state", common: { name: "Close input number, where: 0 - IN1, 1 - IN2.", type: "number", role: "value", read: true, write: false }
'gatebox#settings.gate.closeLimitSwitchInputNumber': {
path: 'settings.gate.closeLimitSwitchInputNumber',
type: 'state',
common: {
name: 'Close input number, where: 0 - IN1, 1 - IN2.',
type: 'number',
role: 'value',
read: true,
write: false,
},
},
'gatebox#gate.currentPos': {
path: 'gate.currentPos',
type: 'state',
common: {
name: 'Current position is the open percent of the gate. 0 - fully closed, 50 - somewhere between open and close, 100 - fully close.',
type: 'number',
role: 'value',
read: true,
write: false,
},
},
"gatebox#gate.currentPos": {
path: "gate.currentPos", type: "state", common: { name: "Current position is the open percent of the gate. 0 - fully closed, 50 - somewhere between open and close, 100 - fully close.", type: "number", role: "value", read: true, write: false }
}
};

function init () {

}
/**
* init device if needed
*/
function init() {}

// eslint-disable-next-line no-unused-vars
function getApiUrl (type, value) {
/**
* Generate URLs for requested type and submitted value.
*
* @param type requested type
* @param _value value for url-generation
*/
function getApiUrl(type, _value) {
switch (type) {
case "deviceUptime":
return "/api/device/uptime";
case "settingsState":
return "/api/settings/state";
case "gateExtendedState":
return "/state/extended";
case "deviceState":
return "/info";
case "gatePrimary":
return "/s/p";
case "gateSecondary":
return "/s/s";
case "gateOpen":
return "/s/o";
case "gateClose":
return "/s/c";
case 'deviceUptime':
return '/api/device/uptime';
case 'settingsState':
return '/api/settings/state';
case 'gateExtendedState':
return '/state/extended';
case 'deviceState':
return '/info';
case 'gatePrimary':
return '/s/p';
case 'gateSecondary':
return '/s/s';
case 'gateOpen':
return '/s/o';
case 'gateClose':
return '/s/c';
default:
break;
}
}

function getDeviceTypeMapping () {
/**
* Allow multiple devices described by this API
*
* @returns Array of supported devices by theis API description
*/
function getDeviceTypeMapping() {
const supportedApiTypes = {
gatebox: "gatebox"
gatebox: 'gatebox',
};
return supportedApiTypes;
}
Expand All @@ -115,5 +261,5 @@ module.exports = {
datapoints,
init,
getApiUrl,
getDeviceTypeMapping
getDeviceTypeMapping,
};
Loading
Loading