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

Added drivers for TESmart and Shinybow #90

Merged
merged 3 commits into from
Nov 4, 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
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = defineConfig(({ useVue, useNode, useTypeScript }) => {
}
},
{
files: ['src/renderer/**/*.ts', 'src/renderer/**/*.js', 'src/renderer/**/*.vue'],
files: ['src/renderer/**/*.ts', 'src/renderer/**/*.tsx', 'src/renderer/**/*.js', 'src/renderer/**/*.vue'],
parserOptions: {
project: './tsconfig.web.json'
}
Expand Down
7 changes: 0 additions & 7 deletions PLAN.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
- Milestones
- v2.1
- (#86) Add a means to select a not-in-use port for the tRPC channel.
- (#85) Attempt to secure `serialport` interactione.
- More drivers.
- (#88) Add means to mark and label experimental drivers.
- (#83) Shinybow
- (#84) TESmart
- v2.2
- Move more modules to core.
- tRPC over Electron IPC.
Expand All @@ -24,9 +19,7 @@
- Need a means to identify it's URL via the local UI.
- May need a way to disable the power-off button in the remote UI.
- Drivers
- Shinybow
- Monoprice Blackbird
- J-Tech Digital -- Need to find actual command list.
- ASHATA -- Now unable to find.
- TESmart -- Brand of Tesla Elec (like TelsaSmart)
- No Hassle AV -- Need to contact.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@mdi/js": "^7.4.47",
"@mdi/svg": "^7.4.47",
"@sindresorhus/is": "^7.0.1",
"@sixxgate/lint": "^3.3.0",
"@sixxgate/lint": "^3.3.2",
"@trpc/client": "^10.45.2",
"@trpc/server": "^10.45.2",
"@tsconfig/node20": "^20.1.4",
Expand All @@ -74,7 +74,7 @@
"@types/ini": "^4.1.1",
"@types/leveldown": "^4.0.6",
"@types/levelup": "^5.1.5",
"@types/node": "^20.17.5",
"@types/node": "^20.17.6",
"@types/pouchdb-core": "^7.0.15",
"@types/pouchdb-find": "^7.3.3",
"@types/ws": "^8.5.13",
Expand Down Expand Up @@ -114,9 +114,9 @@
"js-base64": "^3.7.7",
"levelup": "^5.1.1",
"mime": "^4.0.4",
"npm-check-updates": "^17.1.9",
"npm-check-updates": "^17.1.10",
"npm-run-all2": "^7.0.1",
"pinia": "^2.2.5",
"pinia": "^2.2.6",
"pouchdb-adapter-leveldb-core": "^9.0.0",
"pouchdb-core": "^9.0.0",
"pouchdb-find": "^9.0.0",
Expand Down
52 changes: 2 additions & 50 deletions src/main/drivers/extron/sis.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Logger from 'electron-log'
import { defineDriver, kDeviceCanDecoupleAudioOutput, kDeviceSupportsMultipleOutputs } from '../../services/drivers'
import { createCommandStream } from '../../services/stream'
import { useExtronSisProtocol } from '../../services/protocols/extronSis'

const extronSisDriver = defineDriver({
enabled: true,
Expand All @@ -14,54 +13,7 @@ const extronSisDriver = defineDriver({
}
},
capabilities: kDeviceSupportsMultipleOutputs | kDeviceCanDecoupleAudioOutput,
setup: () => {
async function sendCommand(uri: string, command: string) {
const connection = await createCommandStream(uri, {
baudRate: 9600,
dataBits: 8,
stopBits: 1,
parity: 'none',
timeout: 5000,
keepAlive: true
})

// TODO: Other situation handlers...
connection.on('data', (data) => {
Logger.debug(`extronSisDriver: return: ${String(data)}`)
})
connection.on('error', (error) => {
Logger.error(`extronSisDriver: ${error.message}`)
})

await connection.write(command)
await connection.close()
}

async function activate(uri: string, input: number, videoOutput: number, audioOutput: number) {
Logger.log(`extronSisDriver.activate(${input}, ${videoOutput}, ${audioOutput})`)
const videoCommand = `${input}*${videoOutput}%`
const audioCommand = `${input}*${audioOutput}$`
await sendCommand(uri, `${videoCommand}\r\n${audioCommand}\r\n`)
}

async function powerOn() {
Logger.log('extronSisDriver.powerOn')
Logger.debug('extronSisDriver.powerOn is a no-op')
await Promise.resolve()
}

async function powerOff() {
Logger.log('extronSisDriver.powerOff')
Logger.debug('extronSisDriver.powerOff is a no-op')
await Promise.resolve()
}

return {
activate,
powerOn,
powerOff
}
}
setup: useExtronSisProtocol
})

export default extronSisDriver
19 changes: 19 additions & 0 deletions src/main/drivers/shinybow/v2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineDriver, kDeviceSupportsMultipleOutputs } from '../../services/drivers'
import { useShinybowV2Protocol } from '../../services/protocols/shinybow'

const shinybowV2 = defineDriver({
enabled: true,
experimental: true,
guid: '75FB7ED2-EE3A-46D5-B11F-7D8C3C208E7C',
localized: {
en: {
title: 'Shinybow v2.0 compatible matrix switch',
company: 'ShinybowUSA',
provider: 'BridgeCmdr contributors'
}
},
capabilities: kDeviceSupportsMultipleOutputs,
setup: useShinybowV2Protocol
})

export default shinybowV2
19 changes: 19 additions & 0 deletions src/main/drivers/shinybow/v3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineDriver, kDeviceSupportsMultipleOutputs } from '../../services/drivers'
import { useShinybowV3Protocol } from '../../services/protocols/shinybow'

const shinybowV3 = defineDriver({
enabled: true,
experimental: true,
guid: 'BBED08A1-C749-4733-8F2E-96C9B56C0C41',
localized: {
en: {
title: 'Shinybow v3.0 compatible matrix switch',
company: 'ShinybowUSA',
provider: 'BridgeCmdr contributors'
}
},
capabilities: kDeviceSupportsMultipleOutputs,
setup: useShinybowV3Protocol
})

export default shinybowV3
61 changes: 2 additions & 59 deletions src/main/drivers/sony/rs485.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import Logger from 'electron-log'
import { defineDriver, kDeviceHasNoExtraCapabilities } from '../../services/drivers'
import { createCommandStream } from '../../services/stream'
import {
createAddress,
createCommand,
kAddressAll,
kPowerOff,
kPowerOn,
kSetChannel
} from '../../services/support/sonyRs485'
import type { Command, CommandArg } from '../../services/support/sonyRs485'
import { useSonyBvmProtocol } from '../../services/protocols/sonyBvm'

const sonyRs485Driver = defineDriver({
enabled: true,
Expand All @@ -23,54 +13,7 @@ const sonyRs485Driver = defineDriver({
}
},
capabilities: kDeviceHasNoExtraCapabilities,
setup: () => {
async function sendCommand(uri: string, command: Command, arg0?: CommandArg, arg1?: CommandArg) {
const source = createAddress(kAddressAll, 0)
const destination = createAddress(kAddressAll, 0)
const packet = createCommand(destination, source, command, arg0, arg1)

const connection = await createCommandStream(uri, {
baudRate: 38400,
dataBits: 8,
stopBits: 1,
parity: 'odd',
timeout: 5000,
keepAlive: true
})

// TODO: Other situation handlers...
connection.on('data', (data) => {
Logger.debug(`sonyRs485Driver: return: ${String(data)}`)
})
connection.on('error', (error) => {
Logger.error(`sonyRs485Driver: ${error.message}`)
})

await connection.write(packet)
await connection.close()
}

async function activate(uri: string, input: number) {
Logger.log(`sonyRs485Driver.activate(${input})`)
await sendCommand(uri, kSetChannel, 1, input)
}

async function powerOn(uri: string) {
Logger.log('sonyRs485Driver.powerOn')
await sendCommand(uri, kPowerOn)
}

async function powerOff(uri: string) {
Logger.log('sonyRs485Driver.powerOff')
await sendCommand(uri, kPowerOff)
}

return {
activate,
powerOn,
powerOff
}
}
setup: useSonyBvmProtocol
})

export default sonyRs485Driver
50 changes: 2 additions & 48 deletions src/main/drivers/tesla-smart/kvm.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Logger from 'electron-log'
import { defineDriver, kDeviceHasNoExtraCapabilities } from '../../services/drivers'
import { createCommandStream } from '../../services/stream'
import { useTeslaElecKvmProtocol } from '../../services/protocols/teslaElec'

const teslaSmartKvmDriver = defineDriver({
enabled: true,
Expand All @@ -14,52 +13,7 @@ const teslaSmartKvmDriver = defineDriver({
}
},
capabilities: kDeviceHasNoExtraCapabilities,
setup: () => {
async function sendCommand(uri: string, command: Buffer) {
const connection = await createCommandStream(uri, {
baudRate: 9600,
dataBits: 8,
stopBits: 1,
parity: 'none',
timeout: 5000,
keepAlive: true
})

// TODO: Other situation handlers...
connection.on('data', (data) => {
Logger.debug(`teslaSmartKvmDriver: return: ${String(data)}`)
})
connection.on('error', (error) => {
Logger.error(`teslaSmartKvmDriver: ${error.message}`)
})

await connection.write(command)
await connection.close()
}

async function activate(uri: string, input: number) {
Logger.log(`teslaSmartKvmDriver.activate(${input})`)
await sendCommand(uri, Buffer.of(0xaa, 0xbb, 0x03, 0x01, input, 0xee))
}

async function powerOn() {
Logger.log('teslaSmartKvmDriver.powerOn')
Logger.debug('teslaSmartKvmDriver.powerOn is a no-op')
await Promise.resolve()
}

async function powerOff() {
Logger.log('teslaSmartKvmDriver.powerOff')
Logger.debug('teslaSmartKvmDriver.powerOff is a no-op')
await Promise.resolve()
}

return {
activate,
powerOn,
powerOff
}
}
setup: useTeslaElecKvmProtocol
})

export default teslaSmartKvmDriver
55 changes: 2 additions & 53 deletions src/main/drivers/tesla-smart/matrix.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Logger from 'electron-log'
import { defineDriver, kDeviceSupportsMultipleOutputs } from '../../services/drivers'
import { createCommandStream } from '../../services/stream'
import { useTeslaElecMatrixProtocol } from '../../services/protocols/teslaElec'

const teslaSmartMatrixDriver = defineDriver({
enabled: true,
Expand All @@ -14,57 +13,7 @@ const teslaSmartMatrixDriver = defineDriver({
}
},
capabilities: kDeviceSupportsMultipleOutputs,
setup: () => {
const sendCommand = async (uri: string, command: Buffer) => {
const connection = await createCommandStream(uri, {
baudRate: 9600,
dataBits: 8,
stopBits: 1,
parity: 'none',
timeout: 5000,
keepAlive: true
})

// TODO: Other situation handlers...
connection.on('data', (data) => {
Logger.debug(`teslaSmartMatrixDriver: return: ${String(data)}`)
})
connection.on('error', (error) => {
Logger.error(`teslaSmartMatrixDriver: ${error.message}`)
})

await connection.write(command)
await connection.close()
}

const toChannel = (n: number) => String(n).padStart(2, '0')

async function activate(uri: string, input: number, output: number) {
Logger.log(`teslaSmartMatrixDriver.activate(${input}, ${output})`)
const command = `MT00SW${toChannel(input)}${toChannel(output)}NT`
await sendCommand(uri, Buffer.from(command, 'ascii'))

await Promise.resolve()
}

async function powerOn() {
Logger.log('teslaSmartMatrixDriver.powerOn')
Logger.debug('teslaSmartMatrixDriver.powerOn is a no-op')
await Promise.resolve()
}

async function powerOff() {
Logger.log('teslaSmartMatrixDriver.powerOff')
Logger.debug('teslaSmartMatrixDriver.powerOff is a no-op')
await Promise.resolve()
}

return {
activate,
powerOn,
powerOff
}
}
setup: useTeslaElecMatrixProtocol
})

export default teslaSmartMatrixDriver
Loading