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

Unable to transform positive number to negative when group_by func is delta #860

Open
davoau opened this issue Feb 2, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@davoau
Copy link

davoau commented Feb 2, 2025

Checklist

  • [✓] I updated the card to the latest version available
  • [✓] I cleared the cache of my browser
  • [✓] I verified that I'm really running the lastest version in my browser console
  • [✓] I checked if there is another issue opened with the same problem

Desktop (please complete the following information):

  • Browser: chrome
  • Version: 132.0.6834.160 (Official Build) (64-bit)

Describe the bug
I can not change a positive number (float) to negative number using transform: -x; when group_by func: delta is used. This is for export to grid values from energy meter.

I can multiply and divide the number without issue, but can't subtract or add to it.

Version of the card
Version: 2.12

To Reproduce
This is the configuration I used:

type: custom:apexcharts-card
header:
  standard_format: false
  show: true
  show_states: true
  colorize_states: true
  title: Grid Import/Export
graph_span: 24h
show:
  last_updated: true
apex_config:
  chart:
    height: 395
    extend_to: now
  yaxis:
    show: true
    forceNiceScale: true
  stroke:
    show: true
    width: 1
  legend:
    show: true
stacked: true
series:
  - entity: sensor.energy_grid_import_hourly
    type: column
    name: Import
    float_precision: 2
    group_by:
      func: delta
      duration: 1h
  - entity: sensor.energy_grid_export_hourly
    type: column
    name: Export
    transform: return -x;
    float_precision: 2
    group_by:
      func: delta
      duration: 1h

Full code (configuration.yaml and apexchart card) can be found here:
https://community.home-assistant.io/t/apexcharts-card-a-highly-customizable-graph-card/272877/4183

This is what the resulting graph looks like with transform: return -x;, result (x * -1); produces a blank graph with LOADING displayed.

Image

All other func options seem to work ok, except for diff.

@davoau davoau added the bug Something isn't working label Feb 2, 2025
@vingerha
Copy link

vingerha commented Feb 3, 2025

The same applies for func: diff
Added to that, when using delta grouping, transform: return 1 + x; the returned figures are more than odd
@RomRider if you have ideas on a direction, I am OK to spend time on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants