How to write an automation with multiple if statements?

So the first condition should be (something like):

condition: template 
value_template: >
  {% if is_state('device_tracker.bill', 'home') and ('input_select.master_bedroom_override', 'Sleep') %}true
  {% elif is_state('device_tracker.bill', 'not_home') and ('input_select.master_bedroom_override', 'Automatic') %}true
  {% else %} false {% endif %}