Emulating Lunatone's IoT Gateway with python-dali
#139
jktjkt
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
Nice work! (And "ouch" at them sending invalid JSON — I can't see a nice way to work around this in the standard json parser so your hack seems the least-worst option.) At the very least I think this should be in |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
(TL;DR: use Lunatone's DALI Cockpit SW to talk to your
python-dali
using an emulated protocol.)My USB-to-DALI interface is connected to a tiny headless Pi Zero, which is running some Python code (built on top of
python-dali
) for stuff like circadian color temperature control, automatic blinds, automatic light based on movement, etc. This all works well, but every now and then I have a need to run Lunatone's DALI Cockpit to perform some changes in my devices' configuration.That's a Windows application, so I would usually fire up a VM with Windows and the DALI Cockpit, stop my automation, and then use usb-ip to export the USB device over network from my embedded server (
ssh [email protected] systemctl restart usbip-bind@17b5\:0020.service
) to my desktop (usbip attach -r private.example.org -b $(usbip list -p -r private.example.org | grep 17b5:0020 | cut '-d:' -f1 | awk '{print $1}')
), and attach that to the VM (echo "<hostdev mode='subsystem' type='usb' managed='yes'><source><vendor id='0x17b5'/><product id='0x0020'/></source><address type='usb' bus='0' port='3'/></hostdev>" | virsh attach-device win10 /dev/stdin
). That works, but it's a pain, and the automatic lights at the WC won't react to movement, and it's not great if it's dark in there.So I got fed up and wrote a tiny emulator of the Lunatone DALI-2 IoT Gateway. The idea is that you can run this on the Linux machine which has the USB-to-DALI interface already connected, and you can let your Windows VM connect to that over IP, using the device's emulated Websocket entry point. It's possible to run this either as a standalone application, or you can simply put it into your application code.
Here's the script (
fake_lunatone_iot.py
):I'm not sure if this is a good fit to put as an example into the main repo, so I'm sharing this as a discussion on GitHub -- maybe folks will find this useful. @sde1000 , if you think this belongs to the repo, I'll be happy to send a PR (or just pick it yourself at your convenience). I'm using some Python 3.11+ idioms, such as the TaskGroup, though.
Strangely, the GUI is sending some proprietary frames, including the 25bit eDALI stuff which is silently ignored (see the FIXME). Still, I was able to scan the bus, and perform some basic config using this emulator.
Beta Was this translation helpful? Give feedback.
All reactions