Reuse switch / binary_sensor from packages

Hello i’m new on esphome, and trying slipt my config, got multipy shelly devices and i want create config like this

substitutions:
  system_name: xxx
  name: XXXX XXXX
  descricao: "DESCRIPTION"

packages:
  board: !include common/boards/shelly1.yaml
  device_base: !include common/.base.yaml

This works by i need reuse switch / binary_sensor

My shelly1 file is:

esphome:
  <<: !include .esphome.yaml
  platform: ESP8266
  board: esp01_1m

switch:
  - platform: gpio
    id: relay_1
    name: ${name}
    pin: GPIO4
    restore_mode: restore_default_off

binary_sensor:
  - platform: gpio
	id: ${name}_button_status
    name: ${name} Button Status
    pin: GPIO5
    filters:
      - delayed_on_off: 50ms

Now my devies as multi propoes and i need to define per device some actions. I would like to be able to do something like this in device file:

binary_sensor:
	- platform: esphome
	  related_id: xxx_button_status **<-- reuse the binary_sensor created in common/boards/shelly1.yaml**
	  on_state:
	  then:
		- switch.toggle: relay_1

Is possible reuse binary_sensor / switch? It doesn’t have to be exactly that way, just a way that gives

Thanks

Hi there. Did you find a solution to this? I had read in another post that you can include substitutions per package, but I am not sure that’s the case.

packages:
  relay_module:
    path: !include my-module.yaml
    substitutions:
      module_addr: "0x20"

I will keep looking, as it would be very useful for the various configurations I have.

I got a half solution :sweat_smile:

substitutions:
  system_name: bombaac
  name: Bomba AC
  descricao: "Bomba da maquina exterior do ar condicionado"

packages:
  board: !include common/boards/shelly1.yaml
  device_base: !include common/.base.yaml

web_server:
  port: 80

binary_sensor:
  - platform: template
    name: "${name} Deposito Cheio"
    lambda: |-
      return id(button_status).state;
    on_state:
      then:
        - lambda: |-
            if (id(button_status).state) {
              id(relay_1).turn_on();
            } else {
              id(relay_1).turn_off();
            }
    internal: false

It’s working as it should… that’s what matters :grin: