Is there a way to define an entity once, as a placeholder/perameter and then use it multiple times in a card config?

Hi folks I have this code to control cameras…

camera_view: live
type: picture-glance
hold_action:
  action: none
title: Camera 1
camera_image: camera.192_168_10_11
entities:
  - entity: camera.cam_2_mainstreamprofile
    icon: mdi:arrow-left-drop-circle-outline
    tap_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.cam_2_mainstreamprofile
        pan: LEFT
        move_mode: ContinuousMove
    double_tap_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.cam_2_mainstreamprofile
        move_mode: ContinuousMove
    hold_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.cam_2_mainstreamprofile
        pan: LEFT
        move_mode: AbsoluteMove
  - entity: camera.cam_1_mainstreamprofile
    icon: mdi:arrow-down-drop-circle-outline
    tap_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.cam_2_mainstreamprofile
        tilt: DOWN
        move_mode: ContinuousMove
    double_tap_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.cam_2_mainstreamprofile
        move_mode: ContinuousMove
    hold_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.cam_2_mainstreamprofile
        tilt: DOWN
        move_mode: AbsoluteMove
  - entity: camera.cam_2_mainstreamprofile
    icon: mdi:arrow-up-drop-circle-outline
    tap_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.cam_2_mainstreamprofile
        tilt: UP
        move_mode: ContinuousMove
    double_tap_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.cam_2_mainstreamprofile
        move_mode: ContinuousMove
    hold_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.cam_2_mainstreamprofile
        tilt: UP
        move_mode: AbsoluteMove
  - entity: camera.cam_2_mainstreamprofile
    icon: mdi:arrow-right-drop-circle-outline
    tap_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.cam_2_mainstreamprofile
        pan: RIGHT
        move_mode: ContinuousMove
    double_tap_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.cam_2_mainstreamprofile
        move_mode: ContinuousMove
    hold_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.cam_2_mainstreamprofile
        pan: RIGHT
        move_mode: AbsoluteMove
  - entity: camera.cam_2_mainstreamprofile
    icon: mdi:numeric-1-box
    tap_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.cam_2_mainstreamprofile
        preset: Preset001
        move_mode: GotoPreset
  - entity: camera.cam_1_mainstreamprofile
    icon: mdi:numeric-2-box
    tap_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.cam_2_mainstreamprofile
        preset: Preset002
        move_mode: GotoPreset
  - entity: camera.cam_2_mainstreamprofile
    icon: mdi:numeric-3-box
    tap_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.cam_2_mainstreamprofile
        preset: Preset003
        move_mode: GotoPreset
  - entity: camera.cam_2_mainstreamprofile
    icon: mdi:numeric-4-box
    tap_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.cam_2_mainstreamprofile
        preset: Preset004
        move_mode: GotoPreset
  - entity: camera.cam_2_mainstreamprofile
    icon: mdi:numeric-5-box
    tap_action:
      action: call-service
      service: onvif.ptz
      service_data:
        entity_id: camera.cam_2_mainstreamprofile
        preset: Preset005
        move_mode: GotoPreset

I will be reusing the code in several cards and I wondered if there is any way to define the two entities at the top of the file and then refrence them using a common name as required.
It would make editing so much easier.

BTW the code works OK as is, bar for the iegeek cams not responding to all ONVIF commands.
That will be another thread though.

The streame is ageneric camera enhanced with WebToRTC. Testing so just using IP’s right now.
The move controls use ONVIF, hence the two entities.

Thanks for lookig,
Al

“yaml anchors”.

Also maybe this:

And this:

1 Like

Well Anchors are cool, and simple. thanks.
I am new to yaml, and HA, and the structure, allong with its constreignts is bending my head…

Part of my problem right now is that I dont even know what I dont know or how to search for an answer.
On top of that at this stage it is hard to determine if issues are yaml based, IE my errors, or just an inapropriate approach that HA cant handle.

Obviously I am reading error messages but most of them dont make much sense yet either.
I am also finding some of the example code confusing…
The code I posted origionaly had some of the card, properties?, at the bottom of the script. On the far left so part of the card but still, hard to read when you dont know what you are looking for.
I have tried to set it out with a consistant related items in blocks but honestly I have no idea if that is a good or bad thing.

Reading the other suggestions now…
Cheers,
Al