Skip to content

Per-Service Formatters #707

@ignorantbliss

Description

@ignorantbliss

I'm trying to set up my system to send notifications from inside an MQTT topic, but I want to send those notifications to two different destinations which require two different formats.

For example, let's say I want desktopnotify and file.

[/my/mqtt/folder/#]
format = my_formatter()
targets = {
	'/#': ['file:logfile', 'desktopnotify:desktop']
	}

How to I get a different format for the two different services, when I can only have one INI section per topic? It would be easy if I could add a second [/my/mqtt/folder/#], but that's not possible.

It would also be simple if the function call to the formatting function included an indication of which service the formatting was being sent to - this would make it really easy to customise the format to suit each individual destination.

Google Gemini suggests a technique that I can't find in the documentation and doesn't seem to work - it has the idea of putting in per-service formatters, like this...

[/my/mqtt/folder/#]
file:logfile.format = "ALERT: {name}"
desktopnotify:desktop.format = "{\"title\": \"Alert\",\"message\": \"{name}\"}"
targets = {
	'/#': ['file:logfile', 'desktopnotify:desktop']
	}

This would resolve my issue, but as I mentioned, I can't seem to get it to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions