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

Does not work on hass.io #1

Closed
pezmannen opened this issue Jul 1, 2019 · 27 comments
Closed

Does not work on hass.io #1

pezmannen opened this issue Jul 1, 2019 · 27 comments

Comments

@pezmannen
Copy link

If possible, it would be awesome with a hass.io port on this.

@klali
Copy link
Owner

klali commented Jul 1, 2019

One thing to investigate here is if bluepy would work better on hass.io, I had initial issues with getting notifications to work on bluepy and went with pygatt instead. There seems to be a couple of components using bluepy and some of them clain to work on hass.io.

Edit: and with that said it wasn't that tricky to get notifications working with bluepy. Maybe it would be good to move over to bluepy, I might make a test on a branch with that if I find time and interest.

@klali
Copy link
Owner

klali commented Jul 2, 2019

I just pushed some early bluepy code on a branch: https://github.com/klali/ha-plejd/tree/bluepy

This might work better with hass.io, at the least it seems to be a more popular ble library in home assistant. Though it does seem to come with it's own bugs and not being properly maintained.

@pezmannen
Copy link
Author

pezmannen commented Jul 6, 2019

I tried it now but cant get anything to work. Am I missing something? Should I add something more to the folder?
image

Also, in my configuration.yaml i put this as is

light:

  • platform: plejd
    crypto_key: xxxxxxxx
    device:
    11:
    name: bedroom
    13:
    name: kitchen_1
    15:
    name: kitchen_2
    17:
    name: basement1
    19:
    name: basement2
    21:
    name: hallway

I do see this error:
image

@klali
Copy link
Owner

klali commented Jul 7, 2019

Tricky to debug without running it, guess I might have to get hass.io running to be able to get the component running.

Make sure you have bluepy installed and have given it's helper the permissions to run the btle scanning.

@pezmannen
Copy link
Author

Can I really install bluepy separatly? Doesnt that have to be included in the component?

@pezmannen
Copy link
Author

Much appreciated is you get this up and running on hass.io. Most people are running this setup I think

@atrampare
Copy link

I agree would be great to have it working with hass.io witout to much hassle.

Thanks for the work your putting in.

@klali
Copy link
Owner

klali commented Jul 25, 2019

As stated in #4 I had a typo in the example, the config has to be for "devices" not "device".

For better compatibility with hass.io the integration should probably follow https://developers.home-assistant.io/docs/en/creating_integration_manifest.html

If doing the setcap part is to much and additional config is better I guess it's possible to optionally allow adding the adresses of connectable plejd devices to the config and skip the scanning step.

@BertilJ
Copy link

BertilJ commented Jul 25, 2019

I got this working on Hass.io (after changing device to devices), seems to be some issues with Bluepy still, I've got other BT issues, but now I got all my Plejdd lights in HA and they are updated directly when I change them in Plejd app, so all good here.

@pezmannen
Copy link
Author

I got this working on Hass.io (after changing device to devices), seems to be some issues with Bluepy still, I've got other BT issues, but now I got all my Plejdd lights in HA and they are updated directly when I change them in Plejd app, so all good here.

Did you do anything besides copying the files (and adding config in yaml)? Did you install anything else manually?

@BertilJ
Copy link

BertilJ commented Jul 26, 2019

I tried to install bluepy once extra, but that installation ended with an error so I can't say if that made a difference or not.

I did also create a manifest.json for this component, but I'm not sure that did anything either. I can do a PR for the manifest.json later if needed.

@BertilJ
Copy link

BertilJ commented Jul 26, 2019

Another update,

I've now looked through all my lights (+30) and it seems that I also get the not used outputs from Plejd (got a few DIM-02 that is currently only using one output) and I also have a few DIM-01 that are duplicates (got two numbers for each device) and those turn on and off but doesn't update state in HA.

I will take a look at getting the outputAddress instead of input that I'm currently using. Hopefully that fixes the update part.

But I'm still a little puzzled by the duplicates.

@pezmannen
Copy link
Author

Your manifest file would be great!

@atrampare
Copy link

Your manifest file would be great!

Same here!

@klali
Copy link
Owner

klali commented Jul 26, 2019

A manifest might look like:

{
  "domain": "plejd",
  "name": "Plejd",
  "documentation": "https://github.com/klali/ha-plejd",
  "requirements": [ "bluepy" ],
  "dependencies": [],
  "codeowners": [ "@klali" ]
} 

with bluepy replaced with pygatt depending on branch.

