cancel
Showing results for 
Search instead for 
Did you mean: 

broadcast something based on which day is when you ask

Pottati
Community Member

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

1 Recommended Answer

salbando
Community Member

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. 

View Recommended Answer in original post

2 REPLIES 2

salbando
Community Member

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. 

Pottati
Community Member

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