Giter Club home page Giter Club logo

Comments (18)

monteslu avatar monteslu commented on September 28, 2024

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.

gadgethome avatar gadgethome commented on September 28, 2024

Thank you. I'm looking forward to getting it working.

from meshblu.

gadgethome avatar gadgethome commented on September 28, 2024

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.

 avatar commented on September 28, 2024

You need to connect to skynet (port 3000).

from meshblu.

gadgethome avatar gadgethome commented on September 28, 2024

Had to give up in the end. Couldn't get it to work at all :(

from meshblu.

 avatar commented on September 28, 2024

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.

gadgethome avatar gadgethome commented on September 28, 2024

Thanks for the update. I will give it a try this evening.

from meshblu.

gadgethome avatar gadgethome commented on September 28, 2024

"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.

  1. 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?

  2. 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

  1. Or is there a way to do all of this either through NodeBlu or Octoblu?

Thanks

from meshblu.

monteslu avatar monteslu commented on September 28, 2024

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.

gadgethome avatar gadgethome commented on September 28, 2024

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.

monteslu avatar monteslu commented on September 28, 2024

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.

monteslu avatar monteslu commented on September 28, 2024

Here's an example screenshot of using NodeBlu for this purpose: http://azprogrammer.com/nodeblu.png

from meshblu.

gadgethome avatar gadgethome commented on September 28, 2024

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.

monteslu avatar monteslu commented on September 28, 2024

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.

gadgethome avatar gadgethome commented on September 28, 2024

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.

gadgethome avatar gadgethome commented on September 28, 2024

Sorry. Also how to get the Hub to send a message back if the On/Off was successful or not?

from meshblu.

monteslu avatar monteslu commented on September 28, 2024

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.

gadgethome avatar gadgethome commented on September 28, 2024

Thanks for all your help and support :)

from meshblu.

Related Issues (20)

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.