Logging service calls from Node-RED (or other externals) with more detail than "turned on/off by Tim"

I use Node-RED for a few of my automations. As probably is widely known, any service call from NR results in a logbook entry like "X turned on/off by [your name]", whereas an HA automation turning something on or off would result in "X turned on/off by [name of automation]".

Is there a way to (manually) include a name from NR in the service call for the "by [name]" section of the logbook? If not, is this something that’s being considered?

1 Like

Wasn’t known by me but I like the idea.

Hi @Timmiej93 and @Hellis81 here is how I do it:

[{"id":"5a9069c316586746","type":"api-call-service","z":"f1b6eb10f8042de9","name":"Log entry in Logbook","server":"1680b843.4f7308","version":4,"debugenabled":false,"domain":"logbook","service":"log","target":{"areaId":[],"deviceId":[],"entityId":[]},"data":"{\"name\":\"{{data_log.name}}\",\"message\":\"{{data_log.message}} [Node-RED_{{data_log.id}}]\",\"domain\":\"{{data_log.domain}}\",\"entity_id\":\"{{data_log.entity_id}}\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1260,"y":700,"wires":[[]]},{"id":"5fa0080c2b9273c6","type":"inject","z":"f1b6eb10f8042de9","name":"","props":[{"p":"data_log.message","v":"has been turned ON or OFF by Node-RED automation","vt":"str"},{"p":"data_log.entity_id","v":"switch.power_switch_02","vt":"str"},{"p":"data_log.domain","v":"switch","vt":"str"},{"p":"data_log.name","v":"friendly_name","vt":"str"},{"p":"data_log.id","v":"your_own_ID_for_reference","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":990,"y":700,"wires":[["5a9069c316586746"]]},{"id":"1680b843.4f7308","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

It is basically a service call to logbook/log service with the data being passed as a parameter via an object you can add to your messages. Hope this helps.

2 Likes