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

Add "Filters" to Scale or Otherwise Transform Data #170

Open
kaijk opened this issue Mar 26, 2024 · 3 comments
Open

Add "Filters" to Scale or Otherwise Transform Data #170

kaijk opened this issue Mar 26, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@kaijk
Copy link

kaijk commented Mar 26, 2024

Rather than create a new template entity, please consider providing a way to transform the data. I suggest starting with multiply, but other filters could be added as well. (Filters concept lifted from ESPHome and the HA Plotly Graph Card custom integration).

entity_id: sensor.solar_watts
filters:
  - multiply: 0.001 # kW from W
  - multiply: -1 # invert negative to positive values
  - integrate: h # create kWh from kW
@MindFreeze MindFreeze added the enhancement New feature or request label Apr 25, 2024
@MindFreeze
Copy link
Owner

Integrals will not be easy because historical data is needed, so it would only work with energy_date_selection and the accuracy may not be great.
Multiplying to convert W to kW shouldn't be necessary because the card handles this already. There may be a case for kcal to Wh, mi to km, etc.
I see the value in converting negative values to positive as this is needed often.
But overall, all of this can be done easily with HA template entities so I consider it very low priority.

@slyoldfox
Copy link

slyoldfox commented Sep 26, 2024

@kaijk
Stumbled upon this issue when trying to "invert" a value (mainly to subtract energy production sensor).
I managed to do this by including the production sensor as a normal "entity" type, and in the 2nd section using a - type: remaining_parent_state where I subtract_entities the production sensors. Note that you have to specify each sensor twice, because it's already adding that sensor to the sum.

sections:
  - entities:
      - type: entity
        children:
          - sensor.total_energy
        entity_id: sensor.modbus_ac_energy_kwh
        color: var(--warning-color)
        name: Solar
      - type: entity
        children:
          - sensor.total_energy
        name: Consumption Tarif 1
        entity_id: sensor.energy_consumption_tarif_1
      - type: entity
        children:
          - sensor.total_energy
        name: Consumption Tarif 2
        entity_id: sensor.energy_consumption_tarif_2
      - type: entity
        children:
          - sensor.total_energy
        name: Production Tarif 1
        color: var(--energy-grid-return-color)
        entity_id: sensor.energy_production_tarif_1
      - type: entity
        children:
          - sensor.total_energy
        name: Production Tarif 2
        color: var(--energy-grid-return-color)
        entity_id: sensor.energy_production_tarif_2
  - entities:
      - type: remaining_parent_state
        children:
          - sensor.shellyem_123456789_channel_1_energy
          - entity_id: sensor.washer_energy
          - sensor.dishwasher_energy_consumption
          - sensor.slypro_energy
          - sensor.slymini_energy
          - entity_id: sensor.shelly_ventilatie_energy
          - sensor.total_remainder
        subtract_entities:
          - sensor.energy_production_tarif_1 
          - sensor.energy_production_tarif_1 # Subtract this again
          - sensor.energy_production_tarif_2
          - sensor.energy_production_tarif_2
        name: home
        entity_id: sensor.total_energy

image

@kzajac83
Copy link

I showing water usage and mu UoM is m3, cannot change UoM to liters. So proposition:

multiply: 1000 # liters from m3

will easier show me values like 1 l instead 0.001 m3 as now:

image

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

No branches or pull requests

4 participants