Can I add several different functions to one EspHome module?

Can I add several different functions to one EspHome module? For example, ESP32 with a bluetooth proxy + some other sensors or devices. Or temperature sensors and humidity sensors to same module?

Yes you can. Go nuts

Yes, but bt proxy is pretty resource intensive, so there are some limits.

1 Like

Does it depend how many bt devices bt proxy handles or is it resource hungry by itself?

All by itself. That being said, I have quite a few setup and every one of mine is working in addition to the ESP’s primary purpose. There’s only a handful of situations where I haven’t been able to add it as part of another project.

As long as you can serially flash the device, the worst that happens is it compiles, flashes and then crashes/won’t boot up, in which case you remove it, re-compile and flash serially.

Read through the documentation. It will warn you of memory hungry components.

Reason I actually asked this question is that I have device and BT proxy in different esp chips and they work happily as they are. When I try to put them together bcs it seems pointless to me run BT proxy as standalone, I start getting errors by compiling like src/esphome/components/fourheat/common.h:8:37: note: 'std::optional' is only available from C++17 onwards src/esphome/components/fourheat/common.h:8:37: error: 'optional' is not a member of 'std'
there seems to be problem that cant be solved.

Posting your full YAML would be a first step. Also, have you done ‘clean build files’? That fixes a lot of random errors when compiling.

I think the problem is that I tried to merry BT proxy with external component. As I understand from error there is some unresolvable conflict btw C++ versions.

sigh

Listen to @brooksben11

1 Like
substitutions:
  name: bt-proxy-moretti
  friendly_name: Moretti
  tx_pin: GPIO01
  rx_pin: GPIO03

esphome:
  name: ${name}
  friendly_name: ${friendly_name}
  name_add_mac_suffix: false
  project:
    name: esphome.web
    version: '1.0'

esp32:
  board: esp32dev

api:
  encryption:
    key: 
  
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

ota:
  - platform: esphome
    id: ota_esphome

esp32_ble_tracker:
  scan_parameters:
    active: true

bluetooth_proxy:
  active: true

external_components:
  source: github://leoshusar/4heat-esphome

uart:
  tx_pin: ${tx_pin}
  rx_pin: ${rx_pin}
  baud_rate: 9600

fourheat:

switch:
  - id: state_switch
    name: State
    platform: fourheat
    restore_mode: DISABLED
    datapoint: J30001
    on_datapoint: J30253
    off_datapoint: J30254
    on_data: '1'
    off_data: '1'
    parser: |-
      auto size = data.size();
      return
        data[size - 1] != '0' ||
        data[size - 2] != '0';

  - platform: fourheat
    id: charging_motor_off
    datapoint: B20698
    on_data: '1'
    off_data: '0'
    parser: return data[data.size() - 1] != '0';

  - platform: fourheat
    id: Cleaning_Motor_Off
    datapoint: B20701
    on_data: '1'
    off_data: '0'
    parser: return data[data.size() - 1] != '0';

  - platform: fourheat
    id: Cleaning_Motor_2_Off
    datapoint: B20700
    on_data: '1'
    off_data: '0'
    parser: return data[data.size() - 1] != '0';


  - platform: template
    name: Enable night mode menu
    lambda: |-
      if (id(charging_motor_off).state) {
        return true; // if night mode enabled, switch indicates ON
      } else {
        return false; // else OFF
      }
    turn_on_action:
      - switch.turn_on: charging_motor_off
      - switch.turn_on: Cleaning_Motor_Off
      - switch.turn_on: Cleaning_Motor_2_Off
      - select.set:
          id: power
          option: "P3"
    turn_off_action:
      - switch.turn_off: charging_motor_off
      - switch.turn_off: Cleaning_Motor_Off
      - switch.turn_off: Cleaning_Motor_2_Off
      - select.set:
          id: power
          option: "Auto"

text_sensor:
  - id: state
    name: State
    platform: fourheat
    datapoint: J30001
    options:
      0: "OFF"
      1: "Check Up"
      2: "Ignition"
      3: "Stabilization"
      4: "Ignition"
      5: "Run"
      6: "Modulation"
      7: "Extinguishing"
      8: "Safety"
      9: "Block"
      10: "Recover Ignition"
      11: "Standby"
      30: "Ignition"
      31: "Ignition"
      32: "Ignition"
      33: "Ignition"
      34: "Ignition"

  - id: error
    name: Error
    platform: fourheat
    datapoint: J30002
    options:
      0: "No"
      1: "Safety Thermostat HV1: signalled also in case of Stove OFF"
      2: "Safety PressureSwitch HV2: signalled with Combustion Fan ON"
      3: "Extinguishing for Exhausting Temperature lowering"
      4: "Extinguishing for water over Temperature"
      5: "Extinguishing for Exhausting over Temperature"
      6: "unknown"
      7: "Encoder Error: No Encoder Signal (in case of P25=1 or 2)"
      8: "Encoder Error: Combustion Fan regulation failed (in case of P25=1 or 2)"
      9: "Low pressure in to the Boiler"
      10: "High pressure in to the Boiler Error"
      11: "DAY and TIME not correct due to prolonged absence of Power Supply"
      12: "Failed Ignition"
      13: "Ignition"
      14: "Ignition"
      15: "Lack of Voltage Supply"
      16: "Ignition"
      17: "Ignition"
      18: "Lack of Voltage Supply"

  - id: combustion_power
    name: Combustion power
    platform: fourheat
    datapoint: J30011
    icon: "mdi:heating-coil"
    options:
      1: "P1"
      2: "P2"
      3: "P3"
      4: "P4"
      5: "P5"
      6: "Cleaning"
      7: "Standby"
      8: "Ignition 2"
      9: "Modulation"
      10: "Ignition P0"
      11: "MAX P"
      12: "Extinguish"
      100: "Off"
      110: "Off"
      120: "Pmax Test"
      255: "Ignition"
      0: "Stabilizing"

button:
  - id: clear_error
    name: Clear error
    platform: fourheat
    datapoint: J30255


select:
  - id: power
    name: Power
    platform: fourheat
    datapoint: B20364
    options:
      1: "P1"
      2: "P2"
      3: "P3"
      4: "P4"
      5: "P5"
      6: "Auto"
    

binary_sensor:
  - id: stove_offline
    name: Stove offline
    platform: fourheat
    type: module_offline

  - id: room_thermostat_state
    name: Room thermostat state
    platform: fourheat
    datapoint: J40007
    parser: return data[data.size() - 3] == '0';


sensor:
  - id: exhaust_temperature
    name: Exhaust temperature
    platform: fourheat
    datapoint: J30005
    device_class: temperature
    unit_of_measurement: °C

  - id: buffer_temperature
    name: Buffer temperature
    platform: fourheat
    datapoint: J30012
    device_class: temperature
    unit_of_measurement: °C

  - id: boiler_temperature
    name: Boiler temperature
    platform: fourheat
    datapoint: J30017
    device_class: temperature
    unit_of_measurement: °C

  - id: water_pressure
    name: Water pressure
    platform: fourheat
    datapoint: J30020
    device_class: pressure
    unit_of_measurement: mbar

  - id: airflow
    name: Airflow
    icon: "mdi:air-filter"
    platform: fourheat
    datapoint: J30026
    unit_of_measurement: Nr

  - id: comb_fan_speed
    name: Combustion Fan Speed
    icon: "mdi:fan"
    platform: fourheat
    datapoint: J30025
    unit_of_measurement: rpm

  - id: room_temperature
    name: Room temperature
    platform: fourheat
    datapoint: J30006
    device_class: temperature
    unit_of_measurement: °C


number:
  - id: boiler_target_temperature
    name: Boiler target temperature
    platform: fourheat
    datapoint: B20199
    device_class: temperature
    unit_of_measurement: °C
    min_value: 5
    max_value: 110

  - id: buffer_thermostat_threshold
    name: Buffer thermostat threshold
    platform: fourheat
    datapoint: B20241
    device_class: temperature
    unit_of_measurement: °C
    min_value: 1
    max_value: 20

  - id: buffer_target_temperature
    name: Buffer target temperature
    platform: fourheat
    datapoint: B20225
    device_class: temperature
    unit_of_measurement: °C
    min_value: 20
    max_value: 110
      

I think using the word several was misleading. That’s more than 20 functions. :thinking:

1 Like

Have you asked a question on leohusar’s GitHub?

how many nuts make a pile :thinking: :thinking:

1 Like

I have one BT proxy with 7 other functions and it just about manages. It will depend on how much memory is used. Remember you will also be sharing the wifi and Bluetooth on the esp so both will not be running together.
If asked by my wife how many beers I had and I replied several and it was 20 then misleading would not be the word used. :beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers: :beers: Cheers

1 Like

Yeah when I said go nuts… I mean a couple a few, several… Definitely nothing in double digits.

Spouse: Honey there’s a crate from Amazon on the front porch?

Me: I bought several switches…

1 Like

I did. I give here his answer:

"I’m not using any specific C++ version, everything just works for me. But I’m using ESP-IDF framework, so my idea is, maybe it uses C++17?

You can enable C++17 using build flags and it should work, something like this:

esphome:
  platformio_options:
    build_flags: "-std=gnu++17"
    build_unflags: "-std=gnu++11"

I found ESPHome has some custom std::optional reimplementation, but I don’t know if it can do everything I need. When I have some time I might look into it."