moroen / IKEA-Tradfri-plugin

A Python plugin for Domoticz to controll IKEA Gateway
68 stars 23 forks source link

TRADFRI Recessed Spotlight (LEPTITER) - no 'Color preset' device created for scenes #109

Closed martin-g-it closed 3 years ago

martin-g-it commented 3 years ago

Hi, plugin works fine on Domoticz; I noticed one thing; although the TRADFRI Recessed Spotlight (LEPTITER) do have WS (White Spectrum) feature, only the dimmer switch is created, but the selector switch with hex_whites (Cold/Normal/Warm) is not created upon discovery.

Bypassed this by replacing 'return "W"' with 'return "WS"' on line 247 of ..tradfricoap\device.py , and this did create the 2 devices in Domoticz and made it work as it should, but this is obviously not a proper solution.

Been looking into different files, but couldn't find the exact place where the logic decides whether the device is a W/WS/CWS type.

Output of python3 plugin.py list --> Lights: 65549: TRADFRI Recessed Spotlight (State: 0 - Level: 48 - Hex: f5faf6) 65548: TRADFRI bulb (State: 0 - Level: 48 - Hex: f5faf6) Others: 65547: TRADFRI remote control (State: None - Level: None - Hex: None) Batteries: 65547: TRADFRI remote control - 47

moroen commented 3 years ago

It's derived from the device identifier returned from the gateway. Initially this was pretty consistent on Ikea's part, but it appears that this it somewhat changing.

Try the raw-command to see the output from the gateway for the Leptiter device:

$ python3 plugin.py 65549

it will return something like:

{'9001': 'TV-Stue - Bordlampe', '5750': 2, '3': {'0': 'IKEA of Sweden', '1': 'TRADFRI bulb E27 CWS opal 600lm', '2': '', '3': '1.3.013', '6': 1}, '9003': 65554, '9002': 1565036565, '9019': 1, '9020': 1597057451, '9054': 0, '3311': [{'5850': 1, '5708': 42596, '5851': 38, '5707': 5427, '5709': 30015, '5710': 26870, '5706': 'f1e0b5', '9003': 0}]}

This is for a 'TRADFRI bulb E27 CWS opal 600lm' bulb, which you can see is a CWS (full color spectrum) bulb!

If you post the output for your Leptiter device, I'll update the plugin, so it will appear as a WS device!

Or you can try to add this yourself. Take look at the device_info.py file in the tradfricoap-directory, it's currently:

deviceInfo = { "GUNNARP panel round": {"Color_space": "WS"} }

something like: deviceInfo = { "GUNNARP panel round": {"Color_space": "WS"}, "LEPTITER": {"Color_space": "WS"} } should do the trick, as long as you substitute LEPTITER with whatever is returned as the device identifier from the raw command...

I really would like to get a copy of your device_info.py file if it works!

martin-g-it commented 3 years ago

python3 plugin.py raw 65549

Returned following output: {'9001': 'TRADFRI Recessed Spotlight', '9003': 65549, '9002': 1596801104, '5750' : 2, '9054': 0, '9020': 1597063945, '9019': 1, '3': {'0': 'IKEA of Sweden', '2': '', '1': 'LEPTITER Recessed spot light', '3': '2.3.050', '6': 1}, '3311': [{'58 50': 0, '5851': 48, '5717': 0, '5711': 250, '5709': 24841, '5710': 24593, '5706'

Adding "LEPTITER Recessed spot light": {"Color_space": "WS"} to the device_info.py worked! Found this file earlier (it's used as an override to determine the attribute, right?) and tried before with 'TRADFRI Recessed Spotlight', but that didn't work :-)

deviceInfo = {
    "GUNNARP panel round": {"Color_space": "WS"},
    "LEPTITER Recessed spot light": {"Color_space": "WS"}
}