Toggle gpio output at boot

I am new to esphome and home assistant world. I have a nodemcu connected to 8 channel relay module through SN74HC595 (shift register) as I/O expander. When nodemcu boots it turns off all relays with a chatter as I want to operate my relays in normally off position. Please help me how to remove this chattering of relays at boot. One of the experts on esphome facebook channel suggested to turn off Vcc of relay module programmatically at boot. Can anyone guide how can I turn an gpio output off at boot and turn it on afterwards. I don’t want to access this output from home assistant.

sensor:
  - platform: dht
    pin: D1
    temperature:
      name: "Temperature"
    humidity:
      name: "Humidity"
    update_interval: 5s
    model: DHT11
    
# Example configuration entry
sn74hc595:
  - id: 'sn74hc595_hub'
    data_pin: D5
    clock_pin: D8
    latch_pin: D7

# Individual outputs
switch:
  - platform: gpio
    name: "Relay 1"
    pin:
      sn74hc595: sn74hc595_hub
      # Use pin number 0
      number: 0
      inverted: True

  - platform: gpio
    name: "Relay 2"
    pin:
      sn74hc595: sn74hc595_hub
      # Use pin number 1
      number: 1
      inverted: True

  - platform: gpio
    name: "Relay 3"
    pin:
      sn74hc595: sn74hc595_hub
      # Use pin number 2
      number: 2
      inverted: True
      
  - platform: gpio
    name: "Relay 4"
    pin:
      sn74hc595: sn74hc595_hub
      # Use pin number 3
      number: 3
      inverted: True
      
  - platform: gpio
    name: "Relay 5"
    pin:
      sn74hc595: sn74hc595_hub
      # Use pin number 4
      number: 4
      inverted: True
      
  - platform: gpio
    name: "Relay 6"
    pin:
      sn74hc595: sn74hc595_hub
      # Use pin number 5
      number: 5
      inverted: True
      
  - platform: gpio
    name: "Relay 7"
    pin:
      sn74hc595: sn74hc595_hub
      # Use pin number 6
      number: 6
      inverted: True
      
  - platform: gpio
    name: "Relay 8"
    pin:
      sn74hc595: sn74hc595_hub
      # Use pin number 7
      number: 7
      inverted: True


Taking a picture of your screen is not helpful towards us that should help you.
It’s hard to read and we can’t copy paste (which you should have done) and correct what is needed, instead we need to retype it from an image.

Sorry it took me a while to paste the code correctly.

Looking for some support from experts

- platform: gpio
    name: "Relay 1"
    pin:
      sn74hc595: sn74hc595_hub
      # Use pin number 0
      number: 0
      inverted: True
    restore_mode: ALWAYS_OFF # what you need

Thanks @lordzid

I think that restore_mode only works with physical pins and it doesn’t work with ESP8266 (nodemcu)

(ESPHome Core Configuration — ESPHome)

Hey There,
That is true, restore mode wont work behind 74c595,
Most of my relays are connected to 220v to
I had the same problem, and most of my relays are connected to 220v and sometimes it make damage with that short chatter,
So i decided to separate “relay bobbin vcc” and “board vcc”. and finally a delay circuit behind bobins vcc, so everything boot and comes up successfully while bobbins has no power to chatter and after a bit, its work.
Search for Simple Delay Timer Circuits