Skip to content

Commit

Permalink
"rainbird": "^1.1.0-beta.4"
Browse files Browse the repository at this point in the history
  • Loading branch information
donavanbecker committed Aug 31, 2024
1 parent d54b861 commit da0b394
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 168 deletions.
2 changes: 2 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export default antfu(
'test/no-only-tests': 'error',
'unicorn/no-useless-spread': 'error',
'unused-imports/no-unused-vars': ['error', { caughtErrors: 'none' }],
'no-new': 0, // Disable the no-new rule
'new-cap': 0, // Disable the new-cap rule
},
},
)
6 changes: 2 additions & 4 deletions src/devices/ContactSensor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,10 @@ export class ContactSensor extends DeviceBase {
async updateHomeKitCharacteristics() {
// Valves
if (this.contactSensor.state === undefined) {
await this.debugLog(`${this.constructor.name} ${this.accessory.displayName} ContactSensorState: ${this.contactSensor.state}, `
+ `${this.accessory.context.zoneId}`)
await this.debugLog(`${this.constructor.name} ${this.accessory.displayName} ContactSensorState: ${this.contactSensor.state}, ${this.accessory.context.zoneId}`)
} else {
this.contactSensor.service.updateCharacteristic(this.hap.Characteristic.ContactSensorState, this.contactSensor.state)
await this.debugLog(`${this.constructor.name} ${this.accessory.displayName} ContactSensorState: ${this.contactSensor.state}, `
+ `${this.accessory.context.zoneId}`)
await this.debugLog(`${this.constructor.name} ${this.accessory.displayName} ContactSensorState: ${this.contactSensor.state}, ${this.accessory.context.zoneId}`)
}
}
}
3 changes: 1 addition & 2 deletions src/devices/DeviceBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ export abstract class DeviceBase {
this.devicePushRate = device.pushRate ?? this.config.options?.pushRate ?? 1
accessory.context.devicePushRate = this.devicePushRate
const pushRate = device.pushRate ? 'Device Config' : this.config.options?.pushRate ? 'Platform Config' : 'Default'
await this.debugLog(`Using ${refreshRate} refreshRate: ${this.deviceRefreshRate}, ${updateRate} updateRate: ${this.deviceUpdateRate},`
+ ` ${pushRate} pushRate: ${this.devicePushRate}`)
await this.debugLog(`Using ${refreshRate} refreshRate: ${this.deviceRefreshRate}, ${updateRate} updateRate: ${this.deviceUpdateRate}, ${pushRate} pushRate: ${this.devicePushRate}`)
}

