webthingsio / gateway Goto Github PK
View Code? Open in Web Editor NEWWebThings Gateway
Home Page: http://webthings.io/gateway
License: Mozilla Public License 2.0
WebThings Gateway
Home Page: http://webthings.io/gateway
License: Mozilla Public License 2.0
As a user I want to log into my gateway so that I can access it securely.
In the WoT draft the /actions
endpoint returns a JSON array of action objects (https://moziot.github.io/wot/#actions-resource). Currently /actions
returns a map from id to action object.
STR:
Expected:
Actual:
What's odd is that when you subsequently call AdapterManager.getDevices() the added device does have a name set.
As a web app developer I want to subscribe to events and property changes of Things hosted by the gateway using WebSockets so that I don't have to keep polling the server.
As a user I want to add additional users to my gateway so that multiple people can have access.
As a user I want to see a list of users who have access to the gateway
As a user I want to connect a device to the gateway so I can control it
Both ZigBee and ZWave use serial dongles. By default (under ubuntu) you need to be root or a member of the dialout group in order to open the serial port.
If the user doesn't have sufficient permissions then we should detect this and report a reasonable error. Currently we just report: ZWave: failed to start driver
As a user I want to see a list of new devices I can connect to
As a user I want to add a Web Thing by its URL, to be managed by my gateway.
This is for Web Things which use the direct integration pattern so provides its own Web Thing API but which the user might want to manage together with other Things using the gateway.
Currently the Add New Device dialog will appear to keep scanning for new devices forever.
We should add a timeout (at the adapter layer, the UI layer, or both) and close open websockets when we're done.
As a user I want to disconnect a Thing from the gateway when I no longer need it
As a user I want to turn a smart plug on and off
As a user I want to configure the web address used to access the gateway
During first time setup.
As a user I would like the API of my gateway to be authenticated so that only authenticated users can consume it.
Authenticate API calls (e.g. using JSON Web Tokens).
As a MozIoT web app developer I would like to be able to request a list of new devices which aren't yet added to the gateway.
In order for the web app to display a list of devices available on the network which can be added to the gateway, it needs to be able to get a list of devices from the adapter manager.
My suggestion would be:
AdapterManager.discoverDevices()
This method would return a Promise which resolves with a list of devices. E.g.
[{
id: '123e4567-e89b-12d3-a456-426655440000',
type: 'onOffSwitch',
name: ' Aeotec Smart Switch 6'
}]
My expectation is that behind the scenes this method would iterate through the list of adapters and initiate a protocol specific process for listing available devices (e.g. entering a pairing or commissioning mode). Ideally the actual pairing shouldn't take place with a further user interaction and a separate AdapterManager.pair(id) method.
As a user I want to see a list of devices connected to the gateway
During first time setup
As a Web Thing API consumer I want to get a Thing Description for a Thing via its Thing URL.
Original report:
If you do a get on /things, each thing has an href which looks like /things/:thingId, but if you do a GET on that there is no handler installed.
The ZWave controller will eventually mark a node as failed if it stops responding after a while. We need a way to tag these nodes as failed, and a way to call the Manager::RemoveFailedNode C++ API.
I think that this can be reproduced by adding a node and then factory resetting it. You can then add the node a second time, and the first nodeId will stick around and should eventually get marked as failed.
As a user I want to edit the name, email address or password of a user so that their details are up to date
As a user I want the option to stay logged in for a period of time after I close my browser so that I don't have to keep logging in every time I use the gateway.
Change properties, actions and events members of the Web Thing Description from arrays to objects, as specified in the latest Web Thing API draft https://moziot.github.io/wot/
As a MozIoT web app developer I would like to call a method to tell an adapter to pair a device with the gateway.
Suggestion:
AdapterManager.pair(id)
Returns a promise which resolves once pairing is successful, or errors with a timeout or error.
Need to make sure JSON responses use JSON MIME type.
As a user I want to know whether a smart plug is on or off
As a user I want to remove a user from the gateway so that they no longer have access
When installing the gateway on Rpi, npm installs the sqlite version 51 and the app wants to run version 46. Symlinking them seems to work, but we need to figure why the divergence occurs.
node-pre-gyp ERR! Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.8/node-v51-linux-arm.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v51 ABI) (falling back to source compile with node-gyp)
pi@vaani:~/wot/gateway $ sudo node app.js
module.js:327
throw err;
^
Error: Cannot find module '/home/pi/wot/gateway/node_modules/sqlite3/lib/binding/node-v46-linux-arm/node_sqlite3.node'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/pi/wot/gateway/node_modules/sqlite3/lib/sqlite3.js:4:15)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
pi@vaani:~/wot/gateway $ ls
adapter.js adapters controllers db.sqlite3 device.js models package.json static utils.js
adapter-manager.js app.js db.js deferred.js LICENSE node_modules README.md thing.py
pi@vaani:~/wot/gateway $ ls /home/pi/wot/gateway/node_modules/sqlite3/lib/binding/node-v46-linux-arm/
ls: cannot access /home/pi/wot/gateway/node_modules/sqlite3/lib/binding/node-v46-linux-arm/: No such file or directory
pi@vaani:~/wot/gateway $ ls /home/pi/wot/gateway/node_modules/sqlite3/lib/binding/
node-v51-linux-arm
STR:
Get error:
Listening at http://:::8088
Loading adapter ./adapters/foo.js
/home/tola/Code/moziot/gateway/adapters.js:43
adapter_manager.adapters.push(new adapter(adapter_manager));
^
TypeError: adapter is not a constructor
at file_list (/home/tola/Code/moziot/gateway/adapters.js:43:47)
at FSReqWrap.oncomplete (fs.js:123:15)
@dhylands Do you not see this error? Are you running test-server.js in a different way?
As a user I want to log out of my gateway so that nobody else can use it from this browsing session
In the GpioAdapter constructor (in adapters/gpio/gpio-adapter.js), should it also register itself with the Adapter Manager by calling this.manager.addAdapter(this); ?
As a user I want to view the current domain name/base web address of my gateway so I know how to securely access the gateway over the Internet
When I try to add a new device, I am seeing the following error in the node app. I can see the device listed in the website, but seems it's not being stored in the database, because doesn't appear in the main page (keeps showing a 'No devices yet.' message)
ZWave: node2 valueAdded: 50:Previous Reading -> 0.025
ZWave: node2 valueAdded: 50:Interval -> 70
Adapter: FooAdapter id Foo1 pairing cancelled
AdapterManager: About to resolve deferredAdd
Deferred: Resolving deferred promise id: 1 arg: { id: 'zwave-da95d8e6-2',
name: 'zwave-da95d8e6-2-Switch',
type: 'onOffSwitch',
properties: [ { name: 'on', type: 'boolean' } ] }
Error saving new thing Error: SQLITE_ERROR: no such table: things
Now we have integration tests for /things, but no integration test for the "remove thing" route. We should add a test for that.
If the openzwave library isn't available then the zwave adapter should detect this and not both scanning for dongles.
In writing a series of integration tests for the /actions
endpoint I've found that sending a POST /actions
with an invalid name (e.g. {name: "potato"}
) will reply with a 400 but still list the action in GET /actions
As a developer of the MozIoT web app front end I want to add a new thing to the gateway
We need an API call/calls which can be used to add a new thing to the gateway. This includes:
As a MozIoT web app developer I would like to call a method to tell an adapter to a set a property on a device.
Suggestion:
AdapterManager.setProperty(deviceId, propertyName, value)
returns a Promise which resolves once the property has been successfully set, perhaps with a representation of the new value.
My suggestion is that this can just be called on the AdapterManager directly (referencing the device ID) so that the web app doesn't necessarily need to care which adapter the Thing is connected to...
As a user I want to see a list of adapters active on the gateway so I can choose which ones to enable.
As we want to use the Adapters section to configure which Adapters are enabled, the latest UI mockups put the Adapters section inside the Settings section of the UI
Occasionally when I try to pair a device OpenZWave segfaults and takes down the Node process with it. So far I haven't been able to come up with reliable STR, it seems intermittent.
Eventually we'd like it to be possible to write adapters (e.g. ZigBee adapter, Z-Wave adapter) in different programming languages, have them run in their own process, and talk to them via some kind of IPC mechanism.
But for our initial NodeJS prototype we’ve discussed having some kind of uniform JavaScript interface for the web app to talk to adapters.
Based on the Web Thing REST API which will be a layer above this JavaScript API, my first thoughts on the what basic underlying features of the adapter layer might be are:
Adapter
Thing
Does this make sense? What have I missed?
As a user I want to reset my password when I've forgotten it
Now that we can add real adapters and Things we should remove the default dummy foo adapter and default Things.
If the app crashes while the zwave dongle is inclusion mode, and you then restart the app, the dongle seems to still be in a state where many devices will timout. I observed that my Leviton devices all got timeouts.
Unplugging and replugging the dongle seemed to resolve this.
We might need to do a controller (dongle) reset. Ideally we'd detect the state that the controller is in and get it out of that state, and only reset the controller if absolutely required.
Currently get/setPropertyValue are of the "fire and forget" variety. They should be changed to use promises.
For the ZigBee & ZWave, the stacks cache the last value so the get will always resolve right away, but that might not be the case for all adapters.
The set should send the command and resolve when the value changed is detected (or reject on a timeout or other error).
In Chrome on my linux desktop, if I browse to:
https://demo.box.knilxof.org:4443/
then I get the Blue background and "No devices yet."
If I browse to the same address using Chrome on my phone then it works.
Browsing to the same address using Firefox works fine (both desktop and phone).
Browsing to my local node server (https://192.168.0.24:4443/ - using a self-signed cert) works fine after doing the security exception (in Chrome/Firefox on desktop or phone)
As a user I want to assign a custom domain name to my gateway instead of/as well as using the tunnelling service provided by Mozilla with a free subdomain
As a user I want to reset my password because I've forgotten it
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.