Integrating Sure Petcare Cat Flap with Manual Location Toggle

Hey everyone, I’ve been diving into Home Assistant lately and it’s been an exciting journey! I’ve managed to set up quite a few things thanks to the amazing tutorials from Simon42. My latest project has been integrating our Sure Petcare cat flap into Home Assistant. It’s been working like a charm so far, but I’m looking to take it a step further.

Currently, the cat flap is seamlessly integrated, and I can monitor our feline friend’s movements right from my phone. However, there’s one feature I’d love to add: the ability to manually toggle the cat’s location. This would be super handy in case our curious kitty decides to ignore the flap and find another way in or out!

I stumbled upon some code in the English-speaking forums that seems to do exactly what I want. It’s a script that uses the Sure Petcare service to set the pet’s location based on the current state. Here’s the gist of it:

yaml
alias: Toggle Cat Location
sequence:

  • choose:
    • conditions:
      • condition: state
        entity_id: binary_sensor.cat
        state: “on”
        sequence:
        • service: surepetcare.set_pet_location
          data:
          pet_name: Cat
          location: Outside
    • conditions:
      • condition: state
        entity_id: binary_sensor.cat
        state: “off”
        sequence:
        • service: surepetcare.set_pet_location
          data:
          pet_name: Cat
          location: Inside
          mode: single
          icon: mdi:swap-horizontal

I’ve tried integrating this into my setup by adding it as a manual card. I adjusted the pet name and binary sensor to match our setup, but I’m a bit stuck on the card type. The visual editor is flagging some keys like alias, sequence, and mode as unsupported. I know alias is mainly for voice commands, so maybe it can be omitted, but I’m not entirely sure about the others. Should I stick with Button as the card type, or is there a better option?

Any advice on tweaking this script or choosing the right card type would be invaluable. I’d love to get this feature up and running smoothly! Thanks in advance for your help, and happy automating! :blush:

1 Like