Code Monkey home page Code Monkey logo

tuya2mqtt's Introduction

Hi there

This is small nodejs code to connect tuya devices to home assistant. Script will pull all devices from tuya cloud then connect with home assistant using local socket in your LAN network Feature:

  • Support switch, binary sensor, presence sensor, curtain, sence switch button
  • Support zigbee device
  • Automatic pull devices config from tuya cloud
  • Auto setup to home assistant via MQTT discovery
  • Near realtime state update/control
  • Auto add ARP record => fix offline problem
  • Auto reconnect after device offline (you can test by turn off then turn device on)

Requirement

Install

With yarn:

git clone https://github.com/duongvanba/tuya2mqtt.git
cd tuya2mqtt
yarn
yarn add ts-node typescript
yarn build

With npm:

git clone https://github.com/duongvanba/tuya2mqtt.git
cd tuya2mqtt
npm install
npm i typescript ts-node
npm run build

Run

With yarn

MQTT_HOST=(your mqtt host) MQTT_PORT=(your mqtt port) MQTT_USERNAME=(your mqtt username) MQTT_PASSWORD=(your mqtt password) API_KEY=(your tuya api key) API_SECRET=(your tuya secret) USER_ID=(tuya user id from tuya developer account) yarn start

With NPM

MQTT_HOST=(your mqtt host) MQTT_PORT=(your mqtt port) MQTT_USERNAME=(your mqtt username) MQTT_PASSWORD=(your mqtt password) API_KEY=(your tuya api key) API_SECRET=(your tuya secret) USER_ID=(tuya user id from tuya developer account) npm run start

You can install screen to run above script in background

sudo apt-get install screen

tuya2mqtt's People

Forkers

daoduc20it yoa305

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.