Skip to content

Commit f6204f1

Browse files
committed
docs: add examples for FHEM integration
1 parent f9456db commit f6204f1

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,66 @@ The configuration is based on environment variables.
370370
|`SIGNAL_ACCOUNT`|Phone number of the signal account|International phone number format with leading `+`|Account from signal-cli configuration|`+493023125000`
371371
|`SIGNAL_CLI_OPTIONS`|signal-cli options|All options [supported by `signal-cli`](https://github.com/AsamK/signal-cli/blob/master/man/signal-cli.1.adoc#options) except `-a` and `-o`|_none_|`--trust-new-identities never -v`
372372

373+
## FHEM integration
374+
The section contains example configurations for integration into [FHEM](https://fhem.de).
375+
376+
It is possible to create either 1 FHEM device per contact or a single FHEM device for all contacts, or both.
377+
378+
### FHEM device per Signal contact or group
379+
#### Contact
380+
- Create a device:
381+
```
382+
define mqtt_signal_user_sally MQTT2_DEVICE
383+
attr mqtt_signal_user_sally devicetopic %2B491713920000
384+
attr mqtt_signal_user_sally readingList signal/in/method/receive/source_number/$DEVICETOPIC/timestamp/[^/]+ message
385+
attr mqtt_signal_user_sally setList message signal/out/method/send/recipient/$DEVICETOPIC
386+
```
387+
- Send a message: `set mqtt_signal_user_sally message FHEM greets Sally`
388+
389+
#### Group
390+
- Create a device:
391+
```
392+
define mqtt_signal_group_admins MQTT2_DEVICE
393+
attr mqtt_signal_group_admins devicetopic LS0%2BYWRtaW5zPz8%2FCg%3D%3D
394+
attr mqtt_signal_group_admins readingList signal/in/method/receive/source_number/[^/]+/timestamp/[^/]+/group_id/$DEVICETOPIC:.* message
395+
attr mqtt_signal_group_admins setList message signal/out/method/send/groupId/$DEVICETOPIC
396+
```
397+
- Send a message: `set mqtt_signal_group_admins message FHEM greets Admins`
398+
399+
### Single device
400+
This configuration creates a single device that receives all messages.
401+
Readings `sourceName`, `message`, and `groupId` are updated when a message arrives.
402+
All remaining message parameters are available as readings prefixed with `json_params_`.
403+
404+
405+
- Requirement: Enable publishing of JSON messages in `compose.yml`:
406+
```yml
407+
services:
408+
signal-mqtt:
409+
environment:
410+
MQTT_PUBLISH_JSONRPC: "true"
411+
```
412+
413+
- Create the device:
414+
```
415+
define mqtt_signal MQTT2_DEVICE
416+
attr mqtt_signal devicetopic signal/in
417+
attr mqtt_signal readingList $DEVICETOPIC:.* { json2nameValue($EVENT, 'json_', $JSONMAP) }
418+
attr mqtt_signal jsonMap \
419+
json_params_envelope_sourceName:sourceName \
420+
json_params_envelope_dataMessage_message:message \
421+
json_params_envelope_dataMessage_groupInfo_groupId:groupId
422+
attr mqtt_signal stateFormat sourceName: message
423+
```
424+
425+
- It is optionally possible to introduce a reading `groupName`. This implementation requires a user attribute `groups` with a space-separated list of key/value pairs containing a mapping from groupId to groupName.
426+
```
427+
attr mqtt_signal userattr groups
428+
attr mqtt_signal groups LS0+YWRtaW5zPz8/Cg== Admins
429+
attr mqtt_signal userReadings groupName:groupId.+ \
430+
{ my %groups = split(' ', AttrVal($NAME, 'groups', undef)); return $groups{ReadingsVal($NAME, 'groupId', undef)}; }
431+
```
432+
373433
## References
374434
* This project is an integration of
375435
* [signal-cli](https://github.com/AsamK/signal-cli/) - A commandline interface for [Signal](https://signal.org/)

0 commit comments

Comments
 (0)