Page 2 of 8

Re: BakSeeDaa´s Google Calendar for Domoticz script (a.k.a.B

Posted: Sunday 11 October 2015 14:32
by kazu
BakSeeDaa wrote:
kazu wrote:Thank you! this works flawlessly. Although there are a few typos in your guide. but no big problems.
Good job!
Thank You @kazu :D Please PM me about the typos so I can correct them. :lol:
I belive you have already fixed them in the guide now.
I have an idea that would be nice. (perhaps its already done and i dont konw how to do it) but it would be very useful if i could set the starting time in the topic of the event in google calander and not just set a fixed starting time (-180) in domoticz. becouse sometimes i want the starting times to be lets say -500. i hope you understand what im trying to explain :)

Re: BakSeeDaa´s Google Calendar for Domoticz script (a.k.a.B

Posted: Sunday 11 October 2015 14:35
by TheeDude
kazu wrote:
BakSeeDaa wrote:
kazu wrote:Thank you! this works flawlessly. Although there are a few typos in your guide. but no big problems.
Good job!
Thank You @kazu :D Please PM me about the typos so I can correct them. Image
I belive you have already fixed them in the guide now.
I have an idea that would be nice. (perhaps its already done and i dont konw how to do it) but it would be very useful if i could set the starting time in the topic of the event in google calander and not just set a fixed starting time (-180) in domoticz. becouse sometimes i want the starting times to be lets say -500. i hope you understand what im trying to explain :)
And maybe use a temp sensor to control that? :)
Would be Great for an engine preheater.

Skickat från min E6553 via Tapatalk

Re: BakSeeDaa´s Google Calendar for Domoticz script (a.k.a.B

Posted: Sunday 11 October 2015 15:31
by BakSeeDaa
kazu wrote:I have an idea that would be nice. (perhaps its already done and i dont konw how to do it) but it would be very useful if i could set the starting time in the topic of the event in google calander and not just set a fixed starting time (-180) in domoticz. becouse sometimes i want the starting times to be lets say -500. i hope you understand what im trying to explain :)
That would not be a minor change to the code. However you may create additional representations of a single Google Calendar in Domoticz. Just name them differently and configure them accordingly. Example "My Calendar", "My Calendar -60", "My Calendar -180" :mrgreen:
TheeDude wrote:And maybe use a temp sensor to control that? :)
Would be Great for an engine preheater.
That's already an easy thing to set up. Make a Lua script (I believe that Blockly can not set a User Variable yet, I may be wrong).

The Lua script captures the change of the temp sensor and calculates a suitable value and sets the GCalXXStartDelta and GCalXXEndDelta user variables followed by setting the "Check Switch" to on to let the script update itself. What You get is a Calendar with variable start time depending on the outside temperature. That's a very cool idea. :idea: :mrgreen:

PS. If Your temperature sensor is reporting it's values often, make sure you don't force the Calendar script to update too often. See what I wrote about spamming Google above :D

Re: BakSeeDaa´s Google Calendar for Domoticz script (a.k.a.B

Posted: Sunday 11 October 2015 15:37
by TheeDude
Yeah it is!
Will hopefully try it out this week, if I get time for it. :)

Edit: Thanks for the heads up on spamming google.


Skickat från min E6553 via Tapatalk

Re: BakSeeDaa´s Google Calendar for Domoticz script (a.k.a.B

Posted: Sunday 11 October 2015 17:06
by kazu
BakSeeDaa wrote:
kazu wrote:I have an idea that would be nice. (perhaps its already done and i dont konw how to do it) but it would be very useful if i could set the starting time in the topic of the event in google calander and not just set a fixed starting time (-180) in domoticz. becouse sometimes i want the starting times to be lets say -500. i hope you understand what im trying to explain :)
BakSeeDaa wrote:That would not be a minor change to the code. However you may create additional representations of a single Google Calendar in Domoticz. Just name them differently and configure them accordingly. Example "My Calendar", "My Calendar -60", "My Calendar -180" :mrgreen:
Didnt think of that. I have now tried this, and it works very well. just change the keywords to -5h, -3h and so on. thanks!

