How to transfer data from homeassistant to custom component

Hello everyone, I’m new here and how can I transfer data to the custom component I use in my project via homeassistant?

substitutions:
  devicename: "devkit-s"

esphome:
  name: $devicename
  friendly_name: $devicename

  includes:
    - i2c.h

  libraries:
    # - "Grove 3-Axis Digital Gyro"
    - "Wire"
    - "SPI"
    - "Adafruit BusIO"
    - "Adafruit Unified Sensor"
    - "Adafruit ADXL345"
    - "BluetoothSerial"
    - "Adafruit ADS1X15"
    - "Adafruit MAX1704X"

esp32:
  board: esp32dev
  framework:
    type: arduino

logger:
  # level: VERY_VERBOSE

api:
  reboot_timeout: 0s

ota:


wifi:
  ssid: !secret wifi_ssid2
  password: !secret wifi_password2

  ap:
    ssid: ${devicename}
    password: ${devicename}

  fast_connect: true
  # power_save_mode: none
  
captive_portal:

web_server:
  port: 80
  css_url: v3
  include_internal: True
  local: True
  version: 2


sensor:
  - platform: internal_temperature
    name: "Internal Temperature"
    update_interval: 1s


custom_component:
- lambda: |-
    auto mybluetooth = new MyBluetoothComponent();
    return {mybluetooth};

- lambda: |-
    auto myi2c = new Myi2cComponent();
    return {myi2c};


button:
  - platform: restart
    name: "Restart"


light:
  - platform: status_led
    name: "status led"
    id: status
    pin: 
      number: GPIO13
      mode:
        output: True
      inverted: False
    on_state:
      if:
        condition:
          wifi.connected:
        then:
        - light.turn_on: 
            id: led
            # effect: strobe

  - platform: binary
    name: "led"
    id: led
    output: o13
    effects:
      - strobe:
          name: strobe
          colors:
            - state: true
              brightness: 100%
              duration: 100ms
            - state: false
              duration: 50ms
            - state: true
              brightness: 100%
              duration: 100ms
            - state: false
              duration: 200ms


output:    
  - platform: gpio
    id: o13
    pin: 
      number: GPIO13
      mode:
        output: True
      inverted: False

Welcome.
What are trying to achieve, exactly?

Web esphome maybe ?

It was my fault that I did not write in detail, sorry. I’m working on custom component and I’m going to create my own custom component. I have the purpose of making an input and output function over Esphome. I have the knowledge of transferring sensor information to esphome with custom component. But I don’t know how to get the value from esphome and render it on custom component. Need help with this last part.

I need help in sending value to custom component part, how to do it.

I’m not sure what you want. You have some some board and you uploaded your yaml file to it. Now you need some sensor that will calculate some output coming from a board.
If you need sensor for calculation you probably need template sensor or history stats.

1 Like