Foscam state check and notify

Hello,
i have two foscam cams, i can enable/disable motion detection but i want to send a notification with notify.notify after executing a script and checking the state.
This is my current situation:

/config/switches.yaml

  - platform: command_line
    switches:
      foscam_ingresso_motion:
        command_on: 'curl -k "http://xxx.xxx.xxx.xxx:XXXXX/cgi-bin/CGIProxy.fcgi?usr=XXXXXX&pwd=XXXXXX&cmd=setMotionDetectConfig&isEnable=1&linkage=15&snapInterval=1&sensitivity=1&triggerInterval=0&schedule0=281474976710655&schedule1=281474976710655&schedule2=281474976710655&schedule3=281474976710655&schedule4=281474976710655&schedule5=281474976710655&schedule6=281474976710655&area0=1023&area1=1023&area2=1016&area3=992&area4=960&area5=896&area6=896&area7=768&area8=768&area9=768"'
        command_off: 'curl -k "http://xxx.xxx.xxx.xxx:XXXXX/cgi-bin/CGIProxy.fcgi?usr=XXXXXX&pwd=XXXXXX&cmd=setMotionDetectConfig&isEnable=0"'
        command_state: 'curl -k --silent "http://xxx.xxx.xxx.xxx:XXXXX/cgi-bin/CGIProxy.fcgi?usr=XXXXXX&pwd=XXXXXX&cmd=getMotionDetectConfig" | grep -oP "(?<=isEnable>).*?(?=</isEnable>)"'
        value_template: '{{ value == "1" }}'
      foscam_corridoio_motion:
        command_on: 'curl -k "http://xxx.xxx.xxx.xxx:XXXXX/cgi-bin/CGIProxy.fcgi?usr=XXXXXX&pwd=XXXXXX&cmd=setMotionDetectConfig&isEnable=1&linkage=15&snapInterval=1&sensitivity=1&triggerInterval=0&schedule0=281474976710655&schedule1=281474976710655&schedule2=281474976710655&schedule3=281474976710655&schedule4=281474976710655&schedule5=281474976710655&schedule6=281474976710655&area0=1023&area1=1023&area2=1023&area3=1023&area4=1023&area5=783&area6=527&area7=775&area8=771&area9=768"'
        command_off: 'curl -k "http://xxx.xxx.xxx.xxx:XXXXX/cgi-bin/CGIProxy.fcgi?usr=XXXXXX&pwd=XXXXXX&cmd=setMotionDetectConfig&isEnable=0"'
        command_state: 'curl -k --silent "http://xxx.xxx.xxx.xxx:XXXXX/cgi-bin/CGIProxy.fcgi?usr=XXXXXX&pwd=XXXXXX&cmd=getMotionDetectConfig" | grep -oP "(?<=isEnable>).*?(?=</isEnable>)"'
        value_template: '{{ value == "1" }}'

/config/shell_commands.yaml

foscam_corridoio_turn_off: 'curl -k "http://xxx.xxx.xxx.xxx:XXXXX/cgi-bin/CGIProxy.fcgi?usr=XXXXXX&pwd=XXXXXX&cmd=ptzGotoPresetPoint&name=AtHome"'
foscam_corridoio_turn_on: 'curl -k "http://xxx.xxx.xxx.xxx:XXXXX/cgi-bin/CGIProxy.fcgi?usr=XXXXXX&pwd=XXXXXX&cmd=ptzGotoPresetPoint&name=Sorveglianza"'
foscam_ingresso_turn_off: 'curl -k "http://xxx.xxx.xxx.xxx:XXXXX/cgi-bin/CGIProxy.fcgi?usr=XXXXXX&pwd=XXXXXX&cmd=ptzGotoPresetPoint&name=AtHome"'
foscam_ingresso_turn_on: 'curl -k "http://xxx.xxx.xxx.xxx:XXXXX/cgi-bin/CGIProxy.fcgi?usr=XXXXXX&pwd=XXXXXX&cmd=ptzGotoPresetPoint&name=Sorveglianza"'

/config/scripts.yaml

  foscam_all_off:
    alias: "Disarm Home Cams"
    sequence:
    - service: switch.turn_off
      data:
        entity_id: switch.foscam_ingresso_motion
    - service: shell_command.foscam_ingresso_turn_off
    - service: switch.turn_off
      data:
        entity_id: switch.foscam_corridoio_motion
    - service: shell_command.foscam_corridoio_turn_off
   **- CHECK STATE CAM 1 WITH CURL > notify.notify ( <isEnable>1</isEnable>  or <isEnable>0</isEnable>  )**
  **- CHECK STATE CAM 2 WITH CURL > notify.notify ( <isEnable>1</isEnable>  or <isEnable>0</isEnable>  )**
  foscam_all_on:
    alias: "Arm Home Cams"
    sequence:
    - service: switch.turn_off
      data:
        entity_id: switch.foscam_ingresso_motion
    - service: shell_command.foscam_ingresso_turn_on
    - service: switch.turn_on
      data:
        entity_id: switch.foscam_ingresso_motion
    - service: switch.turn_off
      data:
        entity_id: switch.foscam_corridoio_motion
    - service: shell_command.foscam_corridoio_turn_on
    - service: switch.turn_on
      data:
        entity_id: switch.foscam_corridoio_motion
   **- CHECK STATE CAM 1 WITH CURL > notify.notify ( <isEnable>1</isEnable>  or <isEnable>0</isEnable>  )**
  **- CHECK STATE CAM 2 WITH CURL > notify.notify ( <isEnable>1</isEnable>  or <isEnable>0</isEnable>  )**

Thank you in dvance

More details, what i tried:
/config/shell_commands.yaml


foscam_corridoio_status: 'curl -k --silent "http://xxx.xxx.xxx.xxx:XXXXX/cgi-bin/CGIProxy.fcgi?usr=XXXXXX&pwd=XXXXXX&cmd=getMotionDetectConfig" | grep -oP "(?<=isEnable>).*?(?=</isEnable>)"'

/config/scripts.yaml


foscam_all_off:
    alias: "Disarm Home Cams"
    sequence:
    - service: switch.turn_off
      data:
        entity_id: switch.foscam_ingresso_motion
    - service: shell_command.foscam_ingresso_turn_off
    - service: switch.turn_off
      data:
        entity_id: switch.foscam_corridoio_motion
    - service: shell_command.foscam_corridoio_turn_off
    - service: shell_command.foscam_corridoio_status
      value_template: '{{ value == "1" }}' **(how i get the result and then notify it ??)**

I need help on how to use “value_template” (or “data_template”?) to get the result from “- service: shell_command.foscam_corridoio_status” and check if contains a string, based on the result notify a message with “notify.notify”.
Thanks

I solved it in a really simple way, I was complicating my life for no reason and I had not yet understood the mechanism of the “command_line” switches.
The solution:

/config/scripts.yaml

  foscam_all_off:
    alias: "Disarm Home Cams"
    sequence:
    - service: switch.turn_off
      data:
        entity_id: switch.foscam_ingresso_motion
    - service: shell_command.foscam_ingresso_turn_off
    - service: switch.turn_off
      data:
        entity_id: switch.foscam_corridoio_motion
    - service: shell_command.foscam_corridoio_turn_off
    - service: notify.notify
      data:
        message: "Stato telecamera ingresso: {{ states('switch.foscam_ingresso_motion') }}\nStato telecamera corridoio: {{ states('switch.foscam_corridoio_motion') }}"
        title: "Comando eseguito"
  foscam_all_on:
    alias: "Arm Home Cams"
    sequence:
    - service: switch.turn_off
      data:
        entity_id: switch.foscam_ingresso_motion
    - service: shell_command.foscam_ingresso_turn_on
    - service: switch.turn_on
      data:
        entity_id: switch.foscam_ingresso_motion
    - service: switch.turn_off
      data:
        entity_id: switch.foscam_corridoio_motion
    - service: shell_command.foscam_corridoio_turn_on
    - service: switch.turn_on
      data:
        entity_id: switch.foscam_corridoio_motion
    - service: notify.notify
      data:
        message: "Stato telecamera ingresso: {{ states('switch.foscam_ingresso_motion') }}\nStato telecamera corridoio: {{ states('switch.foscam_corridoio_motion') }}"
        title: "Comando eseguito"