01-04-2024 02:34 AM
Hi all,
I'm trying to create my first automation in the web automation interface. I would like to create a query with a broadcast action. So I would like to ask google "what's my lunch?" and I would like to have the answer based on the day I'm asking so for example monday "pasta" tuesday "pizza" wednesday "meat". I've tried multiple conditons but I always get errors. Do you have any clue? anyone have done something like this?
Thanks
KR
Answered! Go to the Recommended Answer.
01-04-2024 07:10 AM
You just need to use the same starter ("What is my lunch") seven times. You do this by separating the code into seven sections using the "name" key (for example - name: Monday). In each section, put a conditional for that given day and an appropriate action. Here is an example for Monday and Tuesday.
metadata:
name: Lunch report
description: Tell me my lunch for any given day
automations:
- name: Monday
starters:
- type: assistant.event.OkGoogle
eventData: query
is: What is my lunch?
condition:
type: time.between
weekdays:
- MON
actions:
- type: assistant.command.Broadcast
message: Pasta
devices: Downstairs speaker - Family room
- name: Tuesday
starters:
- type: assistant.event.OkGoogle
eventData: query
is: What is my lunch?
condition:
type: time.between
weekdays:
- TUE
actions:
- type: assistant.command.Broadcast
message: Pizza
devices: Downstairs speaker - Family room
By the way, using the phrase "What is my lunch?" as opposed to "What's my lunch?" is probably better because the apostrophe is used as a delimiter.
01-04-2024 07:10 AM
You just need to use the same starter ("What is my lunch") seven times. You do this by separating the code into seven sections using the "name" key (for example - name: Monday). In each section, put a conditional for that given day and an appropriate action. Here is an example for Monday and Tuesday.
metadata:
name: Lunch report
description: Tell me my lunch for any given day
automations:
- name: Monday
starters:
- type: assistant.event.OkGoogle
eventData: query
is: What is my lunch?
condition:
type: time.between
weekdays:
- MON
actions:
- type: assistant.command.Broadcast
message: Pasta
devices: Downstairs speaker - Family room
- name: Tuesday
starters:
- type: assistant.event.OkGoogle
eventData: query
is: What is my lunch?
condition:
type: time.between
weekdays:
- TUE
actions:
- type: assistant.command.Broadcast
message: Pizza
devices: Downstairs speaker - Family room
By the way, using the phrase "What is my lunch?" as opposed to "What's my lunch?" is probably better because the apostrophe is used as a delimiter.
01-04-2024 07:40 AM
Hi thanks for your support. That's great and it is working... I was trying using variables but with no success. Variables could be a good option for maintenance but I had no success. Anyway a big thanks so far. at least now works I will try to create my variables for testing only