Open flyize opened 3 years ago
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.
+1 Love to see the ability to do this too. I see some mention of it in the code.
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!
Agreed ... this would be a useful addition!
available in the dev branch now ;) but you have to enter the pet id for now, sorry ✌️
Awesome. Can you share the service call for that?
I think that shows everything you wanna know :D
Thanks, but on the dev version you got me to install (bba9b0d), I'm not seeing that service as an option.
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 👍 )
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.
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.
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
THIS IS AWESOME!
Updated my card above as I forgot to add the service call. Now changed it to a hold_action
too.
Got mine all setup in NR. This is super sweet. Thanks @benleb
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 😕
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?
Sorry, not quite sure what you're wanting to do.
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') }}
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?
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
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
@sasgoose Thanks a lot, it works like a charm with your version.
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 .
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
When our cats get out/in the human door, it would be nice to be able to set their status via Home Assistant