async getDeviceConfigSettings(accessory: PlatformAccessory, device: DevicesConfig): Promise<void> {
Expand Down
257 changes: 125 additions & 132 deletions src/homebridge-ui/public/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<p class="text-center">
<img src="https://raw.githubusercontent.com/donavanbecker/homebridge-rainbird/latest/branding/Homebridge_x_Rainbird.svg" alt="homebridge-rainbird logo" style="width: 60%;">
<img src="https://raw.githubusercontent.com/donavanbecker/homebridge-rainbird/latest/branding/Homebridge_x_Rainbird.svg"
alt="homebridge-rainbird logo" style="width: 60%;">
</p>
<div id="pageIntro" style="display: none;">
<p class="lead text-center">Thank you for installing
Expand All @@ -9,13 +10,7 @@
<button type="button" class="btn btn-primary" id="introLink">Continue &rarr;</button>
</div>
</div>
<div
id="menuWrapper"
class="btn-group w-100 mb-0"
role="group"
aria-label="UI Menu"
style="display: none;"
>
<div id="menuWrapper" class="btn-group w-100 mb-0" role="group" aria-label="UI Menu" style="display: none;">
<button type="button" class="btn btn-primary" id="menuSettings">
Settings
</button>
Expand All @@ -26,12 +21,7 @@
Support
</button>
</div>
<div
id="disabledBanner"
class="alert alert-secondary mb-0 mt-3"
role="alert"
style="display: none;"
>
<div id="disabledBanner" class="alert alert-secondary mb-0 mt-3" role="alert" style="display: none;">
Plugin is currently disabled
<button id="disabledEnable" type="button" class="btn btn-link p-0 m-0 float-right">
Enable
Expand Down Expand Up @@ -80,34 +70,37 @@ <h5>Setup</h5>
<a href="https://github.com/donavanbecker/homebridge-rainbird/wiki" target="_blank">Wiki Home</a>
</li>
<li>
<a href="https://github.com/donavanbecker/homebridge-rainbird/wiki/Configuration" target="_blank">Configuration</a>
<a href="https://github.com/donavanbecker/homebridge-rainbird/wiki/Configuration"
target="_blank">Configuration</a>
</li>
<li>
<a href="https://github.com/donavanbecker/homebridge-rainbird/wiki/Beta-Version" target="_blank">
Beta
Version
Version
</a>
</li>
<li>
<a href="https://github.com/donavanbecker/homebridge-rainbird/wiki/Node-Version" target="_blank">
Node
Version
Version
</a>
</li>
<li>
<a href="https://github.com/donavanbecker/homebridge-rainbird/wiki/Uninstallation" target="_blank">Uninstallation</a>
<a href="https://github.com/donavanbecker/homebridge-rainbird/wiki/Uninstallation"
target="_blank">Uninstallation</a>
</li>
</ul>
<h5>Help/About</h5>
<ul>
<li>
<a href="https://github.com/donavanbecker/homebridge-rainbird/issues/new/choose" target="_blank">
Support
Request
Request
</a>
</li>
<li>
<a href="https://github.com/donavanbecker/homebridge-rainbird/blob/latest/CHANGELOG.md" target="_blank">Changelog</a>
<a href="https://github.com/donavanbecker/homebridge-rainbird/blob/latest/CHANGELOG.md"
target="_blank">Changelog</a>
</li>
<li>
<a href="https://github.com/sponsors/donavanbecker" target="_blank">About Me</a>
Expand All @@ -117,127 +110,127 @@ <h5>Disclaimer</h5>
<ul>
<li>
I am in no way affiliated with RainBird and this plugin is a personal project that I maintain in
my free time.
my free time.
</li>
<li>
Use this plugin entirely at your own risk - please see licence for more information.
</li>
</ul>
</div>
<script>
; (async () => {
try {
const currentConfig = await homebridge.getPluginConfig()
showIntro = () => {
introLink.addEventListener('click', () => {
homebridge.showSpinner()
document.getElementById('pageIntro').style.display = 'none'
document.getElementById('menuWrapper').style.display = 'inline-flex'
showSettings()
homebridge.hideSpinner()
})
document.getElementById('menuWrapper').style.display = 'none'
document.getElementById('pageIntro').style.display = 'block'
}
showDevices = async () => {
homebridge.showSpinner()
homebridge.hideSchemaForm()
document.getElementById('menuHome').classList.remove('btn-elegant')
document.getElementById('menuHome').classList.add('btn-primary')
document.getElementById('menuDevices').classList.add('btn-elegant')
document.getElementById('menuDevices').classList.remove('btn-primary')
document.getElementById('menuSettings').classList.remove('btn-elegant')
document.getElementById('menuSettings').classList.add('btn-primary')
document.getElementById('pageSupport').style.display = 'none'
document.getElementById('pageDevices').style.display = 'block'
const cachedAccessories =
typeof homebridge.getCachedAccessories === 'function'
? await homebridge.getCachedAccessories()
: await homebridge.request('/getCachedAccessories')
if (cachedAccessories.length > 0) {
cachedAccessories.sort((a, b) => {
return a.displayName.toLowerCase() > b.displayName.toLowerCase()
? 1
: b.displayName.toLowerCase() > a.displayName.toLowerCase()
? -1
: 0
})
; (async () => {
try {
const currentConfig = await homebridge.getPluginConfig()
showIntro = () => {
introLink.addEventListener('click', () => {
homebridge.showSpinner()
document.getElementById('pageIntro').style.display = 'none'
document.getElementById('menuWrapper').style.display = 'inline-flex'
showSettings()
homebridge.hideSpinner()
})
document.getElementById('menuWrapper').style.display = 'none'
document.getElementById('pageIntro').style.display = 'block'
}
const deviceSelect = document.getElementById('deviceSelect')
deviceSelect.innerHTML = ''
cachedAccessories.forEach(a => {
const option = document.createElement('option')
option.text = a.displayName
option.value = a.UUID
deviceSelect.add(option)
})
showDeviceInfo = async UUID => {
homebridge.showSpinner()
const thisAcc = cachedAccessories.find(x => x.UUID === UUID)
const context = thisAcc.context
document.getElementById('displayName').innerHTML = thisAcc.displayName
document.getElementById('deviceID').innerHTML = context.deviceID
document.getElementById('model').innerHTML = context.model
document.getElementById('FirmwareRevision').innerHTML = context.FirmwareRevision || 'N/A'
document.getElementById('deviceTable').style.display = 'inline-table'
homebridge.hideSpinner()
showDevices = async () => {
homebridge.showSpinner()
homebridge.hideSchemaForm()
document.getElementById('menuHome').classList.remove('btn-elegant')
document.getElementById('menuHome').classList.add('btn-primary')
document.getElementById('menuDevices').classList.add('btn-elegant')
document.getElementById('menuDevices').classList.remove('btn-primary')
document.getElementById('menuSettings').classList.remove('btn-elegant')
document.getElementById('menuSettings').classList.add('btn-primary')
document.getElementById('pageSupport').style.display = 'none'
document.getElementById('pageDevices').style.display = 'block'
const cachedAccessories =
typeof homebridge.getCachedAccessories === 'function'
? await homebridge.getCachedAccessories()
: await homebridge.request('/getCachedAccessories')
if (cachedAccessories.length > 0) {
cachedAccessories.sort((a, b) => {
return a.displayName.toLowerCase() > b.displayName.toLowerCase()
? 1
: b.displayName.toLowerCase() > a.displayName.toLowerCase()
? -1
: 0
})
}
const deviceSelect = document.getElementById('deviceSelect')
deviceSelect.innerHTML = ''
cachedAccessories.forEach(a => {
const option = document.createElement('option')
option.text = a.displayName
option.value = a.UUID
deviceSelect.add(option)
})
showDeviceInfo = async UUID => {
homebridge.showSpinner()
const thisAcc = cachedAccessories.find(x => x.UUID === UUID)
const context = thisAcc.context
document.getElementById('displayName').innerHTML = thisAcc.displayName
document.getElementById('deviceID').innerHTML = context.deviceID
document.getElementById('model').innerHTML = context.model
document.getElementById('FirmwareRevision').innerHTML = context.FirmwareRevision || 'N/A'
document.getElementById('deviceTable').style.display = 'inline-table'
homebridge.hideSpinner()
}
deviceSelect.addEventListener('change', event => showDeviceInfo(event.target.value))
if (cachedAccessories.length > 0) {
showDeviceInfo(cachedAccessories[0].UUID)
} else {
const option = document.createElement('option')
option.text = 'No Devices'
deviceSelect.add(option)
deviceSelect.disabled = true
}
homebridge.hideSpinner()
}
deviceSelect.addEventListener('change', event => showDeviceInfo(event.target.value))
if (cachedAccessories.length > 0) {
showDeviceInfo(cachedAccessories[0].UUID)
showSupport = () => {
homebridge.showSpinner()
homebridge.hideSchemaForm()
document.getElementById('menuHome').classList.add('btn-elegant')
document.getElementById('menuHome').classList.remove('btn-primary')
document.getElementById('menuDevices').classList.remove('btn-elegant')
document.getElementById('menuDevices').classList.add('btn-primary')
document.getElementById('menuSettings').classList.remove('btn-elegant')
document.getElementById('menuSettings').classList.add('btn-primary')
document.getElementById('pageSupport').style.display = 'block'
document.getElementById('pageDevices').style.display = 'none'
homebridge.hideSpinner()
}
showSettings = () => {
homebridge.showSpinner()
document.getElementById('menuHome').classList.remove('btn-elegant')
document.getElementById('menuHome').classList.add('btn-primary')
document.getElementById('menuDevices').classList.remove('btn-elegant')
document.getElementById('menuDevices').classList.add('btn-primary')
document.getElementById('menuSettings').classList.add('btn-elegant')
document.getElementById('menuSettings').classList.remove('btn-primary')
document.getElementById('pageSupport').style.display = 'none'
document.getElementById('pageDevices').style.display = 'none'
homebridge.showSchemaForm()
homebridge.hideSpinner()
}
showDisabledBanner = () => {
document.getElementById('disabledBanner').style.display = 'block'
}
menuHome.addEventListener('click', () => showSupport())
menuDevices.addEventListener('click', () => showDevices())
menuSettings.addEventListener('click', () => showSettings())
disabledEnable.addEventListener('click', () => enablePlugin())
if (currentConfig.length) {
document.getElementById('menuWrapper').style.display = 'inline-flex'
showSettings()
} else {
const option = document.createElement('option')
option.text = 'No Devices'
deviceSelect.add(option)
deviceSelect.disabled = true
currentConfig.push({ name: 'RainBird' })
await homebridge.updatePluginConfig(currentConfig)
showIntro()
}
} catch (err) {
homebridge.toast.error(err.message, 'Error')
} finally {
homebridge.hideSpinner()
}
showSupport = () => {
homebridge.showSpinner()
homebridge.hideSchemaForm()
document.getElementById('menuHome').classList.add('btn-elegant')
document.getElementById('menuHome').classList.remove('btn-primary')
document.getElementById('menuDevices').classList.remove('btn-elegant')
document.getElementById('menuDevices').classList.add('btn-primary')
document.getElementById('menuSettings').classList.remove('btn-elegant')
document.getElementById('menuSettings').classList.add('btn-primary')
document.getElementById('pageSupport').style.display = 'block'
document.getElementById('pageDevices').style.display = 'none'
homebridge.hideSpinner()
}
showSettings = () => {
homebridge.showSpinner()
document.getElementById('menuHome').classList.remove('btn-elegant')
document.getElementById('menuHome').classList.add('btn-primary')
document.getElementById('menuDevices').classList.remove('btn-elegant')
document.getElementById('menuDevices').classList.add('btn-primary')
document.getElementById('menuSettings').classList.add('btn-elegant')
document.getElementById('menuSettings').classList.remove('btn-primary')
document.getElementById('pageSupport').style.display = 'none'
document.getElementById('pageDevices').style.display = 'none'
homebridge.showSchemaForm()
homebridge.hideSpinner()
}
showDisabledBanner = () => {
document.getElementById('disabledBanner').style.display = 'block'
}
menuHome.addEventListener('click', () => showSupport())
menuDevices.addEventListener('click', () => showDevices())
menuSettings.addEventListener('click', () => showSettings())
disabledEnable.addEventListener('click', () => enablePlugin())
if (currentConfig.length) {
document.getElementById('menuWrapper').style.display = 'inline-flex'
showSettings()
} else {
currentConfig.push({ name: 'RainBird' })
await homebridge.updatePluginConfig(currentConfig)
showIntro()
}
} catch (err) {
homebridge.toast.error(err.message, 'Error')
} finally {
homebridge.hideSpinner()
}
})()
</script>
}
})()
</script>
Loading

0 comments on commit da0b394

Please sign in to comment.