Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How change UoM, create calac field and display date? #163

Open
kzajac83 opened this issue Jan 3, 2025 · 0 comments
Open

How change UoM, create calac field and display date? #163

kzajac83 opened this issue Jan 3, 2025 · 0 comments

Comments

@kzajac83
Copy link

kzajac83 commented Jan 3, 2025

Hello.

Try change UoM from kWh -> GJ but code fail, in loga I have:

[23:46:04][W][wmbus:154]: Can't get requested field 'target_energy_consumption' with unit 'GJ'

In fact this is true because my UoM is kWh not GJ but please look at my code, contain two entities:

  1. Historical value, correctly dispaly in HA and process in ESPHome
  2. The same, bu try convert value and UoM kWh -> GJ, finally fail in ESPHome, no data in HA

I work based on this doc https://esphome.io/components/sensor/#sensor-filters however not only I'd like convert value but also change UoM kWh-> GJ to display correct in HA. How to achieve?

      - name: "PEC total target energy BR"
        field: "target_energy_consumption"
        accuracy_decimals: 3
        unit_of_measurement: "kWh"
        device_class: "energy"
        state_class: "total_increasing"
        icon: "mdi:energy"
        filters:
          - offset: 0.0
      - name: "PEC total target GJ energy BR"
        field: "target_energy_consumption"
        accuracy_decimals: 3
        filters:
          - lambda: return x / 277.778;
          - offset: 0.0
        unit_of_measurement: "GJ"
        device_class: "energy"
        state_class: "total_increasing"
        icon: "mdi:energy"

Additional have two temperature, input and output from heat meter:

[23:46:04][V][sensor:043]: 'PEC t1 BR': Received new state 83.300003
[23:46:04][D][sensor:094]: 'PEC t1 BR': Sending state 83.30000 °C with 1 decimals of accuracy

[23:46:04][V][sensor:043]: 'PEC t2 BR': Received new state 58.700001
[23:46:04][D][sensor:094]: 'PEC t2 BR': Sending state 58.70000 °C with 1 decimals of accuracy

How to create 3rd calculated new entity in ESPHome as difference diff=t2-t1 with UoM = "K" or "degC"?

On the end how correctly display date? I getting this info in ESPHome:

[00:10:48][V][sensor:043]: 'PEC target date BR': Received new state 1735599616.000000
[00:10:48][D][sensor:094]: 'PEC target date BR': Sending state 1735599616.00000 date with 0 decimals of accuracy

The code is:

     - name: "PEC target date BR"
        field: "target"
        unit_of_measurement: "date"
        device_class: "date"

but nothing in HA

image

BR, Krzysiek

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant