Code Monkey home page Code Monkey logo

ha-plejd's People

Contributors

bnordli avatar jmderander avatar jonsv322 avatar jyx avatar klali avatar maxiepax avatar mudape avatar rickardrockard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ha-plejd's Issues

Plejd entities stops group propagation

Turning On/Off Plejd entities in groups does not work as expected. The propagation in the list/group stops at the first Plejd entity. Perhaps HA needs some sort of callback of task completion to be able to continue propagating trough the list/group?

Not issue, but development idea

Now when this is working great you of course come to think of other things that potentially can be done. :)

Would it be possible to get the button click and double click as events or similar, so they can be used for other automations?

I.e, I've got a few DIM-02 that is currently only using one output and on those wall switches I got one button that doesn't have a function, would be awesome to be able to have other automations connected to those.

No match for device

I've had this nicely running for a while now and once you find some "ugly" workarounds it does really nice also using plejd in groups in automations.

But I've got one thing that is popping up in my log quite frequently, is this something that should be ignored or do I have an issue?

2019-08-12 21:23:35 DEBUG (SyncWorker_4) [custom_components.plejd.light] no match for device '1' (b'010110001bbeca515d01')
2019-08-12 21:23:36 DEBUG (Thread-6) [custom_components.plejd.light] no match for device '1' (b'010110001bc8ca515d01')
2019-08-12 21:23:44 DEBUG (SyncWorker_2) [custom_components.plejd.light] no match for device '1' (b'010110001bd0ca515d01')
2019-08-12 21:24:02 DEBUG (SyncWorker_10) [custom_components.plejd.light] no match for device '1' (b'010110001bd9ca515d01')
2019-08-12 21:24:07 DEBUG (SyncWorker_0) [custom_components.plejd.light] no match for device '1' (b'010110001bdeca515d01')
2019-08-12 21:24:21 DEBUG (SyncWorker_4) [custom_components.plejd.light] no match for device '1' (b'010110001becca515d01')

Homeassistant will not connect to Plejd

I've tried three separate fresh installs in order to get this working.
Fresh installs on both Raspbian and Homeassistant in venv.

I get error


Nov 03 15:37:46 raspberrypi hass[1540]: 2019-11-03 15:37:46 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Nov 03 15:37:46 raspberrypi hass[1540]: Traceback (most recent call last):
Nov 03 15:37:46 raspberrypi hass[1540]:   File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
Nov 03 15:37:46 raspberrypi hass[1540]:     result = self.fn(*self.args, **self.kwargs)
Nov 03 15:37:46 raspberrypi hass[1540]:   File "/home/homeassistant/.homeassistant/custom_components/plejd/light.py", line 322, in _start_plejd
Nov 03 15:37:46 raspberrypi hass[1540]:     connect(plejdinfo)
Nov 03 15:37:46 raspberrypi hass[1540]:   File "/home/homeassistant/.homeassistant/custom_components/plejd/light.py", line 140, in connect
Nov 03 15:37:46 raspberrypi hass[1540]:     devs = sorted(list(scanner.scan(1)), key=lambda d: d.rssi)[::-1]
Nov 03 15:37:46 raspberrypi hass[1540]:   File "/srv/homeassistant/lib/python3.7/site-packages/bluepy/btle.py", line 852, in scan
Nov 03 15:37:46 raspberrypi hass[1540]:     self.start(passive=passive)
Nov 03 15:37:46 raspberrypi hass[1540]:   File "/srv/homeassistant/lib/python3.7/site-packages/bluepy/btle.py", line 790, in start
Nov 03 15:37:46 raspberrypi hass[1540]:     self._mgmtCmd("le on")
Nov 03 15:37:46 raspberrypi hass[1540]:   File "/srv/homeassistant/lib/python3.7/site-packages/bluepy/btle.py", line 312, in _mgmtCmd
Nov 03 15:37:46 raspberrypi hass[1540]:     raise BTLEManagementError("Failed to execute management command '%s'" % (cmd), rsp)
Nov 03 15:37:46 raspberrypi hass[1540]: bluepy.btle.BTLEManagementError: Failed to execute management command 'le on' (code: 17, error: Invalid Index)

I'm now running version 0.101.2 through virtual environment.
This used to work a while ago, but stopped, hence the reinstall.
What could be causing this?

Detection of "double tap"

It is possible using the plejd app to configure scenes to be triggered by doubletapping the plejd connected buttons. Is it possible to capture these events to trigger automations in homeassistant?

No devices found

So after the dbus up and working i still am not able to find any devices

2020-05-05 15:08:02 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 experience issues with Home Assistant.
2020-05-05 15:08:02 INFO (MainThread) [homeassistant.components.light] Setting up light.plejd
2020-05-05 15:08:04 DEBUG (MainThread) [custom_components.plejd.light] Discovered bluetooth adapter /org/bluez/hci0
2020-05-05 15:08:06 WARNING (MainThread) [custom_components.plejd.light] No plejd devices found
2020-05-05 15:08:06 WARNING (MainThread) [homeassistant.components.light] Platform plejd not ready yet. Retrying in 30 seconds.

There are no apparent error messages but "No plejd devices found".

Running hcitool lescan works SOMETIMES. For some reason the interface seems to not work, i don't understand why:

root@lampberry:~# hcitool dev
Devices:
        hci0    C4:D9:87:37:60:71
root@lampberry:~# hciconfig
hci0:   Type: BR/EDR  Bus: USB
        BD Address: C4:D9:87:37:60:71  ACL MTU: 310:10  SCO MTU: 64:8
        UP RUNNING
        RX bytes:18095661 acl:0 sco:0 events:462779 errors:0
        TX bytes:30380 acl:0 sco:0 commands:3554 errors:0

root@lampberry:~# hcitool lescan
Set scan parameters failed: Input/output error
root@lampberry:~# hciconfig hci0 down
root@lampberry:~# hciconfig hci0 up
root@lampberry:~# hcitool lescan
LE Scan ...
43:CD:4A:3F:72:82 (unknown)
43:CD:4A:3F:72:82 (unknown)
C8:A6:2D:3A:25:6B P mesh
C8:A6:2D:3A:25:6B (unknown)
63:73:36:6D:74:E7 (unknown)
63:73:36:6D:74:E7 (unknown)
F1:BE:89:F0:DD:8F P mesh
63:73:36:6D:74:E7 (unknown)

Trying to get ha-plejd to work on home assistant docker on Synology nas

Hi, and many thanks for all Your hard work!

I´m trying to get ha-plejd to work on the official home assistant docker image on Synology nas, but I'm running in to some problems.

I'm running the docker container with high privelege and ha runs as root.

First i got the file not found error reported here in other issues, after adding " -v /var/run/dbus:/var/run/dbus", i get another error which makes me think i got a little bit further:

2021-03-24 15:53:28 ERROR (MainThread) [homeassistant.components.light] Error while setting up plejd platform for light Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/dbus_next/proxy_object.py", line 214, in get_interface intr_interface = next(i for i in self.introspection.interfaces if i.name == name) StopIteration During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 200, in _async_setup_platform await asyncio.shield(task) File "/config/custom_components/plejd/light.py", line 478, in async_setup_platform await connect(plejdinfo) File "/config/custom_components/plejd/light.py", line 175, in connect om = bus.get_proxy_object(BLUEZ_SERVICE_NAME, '/', om_introspection).get_interface(DBUS_OM_IFACE) File "/usr/local/lib/python3.8/site-packages/dbus_next/aio/proxy_object.py", line 159, in get_interface return super().get_interface(name) File "/usr/local/lib/python3.8/site-packages/dbus_next/proxy_object.py", line 216, in get_interface raise InterfaceNotFoundError(f'interface not found on this object: {name}') dbus_next.errors.InterfaceNotFoundError: interface not found on this object: org.freedesktop.DBus.ObjectManager

hcitool seems to scan fine:

bash-5.0# hcitool dev Devices: hci0 00:1A:7D:DA:71:0C

bash-5.0# hcitool lescan
LE Scan ...
D0:16:3D:92:40:48 P mesh
D0:16:3D:92:40:48 P mesh
E8:63:57:EA:F6:33 P mesh
D0:16:3D:92:40:48 P mesh
D0:16:3D:92:40:48 P mesh
D0:16:3D:92:40:48 P mesh
D0:16:3D:92:40:48 P mesh
D0:16:3D:92:40:48 P mesh
D0:16:3D:92:40:48 P mesh
D0:16:3D:92:40:48 P mesh
D0:16:3D:92:40:48 P mesh

bluetoothctl however has no controller:
[bluetooth]# list [bluetooth]#

Any idea if it is possible to get ha-plejd working on this setup?

Deprecation warnings

Hi!

I got these warnings when starting HA 2021.3.2. Is this something you can look at?
Thanks for this integration, by the way!

2021-03-10 10:38:38 WARNING (MainThread) [homeassistant.loader] No 'version' key in the manifest file for custom integration 'plejd'. This will not be allowed in a future version of Home Assistant. Please report this to the maintainer of 'plejd'
2021-03-10 10:38:38 WARNING (MainThread) [homeassistant.components.light] Light is deprecated, modify PlejdLight to extend LightEntity

DIM-01 New FW not discovered correctly

I just bought a new DIM-01 unit and it has (called Plejd support to confirm this) a new FW version 0.0.4 (the old is 3.1.8). The discovery script does not seem to recognize this unit.
Debug print
2021-09-21 10:38:40 INF [plejd-mqtt] Discovered -unknown- (light) named Belysning Stora Sovrum (35 : E096970F8DF5_0)

it does not get included. Support said that there should be no interface changes with the new FW, but its sure is different.

The problems seem to originate in, master/plejd/PlejdApi.js:
` // eslint-disable-next-line class-methods-use-this
_getDeviceType(plejdDevice) {
// Type name is also sometimes available in device.hardware.name
// (maybe only when GWY-01 is present?)

switch (parseInt(plejdDevice.hardwareId, 10)) {
  case 1:
  case 11:
    return {
      name: 'DIM-01',
      type: 'light',
      dimmable: true,
      broadcastClicks: false,
    };`

Havent had time to debug further at this point in time. Will try to pull master to look. I'm currently using Current version: 0.8.0-beta.

Best regards,
/Christer

'handles'

Coming back with this error:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 121, in handle_call_service
    connection.context(msg))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1150, in async_call
    self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1172, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 295, in async_handle_light_on_service
    await light.async_turn_on(**pars)
  File "/usr/src/homeassistant/homeassistant/components/group/light.py", line 176, in async_turn_on
    light.DOMAIN, light.SERVICE_TURN_ON, data, blocking=True)
  File "/usr/src/homeassistant/homeassistant/core.py", line 1150, in async_call
    self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1172, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 295, in async_handle_light_on_service
    await light.async_turn_on(**pars)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/plejd/light.py", line 111, in turn_on
    plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'handles'

I had this working nicely, but now after the weekend it doesn't work any more. No config changes or updates, I did a restart today that's it. Hass.io on NUC.

MiFlora is up and running so Bluepy should be ok.

Error while setting up platform plejd on raspberry pi4

Iv moved my hassio installation to a pi 4 and can't get i to work. I get this error from the log file. Anyone got a clue of whats wrong?

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
return fut.result()
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/plejd/light.py", line 310, in setup_platform
cryptokey = binascii.a2b_hex(config.get(CONF_CRYPTO_KEY))
binascii.Error: Odd-length string

New test on Hass.io

This is really great work and we are many (Swedes) at least that is really looking forward to this.

I've just tested the new branch on Hass.io and I'm getting an error message that doesn't seem directly related to BLE.

Invalid config for [light.plejd]: [device] is an invalid option for [light.plejd]. Check: light.plejd->device. (See ?, line ?). Please check the docs at https://home-assistant.io/components/light.plejd/

My config is this:

  • platform: plejd
    crypto_key: "XXXXXX"
    device:
    12:
    name: Not known
    13:
    name: Not known
    16:
    name: Not known
    17:
    name: Not known
    20:
    name: Not known

I'm running latest (0.96.3) Hass.io on a NUC.

Addition: Removing the config under light: is removing the error message, so could this be related to how it's configured?

Error doing job: Future exception was never retrieved

I had everything working, but then I decided to upgrade the code with the latest from the component. Now I'm getting error messages.

Running Hass.io 0.96.3 on nuc, other BLE is working fine (MiFlora).

This I'm getting during startup:

Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/plejd/light.py", line 297, in _start_plejd
    connect(plejdinfo)
  File "/config/custom_components/plejd/light.py", line 127, in connect
    devs = sorted(list(scanner.scan(1)), key=lambda d: d.rssi)[::-1]
  File "/usr/local/lib/python3.7/site-packages/bluepy/btle.py", line 854, in scan
    self.stop()
  File "/usr/local/lib/python3.7/site-packages/bluepy/btle.py", line 803, in stop
    self._mgmtCmd(self._cmd()+"end")
  File "/usr/local/lib/python3.7/site-packages/bluepy/btle.py", line 309, in _mgmtCmd
    rsp = self._waitResp('mgmt')
  File "/usr/local/lib/python3.7/site-packages/bluepy/btle.py", line 362, in _waitResp
    raise BTLEDisconnectError("Device disconnected", resp)
bluepy.btle.BTLEDisconnectError: Device disconnected

When trying to operate a light I'm getting this:

'handles'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 121, in handle_call_service
    connection.context(msg))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1150, in async_call
    self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1172, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 295, in async_handle_light_on_service
    await light.async_turn_on(**pars)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/plejd/light.py", line 106, in turn_on
    plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'handles'

Sorry for being a pain in the ass reporting issues on something that is in early development, but I'm really excited for this integration, that's the last thing I need to have full control of my home through HA.

Possibility to also add Plejd wall switch WPH-01?

Hi!

I've been playing around with Plejd wall switch WPH-01 for a couple of days and trying to get it to work with my RPi 3B+/HA v 101.2 setup. I don't have any of the Plejd dimmers or controllers, just the wall switch. And though I thus couldn't set it up completely enough in the iOS app, to test it, at least I managed to find a crypto key from the iPhone back-up files. (Even though it wasn't stored in the same place as described here by iCarl)

So far I've managed to both get hcitool lescan to find the P mesh - but also the plejd custom component to - at least occasionally - find the device. But... as the Plejd component currently is only made up for lights and controllers, it of course brakes when it finds this switch device it doesn't understand anything about. At the moment this is what I get repeatedly in the log file:

2019-11-25 11:26:40 DEBUG (Thread-4) [custom_components.plejd.light] no match for device '00' (b'00011000160b03170a')

Unfortunately I have no clue what the device response b'00011000160b03170a' means. Besides it's some form of protocol for the device. But I thought i'd try repeatedly and in sequence press buttons in the order 'top right' 'top left' 'bottom left' and 'bottom right' to see what happened. And this is the result from the log file:

nov 25 13:49:40 hass[474]: 2019-11-25 13:49:40 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b02140a')

nov 25 13:49:46 hass[474]: 2019-11-25 13:49:46 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b03140a')

nov 25 13:49:47 hass[474]: 2019-11-25 13:49:47 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b03100a')

nov 25 13:49:54 hass[474]: 2019-11-25 13:49:54 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b030d0a')

nov 25 13:50:05 hass[474]: 2019-11-25 13:50:05 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b03090a')

nov 25 13:50:16 hass[474]: 2019-11-25 13:50:16 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b03060a')

nov 25 13:50:22 hass[474]: 2019-11-25 13:50:22 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b01060a')

nov 25 13:50:34 hass[474]: 2019-11-25 13:50:34 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b01020a')

nov 25 13:50:45 hass[474]: 2019-11-25 13:50:45 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b00020a')

nov 25 13:50:50 hass[474]: 2019-11-25 13:50:50 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b00ff09')

nov 25 13:50:53 hass[474]: 2019-11-25 13:50:53 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b00fb09')

nov 25 13:51:01 hass[474]: 2019-11-25 13:51:01 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b00f809')

nov 25 13:51:08 hass[474]: 2019-11-25 13:51:08 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b02f809')

nov 25 13:52:01 hass[474]: 2019-11-25 13:52:01 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b03f809')

nov 25 13:52:26 hass[474]: 2019-11-25 13:52:26 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b01f809')

nov 25 13:52:48 hass[474]: 2019-11-25 13:52:48 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b00f809')

nov 25 13:53:00 hass[474]: 2019-11-25 13:53:00 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b00f409')

nov 25 13:53:14 hass[474]: 2019-11-25 13:53:14 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b02f409')

nov 25 13:53:22 hass[474]: 2019-11-25 13:53:22 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b02f109')

nov 25 13:53:34 hass[474]: 2019-11-25 13:53:34 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b03f109')

nov 25 13:53:37 hass[474]: 2019-11-25 13:53:37 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b03ed09')

nov 25 13:53:44 hass[474]: 2019-11-25 13:53:44 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b01ed09')

nov 25 13:53:52 hass[474]: 2019-11-25 13:53:52 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b00ea09')

nov 25 13:53:57 hass[474]: 2019-11-25 13:53:57 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b02ea09')

nov 25 13:54:02 hass[474]: 2019-11-25 13:54:02 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b03ea09')

nov 25 13:54:15 hass[474]: 2019-11-25 13:54:15 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b01ea09')

nov 25 13:54:20 hass[474]: 2019-11-25 13:54:20 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b00ea09')

nov 25 13:54:41 hass[474]: 2019-11-25 13:54:41 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b02ea09')

nov 25 13:54:57 hass[474]: 2019-11-25 13:54:57 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b03ea09')

nov 25 13:55:12 hass[474]: 2019-11-25 13:55:12 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b01ea09')

nov 25 13:55:28 hass[474]: 2019-11-25 13:55:28 DEBUG (Thread-5) [custom_components.plejd.light] no match for device '00' (b'00011000160b00ea09')

(Note: for easier reading, I've only listed all those occurrences changed from the previous one here!)

Obviously byte 14 (perhaps 13 and 14) is directly connected to the buttons pressed. But I don't understand byte 15-18 that changes seemingly intermittent...

What are the possibilities for also including the wall switch as a known device in the code?
I guess it should be implemented as a binary sensor? Or am I wrong?
(As you probably understand, I'm just not so experienced programmer - yet at least...)

Worked for a while

Thank you for your effort trying to integrate Plejd in Home Assistant!

I first try to install it in 0.86 and it didn't work. When I installed it in a fresh 0.103.4 it worked a while but stopped when I was adding more of my setup.

I looks good when it starts:

2020-01-06 15:33:50 DEBUG (SyncWorker_0) [custom_components.plejd.light] adding device 16 (plejd_matrum)
2020-01-06 15:33:50 DEBUG (SyncWorker_0) [custom_components.plejd.light] adding device 12 (plejd_toa_uppe)
2020-01-06 15:33:58 DEBUG (SyncWorker_7) [custom_components.plejd.light] Starting plejd connection

but I got error below when i try to turn on any device:

2020-01-06 15:35:44 WARNING (SyncWorker_13) [custom_components.plejd.light] Tried to turn on light when plejd is not connected
2020-01-06 15:35:48 WARNING (SyncWorker_18) [custom_components.plejd.light] Tried to turn on light when plejd is not connected

Do you have any idea what could be wrong?

Failure turning on or off lights

First of all, great initiative creating this component. Really hope that is can be an official component in HA.

Sometimes when I turn on or off a plejd light it fails and I see this in the logs:

2019-09-10 19:46:01 WARNING (Thread-4) [custom_components.plejd.light] Encountered bluepy internal error: 'Unexpected response (wr)'

Time zone setting needed

After connecting this component to my Plejd system, I noticed that the time functions started to behave strangely. I added debug logging and saw this:

2021-06-09 08:09:18 DEBUG (MainThread) [custom_components.plejd.light] Plejd network reports time as '2021-06-09 09:09:20'
2021-06-09 08:09:18 INFO (MainThread) [custom_components.plejd.light] Plejd time delta is 3601 seconds, setting time to '2021-06-09 08:09:18.441121'.

After reconnecting with the app, it resynchronizes the devices and the component logs the following. (I have removed the message details.)

2021-06-09 08:22:04 DEBUG (MainThread) [custom_components.plejd.light] No match for command 'b'001b'' (b'**')
2021-06-09 08:22:04 DEBUG (MainThread) [custom_components.plejd.light] No match for command 'b'001b'' (b'**')
2021-06-09 08:22:04 DEBUG (MainThread) [custom_components.plejd.light] No match for command 'b'0038'' (b'**')
2021-06-09 08:22:04 DEBUG (MainThread) [custom_components.plejd.light] No match for device '00' (b'**')
2021-06-09 08:22:04 DEBUG (MainThread) [custom_components.plejd.light] No match for command 'b'001b'' (b'**')
2021-06-09 08:22:05 DEBUG (MainThread) [custom_components.plejd.light] No match for device '00' (b'**')

..and then of course the component reports again:

2021-06-09 08:25:43 DEBUG (MainThread) [custom_components.plejd.light] Plejd network reports time as '2021-06-09 09:25:46'
2021-06-09 08:25:43 INFO (MainThread) [custom_components.plejd.light] Plejd time delta is 3602 seconds, setting time to '2021-06-09 08:25:43.909139'.

I am at UTC+2, but it looks like Plejd is reporting time in UTC +3 (!). The timers from my app worked correctly before I attached Home Assistant, so at least it is internally consistent.

Suggested solution: If possible, read the time zone information from Plejd, otherwise add a time zone (or offset) setting to the component to avoid setting the wrong clock.

HA is not using stored brightness value

When turning on Plejd lights from HA I only get full brightness (Not the current stored brightness value from the Plejd unit). I'm not sure if this is a bug, or just not implemented yet.

ON:
[custom_components.plejd.light] plejd_matsal_koksbord turned True with brightness ffff

OFF (after adjusting brightness in HA to 8080):
[custom_components.plejd.light] plejd_matsal_koksbord turned False with brightness 8080

Unique entity id for lights

Currently the lights are not assigned unique entity id's. This means that they cannot be assigned to a room in HASS

image

The instructions specify using the Customizations menu to edit the entity however AREA/ROOM is not an customizeable option.

Unable to extract .site file from a fresh Plejd installation

I have tried to follow the project guide to extract the .site file from my Android phone but 'adb backup' returns an empty backup file.

After the the zip decompression the tar file is an 1kB empty file with just '\x00'

pi@pidev2:~ $ dd if=backup.ab bs=1 skip=24 | python -c "import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))" > backup.tar
23+0 records in
23+0 records out
23 bytes copied, 0.00277401 s, 8.3 kB/s
pi@pidev2:~ $ hexdump -C backup.tar
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000400

The Plejd system was installed by an electrician and I was just provided an unique ID string that I entered into my app.

What Plejd devices does the component work with?

Hello,

What Plejd devices does the component work with?
I’m thinking of getting a couple of DIM-02, 2-channel dimmers, and would like to integrate these into my existing Home Assistant setup.

Regards, Tom

Unwanted delay in Automations

Hi!

update: for troubleshooting purposes I also made a clean install of latest hassio image and latest build of ha-plejd on different hardware (rpi4) and a new memory card. Same Plejd setup in my house. On top of that I installed only samba and ssh and created a light group to minimize the risk of interference from other plugins/code. Unfortunately the same behavior with only one of several lamps in that group turns on. If turning on lamps one by one it works just fine.

Thanks for a great development project, very useful for us Plejd users.

I want to turn on multiple lights at the same time but with Plejd-Hassio I have been rather unsuccessful.

For example when I run an automation what happens is that the automation turn on the first light immediately but there is an (exact?) delay of 10 seconds between each following light turning on.

If I trigger two lights manually they both turn on immediately.

I have also tried the plugin group lights and starting several entities under one button but that results in only the first light turning on.

I can not be sure but to me it seems like your Plejd-Hassio integration has some kind of flaw?

Thanks again for your work!

Brightness

Hi,
In the "Plejd mobile application" I got brightness value directly. It show i.e 53%.

Everything works great in HA for me, but the brightness attribute is not set if not I turn_on/turn_off/change brightness first in i.e HA or in "Plejd mobile application".

So, if I use an automation to load current brightness value and change that with 10%, then it cant load the current value. and the automation needs to jump and assume the current brightness value it will change from.

Is it possible to change this so the brightness value is loaded from the device directly and when state changes?

ha-plejd not working on RPI/ Bluetooth needing restart

Hi, this has stopped working for me.

I am getting this in my home assistant log. Can that be related somehow?
2021-01-11 10:20:04 WARNING (MainThread) [homeassistant.components.light] Light is deprecated, modify PlejdLight to extend LightEntity
2021-01-11 10:20:15 WARNING (MainThread) [homeassistant.components.light] Setup of light platform plejd is taking over 10 seconds.
2021-01-11 10:21:05 ERROR (MainThread) [homeassistant.components.light] Setup of platform plejd is taking longer than 60 seconds. Startup will proceed without waiting any longer.

Latest ha-plejd
hass 2021.1.1

Extracting crypto keys, small typo

Really great initiative on ha-plejd, thanks so much for taking the time to contribute.
Your "how-to" guide on extracting the crypto keys is more or less accurate, except for the output Addresses which seems to be:

cat site.json | jq '.PlejdMesh._outputAddresses'

suddenly plejd stopped working

Hi!
First of, thanks for a wonderfull function for HA!
have been running this for quite some time, with no problems what so ever, but now suddenly it has stopped working. What can be the problem??

Config: {
site: 'Hillaredplejd',
username: '---scrubbed---',
password: '---scrubbed---',
mqttBroker: 'mqtt://192.168.1.226/',
mqttUsername: 'krexx',
mqttPassword: '---scrubbed---',
includeRoomsAsLights: true,
preferCachedApiResponse: false,
updatePlejdClock: false,
logLevel: 'info',
connectionTimeout: 20,
writeQueueWaitTime: 1300
}
2022-11-13 00:59:51 INF [plejd-main] Log level set to info
Starting Plejd addon and reading configuration...
2022-11-13 00:59:51 INF [plejd-main] Log level set to info
2022-11-13 00:59:51 INF [plejd-main] Plejd add-on, version 0.9.1
2022-11-13 00:59:51 INF [device-comm] Starting Plejd communication handler.
2022-11-13 00:59:51 INF [plejd-ble] Starting Plejd BLE Handler, resetting all device states.
2022-11-13 00:59:51 INF [plejd-main] Main Plejd addon init()...
2022-11-13 00:59:51 INF [plejd-api] init()
2022-11-13 00:59:51 INF [plejd-api] Getting cached api response from disk
2022-11-13 00:59:51 INF [plejd-api] login()
2022-11-13 00:59:51 INF [plejd-api] logging into Hillaredplejd
2022-11-13 00:59:52 INF [plejd-api] got session token response
2022-11-13 00:59:52 INF [plejd-api] Get all Plejd sites for account...
2022-11-13 00:59:52 INF [plejd-api] Got site list response with 1: Hillaredplejd
2022-11-13 00:59:52 INF [plejd-api] Site found matching configuration name Hillaredplejd
2022-11-13 00:59:52 INF [plejd-api] Get site details for 27fe46a9-68da-4869-9e89-8635cc84f773...
2022-11-13 00:59:53 INF [plejd-api] got site details response
2022-11-13 00:59:53 INF [plejd-api] Site details for site id 27fe46a9-68da-4869-9e89-8635cc84f773 found
2022-11-13 00:59:53 INF [plejd-api] Saving cached copy
2022-11-13 00:59:53 INF [plejd-api] Getting devices from site details response...
2022-11-13 00:59:53 INF [plejd-api] No Plejd gateway found on site
2022-11-13 00:59:53 INF [plejd-mqtt] Initializing MQTT connection for Plejd addon
2022-11-13 00:59:53 INF [plejd-ble] init()
2022-11-13 00:59:54 INF [plejd-mqtt] Connected to MQTT.
2022-11-13 00:59:54 INF [plejd-mqtt] Sending discovery for 4 Plejd output devices
2022-11-13 00:59:54 INF [plejd-mqtt] Discovered DIM-01 (light) named Belysning vägg (11 : D8750833883C_0).
2022-11-13 00:59:54 INF [plejd-mqtt] Discovered DIM-01 (light) named Takbelysning köksbord (12 : FE18E394FF8A_0).
2022-11-13 00:59:54 INF [plejd-mqtt] Discovered DIM-01 (light) named Belysning fönster (13 : E20EF99234E1_0).
2022-11-13 00:59:54 INF [plejd-mqtt] Discovered Room (light) named Kök / Matplats (10 : ea29b72c-b304-4fde-89c5-15fdfdf09830).
2022-11-13 00:59:54 INF [plejd-mqtt] Sending discovery for 0 Plejd input devices
2022-11-13 00:59:54 INF [plejd-mqtt] Sending discovery for 0 Plejd scene devices
2022-11-13 00:59:54 INF [device-comm] Plejd got turn off command for Belysning vägg (D8750833883C_0)
2022-11-13 00:59:54 INF [device-comm] Plejd got turn on command for Takbelysning köksbord (FE18E394FF8A_0), brightness undefined
2022-11-13 00:59:54 INF [device-comm] Plejd got turn off command for Belysning fönster (E20EF99234E1_0)
2022-11-13 00:59:54 INF [device-comm] Plejd got turn off command for Kök / Matplats (ea29b72c-b304-4fde-89c5-15fdfdf09830)
2022-11-13 00:59:59 INF [plejd-ble] BLE init done, waiting for devices.
2022-11-13 00:59:59 INF [plejd-main] Main init done
2022-11-13 00:59:59 INF [plejd-main] main() finished
2022-11-13 01:00:19 ERR [plejd-ble] Discovery timeout elapsed, no devices found. Starting reconnect loop...
2022-11-13 01:00:19 INF [plejd-ble] Starting reconnect loop...
2022-11-13 01:00:19 INF [device-comm] Bluetooth reconnecting...
2022-11-13 01:00:24 INF [plejd-ble] Reconnecting BLE...
2022-11-13 01:00:24 INF [plejd-ble] init()
2022-11-13 01:00:29 ERR [plejd-ble] Failed to start discovery. Operation already in progress
DBusError: Operation already in progress
at methodReturnHandlers. (/plejd/node_modules/dbus-next/lib/bus.js:343:27)
at handleMessage (/plejd/node_modules/dbus-next/lib/bus.js:101:11)
at EventEmitter. (/plejd/node_modules/dbus-next/lib/bus.js:151:9)
at EventEmitter.emit (events.js:314:20)
at /plejd/node_modules/dbus-next/lib/connection.js:116:14
at Socket. (/plejd/node_modules/dbus-next/lib/message.js:63:9)
at Socket.emit (events.js:314:20)
at emitReadable
(_stream_readable.js:557:12)
at processTicksAndRejections (internal/process/task_queues.js:83:21)
2022-11-13 01:00:29 INF [plejd-ble] If you continue to get "operation already in progress" error, you can try power cycling the bluetooth adapter. Get root console access, run "bluetoothctl" => "power off" => "power on" => "exit" => restart addon.
2022-11-13 01:00:29 WRN [plejd-ble] Failed reconnecting. Failed to start discovery. Make sure no other add-on is currently scanning.
Error: Failed to start discovery. Make sure no other add-on is currently scanning.
at PlejBLEHandler._startGetPlejdDevice (/plejd/PlejdBLEHandler.js:436:13)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
2022-11-13 01:00:29 INF [device-comm] Bluetooth reconnecting...

HA-Plejd Stops responding

Hi,

I have a dedicated Raspberry Pi 3b with ha-plejd on it, Running a Hass.io installation.
it works for a couple of hours but all of a sudden it stops working and i cant Control the lights Before i reboot the pi.

I have reinstalled Everything on a Pi 3B+ different SD card brand, but i get the same problem.

Here is my log after a reboot and until it stops working.

2019-09-01 06:01:40 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.
2019-09-01 06:07:29 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1864913968] 'data'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 210, in handle_service
self._platforms.values(), func, call, service_name, required_features
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 349, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 371, in _handle_service_platform_call
await getattr(entity, func)(**data)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/plejd/light.py", line 119, in turn_off
plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'data'
2019-09-01 06:37:10 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1864913968] 'data'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/components/light/init.py", line 307, in async_handle_light_on_service
await light.async_turn_on(**pars)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/plejd/light.py", line 109, in turn_on
plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'data'
2019-09-01 06:38:47 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1864913968] 'data'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/components/light/init.py", line 307, in async_handle_light_on_service
await light.async_turn_on(**pars)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/plejd/light.py", line 109, in turn_on
plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'data'
2019-09-01 06:43:50 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1864913968] 'data'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 210, in handle_service
self._platforms.values(), func, call, service_name, required_features
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 349, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 371, in _handle_service_platform_call
await getattr(entity, func)(**data)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/plejd/light.py", line 119, in turn_off
plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'data'
2019-09-01 06:47:10 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1864913968] 'data'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 210, in handle_service
self._platforms.values(), func, call, service_name, required_features
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 349, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 371, in _handle_service_platform_call
await getattr(entity, func)(**data)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/plejd/light.py", line 119, in turn_off
plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'data'
2019-09-01 06:47:10 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1864913968] 'data'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 210, in handle_service
self._platforms.values(), func, call, service_name, required_features
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 349, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 371, in _handle_service_platform_call
await getattr(entity, func)(**data)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/plejd/light.py", line 119, in turn_off
plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'data'
2019-09-01 07:48:29 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1864913968] 'data'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/components/light/init.py", line 307, in async_handle_light_on_service
await light.async_turn_on(**pars)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/plejd/light.py", line 109, in turn_on
plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'data'
2019-09-01 07:48:34 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1864913968] 'data'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/components/light/init.py", line 307, in async_handle_light_on_service
await light.async_turn_on(**pars)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/plejd/light.py", line 109, in turn_on
plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'data'
2019-09-01 07:50:36 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1864913968] 'data'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 210, in handle_service
self._platforms.values(), func, call, service_name, required_features
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 349, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 371, in _handle_service_platform_call
await getattr(entity, func)(**data)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/plejd/light.py", line 119, in turn_off
plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'data'
2019-09-01 07:50:42 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1864913968] 'data'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/components/light/init.py", line 307, in async_handle_light_on_service
await light.async_turn_on(**pars)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/plejd/light.py", line 109, in turn_on
plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'data'
2019-09-01 07:50:43 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1864913968] 'data'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/components/light/init.py", line 307, in async_handle_light_on_service
await light.async_turn_on(**pars)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/plejd/light.py", line 109, in turn_on
plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'data'
2019-09-01 07:51:43 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1862919312] 'data'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/components/light/init.py", line 307, in async_handle_light_on_service
await light.async_turn_on(**pars)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/plejd/light.py", line 109, in turn_on
plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'data'
2019-09-01 07:51:46 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1862919312] 'data'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 210, in handle_service
self._platforms.values(), func, call, service_name, required_features
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 349, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 371, in _handle_service_platform_call
await getattr(entity, func)(**data)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/plejd/light.py", line 119, in turn_off
plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'data'
2019-09-01 07:51:47 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1862919312] 'data'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/components/light/init.py", line 307, in async_handle_light_on_service
await light.async_turn_on(**pars)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/plejd/light.py", line 109, in turn_on
plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'data'
2019-09-01 07:52:43 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1864913968] 'data'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/components/light/init.py", line 307, in async_handle_light_on_service
await light.async_turn_on(**pars)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/plejd/light.py", line 109, in turn_on
plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'data'
2019-09-01 07:55:38 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1863859376] 'data'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/components/light/init.py", line 307, in async_handle_light_on_service
await light.async_turn_on(**pars)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/plejd/light.py", line 109, in turn_on
plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'data'
2019-09-01 07:55:39 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1863859376] 'data'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 210, in handle_service
self._platforms.values(), func, call, service_name, required_features
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 349, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 371, in _handle_service_platform_call
await getattr(entity, func)(**data)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/plejd/light.py", line 119, in turn_off
plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'data'
2019-09-01 07:57:44 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1864913968] 'data'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 210, in handle_service
self._platforms.values(), func, call, service_name, required_features
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 349, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 371, in _handle_service_platform_call
await getattr(entity, func)(**data)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/plejd/light.py", line 119, in turn_off
plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'data'

newbie instructions for hassio

Hi,

I've never used Home Assistant earlier, but turns out this plugin would be able to control the lights for me. I don't find this from the "add integration" button in hassio. I just installed the HA on RPi3. Could there be step by step instructions how to install this plugin there for a total newbie?

DIM-02 with dual outputs

I have a couple of DIM-02, but only one of the output channels can be controlled and found.
How do I control both outputs?

Crypto key on IOS

I tried to extract the crypto key on IOS, and in the folder apps/com.plejd.plejdapp/ its now just a group.com.plejd.consumer.light.plist, and no crypto key - is it anything I am missing?

Integration has likely been deprecated?

Looks like homeassistant expected some additional variable that is not being provided? Has this integration completely stopped working?

Logger: homeassistant.components.light
Source: custom_components/plejd/light.py:519
Integration: Light (documentation, issues)
First occurred: 4:39:14 PM (1 occurrences)
Last logged: 4:39:14 PM

Error while setting up plejd platform for light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 353, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/plejd/light.py", line 519, in async_setup_platform
    hass.services.async_register("plejd", "write_data", plejd_service)
                                                        ^^^^^^^^^^^^^
NameError: name 'plejd_service' is not defined

Problem get it working

I have been trying to get this working on a new installation of Hassbian.

I have made the installation like this:

First i extracted the cryptoKey (not my exact key: 5BDB62A12E1012C2B4A71CE3F3D77786 ) and outputAdresses (only gave me a list of number like: 11,16,17,18,19 and so on. no name on rooms, is that right? )
then:

  • sudo apt-get install python3-pip libglib2.0-dev
  • sudo pip3 install bluepy
  • copied /usr/local/lib/python3.7/dist-packages/bluepy > /srv/homeassistant/lib/python3.7/site-packages/bluepy
  • sudo setcap cap_net_raw,cap_net_admin,cap_net_bind_service+eip /srv/homeassistant/lib/python3.7/site-packages/bluepy/bluepy-helper
  • created directory /home/homeassistant.homeassistant/custom_components
  • downloaded the three files: init.py , light.py, manifest.json

added this at the end to configuration.yaml (i didn´t add all devices yet, just som to start)

light:

  • platform: plejd
    crypto_key: 5BDB62A12E1012C2B4A71CE3F3D77786
    devices:
    11:
    name: bedroom
    16:
    name: kitchen_1
    17:
    name: kitchen_2
    18:
    name: bathroom

i can now see the devices in HA, but when trying to turn something on i get this error in the HA web interface: Misslyckades med att anropa tjänsten light/turn_on. 'handles'
and this in the log:

2019-08-09 21:47:00 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/light/init.py", line 303, in async_handle_light_on_service
await light.async_turn_on(**pars)
File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/homeassistant/.homeassistant/custom_components/plejd/light.py", line 106, in turn_on
plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
KeyError: 'handles'

Does anyone know what i could have made wrong?

If i run "sudo hcitool lescan" I get a long list of devices Like:
FA:12:D5:9D:CA:21 P mesh
FA:12:D5:9D:CA:21 (unknown)
41:ED:60:44:4D:92 (unknown)
C7:B0:31:7B:36:D0 P mesh
C7:B0:31:7B:36:D0 (unknown)
41:ED:60:44:4D:92 (unknown)
……...

No plejd devices found. Radio interference?

Hi,

I am having huge issues at the moment connecting to plejd devices. Home assistant almost always says "No plejd devices found"

I recently moved from SD-card to SSD over USB3 on my Rpi4.
Could this be the problem, what are the gathered experience here?
I also had a lot of problems with my conbee Zigbee controller.
Those problems were solved by adding a 3m long USB extension cord.

Have anyone here had the same issues?
Has anyone tested to replace built-in BLE with a USB one?

FileNotFoundError

Hi!

I have not been able to get this to work on Hass on a RPi4.
Running HASS 0.103.6 on Raspian Buster

  • I have made sure the the custom_component folder and files have the same rights as other custom components.
  • I can run bluetooth scans and see my plejd device in the list.
  • HASS user is member of group bluetooth
  • Fetched decryption key and device id

Please advice.

