Comments (18)
I think the easiest route would be to install the hub shell plugin: npm install skynet-gw-shell
Then there's a few ways to configure a subdevice, but a simple one is if you have a websocket
socket.emit('gatewayConfig', {
uuid: 'xxxxxx----my hub uuid----xxxxxx',
token: 'xxxx----my hub token----xxxx',
method: 'createSubdevice',
type: 'skynet-gw-shell',
name: 'tellstick',
options: {shellCommand: 'tdtool'}
}, function(results){ console.log(results); });
after that you can message the gatway:
socket.emit('message', {
devices: 'xxxxxx----my hub uuid----xxxxxx',
subdevice: 'tellstick',
payload: ['--on', '1']
});
from meshblu.
Thank you. I'm looking forward to getting it working.
from meshblu.
Just trying the websocket. Is the socket I connect to, the hub socket? (8889 in my case) or the local copy of skynet.im (3000) ?
I tried the following code. There are no errors but I think its because its not connecting at all.
var io = require('socket.io-client')
socket = io.connect('raspberrypi', {
port: 8889
});
socket.on('connect', function(){
console.log('Requesting websocket connection to SkyNet');
socket.on('identify', function(data){
console.log('Websocket connecting to SkyNet with socket id: ' + data.socketid);
console.log('Sending device uuid');
socket.emit('identity', {uuid: 'xxxxxxxxxxxxxxxxxx0b1', socketid: data.socketid, token: 'xxxxxxxxxxxxxxxxxx287'});
});
socket.on('notReady', function(data){
if (data.status == 401){
console.log('Device not authenticated with SkyNet');
}
});
socket.on('ready', function(data){
if (data.status == 201){
console.log('Device authenticated with SkyNet');
// Send/Receive messages
socket.emit('gatewayConfig', {
uuid: 'xxxxxxxxxxxxxxxxxxxxx0b1',
token: 'xxxxxxxxxxxxxxxxxxxx287',
method: 'createSubdevice',
type: 'skynet-gw-shell',
name: 'tellstick',
options: {shellCommand: 'tdtool'}
}, function(results){ console.log(results); });
}});
});
from meshblu.
You need to connect to skynet (port 3000).
from meshblu.
Had to give up in the end. Couldn't get it to work at all :(
from meshblu.
We just pushed an update that lets you deploy SkyNet without Redis or MongoDB! Could you try to pull the code again and remove the redis and mongo sections from your config.js and re-run? Note: you will need to also run npm install before running.
from meshblu.
Thanks for the update. I will give it a try this evening.
from meshblu.
"We just pushed an update that lets you deploy SkyNet without Redis or MongoDB! Could you try to pull the code again and remove the redis and mongo sections from your config.js and re-run? Note: you will need to also run npm install before running."
I did a fresh install as above and removed redis and mongo from the config. Still having issue either getting the hub on the Pi to communicate with skynet on my Pi and registering a subdevice so that I can issue commands to turn things on/off for home automation.
-
The hub has its own UUID and token. Are these registered on skynet.im or are they registered on my local version running on the pi?
-
Is there a command such as curl to registered the subdevice and the parameters to turn on/off device. Trying through a websocket, I'm either doing it wrong not understanding the correct way of doing it.
I think once I have one subdevice configured and active, adding more should be easier
- Or is there a way to do all of this either through NodeBlu or Octoblu?
Thanks
from meshblu.
Might have been a bit of confusion here.
If you simply want to add a subdevice to your hub, I've added a clarification to the hub documentation on how to do that with a curl command: https://github.com/skynetim/hub
from meshblu.
Thanks. With your help managed to add the subdevice using curl and its now appearing under the subdevices on the hub. Whats is the easiest way to send a message to the subdevice to check its receiving it correctly?
from meshblu.
There's several ways to talk to it. All you need to make sure is that your message has a subdevice property.
You might want to give it a shot with NodeBlu: https://chrome.google.com/webstore/detail/nodeblu/aanmmiaepnlibdlobmbhmfemjioahilm
Just need an inject button, then a javascript function block that adds the correct subdevice name to the msg object, then finally output to a skynet block that has the uuid of your hub.
from meshblu.
Here's an example screenshot of using NodeBlu for this purpose: http://azprogrammer.com/nodeblu.png
from meshblu.
My hub subdevices are set up as follows:
Skynet Gateway Sub-devices
Name Plugin Type Options remove
greeting skynet-greeting [object Object] X
living_Room_Lights skynet-gw-shell [object Object] X
I created the following function as in the screenshot
msg.subdevice = 'living_Room_Lights';
msg.payload = {
setState: {'--on', '2'}
};
return msg;
And then the command should run as tdtool --on 2 (this should turn a powersocket on)
In Nodeblue, it shows this
{"topic":"","payload":"--on 2","subdevice":"living_Room_Lights"}
and then followed by
{"topic":"","payload":{"error":"request timeout"},"subdevice":"living_Room_Lights","devices":["xxxxx-my UUID-xxxxxxx"]}
I'm getting close but still not there yet.
from meshblu.
Uncheck the forward response checkbox in nodeBlu. The hub shell plugin doesn't return anything when called.
Also I think they payload can just be:
msg.payload = ['--on', '2'];
you might want to connect a debug node directly to the output of your javascript function as well as the skynet output block
from meshblu.
Excellent. Thanks both your suggestions worked and now able to turn on and off powersockets.
If I want to run this outside of my LAN, is it just port 8888 that needs to be enabled and this will allow nodeblu to communicate with the Hub on my Pi?
from meshblu.
Sorry. Also how to get the Hub to send a message back if the On/Off was successful or not?
from meshblu.
You shouldn't need to do any port forwarding at all. As long as the hub is connected to skynet and you know its uuid, you can message it from anywhere.
The current shell plugin is pretty basic and doesn't do anything with the out of the shell command. In order to get it to return a result, you'd likely need to write a custom plugin. Other plugins such as the skynet-hue do give responses on commands.
You could however call the greeting plugin just to make sure that the gateway is up and running.
from meshblu.
Thanks for all your help and support :)
from meshblu.
Related Issues (20)
- Help!!! Can not get message when i run meshblu on ubuntu14.04 x64 HOT 2
- Send/Receive messages HOT 5
- Cross-protocol send/Receive messages
- About unifying APIs for all protocols HOT 2
- Retaining messages HOT 1
- TypeError: callback is not a function HOT 2
- config.token or environment variable TOKEN is required. Exiting. HOT 1
- Forwarder of webhook
- Provide a way to run core-dispatcher & protocol adapters
- DispatcherWorker constructor is missing "@pepper on Ubuntu
- DispatcherWorker constructor is missing "@pepper
- meshblu.createConnection is not a function HOT 1
- Issues about "update" API in WebSocket / HTTP protocol with Meshblu 4.0.1 HOT 1
- Issues about "broadcast message" in WebSocket with Meshblu 4.0.1
- Issues about "subscribe" API in WebSocket with Meshblu 4.0.1 HOT 1
- Add optional support for Socket.io and Websockets
- Cannot receive message using "message.received" subscription
- Can get Devices use regex? HOT 1
- How to improve the amount of concurrency per second about Meshblu
- localhost 拒绝了我们的连接请求
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 meshblu.