Skip to content
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
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@

All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/).

## 0.2.2 (2024-12-23)

## [Version 0.2.2](https://github.com/northernman54/homebridge-tasmota/compare/0.2.1...0.2.2)

#### Changes

- Fix for cleanup = 0 ( no cleanup )

## 0.2.1 (2024-12-14)

## [Version 0.1.12](https://github.com/northernman54/homebridge-tasmota/compare/0.2.0...0.2.1)
## [Version 0.2.1](https://github.com/northernman54/homebridge-tasmota/compare/0.2.0...0.2.1)

#### Changes

Expand All @@ -13,7 +21,7 @@ All notable changes to this project will be documented in this file. This projec

## 0.2.0 (2024-12-10)

## [Version 0.1.12](https://github.com/northernman54/homebridge-tasmota/compare/v0.1.18...v0.2.0)
## [Version 0.2.0](https://github.com/northernman54/homebridge-tasmota/compare/v0.1.18...v0.2.0)

#### Changes

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"displayName": "Tasmota",
"name": "homebridge-tasmota",
"version": "0.2.1",
"version": "0.2.2",
"type": "module",
"description": "Homebridge plugin for Tasmota devices leveraging home assistant auto discovery.",
"license": "Apache-2.0",
Expand Down
44 changes: 24 additions & 20 deletions src/tasmotaPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export class tasmotaPlatform implements DynamicPlatformPlugin {
if (this.discoveryTopicMap[topic]) {
const existingAccessory = this.accessories.find(accessory => accessory.UUID === this.discoveryTopicMap[topic].uuid);
if (existingAccessory) {
// debug('Remove', this.discoveryTopicMap[topic]);
// debug('MQTT Remove', this.discoveryTopicMap[topic]);
switch (this.discoveryTopicMap[topic].type) {
case 'Service':
this.serviceCleanup(this.discoveryTopicMap[topic].uniq_id, existingAccessory);
Expand Down Expand Up @@ -510,30 +510,34 @@ export class tasmotaPlatform implements DynamicPlatformPlugin {

autoCleanup(accessory: PlatformAccessory): number | null {
let timeoutID: number;

// debug('autoCleanup', this.cleanup, accessory.displayName, accessory.context);
// Check if 'stat_t' is available in the accessory context
if (findVal(accessory.context.device, 'stat_t')) {
if (accessory.context.timeout) {
// Clear existing timeout if present
timeoutID = accessory.context.timeout;
clearTimeout(this.timeouts[timeoutID]);
delete this.timeouts[timeoutID];
}
if (this.cleanup) {
if (findVal(accessory.context.device, 'stat_t')) {
if (accessory.context.timeout) {
// Clear existing timeout if present
timeoutID = accessory.context.timeout;
clearTimeout(this.timeouts[timeoutID]);
delete this.timeouts[timeoutID];
}

// Create a new timeout ID and store it
timeoutID = this.timeoutCounter++;
this.timeouts[timeoutID] = setTimeout(
this.accessoryCleanup.bind(this),
this.cleanup * 60 * 60 * 1000, // Convert cleanup interval to milliseconds
accessory,
);
// Create a new timeout ID and store it
timeoutID = this.timeoutCounter++;
this.timeouts[timeoutID] = setTimeout(
this.accessoryCleanup.bind(this),
this.cleanup * 60 * 60 * 1000, // Convert cleanup interval to milliseconds
accessory,
);

// Save the new timeout ID in the accessory context for future clearing
accessory.context.timeout = timeoutID;
// Save the new timeout ID in the accessory context for future clearing
accessory.context.timeout = timeoutID;

return timeoutID;
return timeoutID;
} else {
// Return null if 'stat_t' is unavailable
return null;
}
} else {
// Return null if 'stat_t' is unavailable
return null;
}
}
Expand Down
6 changes: 2 additions & 4 deletions test/hbConfig/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@
"platform": "Tasmota",
"name": "Tasmota",
"mqttHost": "mqtt.local",
"cleanup": 0.1,
"history": false,
"debug": true,
"cleanup": 0,
"filterAllow": [
"AC5811",
"CBA0E5",
"302F1B"
"130C86"
],
"filterDeny": [
"5673B2",
Expand Down
Loading