BakSeeDaa´s Google Calendar for Domoticz (deprecated)

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

kazu
Posts: 3
Joined: Thursday 08 October 2015 23:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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 :)
TheeDude
Posts: 46
Joined: Wednesday 07 October 2015 0:43
Target OS: Linux
Domoticz version:
Contact:

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

Post 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
BakSeeDaa
Posts: 485
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version:

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

Post 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
Last edited by BakSeeDaa on Sunday 11 October 2015 15:37, edited 1 time in total.
TheeDude
Posts: 46
Joined: Wednesday 07 October 2015 0:43
Target OS: Linux
Domoticz version:
Contact:

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

Post 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
kazu
Posts: 3
Joined: Thursday 08 October 2015 23:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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!
BakSeeDaa
Posts: 485
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version:

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

Post 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
TheeDude
Posts: 46
Joined: Wednesday 07 October 2015 0:43
Target OS: Linux
Domoticz version:
Contact:

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

Post 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 ?
BakSeeDaa
Posts: 485
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version:

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

Post 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
korniza
Posts: 157
Joined: Thursday 27 August 2015 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.6028
Location: Greece
Contact:

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

Post 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
>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)
BakSeeDaa
Posts: 485
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version:

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

Post 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:
BakSeeDaa
Posts: 485
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version:

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

Post by BakSeeDaa »

I've updated the initial post with DEBUGGING AND TROUBLE SHOOTING information.
BakSeeDaa
Posts: 485
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version:

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

Post by BakSeeDaa »

V 0.1.4 Released

See the UPGRADE INSTRUCTIONS in the initial post for how to upgrade.
TheeDude
Posts: 46
Joined: Wednesday 07 October 2015 0:43
Target OS: Linux
Domoticz version:
Contact:

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

Post 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.
redcam
Posts: 2
Joined: Tuesday 13 October 2015 11:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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.
BakSeeDaa
Posts: 485
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version:

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

Post 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?
redcam
Posts: 2
Joined: Tuesday 13 October 2015 11:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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.
BakSeeDaa
Posts: 485
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version:

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

Post 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!)
TheeDude
Posts: 46
Joined: Wednesday 07 October 2015 0:43
Target OS: Linux
Domoticz version:
Contact:

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

Post 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.
BakSeeDaa
Posts: 485
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version:

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

Post 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.
TheeDude
Posts: 46
Joined: Wednesday 07 October 2015 0:43
Target OS: Linux
Domoticz version:
Contact:

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

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest