Switches, Global Variables and Substitution

Hi,

how can I define a variable / substitution for configure a switch (PCF)?

  - platform: gpio
    name: "ch00"
    pin:
      pcf8574: pcf8574_hub
      number: 0
      mode: ${pcf8575_bank_2_mode}
      inverted: id(pcf_bank_1_invert)

This ${pcf8575_bank_2_mode} seemed to work, defined as substitution:
pcf8575_bank_1_mode: "OUTPUT"

This do not work I got “Boolean expected”, defined as global var, as substitution boolean doesn’t work either:

  - id: pcf_bank_2_invert
    type: boolean
    restore_value: no
    initial_value: 'true'

i tried the last one with all lambda syntaxes I know - without success.

How can i achieve this and as second, nice to have, can I do this from HA by toggling a switch - change from OUTPUT to INPUT and from invert: true to invert:false.

Thanks

I have a similar toggle to make things “internal” and so I think the below will work.

substitutions:
  invert_pins: "true"

#....later on under pin:

  inverted: ${invert_pins}