Re: BakSeeDaa´s Google Calendar for Domoticz script (a.k.a.B

Posted: Sunday 11 October 2015 18:22
by BakSeeDaa
kazu wrote:Didnt think of that. I have now tried this, and it works very well. just change the keywords to -5h, -3h and so on. thanks!
Great! I'm happy it works :D

Re: BakSeeDaa´s Google Calendar for Domoticz script (a.k.a.B

Posted: Sunday 11 October 2015 22:04
by TheeDude
I have tried to set this up tonight.
I guess most of it went fine, but I must have missed something.
When I press GCalCheck it checks my calendar, I have an event there, I have also tried a couple of keywords, and tried without.
But I can´t get the Switch to switch on, and status just saying "Hello world"

Code: Select all

This is the log

2015-10-11 22:01:34.791 LUA: GCal3 V 0.1.3: Running Plugin ...
2015-10-11 22:01:34.792 LUA: GCal3 V 0.1.3: local function: checkGCal
2015-10-11 22:01:34.792 LUA: GCal3 V 0.1.3: Checking semaphore
2015-10-11 22:01:34.804 LUA: GCal3 V 0.1.3: Command /bin/ls /home/pi/domoticz/GCal3/GCal3.sem returned true
2015-10-11 22:01:34.805 LUA: GCal3 V 0.1.3: Semaphore file returned 9
2015-10-11 22:01:34.817 LUA: GCal3 V 0.1.3: Command /bin/ls /home/pi/domoticz/GCal3/GCal3.sem returned true
2015-10-11 22:01:34.817 LUA: GCal3 V 0.1.3: Device 9 claimed semaphore
2015-10-11 22:01:34.818 LUA: GCal3 V 0.1.3: StartMin is 2015-10-10T22:00:00Z StartMax is 2015-10-12T21:01:00Z
2015-10-11 22:01:34.818 LUA: GCal3 V 0.1.3: End of day is 2015-10-11T23:59:59
2015-10-11 22:01:34.818 LUA: GCal3 V 0.1.3: local function: requestCalendar
2015-10-11 22:01:34.818 LUA: GCal3 V 0.1.3: local function: get_access_token
2015-10-11 22:01:34.818 LUA: GCal3 V 0.1.3: Getting a new token
2015-10-11 22:01:35.520 LUA: GCal3 V 0.1.3: Got new token
2015-10-11 22:01:35.521 LUA: GCal3 V 0.1.3: Checking google calendar
2015-10-11 22:01:35.947 LUA: GCal3 V 0.1.3: No event in the next day. Retry later...
2015-10-11 22:01:35.948 LUA: GCal3 V 0.1.3: local function: setTrippedOff
2015-10-11 22:01:35.948 LUA: GCal3 V 0.1.3: Event-End Inactive
2015-10-11 22:01:35.949 LUA: GCal3 V 0.1.3: Device 9 released the semaphore - reason: calendar check complete
2015-10-11 22:01:35.949 LUA: GCal3 V 0.1.3: nextTimeCheck is midnight
2015-10-11 22:01:35.949 LUA: GCal3 V 0.1.3: Next check will be in 7105 sec on 2015-10-12 at 00:00:00
2015-10-11 22:01:35.952 LUA: GCal3 V 0.1.3: Device 9 released the semaphore - reason: initialization complete
2015-10-11 22:01:35.952 LUA: GCal3 V 0.1.3: Switch recent status: Off
I guess it would be something with keywords, but I really don´t know right now.
Here they are anyway.

Code: Select all

13	GCal9triggerNoKeyword	Sträng	false	2015-10-11 19:16:11
12	GCal9ignoreKeyword	Sträng	false	2015-10-11 19:16:11
11	GCal9exactKeyword	Sträng	false	2015-10-11 21:20:20
10	GCal9Keyword	Sträng	heater	2015-10-11 21:19:50
Any ideas?

Edit: I am editing User variables in Settings -> More Settings -> User variables.
I guess that is right, that I don´t need to change them in the script_device_gcal.lua ?

Re: BakSeeDaa´s Google Calendar for Domoticz script (a.k.a.B

Posted: Monday 12 October 2015 7:49
by BakSeeDaa
TheeDude wrote: Any ideas?

Edit: I am editing User variables in Settings -> More Settings -> User variables.
I guess that is right, that I don´t need to change them in the script_device_gcal.lua ?
@TheeDude, You are right, user variables are edited in Settings -> More Settings -> User variables. The only file that You edit is the gcalconfig.lua

First check that the idx number for the Text Device in your config file is correct. If You still cant find the problem, please enclose the contents of your gcalconfig.lua together with a listing of your 3 calendar virtual devices (filter the output on your calendar name).

Let's get the BGCD working first before trying more advanced features like the keyword filtering. :D

Re: BakSeeDaa´s Google Calendar for Domoticz script (a.k.a.B

Posted: Monday 12 October 2015 8:02
by korniza
Really nice project!
I have installed, i can get events from google calendar BUT I can not figure out howto trigger a device (let's say a virtual switch) to power on/off.
do I have to put a url as event on google calendar?

Thank you1

Re: BakSeeDaa´s Google Calendar for Domoticz script (a.k.a.B

Posted: Monday 12 October 2015 9:01
by BakSeeDaa
korniza wrote:Really nice project!
I have installed, i can get events from google calendar BUT I can not figure out howto trigger a device (let's say a virtual switch) to power on/off.
do I have to put a url as event on google calendar?

Thank you1
You're welcome @korniza :D

Use Blockly to trigger on the state of the "Calendar Device"
Untitled.png
The example above just writes some text to the log file but you can turn on a lamp, start a block heater or whatever you fancy.

If You prefer to write device scripts, it could look something like the following:

Code: Select all

commandArray = {}


if (devicechanged['GCalCheck FGS klass 15 NA'] == "On") then
-- Put code here to do whatever you like when a calendar event is active
end

return commandArray
Of course, in both examples above you need to replace "GCalCheck FGS klass 15 NA" with the name of your BGCD Calendar device. :lol:

Re: BakSeeDaa´s Google Calendar for Domoticz script (a.k.a.B

Posted: Monday 12 October 2015 9:04
by BakSeeDaa
I've updated the initial post with DEBUGGING AND TROUBLE SHOOTING information.

Re: BakSeeDaa´s Google Calendar for Domoticz V 0.1.4 Release

Posted: Monday 12 October 2015 12:42
by BakSeeDaa
V 0.1.4 Released

See the UPGRADE INSTRUCTIONS in the initial post for how to upgrade.

Re: BakSeeDaa´s Google Calendar for Domoticz script (a.k.a.B

Posted: Monday 12 October 2015 12:55
by TheeDude
BakSeeDaa wrote:
TheeDude wrote: Any ideas?

Edit: I am editing User variables in Settings -> More Settings -> User variables.
I guess that is right, that I don´t need to change them in the script_device_gcal.lua ?
@TheeDude, You are right, user variables are edited in Settings -> More Settings -> User variables. The only file that You edit is the gcalconfig.lua

First check that the idx number for the Text Device in your config file is correct. If You still cant find the problem, please enclose the contents of your gcalconfig.lua together with a listing of your 3 calendar virtual devices (filter the output on your calendar name).

Let's get the BGCD working first before trying more advanced features like the keyword filtering. :D

You were absolutely right, I had mixed the idx numbers up, now they are corrected and the text device are working.
So the BGCD script are working I suppose, but I´m back at "No events found today".

Thanks for all the help! :)
Will upgrade to 0.1.4 also!

Edit: Yes! Now I just have to say that I have got it to work, I have used the wrong calendar id in domoticz.
I used the one that I created when I did my service account, but I should have used my calendar ID from my specific calendar, but not it works!
Now I just have to figure out how I will script temp control to this.

Re: BakSeeDaa´s Google Calendar for Domoticz V 0.1.4 Release

Posted: Tuesday 13 October 2015 11:39
by redcam
Hello,
Everything working fine here, calendar is read, text device showing events, etc...
The only point is how do you name your blocky events in domoticz then how do you write them to your calendar.
I've made an event just like the one you gave as example. If GCAL calendar device = on then log "blablabla" and named that domoticz event as "TEST". Shall i active it ? Do i need to write an "TEST=on" or "TEST {ON}" in google calendar ?
You said instead of Blocky you can script. Can I launch a LUA device trigger event. Got a script in LUA folder named script_device_confort.lua if I write in google calendar confort = On nothing happened. But if i switch my virtual device confort on then script_device_confort.lua is run. So which event shall i write in google calendar to make BGCD launch my script or at least switch on my device.

Thx in advance.

Re: BakSeeDaa´s Google Calendar for Domoticz V 0.1.4 Release

Posted: Tuesday 13 October 2015 13:24
by BakSeeDaa
redcam wrote:Hello,
Everything working fine here, calendar is read, text device showing events, etc...
The only point is how do you name your blocky events in domoticz then how do you write them to your calendar.
I've made an event just like the one you gave as example. If GCAL calendar device = on then log "blablabla" and named that domoticz event as "TEST". Shall i active it ? Do i need to write an "TEST=on" or "TEST {ON}" in google calendar ?
You said instead of Blocky you can script. Can I launch a LUA device trigger event. Got a script in LUA folder named script_device_confort.lua if I write in google calendar confort = On nothing happened. But if i switch my virtual device confort on then script_device_confort.lua is run. So which event shall i write in google calendar to make BGCD launch my script or at least switch on my device.

Thx in advance.
Hi @redcam

It's a bit out of the scope for this topic but You need to activate a Blockly event before it actually does anything. You can name Your Blockly event to whatever you wish, the name won't affect the function of BGCD.

You don't need to write anything special in your Google Calendar. In Domoticz you will trigger your scripts on the Calendar Device which is actually a switch. The Calendar Device will be either "On" or "Off" depending on if there is an active calendar event. For Domoticz, the Calendar Device is just a normal light switch.

Below is an example of a simple lua device script using a Calendar Device to turn a block heater on or off. The script can be named script_device_XXXXXXX.lua where you can replace XXXXXX to something suitable. Put Your device scripts in the /home/pi/domoticz/scripts/lua folder.

In the script, you need to replace "GCal MYCALENDARNAME" to match whatever you named your Calendar Device

Code: Select all

-- script_device_test.lua

commandArray = {}


-- In the example below we check if the "Calendar Device" switched
if (devicechanged['GCal MYCALENDARNAME']) then

	if (devicechanged['GCal MYCALENDARNAME'] == "On") then
		print("The Calendar device was switched on")
		commandArray["My Block Heater"] = "On"
	end

	if (devicechanged['GCal MYCALENDARNAME'] == "Off") then
		print("The Calendar device was switched off")
		commandArray["My Block Heater"] = "Off"
	end
	
end

return commandArray
If You are not used to Lua scripting I recommend that you try Blockly first. With Blockly You will probably be able to define all the logic You need.

Is that an answer to your question @redcam?

Re: BakSeeDaa´s Google Calendar for Domoticz V 0.1.4 Release

Posted: Tuesday 13 October 2015 17:21
by redcam
Thanks for the reply, it's more clear now thx.
Just one last thing, got problem removing a keyword from user variables. Can't empty it i'm getting ERR.

Re: BakSeeDaa´s Google Calendar for Domoticz V 0.1.4 Release

Posted: Tuesday 13 October 2015 17:46
by BakSeeDaa
redcam wrote:Thanks for the reply, it's more clear now thx.
Just one last thing, got problem removing a keyword from user variables. Can't empty it i'm getting ERR.
You are absolutely right about that. I will update my instruction.

I don't know why we can't empty a text user variable in Domoticz.

But I have a solution. If You write

Code: Select all

Empty String
in the text variable, BGCD will take care of the problem and empty it for you the next time it runs. (Must be written exactly that way... copy and paste!)

Re: BakSeeDaa´s Google Calendar for Domoticz V 0.1.4 Release

Posted: Friday 16 October 2015 0:28
by TheeDude
I have found some kind of bug today.
After I set up my domoticz installation with a web password, my Text Device stopped reporting on events.
I used Login Page, haven´t tried Basic Auth yet.

Re: BakSeeDaa´s Google Calendar for Domoticz V 0.1.4 Release

Posted: Friday 16 October 2015 15:59
by BakSeeDaa
TheeDude wrote:I have found some kind of bug today.
After I set up my domoticz installation with a web password, my Text Device stopped reporting on events.
I used Login Page, haven´t tried Basic Auth yet.
Can You try the attached file (unzip first). Replace the existing file with same name. Please let me know the results.

Re: BakSeeDaa´s Google Calendar for Domoticz V 0.1.4 Release

Posted: Friday 16 October 2015 18:27
by TheeDude
BakSeeDaa wrote:
TheeDude wrote:I have found some kind of bug today.
After I set up my domoticz installation with a web password, my Text Device stopped reporting on events.
I used Login Page, haven´t tried Basic Auth yet.
Can You try the attached file (unzip first). Replace the existing file with same name. Please let me know the results.
Yes, the new file does the job!
It works good now!
Thanks