homebridge-tuya-laundry
Version:
Allows washer/dryer cycle completion notifications using Tuya smart plugs with power meter, now using local control.
30 lines • 1.04 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.NtfyGateway = void 0;
const axios_1 = __importDefault(require("axios"));
class NtfyGateway {
constructor(log, config) {
this.log = log;
this.config = config;
this.serverUrl = config.serverUrl || 'https://ntfy.sh';
}
async send(message) {
try {
const url = `${this.serverUrl}/${this.config.topic}`;
await axios_1.default.post(url, message, {
headers: {
'Title': this.config.title,
},
});
this.log.debug(`Sent notification to ntfy topic ${this.config.topic}`);
}
catch (error) {
this.log.error(`Failed to send notification via ntfy: ${error.message}`);
}
}
}
exports.NtfyGateway = NtfyGateway;
//# sourceMappingURL=ntfyGateway.js.map