Though this wont install correctly since the imports in light.py is in top level rather than function level. If the requirements are already installed correctly it will work though (and should without the manifest as well).

@pezmannen
Copy link
Author

A manifest might look like:

{
  "domain": "plejd",
  "name": "Plejd",
  "documentation": "https://github.com/klali/ha-plejd",
  "requirements": [ "bluepy" ],
  "dependencies": [],
  "codeowners": [ "@klali" ]
} 

with bluepy replaced with pygatt depending on branch.

Though this wont install correctly since the imports in light.py is in top level rather than function level. If the requirements are already installed correctly it will work though (and should without the manifest as well).

Could you perhaps guide me on how to install the prereqs on hass.io?

@pezmannen
Copy link
Author

Finally got it working!

To install bluepy i added this repository to the add-on store: https://github.com/home-assistant/hassio-addons-development

I then installed the "Custom deps deployment" add-on with the following config
{
"pypi": [
"https://wheels.home-assistant.io/alpine-3.10/armhf/bluepy-1.3.0-cp37-none-any.whl"
],
"apk": []
}

And my manifest.json looks like this:
{
"domain": "plejd",
"name": "Plejd",
"documentation": "https://github.com/klali/ha-plejd",
"dependencies": [],
"codeowners": ["@klali"],
"requirements": ["bluepy"]
}

@BertilJ
Copy link

BertilJ commented Jul 27, 2019

Curious if you got any error messages installing bluepy? I did it the old fashion way with "pip3 install bluepy" and the installation ended with an error.

klali added a commit that referenced this issue Jul 27, 2019
this should make it possible to pull in bluepy automatically

relates #1
@pezmannen
Copy link
Author

No errors as far as I can recall

@atrampare
Copy link

I get this error when trying to set it up.

2019-07-28 13:43:07 ERROR (MainThread) [homeassistant.setup] Setup failed for devices: Integration not found.
2019-07-28 13:43:07 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for plejd which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.

This is my configuration.yaml

light:

  • platform: plejd
    crypto_key: XXXXXXXXXXXXXXXXXXXXXXXXXX
    devices:
    11:
    name: XX
    13:
    name: XX
    15:
    name: XX

device_tracker:

  • platform: bluetooth_tracker
    interval_seconds: 15
    consider_home: 150
    track_new_devices: yes

Is this bluetooth device_tracker part neccesary?

When i run the bluepy code in Custom deps deployment i get this in the log.

[Info] Remove old deps
[Info] Install pypi modules into deps
The scripts blescan, sensortag and thingy52 are installed in '/config/deps/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
You are using pip version 19.0.2, however version 19.2.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[Info] done

My foldersetup is for the plejd files is

/config/custom_components/plejd

Im running a pi 3B

@pezmannen
Copy link
Author

Got the same messages as you. Did you add the manifest file?

@atrampare
Copy link

Yes i added the manifest in the same folder as light.py and init.py

@BertilJ
Copy link

BertilJ commented Jul 30, 2019

I've been having issues on and off with this, first I got it working, then I did some changes and it didn't work any more.

Today I decided to set up a pi3 just with a clean Hass.io to see if I got it working and it works "out of the box". Add the three files (init, light and manifest) in custom components and add the config to config.yaml. Restart and it works.

Did the same on my nuc, installed a fresh installation and the files and config and it works. So the steps to add some extra isn't needed, probably due to the manifest.json or if bluepy actually is installed in Hass.io.

It doesn't work perfect for me, having a lot of issues to get the correct states back to HA, but all lights turn on and off and dims as they should.

I'm guessing that with older installations that have gone through several upgrades there may be some leftovers or other things that prevent this from working properly. So I would say that this issue should be closed. It does work on a vanilla installation on Hass.io both on pi3 and nuc.

@atrampare
Copy link

I also got it up and running now:-)= I did a clean installation of Hass.io. But I also had to do the step with "custom dep deployment" as described previously befor i got it to work.

@klali
Copy link
Owner

klali commented Aug 2, 2019

I've merged the bluepy branch, that comes with a manifest and the correct way of including dependencies and in a virtualenv installation the pulls in dependencies correctly.

When running on hass.io, did you have to do the setcap tricks to get it the correct permissions?

@klali klali closed this as completed Aug 2, 2019
@keylogicjohan
Copy link

Got it running in hassio on a Thnikerboard S, I didn´t use the setcap tricks

@BertilJ
Copy link

BertilJ commented Aug 5, 2019

No, no setcap on NUC either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants