Skip to content

Commit

Permalink
Merge pull request #40 from bitfocus/bug/noconfig
Browse files Browse the repository at this point in the history
Fix crash on new module with empty config
  • Loading branch information
istnv authored Nov 5, 2024
2 parents af714b0 + 75ad6da commit 1b162fe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tplink-kasasmartplug",
"version": "2.2.2",
"version": "2.2.3",
"main": "src/index.js",
"type": "module",
"scripts": {
Expand Down
5 changes: 3 additions & 2 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ export function getConfigFields() {
width: 12,
})

let ch = []
let ch = [{id: 'none', label: 'No Kasa Plugs Located'}]
let def = 'none'
if (Object.keys(this.FOUND_PLUGS || {}).length == 0) {
ch = [{ id: 'none', label: 'No Kasa Plugs located' }]
if (this.config) {
this.config.plugId = 'none'
this.saveConfig(this.config)
}
} else {
ch = [{ id: 'none', label: 'No plug selected' }]
const plugs = this.FOUND_PLUGS
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class kasaplugInstance extends InstanceBase {
if (config.host != '') {
this.updateStatus(InstanceStatus.Connecting)
} else {
this.updateStatus(InstanceStatus.BadConfig, 'IP address not set')
this.updateStatus(InstanceStatus.ConnectionFailure, 'IP address not set')
this.FOUND_PLUGS = []
resave = true
}
Expand Down

0 comments on commit 1b162fe

Please sign in to comment.