GithubHelp home page GithubHelp logo

5l1v3r1 / hs100tomqtt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dersimn/hs100tomqtt

0.0 1.0 0.0 27 KB

Script to control TP-Link HS100 & HS110 devices via MQTT

JavaScript 97.43% Dockerfile 2.57%

hs100tomqtt's Introduction

NodeJS script to control TP-Link HS100 & HS110 devices via MQTT.

Topics:

hs100/maintenance/_bridge    /online    -> bool
hs100/maintenance/<DEVICE_ID>/online    -> bool

hs100/status/<DEVICE_ID>    -> JSON: {"val":false,"power":0,"voltage":230.68353,"current":0.012407}
hs100/set   /<DEVICE_ID>    <- bool

(Spaces here are only for formatting, the actual topics won't have them.)

Usage

Native

git clone <this repo URL> HS100toMQTT
cd HS100toMQTT
npm install
node index --help

Docker

Show all available options:

docker run --rm dersimn/hs100tomqtt --help

Start with:

docker run -d --net=host dersimn/hs100tomqtt -m mqtt://<MQTT Broker IP>

In order to use automatic device discovery, your Docker host has to suport the --net=host parameter - not all Docker installations can do this (see Docker for Mac issue).
If you prefer to run the script in bridge mode or your host doesn't support host networking, provide a list of IP addresses via the --devices option:

docker run -d dersimn/hs100tomqtt -m mqtt://<MQTT Broker IP> --devices="10.1.1.100 10.1.1.101"

Blocking internet access for your devices

Even though there are currently no known security issues for the HS100 / HS110, if you choose to block internet access for your plugs, be aware that the unterlying tplink-smarthome-api will throw an error on every polling cycle, because the TP-Link devices will have a wrong time set-up (quite obvious: no Internet, no NTP server, no correct set time and date).

I've written this workaround until I found a better way to solve this problem: According to this source, the plugs are using fr.pool.ntp.org to get their time. If you are able to alter the DNS resolving mechanism of your router (for e.g. when you're using OpenWRT), just make sure to redirect the DNS name to your router IP and setup a local NTP server.

In OpenWRT you can configure this with:

/etc/config/firewall:

config rule
	option enabled '1'
	option src 'lan'
	option name 'Block HS110'
	option src_mac '00:00:00:00:00:00'
	option dest 'wan'
	option target 'REJECT'

/etc/config/dhcp:

config domain
	option name 'fr.pool.ntp.org'
	option ip '10.1.1.1'

Development

Show debugging output

For some reason Ctrl-C is not working, workaround:

docker run --rm -it --name=hs100tomqtt dersimn/hs100tomqtt --mqtt-retain=false -m mqtt://MQTT_IP -v debug
Ctrl-P Ctrl-Q
docker stop hs100tomqtt

Manually build

docker build -t hs100tomqtt .
docker build -t hs100tomqtt:armhf -f Dockerfile.armhf .

Credits

This project follows Oliver "owagner" Wagner's architectural proposal for an mqtt-smarthome.
Built by copy-pasting together Sebastian "hobbyquaker" Raff's mqtt-smarthome scripts and Patrick "plasticrake" Seal's tplink-smarthome-api.

hs100tomqtt's People

Contributors

dersimn avatar

Watchers

 avatar

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.