Skip to content

Commit

Permalink
Fixed Time to Discharge
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanm101 authored Mar 17, 2023
1 parent 489d505 commit e94acbb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/energy_stats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@ template:
availability: >
{{ states('sensor.solaredge_b1_status_text') == 'Charging' }}
# WRONG!!!!!
- name: "Solar Battery Time to Empty"
unique_id: battery_time_to_empty
state: >
{% set ct = ((states('sensor.solaredge_b1_maximum_energy') | float * (100 - states('sensor.solaredge_b1_state_of_energy')| float) /100) / ((states('sensor.solaredge_b1_dc_power') |float *-1)/1000) * 60) | int %}
{% if ct > 60 %}{{ ct // 60 }}:{{ '{:0>2d}'.format(ct%60) }} hours{% else %}{{ct}} minutes{% endif %}
{% set batterypower = (states('sensor.solaredge_b1_dc_power') | int * -1) %}
{% set wattsToDischarge = ((states('sensor.solaredge_b1_maximum_energy') | float(0) *1000)/100)*(states('sensor.solaredge_b1_state_of_energy') | float) %}
{% set totalhrs = (wattsToDischarge | float / batterypower | float) | round(2) %}
{{ '%02d:%02d' | format((totalhrs | int),((totalhrs*60) % 60) | round(0)) }}
availability: >
{{ states('sensor.solaredge_b1_status_text') == 'Discharging' }}
Expand Down

0 comments on commit e94acbb

Please sign in to comment.