cancel
Showing results for 
Search instead for 
Did you mean: 

Setting Cat's Status to In or Out

Poppy33
Community Member

Is there a way I can say OK Google, "Poppy is in" or "Poppy is out" and for Google to log this status about the cat.

Then, when I ask "OK Google, where is Poppy?" Google can reply with the last recorded status?

If I can get the current status displayed on my phone, that would be an extra bonus.

 

 

 

 

 

2 Recommended AnswerS

salbando
Community Member

Go to Google Home Playground. Create a virtual switch and name it whatever you like. Make your routine turn this switch on when you say Poppy is in. Make another routine to turn this switch off when you say Poppy is out. Make another routine that checks if this switch is on or off when you ask is Where is Poppy, and then it broadcasts the appropriate response based on this virtual switch. I can show you how to do an "If-then-else" to accomplish this if you want.

View Recommended Answer in original post

salbando
Community Member

To do an if-then-else you just need to use the same starter twice. You do this by separating the code into two sections using the "name" key. Hopefully, an actual if-then-else structure will be implemented some day. Naturally, if you get tired of saying, "Hey Google, turn off Poppy in out switch" each time Poppy goes out and "Hey Google, turn on Poppy in out switch" when Poppy comes in, then just write separate routines that use your phrases of "Poppy is in" and "Poppy is out", and have them set that switch. BTW, Google does understand the word "Toggle" when it comes to switches. If you are diligent about it, you could just say, "Hey Google, toggle Poppy in out" and it will flip the switch to the opposite condition. I have checked the following code and it works just fine. Hope this helps.

 

 

metadata:
  name: Report on Poppy
  description: Report on the location of Poppy
automations:
  - name: Poppy is in
    starters:
      - type: assistant.event.OkGoogle
        eventData: query
        is: Where is Poppy
    condition:
      type: device.state.OnOff
      state: on
      is: true
      device: Poppy_in_out - Playground
    actions:
      - type: assistant.command.Broadcast
        message: Poppy is in
        devices: Kitchen speaker - Kitchen
  - name: Poppy is out
    starters:
      - type: assistant.event.OkGoogle
        eventData: query
        is: Where is Poppy
    condition:
      type: device.state.OnOff
      state: on
      is: false
      device: Poppy_in_out - Playground
    actions:
      - type: assistant.command.Broadcast
        message: Poppy is out
        devices: Kitchen speaker - Kitchen

 

 

If you want a notification on your phone then include the following in the Actions blocks:

 

      - type: home.command.Notification
        title: Poppy whereabouts
        body: Poppy is in
        members:
          - User name - email address

 

View Recommended Answer in original post

4 REPLIES 4

salbando
Community Member

Go to Google Home Playground. Create a virtual switch and name it whatever you like. Make your routine turn this switch on when you say Poppy is in. Make another routine to turn this switch off when you say Poppy is out. Make another routine that checks if this switch is on or off when you ask is Where is Poppy, and then it broadcasts the appropriate response based on this virtual switch. I can show you how to do an "If-then-else" to accomplish this if you want.

Poppy33
Community Member

Thanks so much, and thanks for replying on Christmas Day! 

I'm halfway there. Just trying to figure how to implement ELSE into the code. No luck after plenty of time fiddling. Here's where i'm up to. 

----------------------------------------

starters:
- type: assistant.event.OkGoogle
eventData: query
is: Where is Poppy

 

condition:
device: Poppy_in_out - Playground
type: device.state.OnOff 
state: on
is: true

actions:
- type: assistant.command.Broadcast
message: Poppy is in
devices: Kitchen speaker - Kitchen

----------------------------------------

The nest will say poppy is in, so this code is working, but i'm not sure how/where to include ELSE within this.

Thanks for your help so far! 

salbando
Community Member

To do an if-then-else you just need to use the same starter twice. You do this by separating the code into two sections using the "name" key. Hopefully, an actual if-then-else structure will be implemented some day. Naturally, if you get tired of saying, "Hey Google, turn off Poppy in out switch" each time Poppy goes out and "Hey Google, turn on Poppy in out switch" when Poppy comes in, then just write separate routines that use your phrases of "Poppy is in" and "Poppy is out", and have them set that switch. BTW, Google does understand the word "Toggle" when it comes to switches. If you are diligent about it, you could just say, "Hey Google, toggle Poppy in out" and it will flip the switch to the opposite condition. I have checked the following code and it works just fine. Hope this helps.

 

 

metadata:
  name: Report on Poppy
  description: Report on the location of Poppy
automations:
  - name: Poppy is in
    starters:
      - type: assistant.event.OkGoogle
        eventData: query
        is: Where is Poppy
    condition:
      type: device.state.OnOff
      state: on
      is: true
      device: Poppy_in_out - Playground
    actions:
      - type: assistant.command.Broadcast
        message: Poppy is in
        devices: Kitchen speaker - Kitchen
  - name: Poppy is out
    starters:
      - type: assistant.event.OkGoogle
        eventData: query
        is: Where is Poppy
    condition:
      type: device.state.OnOff
      state: on
      is: false
      device: Poppy_in_out - Playground
    actions:
      - type: assistant.command.Broadcast
        message: Poppy is out
        devices: Kitchen speaker - Kitchen

 

 

If you want a notification on your phone then include the following in the Actions blocks:

 

      - type: home.command.Notification
        title: Poppy whereabouts
        body: Poppy is in
        members:
          - User name - email address

 

Poppy33
Community Member

Incredible. Thank you.