Make automation with google calender

No sorry… let’s do this. Next time your calendar event is active, the one you want to use in this automation I mean, send me a picture like the last one with all the information from your event please.

I have change the time so I should start the automation at 19:20 on the event that is 21:30. (I have change the times in atomation.yaml
In notification this turnes upp:

image

Sorry… I really don’t understand what you’re doing… You are trying to test the automation? so it triggers at 19:20?

this particular automation will only trigger if the start time equals ‘06:30’. You next event starts at 21:30, so there’s no use in testing it unless you change the ‘06:30’ from the condition section.

There’s an easier way to do this. Go to “Developer tools”, “Template”, and copy and paste there the condition section from the automation, this:

"{{state_attr('calendar.maria_tjg', 'start_time')[0:10] == states('sensor.date') and state_attr('calendar.maria_tjg', 'start_time')[11:16] == '06:30'}}"

replace ‘06:30’ with the next start time from your calendar. If everything checks, you’ll see “true” in the results box.

To avoid errors in your config, use this one:

- id: '16XXXXX'
  alias: Turn on the lights at 05:30 if Maria starts work at 06:30
  description: Slå på lyset i vardagsrummet kl. 05:30 om Maria börjar kl 06:30
  trigger:
  - platform: time
    at: '05:30:00'
  condition:
  - condition: template
    value_template: "{{state_attr('calendar.maria_tjg', 'start_time')[0:10] == states('sensor.date') and state_attr('calendar.maria_tjg', 'start_time')[11:16] == '06:30'}}"
  action:
  - type: turn_on
    device_id: cXXXX
    entity_id: light.8XXXX
    domain: light
  - type: turn_on
    device_id: 4XXXXX
    entity_id: light.3XXXX
    domain: light
  - type: turn_on
    device_id: dXXXXXX
    entity_id: light.bfXXXXXX
    domain: light
  mode: single

Big thanks, it’s working well. :slight_smile:
Is it possible to add that it should not start if the sun has raised?
I have tried, but didn’t get it to work…

you could do this but it’s not 100% precise

  condition:
  - condition: template
    value_template: "{{state_attr('calendar.maria_tjg', 'start_time')[0:10] == states('sensor.date') and state_attr('calendar.maria_tjg', 'start_time')[11:16] == '06:30'}}"
  - condition: state
    entity_id: sun.sun
    state: below_horizon

Problem is it depends on your building, orientation, weather, etc. More precise would be to check the value of the elevation attribute of the sun at the given time you want it not to act. Once you got that number you could do this:

  condition:
  - condition: template
    value_template: "{{state_attr('calendar.maria_tjg', 'start_time')[0:10] == states('sensor.date') and state_attr('calendar.maria_tjg', 'start_time')[11:16] == '06:30'}}"
  - condition: template
    value_template: "{{state_attr('sun.sun', 'elevation')|float <= X }}"

Where X is the value of the elevation at the exact threshold you want it to stop working. Again, that’s not a 100% precise because it can’t tell the difference between a sunny day and a snowy day, but it’s better than just above or below horizon.

Whenever there’s sufficient sun light in the morning, go to Developers tools in the left menu, go to States and seek the elevation value like in the picture below (39.28 in this case). Keep it and swap it in the place of the X from the code above:

100% precise would be to have a light sensor monitor the outdoor amount of light and code your own sun sensor. It’s really simple, not that expensive and totally worth it. It comes in handy with the majority, if not all, of your light automations.

[quote=“obaldius, post:25, topic:274174”]

I will start with your first exempel and then add a light sensor later. Big thanks for your help.

Can you help me with on other thing?
If the calender “calendar.maria_tjg” says a event ends at 23:00, I whant to turn of the light at 00:15.
Is that also possible?