icanos / hassio-plejd

Hass.io add-on for Plejd home automation devices
Apache License 2.0
126 stars 37 forks source link

DWN-01 #287

Closed arnoslag closed 11 months ago

arnoslag commented 11 months ago

Will there support for the DWN-01 / DWN-02 ?

SweVictor commented 11 months ago

Sure, why not? We will need some verbose logs from the discovery phase from someone that has the devices to be able to add them successfully.

Will give us hardware IDs etc.

arnoslag commented 11 months ago

ik have have the devices , what do you need from the verbose log?

arnoslag commented 11 months ago

2023-09-21 06:27:16 INF [plejd-ble] Got time response. Plejd clock time in sync with Home Assistant time 2023-09-21 06:27:16 VRB [plejd-ble] Raw event received: 26010300380000140000002400000000000000 2023-09-21 06:27:16 VRB [plejd-ble] Decoded: Device null (BLE address 38), cmd 38, state 0, dim 20 2023-09-21 06:27:16 VRB [plejd-ble] Command 38 unknown. 26010300380000140000002400000000000000. Device Unknown (38: null) 2023-09-21 06:27:16 VRB [plejd-ble] Raw event received: 26010300380000160000001f00000000000000 2023-09-21 06:27:16 VRB [plejd-ble] Decoded: Device null (BLE address 38), cmd 38, state 0, dim 22 2023-09-21 06:27:16 VRB [plejd-ble] Command 38 unknown. 26010300380000160000001f00000000000000. Device Unknown (38: null) 2023-09-21 06:27:16 VRB [plejd-ble] Raw event received: 260110009800bcbc00 2023-09-21 06:27:16 VRB [plejd-ble] Decoded: Device null (BLE address 38), cmd 98, state 0, dim 188 2023-09-21 06:27:16 DBG [plejd-ble] Unknown (null) got state+dim update. S: 0, D: 188 2023-09-21 06:27:16 WRN [device-registry] Trying to set state for null which is not in the list of known outputs. 2023-09-21 06:27:16 WRN [plejd-mqtt] Unknown output id null - not handled by us. 2023-09-21 06:27:17 VRB [plejd-ble] Raw event received: 26010300380000140000002400000000000000 2023-09-21 06:27:17 VRB [plejd-ble] Decoded: Device null (BLE address 38), cmd 38, state 0, dim 20 2023-09-21 06:27:17 VRB [plejd-ble] Command 38 unknown. 26010300380000140000002400000000000000. Device Unknown (38: null) 2023-09-21 06:27:18 VRB [plejd-ble] Raw event received: 260110009800bcbc00 2023-09-21 06:27:18 VRB [plejd-ble] Decoded: Device null (BLE address 38), cmd 98, state 0, dim 188 2023-09-21 06:27:18 DBG [plejd-ble] Unknown (null) got state+dim update. S: 0, D: 188 2023-09-21 06:27:18 WRN [device-registry] Trying to set state for null which is not in the list of known outputs. 2023-09-21 06:27:18 WRN [plejd-mqtt] Unknown output id null - not handled by us.


ID: EE3BCAD9322F

SweVictor commented 11 months ago

Hi, We would need the bits from the startup phase. Where we get response from the Plejd api with all devices and so on.

Look in the readme how to extract logs. Getting from the UI is quite tricky.

arnoslag commented 11 months ago

something like this ?

},
"notes": "DWN-01",
"data": {
  "__type": "File",
  "name": "f7a82c76acd82559692711faa22cf8f9_40a2353d17498aa6445cdbd83ab6262e_data_63b9496b-2bce-4f0b-9a97-73a8d32b7d9c.bin",
  "url": "https://cloud.plejd.com/parse/files/zHtVqXt8k4yFyk2QGmgp48D9xZr2G94xWYnF4dak/f7a82c76acd82559692711faa22cf8f9_40a2353d17498aa6445cdbd83ab6262e_data_63b9496b-2bce-4f0b-9a97-73a8d32b7d9c.bin"
},
"metaData": {
  "__type": "File",
  "name": "68d3dde6559a2aeaa8fca8952fa54299_01a414048edddac0b2e6a24344e115e6_metaData_2a2d693a-a10b-4d23-bc24-c9bc33b459b3.bin",
  "url": "https://cloud.plejd.com/parse/files/zHtVqXt8k4yFyk2QGmgp48D9xZr2G94xWYnF4dak/68d3dde6559a2aeaa8fca8952fa54299_01a414048edddac0b2e6a24344e115e6_metaData_2a2d693a-a10b-4d23-bc24-c9bc33b459b3.bin"
},
"version": "2.3.8",
"firmwareApi": "10",
"buildTime": 202306191703167,
"createdAt": "2023-06-28T11:23:46.265Z",
"updatedAt": "2023-09-26T08:48:23.285Z",
"firmwareNumber": 4,
"ACL": {},
"objectId": "GTUQcTgjkC",
"__type": "Object",
"className": "Firmware"

}, "createdAt": "2023-09-19T13:04:43.687Z", "updatedAt": "2023-09-21T03:24:57.797Z", "diagnostics": "0000150000002000000000000000", 
"ACL": {}, "objectId": "F4C5GSEhHx", "__type": "Object", "className": "PlejdDevice" } 2023-09-30 08:00:57 ERR [plejd-api] Error trying to create output device: Error: Unknown device type with id 167 2023-09-30 08:00:57 WRN [plejd-api] device (from API response) when error happened: { "deviceId": "DDCF721E7C89", "siteId": "***", "title": "Spot 1", "traits": 9, "hiddenFromRoomList": false, "roomId": "89b803f9-69fb-453e-94d7-be3b6ec8de62", "createdAt": "2023-09-19T13:28:38.347Z", "updatedAt": "2023-09-19T13:28:38.347Z",

SweVictor commented 11 months ago

@arnoslag: I have added support for the DWN-01 in the https://github.com/icanos/hassio-plejd/tree/develop branch. Please install it using the manual install method and test whether it works as expected.

arnoslag commented 11 months ago

@SweVictor I did test it today, i see now my six DWN-01 Butt i get a error when switch the lights on in the plejd app. The light status is unkown. Here some logs:

2023-10-02 18:14:09 DBG [plejd-mqtt] Sending discovery for Badkamer spotjes 2023-10-02 18:14:09 INF [plejd-mqtt] Discovered DWN-01 (light) named Badkamer spotjes (38 : EE3BCAD9322F_0). 2023-10-02 18:14:09 DBG [plejd-mqtt] Sending discovery for Spot 1 2023-10-02 18:14:09 INF [plejd-mqtt] Discovered DWN-01 (light) named Spot 1 (38 : D0188F9687E2_0). 2023-10-02 18:14:09 DBG [plejd-mqtt] Sending discovery for Spot 1 2023-10-02 18:14:09 INF [plejd-mqtt] Discovered DWN-01 (light) named Spot 1 (38 : E631B8CBE4C7_0). 2023-10-02 18:14:09 DBG [plejd-mqtt] Sending discovery for Spot 1 2023-10-02 18:14:09 INF [plejd-mqtt] Discovered DWN-01 (light) named Spot 1 (38 : D90CAA2F1331_0). 2023-10-02 18:14:09 DBG [plejd-mqtt] Sending discovery for Spot 1 2023-10-02 18:14:09 INF [plejd-mqtt] Discovered DWN-01 (light) named Spot 1 (38 : DDCF721E7C89_0). 2023-10-02 18:14:09 DBG [plejd-mqtt] Sending discovery for Spot 1 2023-10-02 18:14:09 INF [plejd-mqtt] Discovered DWN-01 (light) named Spot 1 (38 : E665B5024194_0).

2023-10-02 18:16:19 WRN [device-registry] Trying to set state for null which is not in the list of known outputs. 2023-10-02 18:16:19 WRN [plejd-mqtt] Unknown output id null - not handled by us. (node:302) UnhandledPromiseRejectionWarning: RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 1. Received 5 at boundsError (internal/buffer.js:82:9) at Buffer.readInt32LE (internal/buffer.js:386:5) at PlejBLEHandler._onLastDataUpdated (/plejd/PlejdBLEHandler.js:875:42) at processTicksAndRejections (internal/process/task_queues.js:97:5) (node:302) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:302) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

SweVictor commented 11 months ago

@arnoslag: The logs are incomplete, so it's hard to know what's going on, unfortunately. It is a bit strange that the same (?) "Spot 1" is discovered 5 times with the same BLE mesh id (38, the one we use to control the device) but with different hardware ids.

Please post a full log and include markers for when you

Given the first point (multiple discovered things) it would be interesting to see how you Plejd app looks - one device or many? One light or many? How does the device details page look like? How does the device look in HA?

Also:

arnoslag commented 11 months ago

I will upload later a compleet log. The lights are in a group.

arnoslag commented 11 months ago

Screenshot_20231003-130251 Screenshot_20231003-130248 Screenshot_20231003-130244

SweVictor commented 11 months ago

Interesting! "Groups" it not something that exists in my system (apart from Rooms which is a type of group). Out of curiosity, Is this a top menu item in the app next to Users/Devices/Rooms/... or something else? How do you group devices? Can you group other devices than the DWN ones?

arnoslag commented 11 months ago

Here is the link to logfile https://drive.google.com/file/d/1K3HnQo-r7vOvN-mpKONOCKoYm4CM7Kog/view?usp=drive_link

arnoslag commented 11 months ago

Here are the install options Screenshot_20231003-182340 Screenshot_20231003-182403 Screenshot_20231003-182419

SweVictor commented 11 months ago

Thanks for that. Requested access to the logs.

Can you group other device types or only the DWN-xx ones?

arnoslag commented 11 months ago

@SweVictor No, ik kan only create a group with DWN devices.

SweVictor commented 11 months ago

Thanks for the logs. Some follow-up questions towards the end @arnoslag

Pasting some important bits here for reference

Output devices (excerpt). All in group/output id 38.

2023-10-03 17:58:19 INF [plejd-mqtt] Discovered DWN-01 (light) named Badkamer spotjes (38 : EE3BCAD9322F_0).
2023-10-03 17:58:19 DBG [plejd-mqtt] Sending discovery for Spot 1
2023-10-03 17:58:19 INF [plejd-mqtt] Discovered DWN-01 (light) named Spot 1 (38 : D0188F9687E2_0).
2023-10-03 17:58:19 DBG [plejd-mqtt] Sending discovery for Spot 1
2023-10-03 17:58:19 INF [plejd-mqtt] Discovered DWN-01 (light) named Spot 1 (38 : E631B8CBE4C7_0).
2023-10-03 17:58:19 DBG [plejd-mqtt] Sending discovery for Spot 1
2023-10-03 17:58:19 INF [plejd-mqtt] Discovered DWN-01 (light) named Spot 1 (38 : D90CAA2F1331_0).
2023-10-03 17:58:19 DBG [plejd-mqtt] Sending discovery for Spot 1
2023-10-03 17:58:19 INF [plejd-mqtt] Discovered DWN-01 (light) named Spot 1 (38 : DDCF721E7C89_0).
2023-10-03 17:58:19 DBG [plejd-mqtt] Sending discovery for Spot 1
2023-10-03 17:58:19 INF [plejd-mqtt] Discovered DWN-01 (light) named Spot 1 (38 : E665B5024194_0).

Looking at the first one - EE3BCAD9322F_0 after decoding

{
    "bleOutputAddress": 38,
    "deviceId": "EE3BCAD9322F",
    "dimmable": false,
    "name": "Badkamer spotjes",
    "output": 0,
    "roomId": "89b803f9-69fb-453e-94d7-be3b6ec8de62",
    "roomName": "Badkamer",
    "type": "light",
    "typeDescription": "Smart tunable downlight with a built-in dimmer function, 8W",
    "typeName": "DWN-01",
    "version": "2.3.8",
    "uniqueId": "EE3BCAD9322F_0"
}

The other DWN-01 lights are simply named "Spot 1". Apart from that and a unique device id they look the same.

Q1: I'm guessing you can't control them individually, only as a group?

Based on the above assumption, we should probably just add one light (is it really safe to just use "the first"?) from the API response.

In the current version, the messages we receive get decoded as the last spot in the group, presumably that's why it's not working. Id E665B5024194

Q2: It would be interesting to see the full site response, but that is logged on the "silly" level I realize now. If you could post that as well (a long JSON in the beginning), please do so

SweVictor commented 11 months ago

@arnoslag: Based on the above I pushed a code update to https://github.com/icanos/hassio-plejd/tree/develop branch that only adds the first output for a certain id.

Please try it out and report back if possible.

arnoslag commented 11 months ago

Q1: I'm guessing you can't control them individually, only as a group? No i can't, only as a group Here is the silly log, with the latest develop update running https://drive.google.com/file/d/1gdd7s4FyU2l0aiYGoTU_6H6DwYowiuyl/view?usp=drive_link

It seems to work right now

SweVictor commented 11 months ago

It seems to work right now

First things first, great to hear @arnoslag!

Secondly, got a hold of the site json and did some digging for anyone interested. I'm missing a lot of keys in the JSON still, but maybe the response is a lot smaller than on my system (which has a gateway). Example keys, I'm missing devices and plejdDevices notably: image

Anyway - outputs match our decoding, multiple for BLE address 38:

    "DFAE89F68958": {
      "0": 37
    },
    "EE3BCAD9322F": {
      "0": 38  // the main one we're talking about above
    },
    "D0188F9687E2": {
      "0": 38  // the other 38s are the grouped ones
    },
    "E631B8CBE4C7": {
      "0": 38
    },
    "D90CAA2F1331": {
      "0": 38
    },
    "DDCF721E7C89": {
      "0": 38
    },
    "E665B5024194": {
      "0": 38
    },

Same for devices

  "deviceAddress": {
    "F53DF65F0BEF": 7,
    "F518B5E2538D": 14,
    "C93A78FB6311": 21,
    "DFF90D5E9A7F": 23,
    "C034B02146EC": 19,
    "E701C4C5745F": 26,
    "DFAE89F68958": 37,
    "EE3BCAD9322F": 38,  // the main one we're talking about above
    "D0188F9687E2": 38,   // the other "38" are the other grouped spots
    "E631B8CBE4C7": 38,
    "D90CAA2F1331": 38,
    "DDCF721E7C89": 38,
    "E665B5024194": 38,
    "EC74FB035442": 46
  },

Groups talk about the device BLE id and the room BLE id, I can't see any other "group" ids available.

  "outputGroups": {
    "C034B02146EC": {
      "0": [
        18,
        19,
        24
      ]
    },
    "EE3BCAD9322F": {
      "0": [
        23, // WPH-01 device ("badkamer ", guessing this controls the spots)
        28, // Room id
        38, // Output id
        39  // Not sure - secondary output? 
      ]
    },
...
SweVictor commented 11 months ago

Planned for 0.11