Adam’s July 2023 Meeting Summary

  • Home Automation with Delphi, MQTT and Home Assistant – David Akerman
  • Fast Fourier Transform – Kevin Bond
  • Auto archiving database data to keep all versions – Andrew Cutforth
  • Open Mic for Mote /Fleck/Gobbit/Tools / Tricks / Ticks

Adam’s Summary

News/Catchup

The meeting started with some useful updates from members who had attended the International Pascal Conference in Salamanca. This sounded like a good event, with a broad focus. Group member Richard Hatherall had presented, and Marco Cantu was given a life-time achievement award.

Home Automation with Delphi, MQTT and Home Assistant – David Akerman

David is an incredible engineer, the group has already been wowed by amazing presentations from David about his high altitude balloons, and work writing manufacturing software. David seems to be just as happy building his own kit (things like radio transmitter & receiver devices or other Raspberry-pi based machines) as he is writing code for FMX or VCL applications.
David spoke about “Home Assistant” an Application he uses to manage home automation and control devices in the “internet of things” (IOT). It allows him to do things like switch lights and devices on and off, control the temperature in rooms of his house on complex energy-saving timetables, and monitor devices like 2D and 3D printers.
My main take-aways from the talk were that there are new risks with “intelligent” devices, that the manufacturer can switch features on and off with impacts on users which they have little control over. David introduced us to MQTT (Message Queue Telemetry Transport) which is useful in managing transport of data from IOT devices.
David showed using TMS and native Delphi REST components to communicate with IOT devices. The process essentially involves parcelling up GET and POST statements of XML or JSON data together with appropriate keys. The native Delphi components seemed extremely adequate for the task, the TMS components added a good deal of useful functionality such as the ability to subscribe to specific devices, rather than polling for all the data.
Home Assistant
REST API – https://funprojects.blog/2020/12/12/home-assistant-rest-api/
WebSocket API – https://developers.home-assistant.io/docs/api/websocket/
MQTT
https://learn.sparkfun.com/tutor…/introduction-to-mqtt/all
Delphi and Home Assistant
Andrew Simard’s series on TMS Web Core with Home Assistant:
https://www.tmssoftware.com/site/blog.asp?post=1044
https://www.tmssoftware.com/site/blog.asp?post=1052
https://www.tmssoftware.com/site/blog.asp?post=1054
https://www.tmssoftware.com/site/blog.asp?post=1056
Sample Code

Contact ukdevgroup@jac2ltd.co.uk for more information

Fast Fourier Transform – Kevin Bond

Kevin is a retired Delphi educationalist, with decades of programming experience, and is the author of curriculum text books on computing. He spoke about Fast Fourier Transforms (FFT), starting from their origin in mathematics and the cold-war. FFT’s allow the analysis of signals. If you have ever seen a spectographic charts of sound you are looking at an FFT analysis. The technology has very wide-ranging applications in everything from video processing to detecting atomic bomb-blasts.
Fourier Transforms are very slow and intensive. FFTs are also complex, but much less so. Using Delphi mathematically to manipulate sines and cosines is really not my area of expertise, and I had difficulty following a good deal of Kevin’s presentation, which included a good deal of Delphi code to both generate test signals and then analyse them with Fourier Transform.
If you have any need of code of this type, I am sure Kevin would be happy to share his examples.

Auto archiving database data to keep all versions – Andrew Cutforth

Andrew has written his own business object framework. It automates the creation of complex databases to manage applications for financial and legal businesses.
A subsystem of his framework automatically generates a universal backup recording all changes to all tables within his database, which was the topic for this presentation. Obviously this is an extremely data-intensive process and is only suitable for certain types of application, but when needed can be valuable.
Andrew’s system consists of 2 parts: A “change-log” table, which holds a list of all changes with the changed table’s name, key-ID, user-ID and time-stamp and an archive table.
When a database table is created in Andrew’s framework this archive table is also created. The archive table exactly mirrors the main data-table with 5 additional fields that capture the date-time, type of change (insert, edit, delete), changing-user, and a UID.
The main-table then also has 3 triggers added, AfterInsert, AfterEdit and BeforeDelete. Each of these triggers inserts new rows into the Change-Log table and the appropriate archive table.
The whole set up is rock-solid and means that all changes to all data within his database are always logged. The fact that the whole system is well defined also means that adding new entities to a database does not require any work to hand-code the creation of the archive elements and triggers as this can all be done with predefined code.
In high-data situations Andrew’s solution would result in high volumes of data, but purging of key data after specific intervals can also be added.