Please format your posts correctly. See: 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 you have been a forum member for 5 years, we shouldn’t have to tell you this.
Change the trigger:
triggers:
- trigger: state
entity_id: binary_sensor.your_entity_here
to: "off"
not_from:
- unknown
- unavailable
Also read this: Why and how to avoid device_ids in automations and scripts