This is the log output in HASS:
Error while setting up platform plejd
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
return fut.result()
File "/config/custom_components/plejd/light.py", line 414, in async_setup_platform
await connect(plejdinfo)
File "/config/custom_components/plejd/light.py", line 149, in connect
bus = await MessageBus(bus_type=BusType.SYSTEM).connect()
File "/usr/local/lib/python3.7/site-packages/dbus_next/aio/message_bus.py", line 38, in init
super().init(bus_address, bus_type, ProxyObject)
File "/usr/local/lib/python3.7/site-packages/dbus_next/message_bus.py", line 71, in init
self._setup_socket()
File "/usr/local/lib/python3.7/site-packages/dbus_next/message_bus.py", line 447, in _setup_socket
raise err
File "/usr/local/lib/python3.7/site-packages/dbus_next/message_bus.py", line 441, in _setup_socket
self._sock.connect(filename)
FileNotFoundError: [Errno 2] No such file or directory

Component not working

My setup is a raspberry pi 3+ with hassbian
I have run through the steps with pygatt and extrakting the crypto key, no problems here.

When i try to run it I can´t find any lights, no erreors in "home-assistant.log".
The only place where I can find a error is in "Configuration validation", when I check my config I get "Platform not found: light.plejd"

My guess is that something is initiating correctly.
Is there any sepererat logfiles for the plejd component?

/Johan

Cannot use/login to Plejd integration since a few weeks ago

Hi! I had had problems using the Plejd integration for a few weeks. When checking the log it seems as the commands propagated from i e google home are propagated into HA but nothing happens with the lights. When trying the same things through the Plejd app, nothing gets detected.

Now, when trying to uninstall/reinstall the integration I get the following error:

2021-01-22 08:04:38Z ERR plejd-api Server returned status 400. probably invalid credentials, please verify.
(node:4096) UnhandledPromiseRejectionWarning: unable to retrieve session token response: Error: Request failed with status code 400

I only copied the configuration so it shouldn't be a problem. Any tips for me regarding my problem(s)?

Light won't turn on

I'm not sure what's wrong, I can't tell from the logs, but it seems the light state is not discovered. Here's what the entity looks like in HA when the physical light is actually on:
image
When I click the on-button it seems to time out and switches back to off.
configuration.yaml:

light:
  - platform: plejd
    crypto_key: <redacted>
    devices:
      1:
        name: hallbelysning

log:

[homeassistant.loader] We found a custom integration plejd which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
[homeassistant.components.light] Setting up light.plejd
[custom_components.plejd.light] Discovered bluetooth adapter /org/bluez/hci0
[homeassistant.components.light] Setup of light platform plejd is taking over 10 seconds.
[custom_components.plejd.light] Discovered plejd /org/bluez/hci0/dev_D4_DB_C9_4E_97_4F with RSSI -76
[custom_components.plejd.light] Connecting to /org/bluez/hci0/dev_D4_DB_C9_4E_97_4F
[custom_components.plejd.light] Failed connecting to plejd service
[homeassistant.components.light] Platform plejd not ready yet: None; Retrying in background in 30 seconds
[homeassistant.components.light] Setting up light.plejd
[custom_components.plejd.light] Discovered bluetooth adapter /org/bluez/hci0
[custom_components.plejd.light] Disconnecting /org/bluez/hci0/dev_D4_DB_C9_4E_97_4F
[custom_components.plejd.light] Discovered plejd /org/bluez/hci0/dev_D4_DB_C9_4E_97_4F with RSSI -76
[custom_components.plejd.light] Connecting to /org/bluez/hci0/dev_D4_DB_C9_4E_97_4F
[custom_components.plejd.light] Successfully pinged with b5
[custom_components.plejd.light] Adding device 1 (hallbelysning)
[homeassistant.helpers.entity_registry] Registered new light.plejd entity: light.hallbelysning
[custom_components.plejd.light] All plejd setup completed
[custom_components.plejd.light] Successfully pinged with 69
[custom_components.plejd.light] No match for command 'b'001b'' (b'010110001b3d31256101')
[custom_components.plejd.light] No match for device '0b' (b'0b0110009801ffff00')
[custom_components.plejd.light] Turning on hallbelysning(01) with brigtness 00
[custom_components.plejd.light] Successfully pinged with d5
[custom_components.plejd.light] Turning on hallbelysning(01) with brigtness 00
[custom_components.plejd.light] Turning on hallbelysning(01) with brigtness 00
[custom_components.plejd.light] Successfully pinged with e4
[custom_components.plejd.light] No match for device '0b' (b'0b0110009801ffff00')
[custom_components.plejd.light] No match for command 'b'001b'' (b'010110001ba933256101')
[custom_components.plejd.light] Successfully pinged with bc
[custom_components.plejd.light] Successfully pinged with 0d
[custom_components.plejd.light] Turning on hallbelysning(01) with brigtness 00
  1. How do I know which number to use for the device in configuration.yaml? This is not mentioned in any documentation or issue.
  2. Should the crypto key be entered with quotes around it or not?
  3. How do I know if the crypto key has been accepted

Exception while access self._brightness

Access to self._brightness was accessed before it has been declarated causing an exception in brightness method.

home-assistant   |     data[ATTR_BRIGHTNESS] = self.brightness
home-assistant   |   File "/config/custom_components/plejd/light.py", line 111, in brightness
home-assistant   |     if self._brightness:
home-assistant   | AttributeError: 'PlejdLight' object has no attribute '_brightness'

dbus app-armor blocking?

Hi,

I have taken a break from getting this plugin to work for a while as my bluez version was too old. I finally got around to updating it to a more respectable 5.46, but get the following errors when starting HA (Home assistant is running in a docker image, bluetoothd is running outside docker)

home-assistant | 2021-04-08 22:28:56 ERROR (MainThread) [homeassistant.components.light] Error while setting up plejd platform for light
home-assistant | Traceback (most recent call last):
home-assistant | File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 200, in _async_setup_platform
home-assistant | await asyncio.shield(task)
home-assistant | File "/config/custom_components/plejd/light.py", line 478, in async_setup_platform
home-assistant | await connect(plejdinfo)
home-assistant | File "/config/custom_components/plejd/light.py", line 174, in connect
home-assistant | om_introspection = await bus.introspect(BLUEZ_SERVICE_NAME, '/')

home-assistant | File "/usr/local/lib/python3.8/site-packages/dbus_next/aio/message_bus.py", line 216, in introspect
home-assistant | return await asyncio.wait_for(future, timeout=timeout)
home-assistant | File "/usr/local/lib/python3.8/asyncio/tasks.py", line 494, in wait_for
home-assistant | return fut.result()
home-assistant | File "/usr/local/lib/python3.8/site-packages/dbus_next/message_bus.py", line 196, in reply_notify
home-assistant | BaseMessageBus._check_method_return(reply, err, 's')
home-assistant | File "/usr/local/lib/python3.8/site-packages/dbus_next/message_bus.py", line 605, in _check_method_return
home-assistant | raise err
home-assistant | File "/usr/local/lib/python3.8/site-packages/dbus_next/aio/message_bus.py", line 366, in _message_reader
home-assistant | if self._unmarshaller.unmarshall():
home-assistant | File "/usr/local/lib/python3.8/site-packages/dbus_next/_private/unmarshaller.py", line 304, in unmarshall
home-assistant | self._unmarshall()
home-assistant | File "/usr/local/lib/python3.8/site-packages/dbus_next/_private/unmarshaller.py", line 243, in _unmarshall
home-assistant | self.read(16, prefetch=True)
home-assistant | File "/usr/local/lib/python3.8/site-packages/dbus_next/_private/unmarshaller.py", line 91, in read
home-assistant | raise EOFError()
home-assistant | EOFError

When running dbus-monitor, i get a clue as to what might be wrong:

method call time=1617913736.312933 sender=:not.active.yet -> destination=org.freedesktop.DBus serial=1 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=Hello
error time=1617913736.312955 sender=org.freedesktop.DBus -> destination=:not.active.yet error_name=org.freedesktop.DBus.Error.AccessDenied reply_serial=1
string "An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender="(null)" (inactive) interface="org.freedesktop.DBus" member="Hello" error name="(unset)" requested_reply="0" destination="org.freedesktop.DBus" (bus)"
method call time=1617913736.380199 sender=:not.active.yet -> destination=org.bluez serial=2 path=/; interface=org.freedesktop.DBus.Introspectable; member=Introspect

My guess is some policy mög which is killing all communication from the container to the bluetooth daemon.
Anyone else had this problem and have any tips to fix it? Thanks in advance

FileNotFound

Hi,

I'm using the standard homeassistant docker container (not hass.io). After creating the custom components folder, cloning in the files and adding the configuration.yaml section i get the following error in the log:


2020-05-04 20:47:38 ERROR (MainThread) [homeassistant.components.light] Error while setting up plejd platform for light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/config/custom_components/plejd/light.py", line 417, in async_setup_platform
    await connect(plejdinfo)
  File "/config/custom_components/plejd/light.py", line 149, in connect
    bus = await MessageBus(bus_type=BusType.SYSTEM).connect()
  File "/usr/local/lib/python3.7/site-packages/dbus_next/aio/message_bus.py", line 39, in __init__
    super().__init__(bus_address, bus_type, ProxyObject)
  File "/usr/local/lib/python3.7/site-packages/dbus_next/message_bus.py", line 72, in __init__
    self._setup_socket()
  File "/usr/local/lib/python3.7/site-packages/dbus_next/message_bus.py", line 499, in _setup_socket
    raise err
  File "/usr/local/lib/python3.7/site-packages/dbus_next/message_bus.py", line 493, in _setup_socket
    self._sock.connect(filename)
FileNotFoundError: [Errno 2] No such file or directory

When i run hcitool lescan inside the container i get the expected output:

bash-5.0# hcitool lescan
LE Scan ...
33:DE:F5:9F:FE:58 (unknown)
FA:43:4E:45:BD:A4 P mesh
FA:43:4E:45:BD:A4 (unknown)
CC:D3:19:98:B5:EF P mesh
33:DE:F5:9F:FE:58 (unknown)

What would be the next step be in troubleshooting? It seems to me like there is some dbus issue but it's beyond my debugging capabilities

Frequently disconnecting

Plejd has been disconnecting for a few couple of days.

The most recent log when this was happening is:

2019-08-25 17:25:54 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall light.turn_on (c:7a0c4081cef146499bf7ef7d07116164): entity_id=['light.badrum']>
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1159, in _safe_execute
    await self._execute_service(handler, service_call)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1172, in _execute_service
    await handler.func(service_call)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/light/__init__.py", line 295, in async_handle_light_on_service
    await light.async_turn_on(**pars)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/plejd/light.py", line 109, in turn_on
    plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
  File "/home/homeassistant/.homeassistant/custom_components/plejd/light.py", line 292, in plejd_write
    pi["device"].writeCharacteristic(handle, data, wait)
  File "/srv/homeassistant/lib/python3.5/site-packages/bluepy/btle.py", line 543, in writeCharacteristic
    return self._getResp('wr')
  File "/srv/homeassistant/lib/python3.5/site-packages/bluepy/btle.py", line 407, in _getResp
    resp = self._waitResp(wantType + ['ntfy', 'ind'], timeout)
  File "/srv/homeassistant/lib/python3.5/site-packages/bluepy/btle.py", line 338, in _waitResp
    if self._helper.poll() is not None:
AttributeError: 'NoneType' object has no attribute 'poll'
2019-08-25 17:25:54 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall light.turn_on (c:6ecba558a72946fca5eecd53887657b3): entity_id=['light.badrum']>
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1159, in _safe_execute
    await self._execute_service(handler, service_call)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1172, in _execute_service
    await handler.func(service_call)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/light/__init__.py", line 295, in async_handle_light_on_service
    await light.async_turn_on(**pars)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/plejd/light.py", line 109, in turn_on
    plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
  File "/home/homeassistant/.homeassistant/custom_components/plejd/light.py", line 292, in plejd_write
    pi["device"].writeCharacteristic(handle, data, wait)
  File "/srv/homeassistant/lib/python3.5/site-packages/bluepy/btle.py", line 543, in writeCharacteristic
    return self._getResp('wr')
  File "/srv/homeassistant/lib/python3.5/site-packages/bluepy/btle.py", line 407, in _getResp
    resp = self._waitResp(wantType + ['ntfy', 'ind'], timeout)
  File "/srv/homeassistant/lib/python3.5/site-packages/bluepy/btle.py", line 338, in _waitResp
    if self._helper.poll() is not None:
AttributeError: 'NoneType' object has no attribute 'poll'
2019-08-25 17:25:54 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall light.turn_on (c:e471a4254e5341fb83c49a7dafca3ff6): entity_id=['light.badrum']>
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1159, in _safe_execute
    await self._execute_service(handler, service_call)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1172, in _execute_service
    await handler.func(service_call)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/light/__init__.py", line 295, in async_handle_light_on_service
    await light.async_turn_on(**pars)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/plejd/light.py", line 109, in turn_on
    plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
  File "/home/homeassistant/.homeassistant/custom_components/plejd/light.py", line 292, in plejd_write
    pi["device"].writeCharacteristic(handle, data, wait)
  File "/srv/homeassistant/lib/python3.5/site-packages/bluepy/btle.py", line 543, in writeCharacteristic
    return self._getResp('wr')
  File "/srv/homeassistant/lib/python3.5/site-packages/bluepy/btle.py", line 407, in _getResp
    resp = self._waitResp(wantType + ['ntfy', 'ind'], timeout)
  File "/srv/homeassistant/lib/python3.5/site-packages/bluepy/btle.py", line 338, in _waitResp
    if self._helper.poll() is not None:
AttributeError: 'NoneType' object has no attribute 'poll'
2019-08-25 17:25:54 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall light.turn_on (c:3a53b9e1c0e54288970c9fb6421773ce): entity_id=['light.badrum']>
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1159, in _safe_execute
    await self._execute_service(handler, service_call)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1172, in _execute_service
    await handler.func(service_call)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/light/__init__.py", line 295, in async_handle_light_on_service
    await light.async_turn_on(**pars)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/plejd/light.py", line 109, in turn_on
    plejd_write(pi, pi["handles"]["data"], plejd_enc_dec(pi["key"], pi["address"], payload))
  File "/home/homeassistant/.homeassistant/custom_components/plejd/light.py", line 292, in plejd_write
    pi["device"].writeCharacteristic(handle, data, wait)
  File "/srv/homeassistant/lib/python3.5/site-packages/bluepy/btle.py", line 543, in writeCharacteristic
    return self._getResp('wr')
  File "/srv/homeassistant/lib/python3.5/site-packages/bluepy/btle.py", line 407, in _getResp
    resp = self._waitResp(wantType + ['ntfy', 'ind'], timeout)
  File "/srv/homeassistant/lib/python3.5/site-packages/bluepy/btle.py", line 338, in _waitResp
    if self._helper.poll() is not None:
AttributeError: 'NoneType' object has no attribute 'poll'
2019-08-25 17:25:56 WARNING (Thread-2) [custom_components.plejd.light] failed connecting to device '***MAC-adress***' : 'Failed to connect to peripheral ***MAC-adress***, addr type: random'
2019-08-25 17:25:56 WARNING (Thread-2) [custom_components.plejd.light] no device found on iteration 1
2019-08-25 17:25:58 WARNING (Thread-2) [custom_components.plejd.light] failed connecting to device '***MAC-adress***' : 'Failed to connect to peripheral ***MAC-adress***, addr type: random'
2019-08-25 17:25:58 WARNING (Thread-2) [custom_components.plejd.light] no device found on iteration 2
2019-08-25 17:25:59 WARNING (Thread-2) [custom_components.plejd.light] failed connecting to device '***MAC-adress***' : 'Failed to connect to peripheral ***MAC-adress***, addr type: random'
2019-08-25 17:25:59 WARNING (Thread-2) [custom_components.plejd.light] no device found on iteration 3
2019-08-25 17:26:01 WARNING (Thread-2) [custom_components.plejd.light] failed connecting to device '***MAC-adress***' : 'Failed to connect to peripheral ***MAC-adress***, addr type: random'
2019-08-25 17:26:01 WARNING (Thread-2) [custom_components.plejd.light] no device found on iteration 4
2019-08-25 17:26:03 WARNING (Thread-2) [custom_components.plejd.light] failed connecting to device '***MAC-adress***' : 'Failed to connect to peripheral ***MAC-adress***, addr type: random'
2019-08-25 17:26:03 WARNING (Thread-2) [custom_components.plejd.light] no device found on iteration 5
2019-08-25 17:26:05 WARNING (Thread-2) [custom_components.plejd.light] failed connecting to device '***MAC-adress***' : 'Failed to connect to peripheral ***MAC-adress***, addr type: random'
2019-08-25 17:26:05 WARNING (Thread-2) [custom_components.plejd.light] no device found on iteration 6
2019-08-25 17:26:07 WARNING (Thread-2) [custom_components.plejd.light] failed connecting to device '***MAC-adress***' : 'Failed to connect to peripheral ***MAC-adress***, addr type: random'
2019-08-25 17:26:07 WARNING (Thread-2) [custom_components.plejd.light] no device found on iteration 7
2019-08-25 17:26:09 WARNING (Thread-2) [custom_components.plejd.light] failed connecting to device '***MAC-adress***' : 'Failed to connect to peripheral ***MAC-adress***, addr type: random'
2019-08-25 17:26:09 WARNING (Thread-2) [custom_components.plejd.light] no device found on iteration 8

It won't always reconnect, bud it did this time,
What could be the cause?

Homebridge implementation

Hi, thanks for all the work that has been done reverse engineering this.

This is not an issue with this project per se, so feel free to delete / close it if you don't think it belongs here.

I am trying to do a Homebridge plugin for the Plejd system and have got the communication and auth sorted, mostly thanks for his repo. However when receiving messages from the mesh I am not able to decode it, I have even run the messages through your plejd_enc_dec method and the data I get out of it doesn't make any sense to me.

Sample when turning on a light with the DIM-02:
Hex data from mesh: 673904805185c81874
When run thru your plejd_enc_dec with my key and BT address of the connected device: b'74d6eee3708623c07c'.

Any idea what might cause this or what I might be doing wrong?

Thanks in advance if you got the time to answer this even though its not related to this project!

Rejected at scanend

I am running Home Assistant on a Ubuntu Linux machine. Home assistant is installed using virtual environment. I also have three Plejd dimmers installed, which works when I connect to them with the iOS app. I extracted the cryptokeys and removed the "" before and after the key and added it to my configuration.yaml.

I get this error message when I added the debug flag to the logging. The final message "Rejected" sounds to me like the cryptokey is wrong, I added my configuration.yaml at the bottom. The addresses in the first few lines when it reports "failed connecting" does match the Plejd dimmers.

2019-08-27 17:37:36 DEBUG (SyncWorker_10) [custom_components.plejd.light] Starting plejd connection
2019-08-27 17:37:37 WARNING (SyncWorker_10) [custom_components.plejd.light] failed connecting to device 'c8:e4:1a:d3:de:3c' : 'Failed to connect to peripheral c8:e4:1a:d
3:de:3c, addr type: random'
2019-08-27 17:37:37 WARNING (SyncWorker_10) [custom_components.plejd.light] failed connecting to device 'fe:dc:4b:78:c2:16' : 'Failed to connect to peripheral fe:dc:4b:7
8:c2:16, addr type: random'
2019-08-27 17:37:37 WARNING (SyncWorker_10) [custom_components.plejd.light] no device found on iteration 1
2019-08-27 17:37:37 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/plejd/light.py", line 311, in _start_plejd
    connect(plejdinfo)
  File "/home/homeassistant/.homeassistant/custom_components/plejd/light.py", line 133, in connect
    devs = sorted(list(scanner.scan(1)), key=lambda d: d.rssi)[::-1]
  File "/srv/homeassistant/lib/python3.6/site-packages/bluepy/btle.py", line 852, in scan
    self.start(passive=passive)
  File "/srv/homeassistant/lib/python3.6/site-packages/bluepy/btle.py", line 797, in start
    self._mgmtCmd(self._cmd()+"end")
  File "/srv/homeassistant/lib/python3.6/site-packages/bluepy/btle.py", line 312, in _mgmtCmd
    raise BTLEManagementError("Failed to execute management command '%s'" % (cmd), rsp)
bluepy.btle.BTLEManagementError: Failed to execute management command 'scanend' (code: 11, error: Rejected)

configuration.yaml extract:

light:

  • platform: plejd
    crypto_key: !secret plejdsec
    devices:
    11:
    name: trappa1
    12:
    name: trappa2
    14:
    name: trappa3

I extracted the cryptokeys through ibackup viewer and did like the readme:

cat site.json | jq '.PlejdMesh.CryptoKey' | sed 's/-//g'

parse error: Invalid numeric literal at EOF at line 1, column 18688
"5FB3B****************************19CA4"

The above string is what I put in my secrets.yaml but without the "". I tried with the "" as well just to be sure but that didn't work either.

Any help would be much appreciated.

More some help needed, than an issue =)

I'm running an Unraid server with HA as an docker. I just bought some Plejd stuff I would like to get in to HA.

I got the crypto key from my android phone and also the devices and I cloned this projekt to /mnt/user/appdata/home-assistant/custom_components/plejd and edited configuration.yaml as in README.

I bought a USB dongle that my unraid server finds
root@Tower:~# lsusb
Bus 002 Device 005: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

When I restarts HA it starts in failsafe mode and the error says.
2020-04-03 15:01:05 ERROR (SyncWorker_1) [homeassistant.util.yaml.loader] while scanning for the next token
found character '\t' that cannot start any token
in "/config/configuration.yaml", line 140, column 1
2020-04-03 15:01:05 ERROR (MainThread) [homeassistant.bootstrap] Failed to parse configuration.yaml: while scanning for the next token
found character '\t' that cannot start any token
in "/config/configuration.yaml", line 140, column 1. Activating safe mode

I got this error even yesterday, before I got the BT adapter.

  1. How do I make sure HA has access to the BT adapter?
  2. Do I need to change something with the config folder path since I use Unraid?

Thanks.

/Söder

Typo in light.py

On line 442 in light.py, there is a typo
except DbusError as e:
should be
except DBusError as e:

Error while setting up plejd platform for light

I can not get my plejd device to show up in HA. I get the following error in the HA logs:

HA Log

Error while setting up plejd platform for light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 179, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/config/custom_components/plejd/light.py", line 417, in async_setup_platform
    await connect(plejdinfo)
  File "/config/custom_components/plejd/light.py", line 149, in connect
    bus = await MessageBus(bus_type=BusType.SYSTEM).connect()
  File "/usr/local/lib/python3.7/site-packages/dbus_next/aio/message_bus.py", line 38, in __init__
    super().__init__(bus_address, bus_type, ProxyObject)
  File "/usr/local/lib/python3.7/site-packages/dbus_next/message_bus.py", line 71, in __init__
    self._setup_socket()
  File "/usr/local/lib/python3.7/site-packages/dbus_next/message_bus.py", line 447, in _setup_socket
    raise err
  File "/usr/local/lib/python3.7/site-packages/dbus_next/message_bus.py", line 441, in _setup_socket
    self._sock.connect(filename)
FileNotFoundError: [Errno 2] No such file or directory

Setup

HW: Raspberry Pi 4
SW: Home Assistant Supervised i.e. running Home Assistant on a generic (Raspbian Lite) Linux Dist.

Install

Got the latest branch cloned into:
/usr/share/hassio/homeassistant/custom_components/plejd
which contains the following files.

drwxr-xr-x 8 root root  4096 Feb 28 23:06 .git
-rw-r--r-- 1 root root    23 Feb 28 23:06 __init__.py
-rw-r--r-- 1 root root 11357 Feb 28 23:06 LICENSE.md
-rw-r--r-- 1 root root 15130 Feb 28 23:06 light.py
-rw-r--r-- 1 root root   202 Feb 28 23:06 manifest.json
drwxr-xr-x 2 root root  4096 Mar  2 10:23 __pycache__
-rw-r--r-- 1 root root  4230 Feb 28 23:06 README.md

hcitool

Running hcitool as user 'pi':

 hcitool dev
Devices:
	hci0	DC:A6:32:3A:5D:EC

configuration.yaml:

logger:
   logs:
     custom_components.plejd: debug
 light:
   - platform: plejd
     crypto_key: '34*************A2'
     devices:
       11:
         name: bathroom

Please help.

I've not moved any. user to bluetooth group. To be honest I 'm not sure which user Home Asssistant is running as.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.