3 ms·
I'd love to see this! That exact idea has been tingling through my mind for a while. I did some experiments, but Prolog (and anything logic programming, really
by pedrovhb 5y ago
I'd love to see this!
That exact idea has been tingling through my mind for a while. I did some experiments, but Prolog (and anything logic programming, really) is a bit of a pain to integrate nicely with Python, which is what I'm building my system with.
I'm looking to make things declarative as much as possible, but having Prolog manage the automation rules would be next level. I imagine it abstracts away a lot of the boilerplate and unnecessary implementation details.
- sprior 5y agoSee my reply to ojford with a bigger description below.
- sprior 5y agoInstead of trying to directly integrate for example Prolog and Python I set up services in whatever language/hardware and communicate between then using JSON messages transported via MQTT. With this method I've got Docker containers running Java, Python, and Prolog code interoperating with ESP8266 and ESP32 devices I programmed in C++ and anyone can talk to anyone. I also wrote a Java server that interfaces with an Insteon gateway so my little MQTT cluster can respond to devices turning on/off or send a MQTT message to control a device. The pieces don't know or care what language the other pieces are written in. On the Prolog side of things with not that much framework code here is a trivial example: message(['Smarthome','Notify','brain','ping'],_):- publish(['Smarthome', 'Notify', 'brain', 'ping_response']). This code receives a MQTT message with a topic of Smarthome/Notify/brain/ping ignoring the message body and then publishes a return message on topic Smarthome/Notify/brain/ping_response I even have a container that runs nothing but cron with a mqtt client installed that sends mqtt messages at various times of the day and all Prolog has to do is subscribe to those topics and handle those messages.