Comments (2)
There is no way currently to specify more than one plug ip but you could startup multiple containers pointing to different plugs and then send the netcat call to each?
For Example:
docker run -d -p 127.0.0.1:9000:9000 \
-e PLUG_IP='192.168.86.16' \
--name some_name snipzwolf/hs100-api-endpoint
docker run -d -p 127.0.0.1:8000:9000 \
-e PLUG_IP='192.168.86.17' \
--name some_name snipzwolf/hs100-api-endpoint
Another option if your familar with javascript/node would be to modifiy https://github.com/Snipzwolf/hs100-api-endpoint/blob/master/src/server.js to accept the ip being passed in when you send the command, i havn't tested it but i think something like this change could work while keeping the old behviour by default.
function onConnData(d) {
console.log('connection data from %s: %j', remoteAddress, d);
var dataArr = d.split(' ');
const plug = client.getPlug({host: data[1] || process.env.PLUG_IP});
const res = plug.setPowerState((data[0].trim().toLowerCase() === 'true'));
//console.log(res);
conn.write("done");
}
you could then change your nc commands to this
/usr/bin/echo "true 192.168.86.16" | /usr/bin/nc 127.0.0.1 9999
/usr/bin/echo "true 192.168.86.17" | /usr/bin/nc 127.0.0.1 9999
I'm actually not sure why i included the -q command to be honest it's been a while and i actually had to lookup what it did, possibly while debugging it i occassionally had hung requests and just ended up including it in the example without thinking.
from hs100-api-endpoint.
Hey awesome ! I tried the first option creating for each device one docker container. Works. However having more than five devices gets quite complicated. I will try fiddling around with option two. Thank you very much for your help. Thanks !
from hs100-api-endpoint.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hs100-api-endpoint.