Open mareknbg opened 10 years ago
Your curl is correct for creating the blink1 subdevice. Did you run npm install skynet-blink1 on the hub?
If your blink1 is connected to your MAC and you are running the blink1 API server is enabled, try the following:
set the ipAddress in options to 127.0.0.1 (localhost) add a port field in options set to the default port for the Blink1 API server.
Let us know if that works.
@chrismatthieu yes of course I did run npm on the hub. @kmariano yes thank you, I've tried everything but the ipAddres makes no sense for me because my blink1 is connected to my iMac and not to my hub. Furthermore the messageSchema is an object with just two properties (on, rgb) and there is no port property.
Where there any changes in the Mac settings? e.g. firewall, etc. (in addition: I can connect my blink1 from IFTTT)
@kmariano sorry but I mean optionsSchema not messageSchema and there is only one property ipAddress with no port property
Blink1 defaults to port 8934. Perhaps we should add this to the options schema and default them.
The cool thing about the Blink1 is that you could plug it into any machine on your network (not necessarily the one running the hub). The hub needs to know its IP address for the REST API calls.
Our plugin currently only supports on/off and color changing - not patterns (yet).
Once you have the hub running with the blink1 subdevice installed, you should be able to send it messages via javascript commands over skynet. Try going to http://skynet.im/jsconsole and open your developer console and type:
conn.message({ "devices": ":yourHubsUUID/blink1iMac", "payload": {"on": true, "rgb": "#FFFFFF"} }, function(result){console.log('data',result)});
You should not need to change any firewall settings. Our hub uses websockets.
On the jsconsole I see this: Connection {_events: Object, _maxListeners: undefined, _callbackHandlers: Object, _ackId: 11, options: Object…} data Object {error: "timeout 10000"}
@chrismatthieu Because I still cannot send any messages to my blink1 through skynet, I wanted to specify the facts.
The blink1 is connected to my iMac (10.0.1.80). I downloaded Blik1Control v1.91 (Blink1Control-mac.zip) from https://github.com/todbot/blink1/releases and started Blik1Control API Server. On the iMac I opened a terminal and put in the following command: netstat -a | grep 8934 I received this: tcp4 0 0 localhost.8934 . LISTEN
That means that the Blink1Control-Webserver is now bounded to the localhost interface. That means again that this webserver cannot be accessible from the outside.
My Hub(gateblu) runs on a different computer (in my case a RaspberryPi). As described I created a sub device "blink1iMac" und installed the skynet-blink1 plugin. I can find the sub device entry "blink1iMac" in subdevices.db:
{"uuid":"70e85858-1f56-49f9-953c-xxxxxxxx","name":"blink1iMac","type":"skynet-blink1","options":{"ipAddress":"10.0.1.80"},"_id":"Fqxcapa9tSQtCqjl"}
When I send a message through skynet to the sub device "blink1iMac“, skynet sends a message to my Hub. In subdevices.db my Hub finds the sub device entry "blink1iMac" with my iMac’s IP address (where my blink1 ist connected). In your skynet-blink1 plugin (index.js) the attempt is being made to connect to the Blink1Control-Webserver:
request.get('http://' + this.options.ipAddress + ':8934/blink1/fadeToRGB', {qs: {'rgb': color}} , function (error, response, body) { console.log(body); });
this part "this.options.ipAddress" is going to be replaced by the IP address from subdevices.db and the request looks in the end like this:
request.get('http://10.0.1.80:8934/blink1/fadeToRGB', {qs: {'rgb': color}} , function (error, response, body) { console.log(body); });
And this kind of request is not possible. Blink1Control-Webserver is not bounded to the interface "10.0.1.80" but "localhost" (on my iMac).
Did you maybe modified the Blink1Control software by yourself? Maybe I’m doing something wrong but I think that you can just connected blink1 through the Hub only when both are on the same computer.
Markus
Wow! You are right. Blink1 doesn't seem to allow calls other than localhost via the API.
This works: http://127.0.0.1:8934/blink1/fadeToRGB?rgb=%23ffffff
This does not work: http://192.168.112.21:8934/blink1/fadeToRGB?rgb=%23ffffff
After reviewing their interface, it looks like this may be locked down by ThingM for security reasons. Further research will be required.
I cannot connect to my Blink1. The Blink1 API server is on and I have created a subdevice with this curl command:
curl -X POST http://ipAddres-of-my-hub:8888/subdevices -H "Content-Type: application/json" -d '{"name":"blink1iMac", "type":"skynet-blink1", "options":{"ipAddress":"ipAddress-of-my-iMac"}}'
After I have send a message to my Blink1 I found this in hub/hub.log:
matching subdevice found: blink1iMac blink1 data { payload: { on: true, rgb: '#3696F7' }, devices: 'uuid-of-my-hub', subdevice: 'blink1iMac', fromUuid: 'uuid-of-my-nodeblu', timestamp: '2014-08-09T08:14:13.596Z', eventCode: 300, _id: '53e5d85531cc8c9d7bcebcf9' } response undefined error { [Error: connect ECONNREFUSED] code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect' } undefined
Should I do something else?