• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
action: file
I created a file action for pilight V7 (development version).
It is intended to be used in rules to create files and write lines of text to them.
IF ... THEN file TO /home/pi/mylogs/myfile.txt MODE append TEXT My line of text

Functions and device variables can be used both in the file name and in the text to be written.

I myself am using it to log (rare) events, so I can examine them afterwards without having to sit and wait for them to happen.

The code and a more detailed description can be found here
Why not call it a write action?
What's in a nameSmile
Because it is filing information, I called it file, but write would be fine for me as well.
Just because of the language:

write TO /tmp/log
log TO /tmp/log

instead of

file TO /tmp/log

That's what i meant.
As I said, write is ok, but what do you think of this action? Is it worth making a PR?
If so, I will change the name to write first.
first of all great idea, I'd support that as well.
Is the order of the parameters fixed or variable? Like having this ->
IF ... THEN write TEXT My line of text TO /var/log/myfile.txt MODE append
working as well?
... and the mode is also optional?

I know these are "luxury" problems, just a spontaneous thought.. Big Grin
There is no check on the order of the parameters, but they all have to be present.
It would have been easy to make MODE optional, but I think it is better to let the user explicitly define what the action must do.

Fyi. the current version on my github still is called "file".
You can always do the pull-request Smile
Yes, I know, but I prefer to do that only when you think a file/write action as such is useful enough to add it to pilight.Smile
A write action would be nice. Could be extended to other writeable location like sockets.

Possibly Related Threads...
Thread Author Replies Views Last Post
  _VARSTORE_ set action fourty2 1 1,215 05-19-2019, 09:07 PM
Last Post: curlymo
  skipping overridden action switch do1eh 2 874 01-19-2019, 05:25 PM
Last Post: do1eh
  http action Niek 21 5,832 08-12-2018, 11:44 AM
Last Post: rorie
  action: Pushbullet bazb 24 13,709 01-04-2018, 08:38 PM
Last Post: curlymo
  action: pushover Niek 36 20,447 12-03-2017, 11:13 AM
Last Post: Alex
  action: switch Niek 54 23,553 03-31-2016, 06:24 PM
Last Post: jjj
  action: program bazb 16 9,178 03-31-2016, 09:14 AM
Last Post: Niek
  action: toggle Niek 1 2,683 02-19-2016, 03:04 PM
Last Post: Joeks
  action: dim terrar 10 6,803 08-13-2015, 05:13 PM
Last Post: terrar
  Event action sipcal to make a voip phonecall pieterd 7 5,046 05-15-2015, 05:47 PM
Last Post: koos147

Forum Jump:

Browsing: 1 Guest(s)