Closed grantalewis closed 6 years ago
I will try and get this accepted into the hassio community addon repository, but it may take 2 or 3 weeks until I can actually work on that (exams are keeping me busy).
Sorry to keep you waiting!
Thanks!
@mKeRix You don't have to get it listed in any specific repository, you can create your own config.json file in this github repo and we can utilize it directly.
https://home-assistant.io/developers/hassio/addon_development/
I spent a couple hours trying to figure this out today - and I still haven't got it working. I think my new Dockerfile should be correct for Hass.io usage, but I'm running into issues with the node dependencies. Some libraries won't compile in the alpine containers and I can't seem to find the missing libraries.
I have to put this on ice for a while, I'll take another look at this in the future. My current idea is moving away from the alpine base images proposed by all the examples, because then I can get around all the dependency issues. Or someone else with more hass.io know-how comes along. Sorry. :(
Is there any code in this repo we can use for further trying?
@escoand I just uploaded my local stash to the hassio
branch: https://github.com/mKeRix/room-assistant/tree/hassio
Got it working: https://github.com/mKeRix/room-assistant/pull/50
Nice! Great work!
Quick update: I sat down and played with this stuff for a bit, but currently I'm stuck at an issue with Travis - the arm images get stuck in the build process (just freeze, no error).
It works locally though, so possibly I'll just have to complete the hass.io images manually.
Any update on the progress of this? I'd love to get room assistant running on my pi 3 as well, since I've already got the hardware and it would free up a pi zero for a different room.
It's already working. Download the hassio branch, put it in a subdirectory of addons and remove the line with "image". Then you should see the room-assistant add-on in the web interface.
It took me a little searching to find the right line to remove. It's in the base directory config.json file, here.
@mKeRix would it be okay to make a pull request against the readme.md file for this branch? I would be happy to add it as a sub-section, unless there are imminent plans for publishing.
Yes, I've feared it wasn't exactly enough but it was late and I was tired. :-) Good that you were able to find it after all...
After some digging I found the issue blocking the armhf and aarch64 builds before and managed to push out a release manually today. A dependency we used didn't continue their versioning correctly, so to get an updated working version I had to pull directly from their git page.
I created a repository for my builds here: https://github.com/mKeRix/hassio-repo - if people could test it and let me know if it works for them (and on which hardware) that would be awesome :)
Once I have the time to get the automatic releases working and clean up I will make this add-on official. Thanks for all the help & wait guys :)
I've error messages when enabling ble scanning on RPi3 (armhf):
module.js:538
throw err;
^
Error: Cannot find module '../build/Release/binding.node'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/room-assistant/node_modules/bluetooth-hci-socket/lib/native.js:3:15)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
I could reproduce the error, but unfortunately now I'm back to the issue I've had before (can also be seen on the latest Travis CI build). Despite no changes to the files since the last successful compilation the builds for armhf and aarch64 are now stuck at the the node-gyp configure stage for the usb module. :/
Where do they build the official addons? Maybe there we can have a look how they do it...
Can you please remove the image parameter of the config.json in the repo in the meanwhile? So everybody is able to install it by compiling locally.
Forget about it, its not working without all the other files...
Just a quick update: I've just started rewriting room-assistant from scratch, since the current code is somewhat messy. Hopefully I'll be able to fix these Hass.io issues on the way!
I'm not much familiar with node.js but is it really necessary to have nearly 600MB for just so less functionality?
REPOSITORY TAG IMAGE ID CREATED SIZE
mkerix/room-assistant latest-rpi 79837e848605 2 months ago 579MB
No, definitely not - that image still utilizes old build processes that I want to redo in the new version. The hass.io versions of the image are around 100MB big, which is much more reasonable.
Speaking of which: I deployed a new version of room-assistant to my Hass.io repository! It uses my new rewritten software, which already includes console, mqtt, ble and ibeacon functionality. It installs and runs fine on my Hass.io Raspberry, but I don't have a Bluetooth antenna to check whether the ble output runs correctly. Could anybody help me test this?
Use this repo: https://github.com/mKeRix/hassio-repo
Configuration is similar and mostly self explanatory name wise. Only important change you have to note is that instead of putting "enabled": true
everywhere you now need to specify the components you want in the services array, e.g. ["console", "mqtt", "ble"]
. The ibeacon component has been merged into the ble component.
Note: Be patient when room-assistant is starting, it's installing dependencies for the modules you activated in the background. As long as Hass.io shows it is running everything is fine. I built a cache system that skips installations after the first start, but unfortunately that does not seem to be working on Hass.io yet.
EDIT: The builds are updated to also support shell commands and gpio, although those will probably not be of much use on Hass.io. Overall I'm quite happy with the current state, I will test drive this at home for a bit and do some clean up work, then the new version should be ready for release. Only feature left to be implemented from my point of view are the regular Docker files.
Hi!
Also looking to try this out on Hassio (running rpi model 3). Running into 2 seemingly unrelated issues:
On the repo: I cannot add it as the schema in config file appears to be wrong:
WARNING (MainThread) [hassio.addons.data] Can't read /data/addons/git/6e66619d/room-assistant/config.json: expected string or buffer @ data['schema']['gpio']['ports'][0]. Got {'channel': 'str', 'pin': 'int', 'retain': 'bool?'}
expected string or buffer @ data['schema']['shell']['commands'][0]. Got {'channel': 'str', 'command': 'str', 'cron': 'str', 'regexp': 'str?', 'number': 'bool?', 'retain': 'bool?'}
Building as local repo with removed schema also has issues:
gyp ERR! System Linux 4.4.50
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/room-assistant/node_modules/usb/src/binding/usb_bindings.node" "--module_name=usb_bindings" "--module_path=/room-assistant/node_modules/usb/src/binding" "--napi_version=1" "--node_abi_napi=napi"
gyp ERR! cwd /room-assistant/node_modules/usb
gyp ERR! node -v v8.9.3
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/room-assistant/node_modules/usb/src/binding/usb_bindings.node --module_name=usb_bindings --module_path=/room-assistant/node_modules/usb/src/binding --napi_version=1 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/room-assistant/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:126:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:214:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:925:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
node-pre-gyp ERR! System Linux 4.4.50
node-pre-gyp ERR! command "/usr/bin/node" "/room-assistant/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /room-assistant/node_modules/usb
node-pre-gyp ERR! node -v v8.9.3
node-pre-gyp ERR! node-pre-gyp -v v0.10.3
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/room-assistant/node_modules/usb/src/binding/usb_bindings.node --module_name=usb_bindings --module_path=/room-assistant/node_modules/usb/src/binding --napi_version=1 --node_abi_napi=napi' (1)
> bluetooth-hci-socket@0.5.1 install /room-assistant/node_modules/bluetooth-hci-socket
> node-gyp rebuild
make: Entering directory '/room-assistant/node_modules/bluetooth-hci-socket/build'
CXX(target) Release/obj.target/binding/src/BluetoothHciSocket.o
../src/BluetoothHciSocket.cpp: In member function 'void BluetoothHciSocket::poll()':
../src/BluetoothHciSocket.cpp:251:95: warning: 'v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, v8::Local<v8::String>, int, v8::Local<v8::Value>*)' is deprecated [-Wdeprecated-declarations]
Nan::MakeCallback(Nan::New<Object>(this->This), Nan::New("emit").ToLocalChecked(), 2, argv);
^
In file included from ../src/BluetoothHciSocket.cpp:8:0:
../../nan/nan.h:950:46: note: declared here
NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
^~~~~~~~~~~~
../src/BluetoothHciSocket.cpp: In member function 'void BluetoothHciSocket::emitErrnoError()':
../src/BluetoothHciSocket.cpp:275:72: warning: 'v8::Local<v8::Object> v8::Function::NewInstance(int, v8::Local<v8::Value>*) const' is deprecated: Use maybe version [-Wdeprecated-declarations]
Local<Value> error = errorConstructor->NewInstance(1, constructorArgs);
^
In file included from /root/.node-gyp/8.9.3/include/node/v8.h:26:0,
from /root/.node-gyp/8.9.3/include/node/node.h:63,
from /root/.node-gyp/8.9.3/include/node/node_buffer.h:25,
from ../src/BluetoothHciSocket.cpp:7:
/root/.node-gyp/8.9.3/include/node/v8.h:3832:31: note: declared here
Local<Object> NewInstance(int argc, Local<Value> argv[]) const);
^
/root/.node-gyp/8.9.3/include/node/v8config.h:318:3: note: in definition of macro 'V8_DEPRECATED'
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
../src/BluetoothHciSocket.cpp:282:93: warning: 'v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, v8::Local<v8::String>, int, v8::Local<v8::Value>*)' is deprecated [-Wdeprecated-declarations]
Nan::MakeCallback(Nan::New<Object>(this->This), Nan::New("emit").ToLocalChecked(), 2, argv);
^
In file included from ../src/BluetoothHciSocket.cpp:8:0:
../../nan/nan.h:950:46: note: declared here
NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
^~~~~~~~~~~~
SOLINK_MODULE(target) Release/obj.target/binding.node
COPY Release/binding.node
make: Leaving directory '/room-assistant/node_modules/bluetooth-hci-socket/build'
> epoll@2.0.1 install /room-assistant/node_modules/epoll
> node-gyp rebuild
make: Entering directory '/room-assistant/node_modules/epoll/build'
CXX(target) Release/obj.target/epoll/src/epoll.o
SOLINK_MODULE(target) Release/obj.target/epoll.node
COPY Release/epoll.node
make: Leaving directory '/room-assistant/node_modules/epoll/build'
npm WARN moleculer-cron@0.0.2 requires a peer of moleculer@^0.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN moleculer-web@0.8.0 requires a peer of moleculer@>= 0.13.0 but none is installed. You must install peer dependencies yourself.
npm WARN room-assistant@1.0.0 No repository field.
npm WARN room-assistant@1.0.0 No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: xpc-connection@0.1.4 (node_modules/xpc-connection):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for xpc-connection@0.1.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: usb@1.3.2 (node_modules/usb):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: usb@1.3.2 install: node-pre-gyp install --fallback-to-build
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
@MatsNl you can ignore the errors, the failing usb bindings module is optional.
As far as the schema goes: the current version in my Hass.io repo is running the rewritten alpha of room-assistant, which has a slightly different schema than described in the current README. I'm working on updating the configuration, until then here is an example for how you configure gpio and shell:
{
"gpio": {
"ports": [
{
"channel": "channel-to-post-in",
"pin": 4,
"retain": true
}
]
},
"shell": {
"commands": [
{
"channel": "channel-to-post-in",
"command": "echo abc",
"cron": "0 * * * * *",
"regexp": "optional-regex-syntax",
"number": false,
"retain": false
}
]
}
}
The explanation for the options can be found in the current docs mostly, as the logic is similar. Only differences are that GPIO does not need to be polled anymore (reacts on changes automatically) and shell commands run using a cron schema with 6 stars (so * on each would mean every second). The GPIO component now also uses different pin numbering (BCM).
I fixed the schema issue, but currently pushes to Docker Hub from the branches are disabled. Until I release the official beta could you please grab the rewrite
branch and build it locally? :)
No luck, when I press start once addon is installed, nothing happens and the config resets to default (empty) config.
also, gpio requires [""], otherwise the schema throws an error (i.e. cannot save, config not valid)
any suggestions? :)
Could you try re-adding my repo from above and trying the new image that should be available now? I re-enabled pushes for my alpha version and disabled the schema checks Hass.io does because they seem problematic together with the config schema we use. At least on my local raspi it worked when I checked it quickly.
Same issues, maybe the images arent refreshed before version number is incremented? I still get the config reset and error on gpio, also after deleting and reinstalling everything.. (actually did the re-add twice :) ) Any other thoughts?
after filling config, save, start, it returns to this:
not a valid value for dictionary value @ data['options']. Got {'services': [], 'room': 'default-room', 'mqtt': {'url': 'mqtt://localhost', 'username': '', 'password': '', 'rejectUnauthorized': True}, 'ble': {'channel': 'room_presence', 'useAddress': False, 'whitelist': [], 'maxDistance': 0, 'updateFrequency': 0, 'processIBeacon': True, 'onlyIBeacon': False, 'majorMask': '0xFFFF', 'minorMask': '0xFFFF'}, 'gpio': [], 'shell': []}
and then after putting [""] for gpio:
18-07-10 22:17:15 INFO (SyncWorker_15) [hassio.docker.interface] Remove docker mkerix/room-assistant-armhf with latest and 1.0.0-alpha
18-07-10 22:17:18 INFO (MainThread) [hassio.addons.addon] Remove Home-Assistant addon data folder /data/addons/data/6e66619d_room-assistant
18-07-10 22:17:54 INFO (MainThread) [hassio.addons.git] Remove custom addon repository https://github.com/mKeRix/hassio-repo
18-07-10 22:20:05 INFO (MainThread) [hassio.addons] Load addons: 62 all - 0 new - 1 remove
18-07-10 22:21:08 INFO (MainThread) [hassio.addons.git] Clone addon https://github.com/mKeRix/hassio-repo repository
18-07-10 22:21:11 INFO (MainThread) [hassio.addons] Load addons: 63 all - 1 new - 0 remove
18-07-10 22:21:23 INFO (MainThread) [hassio.addons.addon] Create Home-Assistant addon data folder /data/addons/data/6e66619d_room-assistant
18-07-10 22:21:23 INFO (SyncWorker_18) [hassio.docker.interface] Pull image mkerix/room-assistant-armhf tag 1.0.0-alpha.
18-07-10 22:24:50 INFO (SyncWorker_18) [hassio.docker.interface] Tag image mkerix/room-assistant-armhf with version 1.0.0-alpha as latest
18-07-10 22:28:26 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 378, in start
resp = await self._request_handler(request)
File "/usr/lib/python3.6/site-packages/aiohttp/web_app.py", line 341, in _handle
resp = await handler(request)
File "/usr/lib/python3.6/site-packages/aiohttp/web_middlewares.py", line 88, in impl
return await handler(request)
File "/usr/lib/python3.6/site-packages/hassio/api/security.py", line 56, in token_validation
return await handler(request)
File "/usr/lib/python3.6/site-packages/hassio/api/utils.py", line 33, in wrap_api
answer = await method(api, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/hassio/api/addons.py", line 156, in options
body = await api_validate(addon_schema, request)
File "/usr/lib/python3.6/site-packages/hassio/api/utils.py", line 92, in api_validate
data = schema(data)
File "/usr/lib/python3.6/site-packages/voluptuous/schema_builder.py", line 267, in __call__
return self._compiled([], data)
File "/usr/lib/python3.6/site-packages/voluptuous/schema_builder.py", line 587, in validate_dict
return base_validate(path, iteritems(data), out)
File "/usr/lib/python3.6/site-packages/voluptuous/schema_builder.py", line 379, in validate_mapping
cval = cvalue(key_path, value)
File "/usr/lib/python3.6/site-packages/voluptuous/validators.py", line 204, in _run
return self._exec(self._compiled, value, path)
File "/usr/lib/python3.6/site-packages/voluptuous/validators.py", line 249, in _exec
return func(path, v)
File "/usr/lib/python3.6/site-packages/voluptuous/schema_builder.py", line 769, in validate_callable
return schema(data)
File "/usr/lib/python3.6/site-packages/voluptuous/schema_builder.py", line 267, in __call__
return self._compiled([], data)
File "/usr/lib/python3.6/site-packages/voluptuous/validators.py", line 204, in _run
return self._exec(self._compiled, value, path)
File "/usr/lib/python3.6/site-packages/voluptuous/validators.py", line 282, in _exec
v = func(path, v)
File "/usr/lib/python3.6/site-packages/voluptuous/schema_builder.py", line 769, in validate_callable
return schema(data)
File "/usr/lib/python3.6/site-packages/hassio/addons/validate.py", line 214, in validate
options[key] = _nested_validate_list(typ[0], value, key)
File "/usr/lib/python3.6/site-packages/hassio/addons/validate.py", line 275, in _nested_validate_list
c_options = _nested_validate_dict(typ, element, key)
File "/usr/lib/python3.6/site-packages/hassio/addons/validate.py", line 287, in _nested_validate_dict
for c_key, c_value in data_dict.items():
AttributeError: 'str' object has no attribute 'items'
My bad, I forgot to upload my changes to the hassio-repo last night... shouldn't have done it in a hurry, sorry. 😅 Removing the add on, readding the repository and then installing it again pulls everything completely new, at least according to the logs. Unfortunately I am now seeing a different issue: the command it is using to launch the container is incorrect. I am a bit limited today with testing/fixing, but I want to get all this fixed and a beta out tomorrow. So could you maybe wait a day before continuing? :)
Fyi: The Alpha images are available for regular Docker too now, under the rewrite and rewrite-arm32 tags!
Got it, another won't hurt I guess! 👍 Will try the new images on other Pis today then, and let you know if I run into anything
@MatsNl I actually found some additional time for debugging the Hass.io issue today and pushed a fix out. The version off my repo at least starts for me now. Would now appreciate any feedback on how GPIO and BLE services are running!
Cool,will give it a shot today! didn't have time yesterday unfortunately.
fyi, I 'm only able to test BLE in my setup
update- everything seems to be working! Scanning on hassio, regular raspbian and pizero raspbian now. Now to find out whether the mayor hassio freeze was due to roomassistant, if so there's some performance issue to be solved. Will let you know more later
Version 1.0 is officially out, including Hass.io support! 🎉
After spending today testing room-assistant across all the devices I have and making some final touches on the documentation I felt confident enough. :) If you find any issues let me know!
I'd love to try this out. Any thoughts on creating an add-on for Hass.io users?
https://home-assistant.io/hassio/installing_third_party_addons/