UNPKG

homebridge-tuya-laundry

Version:

Allows washer/dryer cycle completion notifications using Tuya smart plugs with power meter, now using local control.

32 lines 1.31 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.PushGateway = void 0; const axios_1 = __importDefault(require("axios")); const form_data_1 = __importDefault(require("form-data")); class PushGateway { // TODO: make sure message sending is capped at x per minute so we avoid spamming constructor(log, config) { this.log = log; this.config = config; } send(message) { const form = new form_data_1.default(); form.append('app_key', this.config.appKey); form.append('app_secret', this.config.appSecret); form.append('content', message); form.append('target_type', 'channel'); form.append('target_alias', this.config.channelAlias); axios_1.default.post('https://api.pushed.co/1/push', form, { headers: form.getHeaders(), }).then(() => { this.log.debug(`Sent push to pushed.co channel alias ${this.config.channelAlias}`); }).catch((e) => { this.log.error('Failed to send push through Pushed.co:', e.message); }); } } exports.PushGateway = PushGateway; //# sourceMappingURL=pushGateway.js.map