Analog Clock demo help

It from this: https://github.com/info-beamer/package-screen-info/blob/master/node.lua

Apparently I haven’t figured out how Info-Beamer is working. I haven’t implemented the “service” for this. I thought it was something standard in Lua.
So let me get this right. If I want to use the “util.data_mapper” - I also need to implement something in the “service” file - and not in the “clock.py” file?

Not quite. Let me explain: info-beamer (the process on each Raspberry Pi) always opens up a local UDP/TCP listen socket on port 4444. This allows other local processes to send data to the running info-beamer process. This can be useful as info-beamer (again, the process) itself cannot, for example, contact any outside service on its own. So it needs to be fed additional non-static data in some way. Using UDP/TCP for that is one way to do that.

Now there are various ways you can do that: If you open the info-beamer port to other machines on the network (here for how to do that, but doing so it usually not recommended as there’s no authentication in any way), another program on another machine can send data. That’s what my netcat call in my previous post did. Another way is to use the device command API call, which essentially allows you to send such UDP packets from anywhere using the API.

The final method is to have a local package service running on each Pi. This isn’t something magic: It’s just that any file named service within a package will be marked executable and will be executed on the Pi when installing that package. Such a package service can be written Python, like this one in the repository you linked. Such a service can also send UDP packets locally to the info-beamer process by sending data to 127.0.0.1:4444.

AH! That’s why the clock is not working. The demo code (https://github.com/dividuum/info-beamer-nodes/tree/master/analogclock) contains a “clock.py” and not a “service” file :slight_smile:

Yep. That’a also from a time when info-beamer hosted didn’t exist yet. So there was no convention on how anything outside of info-beamer or its Lua code should be named. The service name and the special handling that ensured that such a file is executed on a Pi was added to hosted.

If you run info-beamer pi on Raspbian, you can of course name those scripts any way you want, but that’s it’s up to you to ensure they are executed somehow. As that’s boring, info-beamer hosted solves that for you :slight_smile:

1 Like

Another problem seems to be that datetime is no longer supported :upside_down_face:

.py:

from hosted import datetime

It’s import datetime. See https://docs.python.org/library/datetime.html

1 Like