Page 30 of 38

Re: SunTracker - with moving ghost

Posted: Wed Apr 16, 2014 2:38 pm
by krambriw
Dear Pako,
Actually, as usual, a very good suggestion! Maybe I could add a checkbox where you can select 'SunTracker.WeatherConditionChanged' or the current type of event?

Best regards, Walter

Re: SunTracker - with moving ghost

Posted: Wed Apr 16, 2014 2:57 pm
by Pako
Dear Walter !
krambriw wrote: Maybe I could add a checkbox where you can select '<prefix>.WeatherConditionChanged' or the current type of event?
I think that is the ideal solution.
A user who is accustomed to the current state and meets him, he does not need to change anything.
But the user like me, he can select the mode that suits him more.
Great !

Best regards, Pako

Re: SunTracker - with moving ghost

Posted: Wed Apr 16, 2014 6:20 pm
by krambriw
Dear Pako!
A new version is attached. See pictures below.

Here the selection is for getting an event even if the weather condition is unchanged
Image3.jpg
Image3.jpg (5.21 KiB) Viewed 6088 times
Here the setting to get an event only if the weather condition is changed compared to previous
Image4.jpg
Image4.jpg (6.4 KiB) Viewed 6088 times
The upgrade procedure is the same as before (since an attribute has been added, it is needed to it like this)

1) When EG is running current version, disable the SunTracker plugin and all SunTracker actions so that they all stops
- save and exit EG

2) Replace with the new version (see first post)
- start EG again

3) Now configure the SunTracker plugin:
- accept or change the event prefix
- check the boxes to select when the event shall happen
When finished, click ok, then enable the plugin so that it starts.

4) Now for each action, configure each of them by opening them and clicking ok

5) Enable each of the actions

6) Open the settings for the plugin again and check that they are all running
- save the configuration

7) You are done!


Kind regards, Walter

Re: SunTracker - with moving ghost

Posted: Thu Apr 17, 2014 6:36 am
by Pako
Dear Walter,
Thank you for your extraordinary support. :D
I set Create only on weather change and now I'm waiting until the weather changes.
We just have SunTracker.Weather Condition: 'Sunny' and it appears that at least a few hours it will be the same. :wink:

BTW: what settings you use it (regarding the last new options) ?

Best regards, Pako

Re: SunTracker - with moving ghost

Posted: Thu Apr 17, 2014 7:18 am
by krambriw
Dear Pako,
That is excellent, sunny weather is nice! Here, since yesterday we have 'Fair' weather, means clear and sunny, also very good...

My settings are updating weather data every 5 minutes and I get an event every minute because I need it for a specific purpose
Image2.jpg
Image2.jpg (6.39 KiB) Viewed 6075 times
Reason is I have a web page on android tablets showing current status of various things and it is updated with your Tornado plugin with websockets. The current html coding could eventually be improved so that I could avoid to update all the time but it works fine right now so I left it as is.

In the web page (see picture below) I have a banner showing a mix of information as well as a number of buttons to control and show status of lamps and other things. Everything is updated using websockets and it works very well.

My best regards, Walter
Image3.jpg

Re: SunTracker - with moving ghost

Posted: Thu Apr 17, 2014 8:05 am
by krambriw
New version is now published in the first post

New features:
- Added plugin setting for customizing the event prefix
- Weather condition event now synchronized with the update rate
- Added plugin setting to select if weather condition event will be triggered on weather changes only
- Added new day type, 'empty house', and new empty house mode. Empty House mode can be set from external signal and is also saved persistent
- Fixed a bug in function for setting vacation mode. Vacation mode set from external signal is now also saved persistent.
- Synchronization is deactivated during vacation and empty house modes
The vacation and empty house modes are useful when you need to have different behavior of your home automation when you have vacation or if you are away from your house (like a holiday stay elsewhere). To activate the different modes you can use python scripts that you can can trigger with suitable events. The python syntax looks like in the following example:

Code: Select all

#To set/unset vacation mode
eg.plugins.Suntracker.plugin.vacation_m = True
eg.plugins.Suntracker.plugin.vacation_m = False

Code: Select all

#To set/unset empty house mode
eg.plugins.Suntracker.plugin.emptyHouse_m = True
eg.plugins.Suntracker.plugin.emptyHouse_m = False
When set to vacation or empty house mode, the special day and time settings will be used instead of the normal Monday to Sunday settings

The plugin is utilizing Yahoo! Weather to get current local weather conditions. To find your location ID, browse or search for your city from the Yahoo! Weather home page(http://weather.yahoo.com/) The weather ID is in the URL for the forecast page for that city. You can also get the location ID by entering your zip code on the home page. For example, if you search for Berlin in Germany on the Yahoo! Weather home page, the forecast page for that city is http://weather.yahoo.com/germany/berlin/berlin-638242/. The location ID is 638242.

To upgrade from a previous version, it is very important to follow the steps described in the first post.

Re: SunTracker - with moving ghost

Posted: Tue May 06, 2014 4:53 pm
by Pako
Hi Walter,
I have a trouble with this plugin (1.5.2).
Here's how you can reproduce it:
1.) Open a new (empty) configuration file
2.) Add the plugin SunTracker (no need to set anything)
3.) Save the file under any name.
4.) Close and reopen EventGhost
5.) Disable the plugin SunTracker
6.) Save the file
7.) Close EventGhost
8.) Restart EventGhost
9.) Close the EventGhost
Here's the problem: EventGhost will remain in memory.

The procedure looks as absurd. However, you must understand that it is very simplified.
In fact, I perform various other actions and I have some plugins disabled...

Best regards,

Pako

Re: SunTracker - with moving ghost

Posted: Tue May 06, 2014 5:27 pm
by krambriw
Thanks Pako, this is of course no good behaviour, I just wonder how to fix it

What could be blocking the termination? Since the plugin is already disabled one would expect that EG is not doing anything but I think at least the code is also checked for disabled plugins (if there is a syntax error in a disabled plugin, this will also be recognized at startup).

If I just could understand what is happening? Could it be that EG is running some of the code even though the plugin is disabled???

My best regards, Walter

Re: SunTracker - with moving ghost

Posted: Tue May 06, 2014 5:50 pm
by Pako
Hi Walter !
krambriw wrote:What could be blocking the termination?
Maybe if you use -debug switch, so you'll see it. :D

Best regards,
Pako

Re: SunTracker - with moving ghost

Posted: Wed May 07, 2014 4:23 pm
by krambriw
Thanks Pako, I saw the problem with the debug...

The attached version is working now (I made it a beta version untill we know for sure it is OK...).The problem was related to persistent data. I wanted to save some data (variables) persistent (using eg.PersistentData) but when the plugin was closed, the variables to be stored where not alive anymore :oops:

So in this version I have removed the persistens for those variables. My ideal solution is yet to be found.

My best regards & thank you,

Walter
__init__.py
(180.26 KiB) Downloaded 185 times

Re: SunTracker - with moving ghost

Posted: Wed May 07, 2014 5:01 pm
by Pako
Hi Walter!
I thank you for prompt resolution. It seems to be fine.
Yes, I also had some problems earlier (I do not remember the details) with eg.PersistentData and I stopped using it.
There is certainly several possibilities how to solve it, but I use only two options.
1) Saving to an external file (eg xml format). As an example I can mention SchedulGhost. This is definitely the most clean solution.
2) Saving directly into the configuration file (self.info.treeItem). Right now I can not remember a suitable example. But it is not completely clean solution, I think.

Best regards,
Pako

Re: SunTracker - with moving ghost

Posted: Wed May 07, 2014 5:30 pm
by krambriw
Dear Pako,
Thank you for your feedback!

Related to the above, in the attached simple plugin, I have only a variable (var1) that I can configure either 'True' or 'False'.
__init__.py
(1.29 KiB) Downloaded 167 times
In runtime, I can change the value very simple by using this code:

Code: Select all

eg.plugins.MyPlugin.plugin.var1 = True

eg.plugins.MyPlugin.plugin.var1 = False     
Do you know if there is a way to make the plugin save the new configuration in runtime? So if I open the config dialog, this is correctly reflected in the checkbox? If this would be possible, that would then also solve my problem...

My best regards, Walter

Re: SunTracker - with moving ghost

Posted: Wed May 07, 2014 8:52 pm
by Pako
krambriw wrote:Do you know if there is a way to make the plugin save the new configuration in runtime? So if I open the config dialog, this is correctly reflected in the checkbox?
Yes it is possible.
Look at Nmap plugin.
Compare versions 0.2 and 0.3.

Pako

Re: SunTracker - with moving ghost

Posted: Thu May 08, 2014 6:03 am
by Pako
Hi Walter!
I apologize for my previous brief answer.
I had to go to sleep, but I wanted to write something.
So here is the modified plugin (version 0.0.1):
__init__.py
(2.9 KiB) Downloaded 168 times
However, the command is to be changed:

Code: Select all

eg.plugins.MyPlugin.plugin.SetVar1(True)
eg.plugins.MyPlugin.plugin.SetVar1(False)
I had to find a way to make it work regardless of the thread from which it started.

Best regards,
Pako

Re: SunTracker - with moving ghost

Posted: Thu May 08, 2014 8:52 am
by krambriw
Dear Pako, you do never have to apologize! Your advice actually was perfect, I found the way also with your advice

Code: Select all

        trItem = self.info.treeItem
        args = list(trItem.GetArguments())
        trItem.SetArguments(args) #automatically __stop__ / __start__      
        eg.document.SetIsDirty()
        eg.document.Save()
Funny, I was also working this morning with the test version, I also found out I needed the better thread handling...

Anyway, thanks a lot, I think this is a good example, maybe useful for other developers as well ;)

Now I will look at the SunTracker plugin to implement what I have been wanting for long time!!!

My warmest regards,
Walter


EDIT My version is a little bit different, I use a thread that is detecting the variable value change, then terminates itself and calls a function that is updating the configuration. Then the plugin is automatically restarted by the methods you proposed and a new thread is started, just waiting for the variable to change value again. This also works and it allows you to change variable values from a python command or script (or from another plugin).

Using actions as in your example is also working fine. I guess it is a matter of taste which you want to use.

Anyway, both examples will be excellent samples for others as well I think ;)

I will publish mine as well once finished...