Google Calendar custom widget

first lets see if we get it to work as i expect :wink:
my garbage collection calender we had way before i automated.
every collection is put in there 1 day before it gets collected as a whole day event, so that my wife always knows it gets collected tommorow.
in the message text it say garbage gets collected tommorow.
in the app i take out the text tommorow and set the date 1 day later so it shows the real date and says: garbage gets collected.
and because i have a sound app that lets me use TTS from apps, i let on the day before, every hour the TTS say that garbage gets collected tommorow, untill my wife flips a boolean (through the dashboard) telling HASS that the garbage is out.

you see its quite specific, so i made a var to disable that part. i could take it out, but then i would have 2 seperate apps to maintain.

1 Like

I like the idea of the way you have it setup, something else for me to investigate with home assistant.

Well if you get a dry throat whilst coding/helping away, then let me know, There is beer waiting :slight_smile:

1 Like

i uploaded the app in the hope that i didnt make mistakes.

1 Like

I really should be working, but lets give it a test and see what happens. Many thanks in advance, I’ll report back soon :slight_smile:

1 Like

So I am getting this error in AppDeamon

2018-06-03 13:42:25.906880 WARNING AppDaemon: Unexpected error initializing app: hoofdagenda:
2018-06-03 13:42:25.907846 WARNING AppDaemon: ------------------------------------------------------------
2018-06-03 13:42:25.912123 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/appdaemon/appdaemon.py", line 2040, in check_app_updates
    self.init_object(app)
  File "/usr/local/lib/python3.5/dist-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-03 13:42:25.913269 WARNING AppDaemon: ------------------------------------------------------------

which version from appdaemon are you running?
i did expect there could be a problem somwhere but not in the init.

AppDaemon Version 3.0.1 starting

did you change anything in the app?
or did you modify the refresh setting in the yaml?

I changed my appdaemon.yaml from

appdaemon:
  disable_apps: 1
  threads: 10
  app_dir: /home/homeassistant/.homeassistant/appdaemon/apps

to

appdaemon:
  disable_apps: 0
  threads: 10
  app_dir: /home/homeassistant/.homeassistant/appdaemon/apps

As I wasn’t running apps before, and then my calendar.yaml these are the only settings I changed,

  calendarid: xxxx@xxxxxxxxxxx
  amount: '5'
  htmlfile: /home/homeassistant/.homeassistant/appdaemon/apps/google-calendar-app/calendar.html                                # the file that you show in the dashboard
  client_secret_file: client_secret_xxxxxxx-xxxxxxxxx.apps.googleusercontent.com.json                                      # the name from the secret_file
  credential_dir: /home/homeassistant/.homeassistant/appdaemon/apps/google-calendar-app/                                             # the dir where the secret file is

Not sure if the full path’s is a problem ?

Randomly, also all my background css colours have stopped working as well.

widget_style: "background: SlateGray;"

Doesn’t work, but

icon_style_inactive: "color: #363430; font-size: 350%;top: 50px"

still works.

I was getting the same error then created the calendar.html file in the folder I wanted generated and error went away, however now I am getting the following one:

2018-06-03 10:39:26.719138 INFO AppDaemon: Reloading Module: /config/appdaemon/apps/calendar.py
2018-06-03 10:39:26.722605 WARNING AppDaemon: ------------------------------------------------------------
2018-06-03 10:39:26.722743 WARNING AppDaemon: Unexpected error loading module: /config/appdaemon/apps/calendar.py:
2018-06-03 10:39:26.722813 WARNING AppDaemon: ------------------------------------------------------------
2018-06-03 10:39:26.730663 WARNING AppDaemon: Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py”, line 2015, in check_app_updates
self.read_app(mod[“name”], mod[“reload”])
File “/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py”, line 1789, in read_app
importlib.reload(self.modules[module_name])
File “/usr/lib/python3.6/importlib/init.py”, line 166, in reload
_bootstrap._exec(spec, module)
File “”, line 618, in _exec
File “”, line 678, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/config/appdaemon/apps/calendar.py”, line 2, in
import httplib2
ModuleNotFoundError: No module named ‘httplib2’

