sde1000 / python-dali

Library for controlling DALI lighting systems
Other
150 stars 71 forks source link

Device instance type #130

Open ptorrent opened 9 months ago

ptorrent commented 9 months ago

Hello !

What would be the function to call to get the device instance avaiable ?

QueryInstanceType ?

I've device that have implement an occupancy sensor (3) and a light sensor (4) in the same product. How can I know that this device has those sensor from dali bus ?

Thanks for your answer !

jktjkt commented 9 months ago

Yes, QueryInstanceType is what gets the workd done, but since it's very important to know the instance type up front, even for basic stuff such as correctly printing the bus traffic, this library has some helpers which make it much easier to build up this mapping. It's implemented in dali.device.helpers.DeviceInstanceTypeMapper, and the usage is as simple as shown in examples/async-buswatch.py.

ptorrent commented 9 months ago

Got it, thakns for the answer.

Actually if I use QueryInstanceType for device short address 0 (instance 0), this is the buffer I send:

0x01 0x00 0x80 and the answer => 1

if now I send address 0 and instance 3: 0x01 0x03 0x80 and the answer => 4

Not sure to correctly understand the answer of the device

Is there a special way to parse the answer ?

jktjkt commented 9 months ago

Well, the library implements this discovery already, and it should do The Right Thing™. It's indeed working as designed for the control devices that I have (all of which are multi-instance), which are Lunatone DALI-2 MC push-button couplers, the Lunatone DALI-2 ROT Touch buttons-and-click-wheel thingy, as well as the Lunatone DALI-2 CS movement and light level sensors. If you just let this autodiscovery run, you won't have to parse these replies in your code. Note that if you do not let this autodiscovery do its magic, then the packet sniffer/printer that's built into this library won't be able to decode the event frames properly, and it will just dump info about generic events, and also your callbacks won't see the decoded packets. Apparently, you are not doing that for some reason -- why so?

Now, if a device says that its instance number 3 is of a device type 4, then that means that it's a light sensor (part 304). If it says that its instance number 0 is of device type 1, then that means that it's a push button (part 301). IIRC the instance numbers are assigned in a continuous range, so if you have instance number 3, there should also be instance no. 0 (that you mention in this bugreport) and 1 and 2 (which you did not mention).

I guess I'm not sure what exactly you're asking for?

ptorrent commented 9 months ago

Thanks for your answer, that was a lack of dali knowledge from my part !

Thanks again for your support