Automations based on time difference

Another time based question
One of the entity attributes (through mqtt) is endTime (timestamp) one.
Is it possible to reference it in the automation, so that if endTime is less than like 6 hours from now, don’t execute the automation?
Would I need to create like a sensor for that value, so that it can be referenced?
Or if its possible to get it from the existing entity attribute direct via script during action and make it a condition inside the script? Problem is that to change the time difference I would have to modify the script.

Having a hard time to grasp how use entity state/attribute information in various areas. Is there like a global variable section so that I don’t overcrowd the entity section with all variables entities that are just like 1 attribute of a multi attribute mqtt topic

yes.

condition:
  - condition: template
    value_template: "{{ state_attr('sensor.your_mqtt_sensor', 'endTime') < (as_timestamp(now()) + 21600) }}"

Not if you use an input_number.

create an input_number to hold the seconds first (or the hours and then do the math conversion to seconds in the following template) then you can use the following:

condition:
  - condition: template
    value_template: "{{ state_attr('sensor.your_mqtt_sensor', 'endTime') < (as_timestamp(now()) + states('input_number.your_input_number') | int ) }}"

tyhen you can just change the value of the imput number

Thank you!