Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuimo unable to connect to HA #6277

Closed
ouchkilljoys opened this issue Feb 27, 2017 · 27 comments
Closed

Nuimo unable to connect to HA #6277

ouchkilljoys opened this issue Feb 27, 2017 · 27 comments

Comments

@ouchkilljoys
Copy link

Home Assistant release (hass --version):
0.38.4

Python release (python3 --version):
3.4.2

Component/platform:
Nuimo Component
https://home-assistant.io/components/nuimo_controller/

Description of problem:
When using a Raspberry Pi 3 I'm unable to connect my nuimo to HA I tried with and without the mac address and I also ran the command to allow non sudo users to access bluetooth le.

Expected:
The Nuimo should connect to HA and display a home logo on the nuimo device.

Problem-relevant configuration.yaml entries and steps to reproduce:
nuimo_controller:
mac: OPTIONAL

@riker09
Copy link

riker09 commented Mar 9, 2017

I followed the official documentation from Scenic and was able to connect my Nuimo to my RPi3. Here's some output:

pi@hassbian:~ $ python nuimo.py AA:AA:AA:AA:AA:AA
Trying to connect to AA:AA:AA:AA:AA:AA. Press Ctrl+C to cancel.
Connected. Waiting for input events...
('ROTATION', 4)
('BUTTON', 1)
('BUTTON', 0)
('ROTATION', 100)
('ROTATION', 86)
('ROTATION', 51)
('ROTATION', 152)
('ROTATION', 99)
('ROTATION', 125)
('ROTATION', 146)
('ROTATION', 18)
('ROTATION', 255)
('ROTATION', 67)
('ROTATION', 52)
('ROTATION', 204)
('ROTATION', 90)
('ROTATION', -5)
('ROTATION', 200)
('BUTTON', 1)
('Connection error:', BTLEException())

[MAC address changed, since I'm paranoid. The exception was raised when the Nuimo moved out of range, I'm guessing.]

Now what? The official documentation from Home Assistant is - how should I put it? - scarce. Do I need to connect to my Nuimo before starting Home Assistant? Do I have to pair afterwards? So, technically speaking I'm "Unable to connect HA to Nuimo" (or vice versa).

A little bit more documentation would be very helpful and greatly appreciated. If I can pull it off and have my Nuimo control my lights (and possible sound/video as well) without having my smartphone around I could justify the purchase to my wife. ;)

Here's my config:

Home Assistant release (hass --version):
0.39.3

Python release (python3 --version):
3.4.2

[EDIT]
Maybe the library that is shipped with HA is outdated? Looking at the requirements.txt file I can see a reference to a commit from Sep. 2016. Is this what is installed when adding nuimo_controller: to the configuration.yaml? If so, would an upgrade make any difference? There was quite a lot movement in the scenic repo recently (v0.2.4!)
[/EDIT]

[EDIT2]
Doing more poking around. This is what the syslog has to say:

pi@hassbian:/srv/homeassistant $ sudo tailf /var/log/syslog | grep -i nuimo
Mar  9 22:27:46 hassbian hass[4292]: #033[32m17-03-09 22:27:46 INFO (Thread-4) [homeassistant.util.package] Attempting install of --only-binary=all http://github.com/getSenic/nuimo-linux-python/archive/29fc42987f74d8090d0e2382e8f248ff5990b8c9.zip#nuimo==1.0.0#033[0m
Mar  9 22:27:50 hassbian hass[4292]: #033[32m17-03-09 22:27:50 INFO (MainThread) [homeassistant.bootstrap] Setting up nuimo_controller#033[0m
Mar  9 22:27:50 hassbian hass[4292]: #033[32m17-03-09 22:27:50 INFO (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=nuimo_controller>#033[0m
Mar  9 22:27:50 hassbian hass[4292]: File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/nuimo_controller.py", line 89, in run
Mar  9 22:27:50 hassbian hass[4292]: File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/nuimo_controller.py", line 107, in _attach
Mar  9 22:27:50 hassbian hass[4292]: from nuimo import NuimoController, NuimoDiscoveryManager
Mar  9 22:27:50 hassbian hass[4292]: ImportError: No module named 'nuimo'

No module named 'nuimo' Interesting... But I have to catch up on some sleep.
[/EDIT2]

@ouchkilljoys
Copy link
Author

Well at least its not just me having the issue with it, I'm interested in what you come up with hopefully we can find a resolution for it as I'd love to use my nuimo in my home assistant setup.

@Charliedean
Copy link

Charliedean commented Mar 14, 2017

Okay so I'm also having major issues, but a bit closer then you guys. So i can start HA, have it connect to nuimo and also receive touchpad input, BUT as soon as i turn the ring, something seg faults and kills the HA service... I've been trying to debug it all evening and am getting worn out because i can't work out why and what on earth is segment faulting. If nothing comes of this i may try to re write it from scratch when i have time.

@ouchkilljoys
Copy link
Author

Damn, hopefully you won't have to do that, but I guess if there is no other option, just to update I tried it on 0.40 and still got the same issue.

@riker09
Copy link

riker09 commented Mar 19, 2017

@Charliedean Could you please elaborate on how you got closer? I'm still stuck at that I'm able to connect to my Nuimo controller with the demo script. But I still get ImportError: No module named 'nuimo'

I've updated Home Assistant to 0.40.1 (confirmed) and the Nuimo library to 0.3.1. At least I think I did. 😬

@riker09
Copy link

riker09 commented Mar 19, 2017

I've update my bluez library to 5.44 as the documentation of the Nuimo Python SDK states. This got rid of the errors I had when using

sudo nuimoctl --discover
sudo nuimoctl --connect XX:XX:XX:XX:XX:XX

Both commands yielded errors with stack trace etc. With bluez v5.44 those errors where gone (yay!).

But I'm unable to see my Nuimo controller from the web interface. Nothing related pops up in /var/log/syslog, everything seems to be fine. But how to I connect my Nuimo then? The official documentation is not clear here. I tried specifying the MAC address of my Nuimo, no luck. I tried auto discovery but it looks like nothing is ever discovered. Now I've reached a point where I'm basically stuck.

@riker09
Copy link

riker09 commented Mar 30, 2017

I've had another change to look at this issue. In my /var/log/syslog I was able to find some error lines while HA was setting up my Nuimo controller:

Mar 30 13:48:27 hassbian hass[5332]: Exception in thread None:
Mar 30 13:48:27 hassbian hass[5332]: Traceback (most recent call last):
Mar 30 13:48:27 hassbian hass[5332]: File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
Mar 30 13:48:27 hassbian hass[5332]: self.run()
Mar 30 13:48:27 hassbian hass[5332]: File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/nuimo_controller.py", line 89, in run
Mar 30 13:48:27 hassbian hass[5332]: self._attach()
Mar 30 13:48:27 hassbian hass[5332]: File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/nuimo_controller.py", line 107, in _attach
Mar 30 13:48:27 hassbian hass[5332]: from nuimo import NuimoController, NuimoDiscoveryManager
Mar 30 13:48:27 hassbian hass[5332]: File "/srv/homeassistant/lib/python3.4/site-packages/nuimo/__init__.py", line 1, in <module>
Mar 30 13:48:27 hassbian hass[5332]: from .nuimo import ControllerManager, ControllerManagerListener, Controller, ControllerListener, GestureEvent, Gesture, LedMatrix
Mar 30 13:48:27 hassbian hass[5332]: File "/srv/homeassistant/lib/python3.4/site-packages/nuimo/nuimo.py", line 2, in <module>
Mar 30 13:48:27 hassbian hass[5332]: import gatt
Mar 30 13:48:27 hassbian hass[5332]: File "/srv/homeassistant/lib/python3.4/site-packages/gatt/__init__.py", line 1, in <module>
Mar 30 13:48:27 hassbian hass[5332]: from .gatt import DeviceManager, Device, Service, Characteristic
Mar 30 13:48:27 hassbian hass[5332]: File "/srv/homeassistant/lib/python3.4/site-packages/gatt/gatt.py", line 6, in <module>
Mar 30 13:48:27 hassbian hass[5332]: from .gatt_linux import *
Mar 30 13:48:27 hassbian hass[5332]: File "/srv/homeassistant/lib/python3.4/site-packages/gatt/gatt_linux.py", line 13, in <module>
Mar 30 13:48:27 hassbian hass[5332]: from gi.repository import GObject
Mar 30 13:48:27 hassbian hass[5332]: ImportError: No module named 'gi'

After I manually install python-gobject (sudo apt install python-gobject) the stack trace changed slightly:

Mar 30 13:52:36 hassbian hass[5591]: Exception in thread None:
Mar 30 13:52:36 hassbian hass[5591]: Traceback (most recent call last):
Mar 30 13:52:36 hassbian hass[5591]: File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
Mar 30 13:52:36 hassbian hass[5591]: self.run()
Mar 30 13:52:36 hassbian hass[5591]: File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/nuimo_controller.py", line 89, in run
Mar 30 13:52:36 hassbian hass[5591]: self._attach()
Mar 30 13:52:36 hassbian hass[5591]: File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/nuimo_controller.py", line 107, in _attach
Mar 30 13:52:36 hassbian hass[5591]: from nuimo import NuimoController, NuimoDiscoveryManager
Mar 30 13:52:36 hassbian hass[5591]: File "/srv/homeassistant/lib/python3.4/site-packages/nuimo/__init__.py", line 1, in <module>
Mar 30 13:52:36 hassbian hass[5591]: from .nuimo import ControllerManager, ControllerManagerListener, Controller, ControllerListener, GestureEvent, Gesture, LedMatrix
Mar 30 13:52:36 hassbian hass[5591]: File "/srv/homeassistant/lib/python3.4/site-packages/nuimo/nuimo.py", line 2, in <module>
Mar 30 13:52:36 hassbian hass[5591]: import gatt
Mar 30 13:52:36 hassbian hass[5591]: File "/srv/homeassistant/lib/python3.4/site-packages/gatt/__init__.py", line 1, in <module>
Mar 30 13:52:36 hassbian hass[5591]: from .gatt import DeviceManager, Device, Service, Characteristic
Mar 30 13:52:36 hassbian hass[5591]: File "/srv/homeassistant/lib/python3.4/site-packages/gatt/gatt.py", line 6, in <module>
Mar 30 13:52:36 hassbian hass[5591]: from .gatt_linux import *
Mar 30 13:52:36 hassbian hass[5591]: File "/srv/homeassistant/lib/python3.4/site-packages/gatt/gatt_linux.py", line 13, in <module>
Mar 30 13:52:36 hassbian hass[5591]: from gi.repository import GObject
Mar 30 13:52:36 hassbian hass[5591]: File "/srv/homeassistant/lib/python3.4/site-packages/gi/__init__.py", line 39
Mar 30 13:52:36 hassbian hass[5591]: print url
Mar 30 13:52:36 hassbian hass[5591]: ^
Mar 30 13:52:36 hassbian hass[5591]: SyntaxError: Missing parentheses in call to 'print'

Looks like something in the Python Gatt module is borked, but that is definitely way beyond my capabilities.

@Charliedean
Copy link

Hi guys, sorry for not replying earlier. I'm starting to re code the controller for the newest nuimo library. Please bear in mind this is my first implementation i have done for hass. Should have something up and running later today :)

@ouchkilljoys
Copy link
Author

Hows it all been going so far?

@Charliedean
Copy link

Charliedean commented Apr 10, 2017

Got the basics working,
Had a bit of a draw back due to a bug in the new updated library(has been fixed now)
Bit busy atm, but will try to release something to you tonight if i get it working.

For now, follow the steps on the nuimo-python github to update to the newest version of bluez.
https://github.com/getsenic/nuimo-linux-python

@Charliedean
Copy link

Charliedean commented Apr 11, 2017

https://gist.github.com/Charliedean/8d0c649076b2a5265931a4a09952fca0
So far, I've done this.. Its not fully implemented yet. The main struggle was getting it to work with the bluetooth stack and permissions and what not. Will do a full write up on this soon.

The code linked is only on gist as i have not set up a repo yet and has just been used to testing.
Feel free to try it and send me any errors you get by turning on hass logging.

here is sample configuration.yaml:

nuimo_controller:
  mac: 'E9:C9:AA:BA:99:C4'

automation Nuimolifx:
  alias: Nuimolifx
  trigger:
    platform: event
    event_type: nuimo_input
    event_data:
      name: 'Gesture.BUTTON_PRESS'
  action:
    service: homeassistant.toggle
    entity_id: group.all_lights

automation Nuimolifxrotateright:
  alias: nuimoliftrotateright
  trigger:
    platform: event
    event_type: nuimo_input
    event_data:
      name: 'Gesture.ROTATION'
      value: 'RIGHT'
  action:
    service: light.turn_on
    entity_id: light.main_bedroom_light
    data_template:
      brightness: '{{states.light.main_bedroom_light.attributes.brightness + 2}}'

automation Nuimolifxrotateleft:
  alias: nuimoliftrotateleft
  trigger:
    platform: event
    event_type: nuimo_input
    event_data:
      name: 'Gesture.ROTATION'
      value: 'LEFT'
  action:
    service: light.turn_on
    entity_id: light.main_bedroom_light
    data_template:
      brightness: '{{states.light.main_bedroom_light.attributes.brightness - 2}}'

##########

pip3 uninstall nuimo
pip3 uninstall gatt
pip3 install nuimo
Another thing you might have to do is:

  1. sudo nano /etc/dbus-1/system.d/bluetooth.conf
  2. add
<policy group="hass">
<allow send_destination="org.bluez"/>
</policy>

Oh and connect and pair with sudo bluetoothctl first.
scan on
connect mac
pair mac

@ouchkilljoys
Copy link
Author

As much as I'd love to try it out so far, I would rather wait for the fix to be added to the main ha components so that its a more seamless install, thanks for the progress so far though!

@balloobbot
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍

@riker09
Copy link

riker09 commented Jul 19, 2017

Yesterday I've updated my HA installation to the latest release. A quick glance at the log revealed some errors in the nuimo part, but I'm currently not home (work, work, work). You can go ahead and close the issue, if you have to. I'll report my findings here for other users in any case.

@Charliedean
Copy link

If you are still having issues, please use the code that I posted further up.
Works perfectly for me.

@riker09
Copy link

riker09 commented Jul 20, 2017

Okay, I found some time to play around with things. I'm still unable to use my Nuimo in Home Assistant, the log /var/log/syslog shows this error:

Jul 20 20:29:44 hassbian hass[21211]: File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/nuimo_controller.py", line 7, in <module>
Jul 20 20:29:44 hassbian hass[21211]: from nuimo import Controller, ControllerManager, ControllerListener, LedMatrix
Jul 20 20:29:44 hassbian hass[21211]: File "/srv/homeassistant/lib/python3.4/site-packages/nuimo/__init__.py", line 1, in <module>
Jul 20 20:29:44 hassbian hass[21211]: from .nuimo import ControllerManager, ControllerManagerListener, Controller, ControllerListener, GestureEvent, Gesture, LedMatrix
Jul 20 20:29:44 hassbian hass[21211]: File "/srv/homeassistant/lib/python3.4/site-packages/nuimo/nuimo.py", line 2, in <module>
Jul 20 20:29:44 hassbian hass[21211]: import gatt
Jul 20 20:29:44 hassbian hass[21211]: File "/srv/homeassistant/lib/python3.4/site-packages/gatt/__init__.py", line 1, in <module>
Jul 20 20:29:44 hassbian hass[21211]: from .gatt import DeviceManager, Device, Service, Characteristic
Jul 20 20:29:44 hassbian hass[21211]: File "/srv/homeassistant/lib/python3.4/site-packages/gatt/gatt.py", line 6, in <module>
Jul 20 20:29:44 hassbian hass[21211]: from .gatt_linux import *
Jul 20 20:29:44 hassbian hass[21211]: File "/srv/homeassistant/lib/python3.4/site-packages/gatt/gatt_linux.py", line 13, in <module>
Jul 20 20:29:44 hassbian hass[21211]: from gi.repository import GObject
Jul 20 20:29:44 hassbian hass[21211]: File "/srv/homeassistant/lib/python3.4/site-packages/gi/__init__.py", line 39
Jul 20 20:29:44 hassbian hass[21211]: print url
Jul 20 20:29:44 hassbian hass[21211]: ^
Jul 20 20:29:44 hassbian hass[21211]: SyntaxError: Missing parentheses in call to 'print'#033[0m

I assume this has something to do with Home Assistant running in Python2 but the Nuimo Python SDK is for Python3? I'm not very familiar with Python and the whole virtualenv concept to fix this myself, I'm afraid.

@Charliedean Did you ever find the time to do the writeup?

So far, I've done this.. Its not fully implemented yet. The main struggle was getting it to work with the bluetooth stack and permissions and what not. Will do a full write up on this soon.

@Charliedean
Copy link

Yes the code works as it right now. Just need to make a commit to home assistant. Bit busy at the mo now.
For now, you can just use my component

@riker09
Copy link

riker09 commented Jul 25, 2017

Sorry, but no, I can't get it to work. I did a full reinstall of Home Assistant (Hassbian) on my RPi3 B. Now I'm stuck with the error

Jul 25 20:05:26 hassbian hass[1887]: Module 'dbus' not found
Jul 25 20:05:26 hassbian hass[1887]: Please run: sudo apt-get install python3-dbus
Jul 25 20:05:26 hassbian hass[1887]: See also: https://github.com/getsenic/gatt-python#installing-gatt-sdk-for-python

I did install python3-dbus. I even install python-dbus and pip3 install pydbus - with sudo and in the virtualenv folder. No success.

@riker09
Copy link

riker09 commented Aug 17, 2017

I'm trying to make a hass.io addon out of this. Will report back here when I succeed.

@riker09
Copy link

riker09 commented Sep 22, 2017

I have a first draft of the addon ready. It's working great when I run it locally on my computer. I have yet to figure out how to hand over the BT device to the docker container, though. If anyone is interested I can create a repository.

@Charliedean
Copy link

Have you got it on github or anything? Wouldn't mind taking a look

@riker09
Copy link

riker09 commented Sep 25, 2017

Not yet, will do so later this week. 🙂

@riker09
Copy link

riker09 commented Sep 28, 2017

Okay, here's my code: https://github.com/riker09/Nuimo-MQTT-Bridge

Be gentle. 😉

@Charliedean
Copy link

Nice one.
Password and IP is still hard coded in index.js - might want to remove that 😮

@riker09
Copy link

riker09 commented Nov 1, 2017

I got a PR which enabled BT support on RPi3. I got it working, will fine tune the next days/weeks/month. PRs are welcome! 😉

@balloobbot
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍

@balloobbot
Copy link

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem 👍

@home-assistant home-assistant locked and limited conversation to collaborators Jul 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants