Google Calendar custom widget

with new_auth:True

I am getting the following error, is that expected ?

2018-06-04 15:13:47.887424 INFO AppDaemon: Initializing app hoofdagenda using class calendar from module calendar
usage: appdaemon [–auth_host_name AUTH_HOST_NAME] [–noauth_local_webserver]
[–auth_host_port [AUTH_HOST_PORT [AUTH_HOST_PORT …]]]
[–logging_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
appdaemon: error: unrecognized arguments: -c /config/appdaemon -D INFO
2018-06-04 15:13:47.889799 WARNING AppDaemon: ------------------------------------------------------------
2018-06-04 15:13:47.890102 WARNING AppDaemon: Unexpected error running initialize() for hoofdagenda
2018-06-04 15:13:47.890209 WARNING AppDaemon: ------------------------------------------------------------
2018-06-04 15:13:47.892942 WARNING AppDaemon: Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py”, line 1575, in init_object
init()
File “/config/appdaemon/apps/calendar.py”, line 23, in initialize
self.flags = tools.argparser.parse_args()
File “/usr/lib/python3.6/argparse.py”, line 1733, in parse_args
self.error(msg % ’ ‘.join(argv))
File “/usr/lib/python3.6/argparse.py”, line 2389, in error
self.exit(2, _(’%(prog)s: error: %(message)s\n’) % args)
File “/usr/lib/python3.6/argparse.py”, line 2376, in exit
_sys.exit(status)
SystemExit: 2

If I change to self.flags = tools.argparser.parse_args(args=[])
I believe it was what you meant, then I am presented with the same authorization process that finally tries to redirect to localhost:8080 without sucess.

Changing auth: False, presents the same authorization flow as if the previous one hasn’t been done.

So not sure how to continue or if I am missing something.

Thanks

damn.

the error was expected, but i hoped it would go through.
without args the program tries to open a browser and you need to logon there.
so i tried to add the argument that is needed but the argument that we have set for AD conflicts and gives an error.

there is 1 other option that i tried to avoid.
i uploaded an extra file called “start_calendar.py”
the dir in that files needs to be changed
save that in the same dir and with AD down give this command in a terminal

python3 start_calendar.py --noauth_local_webserver

but i am afraid that that option will be difficult for hassio users.

@cee i really dont know why you get that strange error. and i would love to figure it out, but after i get back.
so i dont have time for it untill friday. i am sorry.

not sure how will appdaemon try to open the browser directly, if that is possible at all…only thing I see is the error in the appdaemon console.

please believe me that that is possible and that the app tries that.

dont forget, this was the message you got before:

018-06-03 22:41:03.074904 INFO hoofdagenda: no valid credentials, so get them

Your browser has been opened to visit:

https://accounts.google.com/o/oauth2/auth?client_id=xxxxxxxx.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar.readonly&access_type=offline&response_type=code
If your browser is on a different machine then exit and re-run this
application with the command-line parameter

–noauth_local_webserver

that was the sign for me that it was working.
if you would have a browser installed and a monitor, and keyboard on your device, you would have been authorised now.

So i wasn’t sure if I was having permission issue’s or something, my linux skill’s are not great, still learning everyday. So I did a fresh install of hasbian just now, then did a fresh install of AppDaemon using sudo hassbian-config install appdaemon so I knew it was running under the same user, and the same venv, thats all thats installed, then dropped in the calendar app, and still the same formatyear error :frowning:

2018-06-04 22:12:21.421449 WARNING AppDaemon: ------------------------------------------------------------
2018-06-04 22:12:21.422158 WARNING AppDaemon: Unexpected error initializing app: hoofdagenda:
2018-06-04 22:12:21.422795 WARNING AppDaemon: ------------------------------------------------------------
2018-06-04 22:12:21.426427 WARNING AppDaemon: Traceback (most recent call last):
  File "/srv/appdaemon/lib/python3.5/site-packages/appdaemon/appdaemon.py", line 2040, in check_app_updates
self.init_object(app)
  File "/srv/appdaemon/lib/python3.5/site-packages/appdaemon/appdaemon.py", line 1565, in init_object
self, name, self.logger, self.error, app_args, self.config, self.app_config, self.global_vars
TypeError: formatyear() takes from 2 to 6 positional arguments but 9 were given

2018-06-04 22:12:21.427346 WARNING AppDaemon: ------------------------------------------------------------

So not sure if that helps out on anything at all :laughing:

(appdaemon) homeassistant@hassbian:~/appdaemon/apps/google-calendar-app $ python3 start_calendar.py --noauth_local_webserver                       Traceback (most recent call last):
  File "start_calendar.py", line 6, in <module>
    from apiclient.discovery import build
  File "/srv/appdaemon/lib/python3.5/site-packages/apiclient/__init__.py", line 8, in <module>
    from googleapiclient import discovery
  File "/srv/appdaemon/lib/python3.5/site-packages/googleapiclient/discovery.py", line 32, in <module>
    from six.moves import http_client
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
  File "/srv/appdaemon/lib/python3.5/site-packages/six.py", line 203, in load_module
    mod = mod._resolve()
  File "/srv/appdaemon/lib/python3.5/site-packages/six.py", line 115, in _resolve
    return _import_module(self.mod)
  File "/srv/appdaemon/lib/python3.5/site-packages/six.py", line 82, in _import_module
    __import__(name)
  File "/usr/lib/python3.5/http/client.py", line 71, in <module>
    import email.parser
  File "/usr/lib/python3.5/email/parser.py", line 12, in <module>
    from email.feedparser import FeedParser, BytesFeedParser
  File "/usr/lib/python3.5/email/feedparser.py", line 27, in <module>
    from email import message
  File "/usr/lib/python3.5/email/message.py", line 16, in <module>
    from email import utils
  File "/usr/lib/python3.5/email/utils.py", line 33, in <module>
    from email._parseaddr import quote
  File "/usr/lib/python3.5/email/_parseaddr.py", line 16, in <module>
    import time, calendar
  File "/home/homeassistant/appdaemon/apps/google-calendar-app/calendar.py", line 2, in <module>
    import httplib2
  File "/srv/appdaemon/lib/python3.5/site-packages/httplib2/__init__.py", line 879, in <module>
    class HTTPConnectionWithTimeout(http.client.HTTPConnection):
AttributeError: module 'http' has no attribute 'client'

Not sure if this helps out either.

thats not good.
because you DONT want to have hass and AD in the same venv, but seperate.

and you need to install the google-api-client for sure.
it is possible though that now it tries to use a version that HA installed and might be outdated.

and your last error shows that google-api-client isnt installed correctly :wink:

So running that install script wasn’t a good idea ?

Running as: homeassistant
Configuration dir: /home/homeassistant/appdaemon/ ?

What would be the ideal way you recommend installing on hassbian and i’ll give it a go ?

  • you installed hassbian. thats good.
  • then you create a venv for AD
  • then you go into the venv
  • then you install AD
  • then you install google-api-client
  • then you startup HA
  • then you startup AD from inside the venv

that way libraries from AD and HA will never conflict.

for configuration directories i use 2 different dirs side by side.

for example
/configs/appdaemon
/configs/homeassistant

and then i start HA like

hass -c /configs/homeassistant

and AD

appdaemon -c /configs/appdaemon

that way you cant get right confilcts and still have it all together.
do you already use winscp?
its a great program to get from a pc to a pi with scp.
when you use the advanced option to login with sudo -su you get into it as root user and you can view all files in all dirs and directly see all filerights.
i couldnt live without it even though my linux machine has a monitor, mouse and keyboard.

@ReneTode, you should start a new thread for your much-easier-to-get-working app, so you can top-post the full instructions.

Everyone else: if you’ve asked something about what I posted, please resend because I’ll have missed it.

yeah sorry waz.

because of the fact that it wasnt working on some platforms i thought it was nice to offer my app.
i didnt think it would completly hijack your thread.

as soon as i am back i will let this split up and get you your topic back.
dont worry you missed nothing except us trying to get it to work :wink:

so @cee and @claudiopi as soon as i have something i will open a new topic and have our previous postings moved there. for other please dont refer to my app here.

Hello,

thanks WazWaz for code it works great.

Is there any way to change the time format to 24h?

Thanks
Kind regards
Chris

Good idea. Update and add to your gcal dashboard settings:

twelvehour: "off"

Amazing it worked perfectly!!!

Big thanks to WazWaz and ReneTode.

1 Like

I picked up a super cheap Android 10" tablet to replace my iPad, so means I can run fully kiosk browser now, so meant I could fake the user string, and finally get a calendar working on my Dashboard.

Many many thanks @WazWaz it will help me out tremendously, now to just make it all look pretty :smiley:

p.s. its not really blank, i just blanked out my events.

1 Like

Nice! Is that climate chart using Chartist? I’ve made a very basic AppDaemon integration of that myself because I didn’t know there was one already.

1 Like

It’s just influx and grafana, then piped into HAD with a generic camera image.

Hi ReneTode,

How hard would it be to convert your google-calendar-app to work with icloud calendar?

I’ve got my icloud calendars working in HA using following this method:
https://community.home-assistant.io/t/caldav-with-icloud-working/38688

I’d love to be able to see the next 2 days appointments on my wall mounted ipad running appdaemon3.

Thanks

i have no idea.
i guess there must be some python code that retrieves the icloud calendar data from the calendar.
but i dont know what that would be.

the part from handling the data and creating a webpage from it would be the same.