Tasmota Commands Core
Overview
A core package for controlling Tasmota devices. Doesn't include any implementations for sending the commands. Use the package tasmota-commands-http
or tasmota-commands-mqtt
if you want a ready-to-use solution or create a custom commandHandler
Install
npm install tasmota-commands-core
or yarn add tasmota-commands-core
Custom command handler
Create a function satisfying type "CommandHandler" that sends a command and returns a response. The response should be a json object that Tasmota returns.
import { CommandHandler } from 'tasmota-commands-core';
const myCustomCommandHandler: CommandHandler = async ({ command, payload, logger }) => {
// Send command
// Wait response
return { POWER: 'OFF' };
};
Example
const myCustomCommandHandler = ...;
const commands = new TasmotaCommands(myCustomCommandHandler);
commands.Control.setPower0('on');
Parameters
Parameter | Required | Accepted values | Description |
---|---|---|---|
refreshStateOnInit | no |
boolean |
Get the current state from the device asynchronously after class initialization |
refreshStateInterval | no |
number |
Refresh state interval in milliseconds. Disabled by default. |
logger | no |
logger implementation, should satisfy type Logger
|
Logging implementation. Leave unset to disable logging. Set to console or your custom implementation. |
onStateChanged | no |
OnStateChangeCallback |
Callback that is called always after state is changed |
onStateRefreshed | no |
OnStateChangeCallback |
Callback that is called always after state is refreshed |
Setup Development Environment
Install Development Dependencies
Navigate to the project folder and install dependencies with yarn
yarn install
Roadmap
Contribution
License
MIT