Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Ability to set pets home/away from Home Assistant #5

Open
flyize opened this issue May 10, 2021 · 24 comments
Open

Request: Ability to set pets home/away from Home Assistant #5

flyize opened this issue May 10, 2021 · 24 comments
Assignees
Labels
enhancement New feature or request

Comments

@flyize
Copy link

flyize commented May 10, 2021

When our cats get out/in the human door, it would be nice to be able to set their status via Home Assistant

@flyize
Copy link
Author

flyize commented May 10, 2021

I was just thinking...

Is surepy available to an HA script? Until this could be officially implemented, I could just have an input selector that runs surepy when I set it to home/away.

@benleb benleb added the enhancement New feature or request label May 11, 2021
@xbmcnut
Copy link

xbmcnut commented May 12, 2021

+1 Love to see the ability to do this too. I see some mention of it in the code.

@sasgoose
Copy link
Contributor

sasgoose commented Sep 8, 2021

I would absolutely love this! Being able to create an NFC chip to cycle the location would be awesome because our oldest cat just doesn't want to learn how to use the cat flap!

@Gotcha-1980
Copy link

Agreed ... this would be a useful addition!

@benleb benleb self-assigned this Sep 9, 2021
benleb added a commit that referenced this issue Sep 9, 2021
@benleb
Copy link
Owner

benleb commented Sep 9, 2021

available in the dev branch now ;) but you have to enter the pet id for now, sorry ✌️

@xbmcnut
Copy link

xbmcnut commented Sep 9, 2021

Awesome. Can you share the service call for that?

@benleb
Copy link
Owner

benleb commented Sep 9, 2021

image

I think that shows everything you wanna know :D

@xbmcnut
Copy link

xbmcnut commented Sep 9, 2021

Thanks, but on the dev version you got me to install (bba9b0d), I'm not seeing that service as an option.

image

@benleb
Copy link
Owner

benleb commented Sep 9, 2021

that change came in a commit after yours, refresh HACS or restart HA and you should be able to update :) (Otherwise, try reinstalling the dev 👍 )

@xbmcnut
Copy link

xbmcnut commented Sep 9, 2021

Thanks. The problem is when your running a dev version, there is no longer an option to 'reinstall' as the add-on wants you to install the latest current version. So you have to kind of upgrade to 2.3 and then reinstall to have the ability to pick the new dev version.

[EDIT] Apologies, I take that back. Going into the integrations and clicking on the add-on reveals the reinstall option. Picking dev again now.

@xbmcnut
Copy link

xbmcnut commented Sep 10, 2021

Working great now. For others wanting to do this, I've set up a hold action on this custom-button card to call a script to set the pet as inside.

image

script:
  set_kobe_inside:
    alias: 'Set Kobe Inside'
    sequence:
      - service: sureha.set_pet_location
        data:
          pet_id: '123456' #Kobe's Code
          where: Inside      

And the code for button shown above. Icon changes from green to red when pet goes outside.

entity: binary_sensor.pet_kobe
icon: mdi:cat
layout: icon_name_state
show_name: false
show_state: true
styles:
  icon:
    - color: >
        [[[ if (states['binary_sensor.pet_kobe'].state === 'on') return "green";
        return "red"; ]]]
tap_action:
  action: more-info
hold_action:
  action: call-service
  service: script.set_kobe_inside
type: custom:button-card

@flyize
Copy link
Author

flyize commented Sep 10, 2021

THIS IS AWESOME!

@xbmcnut
Copy link

xbmcnut commented Sep 10, 2021

Updated my card above as I forgot to add the service call. Now changed it to a hold_action too.

@flyize
Copy link
Author

flyize commented Sep 10, 2021

Got mine all setup in NR. This is super sweet. Thanks @benleb

image

@benleb
Copy link
Owner

benleb commented Sep 10, 2021

this reminds me at a project I played with some time ago...

https://github.com/benleb/ad-catrack
an appdaemon app which tracks a pet, a cat in my case, with various sensors like our sure flaps but I also used motion and vibration sensors. I put them at "her" places, cat owners know what is meant ;D For example in the garden on her sleeping chair, in her bedbox, ... the intention was to roughly know where to look for her but I can imagine other use cases too... don't vacuum in the room where she is or such things (she doesn't like the vacuum 🤷‍♀️)
maybe I should give that project another chance 😕

@totalitarian
Copy link

Is it possible to do the opposite here? I.e. when set their home/away status based on if the cat flap says they are inside/outside?

@xbmcnut
Copy link

xbmcnut commented Sep 11, 2021

Sorry, not quite sure what you're wanting to do.

@benleb
Copy link
Owner

benleb commented Sep 11, 2021

Hm mounted the flap the wrong way around? 😂

But I think that's a real edge case we shouldn't implement in sureha 😅 But to solve your problem, you could probably do a binary template sensor like
{{ not states('binary_sensor.pet_goofy') }}

@totalitarian
Copy link

Sorry, not quite sure what you're wanting to do.

I have my pet setup as a ‘person’. I would like her status synced with SureHA. So when the cat flap shows her as outside, the person is marked as away and when the cat flap shows her as inside, she is marked as home. This could be done by creating a device tracker for each pet I guess?

