WebThingsIO / gpio-adapter

GPIO adapter add-on for WebThings Gateway
Mozilla Public License 2.0
5 stars 12 forks source link

Add config schema. #16

Closed mrstegeman closed 6 years ago

dhylands commented 6 years ago

Not sure if this is a problem with this schema or the config stuff in general (more likely). If I click the X to remove gpio 18 and then press + to add one, it gives me an error:

Errors
    .gpios[0].pin is a required property 
mrstegeman commented 6 years ago

@dhylands Fixed here: https://github.com/mozilla-iot/gateway/pull/831

This PR doesn't require any changes.

mrstegeman commented 6 years ago

@dhylands Please try again.

dhylands commented 6 years ago

I followed a similar procedure as with the serial-adapter, getting the output of config-editor.py gpio-adapter to look like:

{
  "gpios": {
    "18": {
      "direction": "out",
      "name": "led",
      "value": 0
    }
  }
}

In order to get the gpio-adapter to try and load on my linux host (rather than trying on the RPi), I checkedout PR 16 and then edited index.js and commented out these lines: https://github.com/mozilla-iot/gpio-adapter/blob/2bf703eb9a6c5c109dcb303c4e7f47580cc478ce/index.js#L20-L25

and then when I enabled the gpio-adapter I got a similar stack crawl as to the one in the serial-adapter:

2018-04-04 15:03:44.724 gpio: Opening database: /home/dhylands/Dropbox/moziot/.mozilla-iot/config/db.sqlite3
2018-04-04 15:03:44.740 gpio: Loading add-on for gpio-adapter from /home/dhylands/Dropbox/moziot/.mozilla-iot/addons/gpio-adapter
2018-04-04 15:03:44.817 gpio: /home/dhylands/Dropbox/moziot/gateway/node_modules/gateway-addon/node_modules/sqlite3/lib/trace.js:27
2018-04-04 15:03:44.817 gpio:                     throw err;
2018-04-04 15:03:44.817 gpio:                     ^
2018-04-04 15:03:44.818 gpio: 
2018-04-04 15:03:44.818 gpio: TypeError: Cannot read property 'value' of undefined
2018-04-04 15:03:44.818 gpio:     at Statement.conn.get (/home/dhylands/Dropbox/moziot/gateway/node_modules/gateway-addon/lib/database.js:98:41)
2018-04-04 15:03:44.818 gpio: --> in Database#get('SELECT value FROM settings WHERE key = ?', [ 'addons.gpio-adapter' ], [Function])
2018-04-04 15:03:44.818 gpio:     at Promise (/home/dhylands/Dropbox/moziot/gateway/node_modules/gateway-addon/lib/database.js:91:17)
2018-04-04 15:03:44.818 gpio:     at new Promise (<anonymous>)
2018-04-04 15:03:44.818 gpio:     at Database.loadConfig (/home/dhylands/Dropbox/moziot/gateway/node_modules/gateway-addon/lib/database.js:90:12)
2018-04-04 15:03:44.818 gpio:     at loadGpioAdapter (/home/dhylands/Dropbox/moziot/.mozilla-iot/addons/gpio-adapter/gpio-adapter.js:207:18)
2018-04-04 15:03:44.818 gpio:     at maybeLoadGpioAdapter (/home/dhylands/Dropbox/moziot/.mozilla-iot/addons/gpio-adapter/index.js:28:10)
2018-04-04 15:03:44.818 gpio:     at pluginClient.register.then (/home/dhylands/Dropbox/moziot/gateway/src/addon-loader.js:81:7)
2018-04-04 15:03:44.818 gpio:     at <anonymous>
2018-04-04 15:03:44.818 gpio:     at process._tickCallback (internal/process/next_tick.js:188:7)
2018-04-04 15:03:44.820 Plugin: gpio-adapter died, code = 1 restarting...
dhylands commented 6 years ago

This problem seems to be cause by the plugin trying to use a database from ~/.mozilla-iot when my profileDir is set like:

profileDir: `${home}/Dropbox/moziot/.mozilla-iot`,

If make ~/.mozilla-iot be a symlink to the real location then this problem goes away