I want to have the next 5 events of one Google Calendar available in AppDaemon.
I got it somehow working with this hacky solution (for testing):
import appdaemon.plugins.hass.hassapi as hass
from requests import get
class test_cal(hass.Hass):
def initialize(self):
self.load_cal()
def load_cal(self):
ha_url = "http://192.168.1.30:8123"
token = self.args["token"]
calendar = "calendar.geburtstage_und_jahrestag"
start_date = "2019-02-04T00:00:00"
end_date = "2019-04-04T00:00:00"
headers = {'Authorization': "Bearer {}".format(token)}
apiurl = "{}/api/calendars/{}?start={}Z&end={}Z".format(ha_url,calendar,start_date,end_date)
r = get(apiurl, headers=headers, verify=False)
self.log(r.json())
By this, I get a json with the raw data.
Can anyone help me achieving this with the “built-in” functionality, not with a separate definition of ha_url and a special token? I think it should be possible with some hass plugin class or method, but I couldn’t find our how. (I do not need the json raw data, I would be happy with the date and the description of the events, no matter in what format).
Or, to make it more general: How do I access stuff from the HASS API which is not predefined in AppDaemon?
what kind of calendar are you using?
i ask because when i try the app i get nothing returned.
that can be because i use another kind of calendar.
if you go to dev page to services, what kind of services are available for you that relate to calendar?
Thank you for your code. I’m playing with your json processing at the moment.
The token and ha_url part did not work for me. I use http://hassio/homeassistant as ha_url, which gets loaded from self.config correctly, but I get “Response [400]” (Bad Request) as a result r. When I change the token so a long lived token, I get a “Response [401]” (Unauthorized). The same for the manually entered ha_url with the token from self.config. I only got it working with the combination of manually defined ha_url (ip:port) and long lived token. But that’s OK for me at the moment. Maybe I’ll have a look on that later.
that the token doesnt work isnt that strange wit hassio.
its no long lived token and you use another platform then python.
you could add a key to appdaemon.yaml for yourself.
add