Automagic Automation on Sailfish

Automagic

As anyone browsing OpenRepos lately might have noticed, I’ve resurrected an ancient daemon and put it to work on Sailfish.

It was mainly intended as a way for me to find a use for the various old Sailfish phones I have lying around, but on the off chance that someone else might find it useful, I started this thread.

It’s something that has developed over quite a while (the project, not the codebase, which is a 100% rewrite in a new language) and was never intended for public release, so not everything in the configuration makes complete sense.

But should someone have trouble using it or any other questions, I’m here to help.

18 Likes

I’m currently running it on a Raspberry Pi to store various sensor data in a MySQL database.
However, I think a phone would not be a bad choice either, as it has a built-in 5G/4G modem as a backup and a long-lasting backup battery. If only it had a proper Ethernet port rather than just Wi-Fi.

Is there maybe a USB Ethernet adapter working with SFOS that would still allow charging while plugged in?

3 Likes

Maybe you could add inotify. I use it on my Jolla C2 as a watchdog for photo uploads to the NAS in my shell script. It monitors the directories /Camera, /Videos, and /Screenshots, and will trigger the script loop when a file write is done in those directories. Because of its event-driven nature, it consumes nearly no system resources.

inotify is a Linux kernel subsystem created by John McCutchan, which monitors changes to the filesystem, and reports those changes to applications. It can be used to automatically update directory views, reload configuration files, log changes, backup, synchronize, and upload. The inotifywait and inotifywatch commands allow using the inotify subsystem from the command line.

6 Likes

Currently files can only be used as a source not as a trigger so yes, inotify may indeed be useful to change that.

2 Likes

I’ve implemented it, at least on the daemon level.
It might take a little longer for the UI but should come with the next release.

It sets the following variables:
“path” - to the file/directory that has been watched
“file” - to the file that has been changed
“write” - true/false if it was a write operation
“create” - true/false …
“remove” - true/false
“rename” - true/false
“chmod” - true/false

These can then be acessed in transformations and pushed into flows:

2026/03/17 15:02:10 startFileTrigger event: WRITE         "/tmp/test1/test1.txt", ok: true
2026/03/17 15:02:10 applyTransformations - copy: arg0 = Hello World! -> body = Hello World!
2026/03/17 15:02:10 applyTransformations - copy: path = /tmp/test1/test1.txt -> file_path = /tmp/test1/test1.txt
2026/03/17 15:02:10 applyTransformations - copy: file = /tmp/test1/test1.txt -> file_name = /tmp/test1/test1.txt
2026/03/17 15:02:10 applyTransformations - copy: write = true -> event_write = true
2026/03/17 15:02:10 applyTransformations - copy: chmod = false -> event_chmod = false
2026/03/17 15:02:10 [1] HandleTriggerEvent - started for trigger: file_trigger
2026/03/17 15:02:10 [1] HandleTriggerEvent - Executing flow process_file_trigger for trigger file_trigger
2026/03/17 15:02:10 [1] Execute - Flow process_file_trigger started
2026/03/17 15:02:10 [1] Running Action: log
2026/03/17 15:02:10 [1] Action_log: Processed /tmp/test1/test1.txt - data: Hello World!, write: true, chmod: false.
2026/03/17 15:02:10 [1] Execute - Flow process_file_trigger finished
2 Likes

inotify is available in version 1.0.7

In addition to the ones mentioned above both sources and triggers of type “file” now expose the following variables:
“exists”-> true/false
“size”-> file size
“base_name”-> name of the file without path
“is_directory”-> true/false
“modify_time”-> mtime epoch
“mode”-> string representation of permissions
“permissions”-> numeric representation of permissions

4 Likes

Version 1.0.11 adds SMTP support, allowing, for example, texts to be forwarded as emails:

5 Likes

This is SOO cool. Thanks a lot!

One thing: the app ships with your default configuration, including a secret in the secrets.json file.

Maybe it would be a good idea to remove that.

4 Likes

These are just example files that are copied over when the app is started for the first time, except for secrets.json, which is generated automatically.

I thought they might be helpful in showcasing some of the capabilities and lowering the barrier to setting up new automations, as existing ones can be easily copied and modified.

5 Likes

Really great! I love being able to automate and link so many events and things.
However, I own an XA2 which is armv7. Is it planned (possible) to be available for it too?
Thanks

2 Likes

I’ve added a build target for armv7 and uploaded the RPM but don’t have any way to test it.
Could you please check if it installs?

5 Likes

With a great pleasure!
Many thanks for your quick answer!
I’ll get back asap.

Edit: Yes, it seems to install well.
I just didn’t get yet how to build a chan (event->action) but am a bit in hurry.
I’ll check later how to do that and test more.

2 Likes

If something like this shows up in the States tab, then the daemon is working:

It may need a reload (from the pulley menu) after the initial install or any changes to the configuration.

3 Likes

Oh, ok, no I have nothing in ‘states’

1 Like

Sorry, looks like there was an error in the spec file.
There should be another RPM (build version 2) that hopefully fixes this.

1 Like

Yesss, states is now populated!
I surely miss perspicaciousness, but how do I build an action from an event?

Here is an example how to forward SMS messages as emails:

  1. Create a new trigger (or use an existing one, e.g. “Incoming SMS”):

The difference between sources and triggers is that triggers can act as both, but can actually be used to start a flow. For example, a D-Bus signal can be a trigger, whereas a D-Bus method call can only be a source.

Both can pass variables to the flow, which are configured under Transformations.

  1. Create a new action (or use an existing one):

  2. Create a flow and select the trigger you want to use.

  3. Add a step to the flow to perform an action, for example an Action step, and select the action you want to use:

  4. Set the parameters you want to pass to the action.

Message and body were left blank in step 2. so that they can be passed as parameters from the flow.

In this example the trigger receives a text message and saves the sender number and the actual text into two variables: sms_sender and sms_text.

The action step in the flow then sets two parameters/variables (body and subject) using the variables from the source to construct the subject and the body of the email respectively, that are then passed to the action.

The action then sends the email using the parameters that were defined in the action plus the ones that were passed from the flow. The later having precedence over the ones defined in the action itself. (e.g. If a subject is defined in the action it would have been used if there was no subject parameter passed from the flow).

8 Likes

Ok, it is clearer now.
Many thanks for the app and for your time!

2 Likes

Version 1.0.12 adds IMAP support:

This should now allow building a complete two-way email-to-sms / sms-to-email gateway.

4 Likes

Version 1.0.13 adds a darkness() function to calculate sunrise/sunset:

It accepts latitude and longitude as parameters and returns:

is_dark: true/false
sunrise: HH:MM:SS
sunset: HH:MM:SS
sunrise_hour: H
sunrise_minute: M
sunset_hour: H
sunset_minute: M

Very useful for e.g. controlling lights etc.

4 Likes