How to create Automation to check two devices are always on together

To cut a long story short, i have an irrigation controller and a pump. The irrigation controller (openspinkler) is the master and controls the pump to turn on and off. On occasions, the irrigation controller will miss the off command to pump causing it to run-dry and cause operational failures to expensive equipment.

How can i create an automation that checks when the pump is running but the irrigation controller is turned idle or even disconnected (if possible)

Trigger on your irrigation controller being idle or disconnected for a few seconds. Then check the state of the pump in a condition:

trigger:
  - platform: state # trigger when irrigation idle or disconnected
    entity_id: sensor.irrigation
    to:
      - idle
      - unknown
      - unavailable
    for: 5 # seconds
condition:
  - condition: state # is the pump still on?
    entity_id: switch.pump
    state: 'on'
action:
  - service: switch.turn_off # try to turn the pump off
    target: 
      entity_id: switch.pump
  - delay: 3
  - condition: state
    entity_id: switch.pump # is the pump still on?
    state: 'on'
  - service: notify.xxx # if on then let someone know.
    data:
      message: "The irrigation is idle but the pump is still on"

Thanks Tom

I have implemented this and ill monitor to see how it goes

I have another similar question if you wouldnt mind. The irrigation i use is fed by a submersible bore and tank water and i would like it to stop in the case of run dry. I have a tank level sensor which i know what value represents near empty, so how would i stop the irrigation controller if it was to run for too long causing pump to run dry causing damage?

The problem i see is that if i hook a trigger up to the Tank Level it will stop it if the program is running which is fine. But if a new program were to start running on the irrigation controller it wont know that the tank level is too low. Any way to accomplish this in a single automation?

Trigger: your tank level going low.

Action: stop irrigation.

And for the inverse case when starting a new irrigation run is created, would i need to have it check that tank level is above threshold otherwise kill the program?

Wasnt sure if i could incorporate them together into a single automation thats all

Yes you could use a condition for that.