Custom sensor using data from packages

Hi,

I feel like it’s a pretty straightforward thing but still can’t get it working. Please kindly help me.

I have an ESP32S3 board that is loaded with a working firmware. It uses a Github based package:

packages:
  ecodan-heatpump: github://tobias-93/esphome-ecodan-heatpump/heatpump.yaml@main

See repository here: GitHub - tobias-93/esphome-ecodan-heatpump: ESPHome firmware for Ecodan heatpumps

Now, this package exposes a couple of sensors, defined in esphome-ecodan-heatpump/heatpump.yaml at 2fdf15ba675699c0c2ca8c1692a31505cb02cc8f · tobias-93/esphome-ecodan-heatpump · GitHub. How on earth can I reuse those sensors to create my own ones? I’m looking for simple things, like doing a division with two of these.
I tried template sensors with lambda - tells me there is no entity with ID e.g. energy_dhw_cons_yesterday.
I tried homeassistant templates, which would read the value back from HA - gives me NaN as the state

What would be the proper way of doing this kind of things?

You will need to add an id key under the name. Then use tht id with lambdas to return and/or manipuate the value of another sensor.

text_sensor:
  - platform: version
    name: ESPHome Version
  - platform: wifi_info
    ip_address:
      name: IP
      id: my_ip
    ssid:
      name: SSID
      id: my_ssd

https://esphome.io/components/sensor/#lambda-calls

Not sure what you mean by that. It indeed has a name. Example:

  - platform: template
    name: HMV COP
    id: hmv_cop
    lambda: |-
      float produced = id(energy_dhw_prod_yesterday).state;
      float consumed = id(energy_dhw_cons_yesterday).state;
      ESP_LOGD("Custom", "Produced: %f, consumed=%f", produced, consumed);
      return produced / consumed;

try

    lambda: |-
      return id(energy_dhw_prod_yesterday).state / id(energy_dhw_cons_yesterday).state;

The ‘compiler’ tells me there is no such entity. That’s my main problem :slight_smile: