I’m working on a TTS script to run in the morning after my alarm, and I want it to summarize all of the events I have for that day. Currently it seems like HA can only access the next event in my calendar, but not any events after that.
Is there any way to access future events after the current next event in a calendar in HA?
Also worth noting that from my experience if you have overlapping events and you’re still in the time frame for the first one, HA still reads the first one rather than the ‘next’ one.
Example:
You have an entry for you receiving a call that could come anytime between 10.00 and 12.00
You have to pick the kids up from swimming at 11, you mark it as 1100 - 11.30
You have a meeting at work from 16.00 - 18.00
Prior to 10 HA will show next event as incoming call. This will stay the case until 12, then next event will then show as meeting at 4pm.
Seeing as it seems that HA doesn’t have this capability, I came up with a workaround. I shared my google calendar publicly so that I could access it via a webscraper.
This python script scrapes the relevant calendar information for my day from my calendar in the agenda format, creates a sentence that summarizes my day and saves that sentence into a txt file. With cron, I have this run at 1am everyday so it is updated when I wake up.
from bs4 import BeautifulSoup
soup = BeautifulSoup(page.content, 'html.parser')
table = soup.select('div.date-section-today tr')
rows = [tb.get_text() for tb in table]
output=""
wholedaycount = 0
partialdaycount=0
for x in rows:
temp = x.split("\n")
if len(temp[0])>1:
if wholedaycount>0 and partialdaycount==0:
output+=". "
if partialdaycount==0:
output+="At "+temp[0]+" you have "+temp[1]
partialdaycount=1
else:
output+=", at "+temp[0]+" you have "+temp[1]
else:
if wholedaycount==0:
output+="Today you have "+temp[1]
wholedaycount=1
else:
output+=" and "+temp[1]
I wanted to find out how did you get your python script running ? Did you create a custom component ?
I am trying to scrape info from a website but cannot get it to display on HA as library import (bs4 in my case) is not permissible with python in HA. How did you manage to do that?
I will probably use a similar script to yours but the information I require is in a tabulated format from which I would need to create at least 5 sensors. Can you help me with that please?
I had the python script running on my pi completely independent of HA. I just set it up with cron so that the file would run once a day and create the text file that HA actually looks at
This is the relevant piece of code for writing the string to the file. I think you should use the whole path to the file and place it within the homeassistant folders so that HA can access it.
I never got it working with Hassio, as I don’t think it would allow me to rund scripts on the pi independent of Hassio. I did this with just the normal Home Assistant configuration
Is it giving you any kind of error code in hass? Maybe check to make sure the content is in the file and the file location put in the config.yaml is the correct whole path to the file
Failed config
sensor.file:
- Invalid config for [sensor.file]: not a file for dictionary value @ data[' file_path']. Got '/root/share/todays_events.txt'. (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.file/
- platform: file
file_path: /root/share/todays_events.txt
name: Todays Events
It would be really great if we could just do it with the help of Home Assistant.
Unfortunately, I also belong to the rather forgetful people.
I would like to send myself a bundled message (once or several times a day) about all upcoming dates on that day.
As far as I could read up, this is not possible with the current google calendar component, until now.
The events pulled by the Google Calendar integration is available under: <hass-url>/calendar.<calendar_id> I think it is better to access that information by a restful sensor or some other magics.
I’ll report back when I’ve created the needed configuration.