I am trying to set up light switches that depend on if there is an event or not. I have a Google Spreadsheet with info about events and dates. This is an example:
If there is an event today, then light 1 should be turned on at sunset. And if Count > 50, so should all lights.
I have sorted out this manually today by entering if there is an event today and entered a number, but my goal is to automate further.
I made a python script that reads the spreadsheet, but how should I use this to populate variables in HA? And how should I use the variables in my templates?
This is my automation today that works manually:
- id: '1600676065786'
alias: Turn on at sunset if event
description: ''
trigger:
- event: sunset
platform: sun
condition:
- condition: state
entity_id: input_boolean.event_today
state: 'on'
action:
- service: switch.turn_on
data_template:
entity_id: "{% if states('input_number.event_count') | int > 50 %}\n group.alll\n\
{% else %}\n switch.switch1\n{% endif %} \n"
mode: single
I also noted that running my python script is not that fast and with poor CPU I get a timeout. It might be good to run a CRON-job reading the spreadsheet and either save it as CSV or enter the values with HA API.
Does anyone have any ideas?