Using toggle on two cameras switches

I am trying to use this code to turn off or on 2 cameras depending on their state when I scan a NFS tag. This routine turns one off and the other on no matter what state they started in.
alias: Toggle front cameras tag
description: “”
triggers:

  • trigger: tag
    tag_id: 6b6a564a-8564-4653-8521-339f9d4a2967
    conditions:
    actions:
  • action: switch.toggle
    metadata: {}
    target:
    device_id:
    - 4a6c0a481b542eec7af91c317f6eec65
    - 978ac242814ff5123599a312e2d4b505
    data: {}
    mode: single

mode: single

Firstly, please edit your post and format your pasted config correctly: https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

Then check the automation trace to see what is going on: Troubleshooting automations - Home Assistant

I found the problem my eufy cameras are slow to update home assistant so didn’t know if they were on or off