@xbmcnut
Copy link

xbmcnut commented Sep 11, 2021

Maybe this?
https://community.home-assistant.io/t/sureflap-connect-pet-door/41488/386
https://github.com/pnbruckner/ha-composite-tracker

@yvansandoz
Copy link

yvansandoz commented Sep 26, 2021

Trying to create a script to switch the state. Any script expert around here? Thanks in advance for your help.

switch_sia_state:
  alias: "Switch Sia State"
  sequence:
    - choose:
        - conditions: >
            {{ binary_sensor.pet_sia == 'on' }}
          sequence:
            - service: sureha.set_pet_location
              data:
                pet_id: "!secret sia_id"
                where: Outside
        - conditions: >
            {{ binary_sensor.pet_sia == 'off' }}
          sequence:
            - service: sureha.set_pet_location
              data:
                pet_id: "!secret sia_id"
                where: Inside

@sasgoose
Copy link
Contributor

sasgoose commented Sep 26, 2021

In the "useful things" section of the Readme I added a toggle location script. But there may be a better way of doing it.

script:
  toggle_thorin_location:
      alias: 'Toggle Thorin location'
      sequence:
        choose:
        - conditions:
            - condition: state
              entity_id: binary_sensor.pet_thorin_2
              attribute: where
              state: 1
          sequence:
            - service: sureha.set_pet_location
              data:
                pet_id: '123456' # Thorin's pet id
                where: Outside
        - conditions:
            - condition: state
              entity_id: binary_sensor.pet_thorin_2
              attribute: where
              state: 2
          sequence:
            - service: sureha.set_pet_location
              data:
                pet_id: '123456' # Thorin's pet id
                where: Inside

@yvansandoz
Copy link

@sasgoose Thanks a lot, it works like a charm with your version.

@yvansandoz
Copy link

yvansandoz commented Sep 26, 2021

And here my combined card for displaying the status and changing the parameters. Tap-hold on the cats with toogle the state as done by @xbmcnut .

image

type: vertical-stack
title: Chatière
cards:
  - type: horizontal-stack
    cards:
      - type: custom:button-card
        entity: binary_sensor.pet_sia
        name: Sia
        icon: mdi:cat
        label: |
          [[[
            return states['sensor.sia_last_state'].state;
          ]]]
        show_label: true
        show_name: true
        styles:
          card:
            - height: 110px
          label:
            - color: gray
            - font-size: 10px
          icon:
            - color: >
                [[[ if (states['binary_sensor.pet_sia'].state === 'on') return
                "green"; return "red"; ]]]
        tap_action:
          action: more-info
        hold_action:
          action: call-service
          service: script.toogle_sia_location
      - type: custom:button-card
        entity: sensor.pet_door_status_template
        show_state: true
        styles:
          card:
            - height: 110px
          state:
            - color: gray
            - font-size: 10px
        state:
          - value: locked_in
            color: rgb(255, 153, 153)
          - value: unlocked
            color: rgb(153, 255, 153)
          - value: locked_out
            color: rgb(255, 153, 153)
          - value: locked_all
            color: rgb(255, 153, 153)
      - type: custom:button-card
        entity: binary_sensor.pet_chilli
        name: Chilli
        icon: mdi:cat
        color: rgb(153, 255, 153)
        state:
          - value: 'off'
            color: rgb(255, 153, 153)
        label: |
          [[[
            return states['sensor.chilli_last_state'].state;
          ]]]
        show_label: true
        show_name: true
        styles:
          card:
            - height: 110px
          label:
            - color: gray
            - font-size: 10px
          icon:
            - color: >
                [[[ if (states['binary_sensor.pet_chilli'].state === 'on')
                return "green"; return "red"; ]]]
        tap_action:
          action: more-info
        hold_action:
          action: call-service
          service: script.toogle_chilli_location
  - type: horizontal-stack
    cards:
      - type: custom:button-card
        entity: sensor.cat_flap_chatiere_cuisine
        name: Unlock
        icon: mdi:clock
        tap_action:
          action: call-service
          service: sureha.set_lock_state
          service_data:
            flap_id: "your flap id"
            lock_state: unlocked
      - type: custom:button-card
        entity: sensor.cat_flap_chatiere_cuisine
        name: Lock In
        icon: mdi:upload-off-outline
        tap_action:
          action: call-service
          service: sureha.set_lock_state
          service_data:
            flap_id: "your flap id"
            lock_state: locked_in
      - type: custom:button-card
        entity: sensor.cat_flap_chatiere_cuisine
        name: Lock Out
        icon: mdi:download-off-outline
        tap_action:
          action: call-service
          service: sureha.set_lock_state
          service_data:
            flap_id: 480566
            lock_state: locked_out
      - type: custom:button-card
        entity: sensor.cat_flap_chatiere_cuisine
        name: Lock All
        icon: mdi:close-octagon
        tap_action:
          action: call-service
          service: sureha.set_lock_state
          service_data:
            flap_id: "your flap id"
            lock_state: locked_all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants