Author Topic: Extending Watcher Plugin  (Read 7561 times)

0 Members and 1 Guest are viewing this topic.

Nodo

  • Jr. Member
  • **
  • Posts: 22
  • Karma: 6
    • View Profile
Extending Watcher Plugin
« on: June 02, 2015, 11:49:42 PM »
Good day,

I have been experimenting with VC for a long time now and I must apologize for not being active on the forum :).

@James: great updates to VC. VC keeps proving that it is such a valuable tool in home automation. Even though I know you do not need the compliments... but as a programmer I know that it does not hurt to know that your work is appreciated from time to time ;).

@nime5ter: Well done on the excellent support, tutorials and innovative ideas to integerate VC with other tools.

With that being said, I have been experimenting with the watcher plugin recently and I know that you have been busy with all the updates that you have no time for the watcher plugin, but I thought to throw my request out there.

I think the watcher plugin can be a great plugin if it was a bit dynamic (i.e. being able to assign a folder to the watcher plugin through a command with a payload). If that is quite hard to implement I think the next best option is to have a check box to enable watching "Subdirectories" at the plugin interface.

Also, another set of Watch plugin commands to enable and disable the plugin would be nice but I think this is a bit of a lower priority and it can be worked around for the time being.

Thank you again for the great tool and just to let you know I plan on purchasing VC once my setup is complete and I move to my new place.


PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 499
  • Karma: 43
    • View Profile
Re: Extending Watcher Plugin
« Reply #1 on: June 03, 2015, 12:07:08 AM »
+1

I think another good feature to add would be the ability to watch multiple folders, I have a Script that I run with eventghost that once the media is finished being transferred or recorded to that folder it then renames and moves the video to the right folder, and if I could get VC to take care of that then eventghost would only be used for my remote  ;D 

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Extending Watcher Plugin
« Reply #2 on: June 03, 2015, 08:54:46 AM »
All good ideas, and I know that Haddood also asked for multiple folders.

I was meaning to get to this eventually but now that I see more demand I will prioritize it.  It won't make it into the upcoming release but hopefully the one after that.

I had not considered actions to extend the plugin.  Good idea.

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 499
  • Karma: 43
    • View Profile
Re: Extending Watcher Plugin
« Reply #3 on: June 03, 2015, 05:41:08 PM »
I just did a little test with the watcher plugin and looks like it only triggers an event when an item is first put in the folder that is being watched,

would it be possible to have the watcher plugin trigger the following events:

Watcher.Created (as it does now)
Watcher.Updated (used to see when a change is made to a file in that folder)
Watcher.Completed (or something similar when the file is fully transferred like a video being recorded or transferred across the network)
Watcher.Deleted (when a file or video is deleted from the folder, I could do this one with my script if I have Watcher.Completed to trigger the script)

these commands would be similar to what the Directory watcher plugin does in eventghost,
hope I'm not sounding greedy, I Could see this being a good addition to the VC plugins

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Extending Watcher Plugin
« Reply #4 on: June 03, 2015, 10:38:16 PM »
All good ideas, and I know that Haddood also asked for multiple folders.

I was meaning to get to this eventually but now that I see more demand I will prioritize it.  It won't make it into the upcoming release but hopefully the one after that.

I had not considered actions to extend the plugin.  Good idea.

now I know, I should be collecting signatures before making new requests  :biglaugh :biglaugh ...
When Voice command gets tough, use hand gestures

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Extending Watcher Plugin
« Reply #5 on: June 06, 2015, 05:24:35 PM »
2.1.4.8 is out and includes the new watcher plugin.

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 499
  • Karma: 43
    • View Profile
Re: Extending Watcher Plugin
« Reply #6 on: June 06, 2015, 06:07:41 PM »
Jitterjames, I just upgraded to 2.1.4.8 and the watcher plugin didn't show up in my plugins list to I opened options and went to the plugins tab and the watcher plugin was still selected so I unselected it and restarted VC then went back into options and selected the watcher plugin and clicked save and close and then clicked ok on the popup that says you must restart VC for the changes to take effect and after that I have an error message popup



after clicking ok on that error I restarted VC and the plugin wasn't added but in options it is still checked

let me know if you need me to check anything else

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Extending Watcher Plugin
« Reply #7 on: June 06, 2015, 06:32:56 PM »
Freaky...  I've no idea what could be causing that either.

I've tested with upgrades and with clean installs and had no issues from the watcher plugin. It loads fine, but you will need to redefine your settings because of the changes.

Do you get the same thing with a fresh install?

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 499
  • Karma: 43
    • View Profile
Re: Extending Watcher Plugin
« Reply #8 on: June 06, 2015, 07:33:34 PM »
Yes it works when I do a fresh install,

I tried to uninstall the plugin and then do the update but still see the same error and the plugin doesn't show up  :bonk

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Extending Watcher Plugin
« Reply #9 on: June 06, 2015, 07:44:40 PM »
OK that's good.  I least we know your machine is capable of running the plugin.

Make sure VC is completely closed before doing an upgrade.  Run task manager to double check there is no VoxCommando.exe process running before you run the installer.

Do an upgrade and make sure to choose to clean dlls.

It should not matter if the plugin in enabled or not when you do the upgrade.

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 499
  • Karma: 43
    • View Profile
Re: Extending Watcher Plugin
« Reply #10 on: June 06, 2015, 08:37:04 PM »
tried all that again and I also tried restarting my pc to make sure, but no luck... would it work if I took the watcher plugin folder from the new install and replace the watcher plugin folder in the updated one

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 499
  • Karma: 43
    • View Profile
Re: Extending Watcher Plugin
« Reply #11 on: June 06, 2015, 08:55:12 PM »
I just copied the watcher plugin folder from the new install to the updated install and it shows up now and no errors are showing up  ;D

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Extending Watcher Plugin
« Reply #12 on: June 06, 2015, 09:21:18 PM »
It makes no sense to me (unless vc was running or the files were locked somehow)  but I'm glad you got it working.

I tested upgrades on four different machines with no issues.  There's nothing special about that plugin versus any others in terms of the installation.  It should just be copying files and overwriting them when they already exist.

Computers eh...   :bonk

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Extending Watcher Plugin
« Reply #13 on: June 07, 2015, 01:59:42 AM »
I had similar issue ... all I did, disabled the watcher plug in ... went to the plugin folder, deleted the options.xml ... restarted VC and enabled the plug in ...all working fine 

BTW @James thank you for this update :)

update: compared both files ... the new options.xml has 2 more tags ... probably that is the issue, when they are missing ... plug-in get confused
    <WatcherList>
        <Watcher>
« Last Edit: June 07, 2015, 02:03:48 AM by Haddood »
When Voice command gets tough, use hand gestures

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Extending Watcher Plugin
« Reply #14 on: June 07, 2015, 08:26:52 AM »
OK.  All you need to do when upgrading is to delete the options.xml from the ".\plugins\watcher" folder.  No other changes are needed.

I will release a fix for this soon.

If you are doing a fresh install or if you never used the watcher plugin before then there is no issue.

The problem with the tests I did here was that I had the watcher enabled but I had not set up any actual watchers in the older version.

Thanks guys for helping figure it out!

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Extending Watcher Plugin
« Reply #15 on: June 07, 2015, 10:59:51 AM »
OK, I've updated the plugin and replaced the installer on the main download page.
http://voxcommando.com/home/downloads/

The version of VC and the installer remains 2.1.4.8

It should now handle your old watcher settings properly and will even convert the old watcher settings (if you have any) to the new format.
« Last Edit: June 07, 2015, 11:32:24 AM by nime5ter »

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Extending Watcher Plugin
« Reply #16 on: June 23, 2015, 08:55:06 PM »
I am wondering if the Watcher plug-in can be extended a bit more ...
I was trying to use to monitor a log file changes ... however it turn out, it monitors only the creation of new files ... but won't generate an event if a file is updated ...
this feature would allow VC to tap into many programs that support logging, and know what is going on ....

here is some python solution for the problem http://timgolden.me.uk/python/win32_how_do_i/watch_directory_for_changes.html, but it is kind of doubling the functions (wasting resources), having watcher and this python runing at the same time
When Voice command gets tough, use hand gestures

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 499
  • Karma: 43
    • View Profile
Re: Extending Watcher Plugin
« Reply #17 on: June 23, 2015, 10:01:58 PM »
I am wondering if the Watcher plug-in can be extended a bit more ...
I was trying to use to monitor a log file changes ... however it turn out, it monitors only the creation of new files ... but won't generate an event if a file is updated ...
this feature would allow VC to tap into many programs that support logging, and know what is going on ....

here is some python solution for the problem http://timgolden.me.uk/python/win32_how_do_i/watch_directory_for_changes.html, but it is kind of doubling the functions (wasting resources), having watcher and this python runing at the same time


I requested the same in a post above:

Watcher.Created (as it does now)
Watcher.Updated (used to see when a change is made to a file in that folder)
Watcher.Completed (or something similar when the file is fully transferred like a video being recorded or transferred across the network)
Watcher.Deleted (when a file or video is deleted from the folder, I could do this one with my script if I have Watcher.Completed to trigger the script)


I wanted the events above for a couple of different ideas that I had, the only one I was able to make a work around for was checking a media file to see if it was done,  I made a group of commands that will test a video file every 10 secs and then if its done will run another script that I use to move and rename the media, its a bit complicated because of all the file paths but it works.

having the "update" event would be nice for watching files of other programs and use the event to trigger backups


jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Extending Watcher Plugin
« Reply #18 on: June 24, 2015, 05:52:14 PM »
OK, OK I will dooooo eeeeeeet!  :biglaugh

I was a bit reluctant to add all these because each event must be processed by VC and I don't want constant events interfering with the normal operation of the program and its ability to listen to voice commands etc.

I will have to make it optional.  Just use it with caution.

I think I will have this option only for event type watchers, and not for action watchers.  Does that make sense to you?

Do we need just one option for "extra events" or should we have an option for each type (updated/completed/deleted)?

Bear in mind that each type of event may have its own anomalies  in terms of when a file is ready / locked because it is still being written etc.  You may have to adapt your macros with ++ and pauses to account for this if you intend to access the files that are generating events.
« Last Edit: June 24, 2015, 06:46:25 PM by jitterjames »

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 499
  • Karma: 43
    • View Profile
Re: Extending Watcher Plugin
« Reply #19 on: June 24, 2015, 06:32:08 PM »
SWEET,  ::bow 

I think making each event type optional would be best, and doing it similar to how you have it now in the watcher plugin, so we could pick witch event(s) we want triggered with that watcher,

watching log file have it trigger "updated"
watching media folder "completed" and "deleted"

with the group I'm working on I have it check the media file every 10 seconds and that seems to work well but I also have it wait to test files while other parts of the group are being used, once I get the group to be more user friendly I'll upload it, right now there are to many different actions that have file paths so I'm setting it up to have it use the payloads off of the watcher event payloads

Quote
I think I will have this option only for event type watchers, and not for action watchers.  Does that make sense to you?

Yes that makes sense,


 ::bow :hugs

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Extending Watcher Plugin
« Reply #20 on: June 25, 2015, 04:42:43 PM »
Sweeeeeeeeeeettttttt.  :hugs
When Voice command gets tough, use hand gestures

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Extending Watcher Plugin
« Reply #21 on: February 03, 2016, 02:33:19 PM »
I am working with watcher plugin to monitor HouseLinc (InstOn Controlling software) to provide VC with events notifications, i.e. pressing a switch on the wall ...
however I noticed that watcher plugin and file.read can not read the log file (I get error the file is open in another process) while HouseLinc is runnin, because HouseLinc keep the file open.

can this behaviour modified? i.e. Notpad++ do not have an issue reading the same file and sense changes while houseLinc is running
When Voice command gets tough, use hand gestures

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 499
  • Karma: 43
    • View Profile
Re: Extending Watcher Plugin
« Reply #22 on: February 03, 2016, 03:00:20 PM »
I am working with watcher plugin to monitor HouseLinc (InstOn Controlling software) to provide VC with events notifications, i.e. pressing a switch on the wall ...
however I noticed that watcher plugin and file.read can not read the log file (I get error the file is open in another process) while HouseLinc is runnin, because HouseLinc keep the file open.

can this behaviour modified? i.e. Notpad++ do not have an issue reading the same file and sense changes while houseLinc is running

with the File.Read I had a similar issue with the Kodi.log when Trying to read it to get a list of Pandora Stations from the log file,

what I did was simply use File.Copy to copy the log file to my VC Folder and then used File.Read from there.


Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Extending Watcher Plugin
« Reply #23 on: February 03, 2016, 03:16:50 PM »
what I did was simply use File.Copy to copy the log file to my VC Folder and then used File.Read from there.

I found this solution too ... however it is half what I need... the most important thing is watcher plugin, trigger the event ... I am just guessing here, I think both use the same access mode
When Voice command gets tough, use hand gestures

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Extending Watcher Plugin
« Reply #24 on: February 03, 2016, 04:06:50 PM »
I don't think it is possible to detect when a file has changed if the program changing it keeps the file open, certainly not with the FileSystem Watcher object provided by .Net 4. Otherwise it would be generating thousands of events (one for every byte that was written to the file).

Before you ask, notepad++ is not detecting a file change. Only when notepad is refocused does it check to see if a file has changed. It's not the same thing. More like polling.

As for reading a file that is open, I think I can fix this but only with programs that have opened the file in a polite way.
« Last Edit: February 03, 2016, 05:07:28 PM by jitterjames »

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Extending Watcher Plugin
« Reply #25 on: February 04, 2016, 12:32:00 AM »
I don't think it is possible to detect when a file has changed if the program changing it keeps the file open, certainly not with the FileSystem Watcher object provided by .Net 4. Otherwise it would be generating thousands of events (one for every byte that was written to the file).

Before you ask, notepad++ is not detecting a file change. Only when notepad is refocused does it check to see if a file has changed. It's not the same thing. More like polling.

As for reading a file that is open, I think I can fix this but only with programs that have opened the file in a polite way.

thanks for clarifying james ...
and for fixing the file read will be a good step forward if it is not too much coding ... as always unparalleled response and support
When Voice command gets tough, use hand gestures

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Extending Watcher Plugin
« Reply #26 on: February 21, 2016, 07:22:30 PM »
however I noticed that watcher plugin and file.read can not read the log file (I get error the file is open in another process) while HouseLinc is runnin, because HouseLinc keep the file open.

2.2.1.6 should allow you to read an open file.

http://voxcommando.com/mediawiki/index.php?title=ChangeLog#Core_Program_14

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Extending Watcher Plugin
« Reply #27 on: February 21, 2016, 09:23:17 PM »
:clap :clap :clap ... best support ever always
When Voice command gets tough, use hand gestures