Home Assistant (Hass.io image running on CentOS 7): 0.70
App Daemon: latest

Not sure how can I get extra modules of python installed in Hass.io image.

I read somewhere to have the sources of the modules in the app folder, but I believe that can be a tedious work cause of dependencies, I am new to python and somehow lost with this. But as I understand hass.io is a docker self contained image. So not sure adding extra modules is possible.

Thanks

did you restart appdaemon after you did edit appdaemon.yaml?
please clear the logs an then restart appdaemon and show me the log from the start.

i want to see if there is another problem, and maybe with filerights.

the appdaemon user needs full rights on all files in the config directory.
did you check if all the new created files and directories have the right rights?

@claudiopi you didnt install google api client in the appdaemon environment.
and without that you cant connect to google.

i thought that they already made it possible to install other libs in the hassio appdaemon addon, but i dont know how.
i really cant support such hassio problems, because i dont have access to hassio and no knowledge how its setup or works (other then what i come accross on the forum)
so to solve the problem from installing the api client inside the appdaemon addon i refer you to the hassio section from the forum.
sorry.

Think it might be a permissions error for me,

Log File,

2018-06-03 16:10:39.107865 INFO AppDaemon Version 3.0.1 starting
2018-06-03 16:10:39.108641 INFO Configuration read from: /home/homeassistant/.homeassistant/appdaemon/appdaemon.yaml
2018-06-03 16:10:39.114027 INFO AppDaemon: Starting Apps
2018-06-03 16:10:39.115867 WARNING config_dir: /home exists, but is not writeable, owner: root
2018-06-03 16:10:39.124581 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2018-06-03 16:10:39.162071 INFO AppDaemon: HASS: HASS Plugin Initializing
2018-06-03 16:10:39.163400 INFO AppDaemon: HASS: HASS Plugin initialization complete
2018-06-03 16:10:39.164401 INFO Starting Dashboards
2018-06-03 16:10:39.167827 WARNING css: /home exists, but is not writeable, owner: root
2018-06-03 16:10:39.170975 WARNING javascript: /home exists, but is not writeable, owner: root
2018-06-03 16:10:39.184756 INFO API is disabled
2018-06-03 16:10:39.200949 INFO AppDaemon: HASS: Connected to Home Assistant 0.70.0
2018-06-03 16:10:39.250760 INFO AppDaemon: Got initial state from namespace default
2018-06-03 16:10:40.734199 INFO HADashboard: New dashboard connected: Music
2018-06-03 16:10:41.372373 INFO AppDaemon: Reading config
2018-06-03 16:10:41.476602 INFO AppDaemon: /home/homeassistant/.homeassistant/appdaemon/apps/google-calendar-app/calendar.yaml added or modified
2018-06-03 16:10:41.478362 INFO AppDaemon: /home/homeassistant/.homeassistant/appdaemon/apps/google-calendar-app/calendar.yaml added or modified
2018-06-03 16:10:41.479678 INFO AppDaemon: App 'hoofdagenda' added
2018-06-03 16:10:41.481176 INFO AppDaemon: Adding /home/homeassistant/.homeassistant/appdaemon/apps to module import path
2018-06-03 16:10:41.482986 INFO AppDaemon: Adding /home/homeassistant/.homeassistant/appdaemon/apps/google-calendar-app to module import path
2018-06-03 16:10:41.485314 INFO AppDaemon: Loading App Module: /home/homeassistant/.homeassistant/appdaemon/apps/google-calendar-app/calendar.py
2018-06-03 16:10:41.487116 INFO AppDaemon: Initializing app hoofdagenda using class calendar from module calendar
2018-06-03 16:10:41.503717 INFO AppDaemon: App initialization complete
2018-06-03 16:11:45.269336 INFO HADashboard: New dashboard connected: Music

Error file,

2018-06-03 16:10:41.488685 WARNING AppDaemon: ------------------------------------------------------------
2018-06-03 16:10:41.490043 WARNING AppDaemon: Unexpected error initializing app: hoofdagenda:
2018-06-03 16:10:41.491248 WARNING AppDaemon: ------------------------------------------------------------
2018-06-03 16:10:41.498164 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/appdaemon/appdaemon.py", line 2040, in check_app_updates
    self.init_object(app)
  File "/usr/local/lib/python3.5/dist-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-03 16:10:41.499881 WARNING AppDaemon: ------------------------------------------------------------

no there are no permission errors.
only the base dir gives a warning but thats expected, so we can ignore that.
the app is initialised allright, so all we need to worry about is the error.

which is an error i have never seen before and i have no clue about, so i need to dig deep into AD.
to bad that @aimc isnt available at the moment, he could give me a clue why this happens.

you could help me with 1 thing.
clear the log and restart AD with -D in the command, so i will get debug info.
after starting then post the logs again, in the hope i see what goes wrong.

I did it with -D DEBUG and this is the output,

2018-06-03 16:28:21.560197 INFO AppDaemon Version 3.0.1 starting
2018-06-03 16:28:21.561175 INFO Configuration read from: /home/homeassistant/.homeassistant/appdaemon/appdaemon.yaml
2018-06-03 16:28:21.561761 DEBUG AppDaemon Section: None
2018-06-03 16:28:21.562275 DEBUG HADashboard Section: None
2018-06-03 16:28:21.567232 INFO AppDaemon: Starting Apps
2018-06-03 16:28:21.569072 WARNING config_dir: /home exists, but is not writeable, owner: root
2018-06-03 16:28:21.572474 DEBUG AppDaemon: Creating worker threads ...
2018-06-03 16:28:21.577666 DEBUG AppDaemon: Done
2018-06-03 16:28:21.578339 DEBUG AppDaemon: Entering run()
2018-06-03 16:28:21.579119 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2018-06-03 16:28:21.616630 INFO AppDaemon: HASS: HASS Plugin Initializing
2018-06-03 16:28:21.617735 INFO AppDaemon: HASS: HASS Plugin initialization complete
2018-06-03 16:28:21.618473 DEBUG AppDaemon: Starting utility loop
2018-06-03 16:28:21.619156 INFO Starting Dashboards
2018-06-03 16:28:21.622704 WARNING css: /home exists, but is not writeable, owner: root
2018-06-03 16:28:21.625903 WARNING javascript: /home exists, but is not writeable, owner: root
2018-06-03 16:28:21.639761 INFO API is disabled
2018-06-03 16:28:21.640424 DEBUG Start Loop
2018-06-03 16:28:21.656535 INFO AppDaemon: HASS: Connected to Home Assistant 0.70.0
2018-06-03 16:28:21.665093 DEBUG AppDaemon: HASS: get_ha_config()
2018-06-03 16:28:21.665768 DEBUG AppDaemon: HASS: get_ha_config: url is http://192.168.1.13:8123/api/config
2018-06-03 16:28:21.679618 DEBUG AppDaemon: HASS: get_ha_state: url is http://192.168.1.13:8123/api/states
2018-06-03 16:28:21.703354 DEBUG AppDaemon: HASS: Got state
2018-06-03 16:28:21.706228 INFO AppDaemon: Got initial state from namespace default
2018-06-03 16:28:23.867017 DEBUG AppDaemon: Starting timer loop
2018-06-03 16:28:23.867839 DEBUG AppDaemon: Reading Apps
2018-06-03 16:28:23.870669 INFO AppDaemon: Reading config
2018-06-03 16:28:23.871674 DEBUG AppDaemon: Reading /home/homeassistant/.homeassistant/appdaemon/apps/google-calendar-app/calendar.yaml
2018-06-03 16:28:23.948337 INFO AppDaemon: /home/homeassistant/.homeassistant/appdaemon/apps/google-calendar-app/calendar.yaml added or modified
2018-06-03 16:28:23.949020 INFO AppDaemon: /home/homeassistant/.homeassistant/appdaemon/apps/google-calendar-app/calendar.yaml added or modified
2018-06-03 16:28:23.949526 INFO AppDaemon: App 'hoofdagenda' added
2018-06-03 16:28:23.950143 INFO AppDaemon: Adding /home/homeassistant/.homeassistant/appdaemon/apps to module import path
2018-06-03 16:28:23.950847 INFO AppDaemon: Adding /home/homeassistant/.homeassistant/appdaemon/apps/google-calendar-app to module import path
2018-06-03 16:28:23.951636 DEBUG AppDaemon: Found module /home/homeassistant/.homeassistant/appdaemon/apps/google-calendar-app/calendar.py
2018-06-03 16:28:23.952299 INFO AppDaemon: Loading App Module: /home/homeassistant/.homeassistant/appdaemon/apps/google-calendar-app/calendar.py
2018-06-03 16:28:23.953059 INFO AppDaemon: Initializing app hoofdagenda using class calendar from module calendar
2018-06-03 16:28:23.960513 INFO AppDaemon: App initialization complete
2018-06-03 16:28:23.964821 DEBUG AppDaemon: Util loop compute time: 3.0ms
2018-06-03 16:28:24.002807 DEBUG AppDaemon: Scheduler loop compute time: 1.0ms
2018-06-03 16:28:24.973062 DEBUG AppDaemon: Util loop compute time: 6.0ms
2018-06-03 16:28:25.005444 DEBUG AppDaemon: Scheduler loop compute time: 3.0ms
2018-06-03 16:28:25.997515 DEBUG AppDaemon: Util loop compute time: 20.0ms
2018-06-03 16:28:26.004986 DEBUG AppDaemon: Scheduler loop compute time: 3.0ms
2018-06-03 16:28:27.009652 DEBUG AppDaemon: Scheduler loop compute time: 3.0ms
2018-06-03 16:28:27.012540 DEBUG AppDaemon: Util loop compute time: 11.0ms
2018-06-03 16:28:28.006003 DEBUG AppDaemon: Scheduler loop compute time: 3.0ms
2018-06-03 16:28:28.020752 DEBUG AppDaemon: Util loop compute time: 6.0ms
2018-06-03 16:28:29.005931 DEBUG AppDaemon: Scheduler loop compute time: 3.0ms
2018-06-03 16:28:29.028732 DEBUG AppDaemon: Util loop compute time: 5.0ms
2018-06-03 16:28:29.741061 INFO HADashboard: New dashboard connected: Music

Not sure if this helps, if you need any other state done, just let me know.

hmm, that doesnt help either.

i have no idea where the formatyear() comes from.
so i googled and i think it must be somthing in the google api client.

ill add some debugging to the app to see how far it goes before the error appears.
we have diner soon, so it could be a few hours before i get back to you.

1 Like

No rush sir, its all good. I should be doing work anyway, so i will give me a chance to get back on with that for a bit :slight_smile: And also to try and work out why my background colour stopped working too.

1 Like

i added a lot of debugging lines.
so when you can download the app again? or just copy paste the code.
in the yaml i just added 1 line:

debug:True

so if you add that and change the code we should get more info on where its going wrong.
(probably the authorisation)

Redownloaded the two files, changed the config to match mine for the calendar, and added debug:true, but still seem to be getting the same output,

hoofdagenda:
  class: calendar
  module: calendar
  debug: True                                                                        # use debug only if neccesary
  calendarid: xxxxxi@xxxxxx                                                        # the calender id you found in google_calendars.yaml
  amount: '5'                                                                          # the amount of events you want to see
  htmlfile: /home/homeassistant/.homeassistant/appdaemon/apps/google-calendar-app/calendar.html                                # the file that you show in the dashboard
  client_secret_file: client_secret_xxxxxx-xxxxxxxx.apps.googleusercontent.com.json                                      # the name from the secret_file
  credential_dir: /home/homeassistant/.homeassistant/appdaemon/apps/google-calendar-app/                                             # the dir where the secret file is
  refreshtime: 3600                                                                    # defaults to once every hour

pi@hassbian:~ $ appdaemon -c /home/homeassistant/.homeassistant/appdaemon/ -D DEBUG

2018-06-03 22:17:13.626468 INFO AppDaemon Version 3.0.1 starting
2018-06-03 22:17:13.627675 INFO Configuration read from: /home/homeassistant/.homeassistant/appdaemon/appdaemon.yaml
2018-06-03 22:17:13.628471 DEBUG AppDaemon Section: None
2018-06-03 22:17:13.629171 DEBUG HADashboard Section: None
2018-06-03 22:17:13.634463 INFO AppDaemon: Starting Apps
2018-06-03 22:17:13.636785 WARNING config_dir: /home exists, but is not writeable, owner: root
2018-06-03 22:17:13.640488 DEBUG AppDaemon: Creating worker threads ...
2018-06-03 22:17:13.646159 DEBUG AppDaemon: Done
2018-06-03 22:17:13.647245 DEBUG AppDaemon: Entering run()
2018-06-03 22:17:13.648309 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2018-06-03 22:17:13.686730 INFO AppDaemon: HASS: HASS Plugin Initializing
2018-06-03 22:17:13.688295 INFO AppDaemon: HASS: HASS Plugin initialization complete
2018-06-03 22:17:13.689454 DEBUG AppDaemon: Starting utility loop
2018-06-03 22:17:13.690436 INFO Starting Dashboards
2018-06-03 22:17:13.694444 WARNING css: /home exists, but is not writeable, owner: root
2018-06-03 22:17:13.698034 WARNING javascript: /home exists, but is not writeable, owner: root
2018-06-03 22:17:13.712636 INFO API is disabled
2018-06-03 22:17:13.713648 DEBUG Start Loop
2018-06-03 22:17:13.729931 INFO AppDaemon: HASS: Connected to Home Assistant 0.70.0
2018-06-03 22:17:13.738783 DEBUG AppDaemon: HASS: get_ha_config()
2018-06-03 22:17:13.739839 DEBUG AppDaemon: HASS: get_ha_config: url is http://192.168.1.13:8123/api/config
2018-06-03 22:17:13.755438 DEBUG AppDaemon: HASS: get_ha_state: url is http://192.168.1.13:8123/api/states
2018-06-03 22:17:13.780924 DEBUG AppDaemon: HASS: Got state
2018-06-03 22:17:13.784248 INFO AppDaemon: Got initial state from namespace default
2018-06-03 22:17:15.973471 DEBUG AppDaemon: Starting timer loop
2018-06-03 22:17:15.974645 DEBUG AppDaemon: Reading Apps
2018-06-03 22:17:15.976563 INFO AppDaemon: Reading config
2018-06-03 22:17:15.977523 DEBUG AppDaemon: Reading /home/homeassistant/.homeassistant/appdaemon/apps/google-calendar-app/calendar.yaml
2018-06-03 22:17:16.008558 DEBUG AppDaemon: Scheduler loop compute time: 1.0ms
2018-06-03 22:17:16.065158 INFO AppDaemon: /home/homeassistant/.homeassistant/appdaemon/apps/google-calendar-app/calendar.yaml added or modified
2018-06-03 22:17:16.066172 INFO AppDaemon: /home/homeassistant/.homeassistant/appdaemon/apps/google-calendar-app/calendar.yaml added or modified
2018-06-03 22:17:16.066884 INFO AppDaemon: App 'hoofdagenda' added
2018-06-03 22:17:16.067713 INFO AppDaemon: Adding /home/homeassistant/.homeassistant/appdaemon/apps to module import path
2018-06-03 22:17:16.068661 INFO AppDaemon: Adding /home/homeassistant/.homeassistant/appdaemon/apps/google-calendar-app to module import path
2018-06-03 22:17:16.069724 DEBUG AppDaemon: Found module /home/homeassistant/.homeassistant/appdaemon/apps/google-calendar-app/calendar.py
2018-06-03 22:17:16.070601 INFO AppDaemon: Loading App Module: /home/homeassistant/.homeassistant/appdaemon/apps/google-calendar-app/calendar.py
2018-06-03 22:17:16.071572 INFO AppDaemon: Initializing app hoofdagenda using class calendar from module calendar
2018-06-03 22:17:16.080806 INFO AppDaemon: App initialization complete

@ReneTode

got through the import issue by adding the following imports to the AppDaemon addon:
“python_packages”: [
“httplib2”,
“google-api-python-client”,
“oauth2client”
]

Now I am getting the following error:

(I changed Debug to info, if not appdaemon shows tons of messages):

2018-06-03 19:06:07.004286 WARNING AppDaemon: ------------------------------------------------------------
2018-06-03 19:07:05.372756 INFO AppDaemon: Terminating hoofdagenda
2018-06-03 19:07:05.372934 INFO AppDaemon: Reloading Module: /config/appdaemon/apps/calendar.py
2018-06-03 19:07:05.375324 INFO AppDaemon: Initializing app hoofdagenda using class calendar from module calendar
2018-06-03 19:07:05.376269 INFO hoofdagenda: debug: True
2018-06-03 19:07:05.376873 INFO hoofdagenda: init untill run_every done
2018-06-03 19:07:05.377489 INFO hoofdagenda: run_every initialised
2018-06-03 19:07:05.378093 INFO hoofdagenda: starting credential check
2018-06-03 19:07:05.378719 INFO hoofdagenda: credentialpath: /config/appdaemon/apps/calendar_client_secret.json
2018-06-03 19:07:05.378944 WARNING AppDaemon: ------------------------------------------------------------
2018-06-03 19:07:05.379024 WARNING AppDaemon: Unexpected error running initialize() for hoofdagenda
2018-06-03 19:07:05.379071 WARNING AppDaemon: ------------------------------------------------------------
2018-06-03 19:07:05.379226 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 35, in initialize
self.controleer_agenda(self)
File “/config/appdaemon/apps/calendar.py”, line 44, in controleer_agenda
credentials = self.get_credentials()
File “/config/appdaemon/apps/calendar.py”, line 251, in get_credentials
credentials = store.get()
File “/usr/lib/python3.6/site-packages/oauth2client/client.py”, line 407, in get
return self.locked_get()
File “/usr/lib/python3.6/site-packages/oauth2client/file.py”, line 54, in locked_get
credentials = client.Credentials.new_from_json(content)
File “/usr/lib/python3.6/site-packages/oauth2client/client.py”, line 302, in new_from_json
module_name = data[’_module’]
KeyError: ‘_module’

My Json file exists in folder /config/appdaemon/apps/calendar_client_secret.json and this is its content:

{“installed”:{“client_id”:“xxxxxxxxxx.apps.googleusercontent.com”,“project_id”:“eternal-cocoa-205201”,“auth_uri”:“https://accounts.google.com/o/oauth2/auth",“token_uri”:“https://accounts.google.com/o/oauth2/token”,“auth_provider_x509_cert_url”:“https://www.googleapis.com/oauth2/v1/certs”,“client_secret”:“xxxxxxxxx”,“redirect_uris”:[“urn:ietf:wg:oauth:2.0:oob”,"http://localhost”]}}

That is the same credential I am using from Home Assistant to connect to the same google calendar.

I exported that to the .json format and copied to the folder

Thanks

nothing more in the log?
and same error?

in that case we have a basic error in AD.
what is in your appdaemon.yaml (complete file)

i guess we have to check if we get apps working at all
so please delete these files and create

import appdaemon.plugins.hass.hassapi as hass

class test(hass.Hass):

    def initialize(self):
        self.log("test app initialised ok")

as test.py
and

test:
  module: test
  class: test

as test.yaml