*** EDIT *** Everythings working now. All code in this first post has been changed to correct some quirks. Full installation instructions can be found some posts below:
— Original post —
This is my first thread here and I’m really learning HA these days. So any help is highly appreciated. And please, english is not my native language - so please don’t laugh
With a mix of several forum entries here I got my QCell Q.Home mostly working. But there are some questions regarding the energy dashboard left:
-
On the energy dashboard certain values are negative. It seems that these values are turned upside down. If you look at my code below I create positive values as advised for these values. Where do the negative values on the energy dashboard come from?
-
The graph shows all dots traveling (and values for all directions) even if the values for some directions are ‘0’. What am I doing wrong?
Many thanks in advance.
My collected solution:
How to call the QCells Cloud (max. 5 min intervall):
https://qhome-ess-g3.q-cells.eu/proxyApp/proxy/api/getRealtimeInfo.do?tokenId=xxxxxxxx&sn=yyyyyyyy
The result of this call:
{"success":true,"exception":"Query success!","result":{"inverterSN":"zzzzzzzz","sn":"yyyyyyyy","acpower":641.0,"yieldtoday":4.7,"yieldtotal":141.9,"feedinpower":0.0,"feedinenergy":44.98,"consumeenergy":17.15,"feedinpowerM2":0.0,"soc":24.0,"peps1":0.0,"peps2":0.0,"peps3":0.0,"inverterType":"14","inverterStatus":"102","uploadTime":"2022-11-03 09:55:19","batPower":568.0,"powerdc1":639.0,"powerdc2":636.0,"powerdc3":null,"powerdc4":null,"batStatus":"0"}}
secrets.yaml:
#xxxxxxxx=Token
#yyyyyyyy=Wifi serial
qcells_cloud: https://qhome-ess-g3.q-cells.eu/proxyApp/proxy/api/getRealtimeInfo.do?tokenId=xxxxxxxx&sn=yyyyyyyy
configuration.yaml:
sensor:
- platform: rest
name: QCells Cloud
resource: !secret qcells_cloud
method: GET
scan_interval: 300
timeout: 60
value_template: 'OK'
json_attributes_path: "$.result"
json_attributes:
- sn
- acpower
- yieldtoday
- yieldtotal
- feedinpower
- feedinenergy
- consumeenergy
- feedinpowerM2
- soc
- peps1
- peps2
- peps3
- inverterType
- inverterStatus
- uploadTime
- batPower
- powerdc1
- powerdc2
- powerdc3
- powerdc4
- batStatus
- platform: template
sensors:
qcells_cloud_sn:
friendly_name: "QCells Unique identifier of communication module"
value_template: "{{ state_attr('sensor.qcells_cloud', 'sn') }}"
qcells_cloud_acpower:
friendly_name: "QCells Inverter AC power total"
value_template: "{{ state_attr('sensor.qcells_cloud', 'acpower') }}"
unit_of_measurement: "W"
device_class: power
qcells_cloud_yieldtoday:
friendly_name: "QCells Inverter AC energy out daily"
value_template: "{{ state_attr('sensor.qcells_cloud', 'yieldtoday') }}"
unit_of_measurement: "kWh"
device_class: energy
qcells_cloud_yieldtotal:
friendly_name: "QCells Inverter AC energy out total"
value_template: "{{ state_attr('sensor.qcells_cloud', 'yieldtotal') }}"
unit_of_measurement: "kWh"
device_class: energy
qcells_cloud_feedinpower:
friendly_name: "QCells Grid power total"
value_template: "{{ state_attr('sensor.qcells_cloud', 'feedinpower') }}"
unit_of_measurement: "W"
device_class: power
qcells_cloud_feedinenergy:
friendly_name: "QCells Grid energy to Grid total"
value_template: "{{ state_attr('sensor.qcells_cloud', 'feedinenergy') }}"
unit_of_measurement: "kWh"
device_class: energy
qcells_cloud_consumeenergy:
friendly_name: "QCells Grid energy from Grid total "
value_template: "{{ state_attr('sensor.qcells_cloud', 'consumeenergy') }}"
unit_of_measurement: "kWh"
device_class: energy
qcells_cloud_feedinpowerm2:
friendly_name: "QCells Inverter Meter2 AC power total"
value_template: "{{ state_attr('sensor.qcells_cloud', 'feedinpowerM2') }}"
unit_of_measurement: "W"
device_class: power
qcells_cloud_soc:
friendly_name: "QCells BMS energy SOC"
value_template: "{{ state_attr('sensor.qcells_cloud', 'soc') }}"
unit_of_measurement: "%"
qcells_cloud_peps1:
friendly_name: "QCells Inverter AC EPS power 1"
value_template: "{{ state_attr('sensor.qcells_cloud', 'peps1') }}"
unit_of_measurement: "W"
device_class: power
qcells_cloud_peps2:
friendly_name: "QCells Inverter AC EPS power 2"
value_template: "{{ state_attr('sensor.qcells_cloud', 'peps2') }}"
unit_of_measurement: "W"
device_class: power
qcells_cloud_peps3:
friendly_name: "QCells Inverter AC EPS power 3"
value_template: "{{ state_attr('sensor.qcells_cloud', 'peps3') }}"
unit_of_measurement: "W"
device_class: power
qcells_cloud_invertertype:
friendly_name: "QCells Inverter Type"
value_template: >-
{% if state_attr('sensor.qcells_cloud', 'inverterType') == "1" %}
X1-LX
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "2" %}
X-Hybrid
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "3" %}
X1-Hybiyd/Fit
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "4" %}
X1-Boost/Air/Mini
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "5" %}
X3-Hybiyd/Fit
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "6" %}
X3-20K/30K
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "7" %}
X3-MIC/PRO
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "8" %}
X1-Smart
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "9" %}
X1-AC
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "10" %}
A1-Hybrid
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "11" %}
A1-Fit
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "12" %}
A1-Grid
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "13" %}
J1-ESS
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "14" %}
X3-Hybrid-G4
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "15" %}
X1-Hybrid-G4
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "16" %}
X3-MIC/PRO-G2
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "17" %}
X1-SPT
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "18" %}
X1-Boost/Mini-G4
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "19" %}
A1-HYB-G2
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "20" %}
A1-AC-G2
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "21" %}
A1-SMT-G2
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "22" %}
X3-FTH
{% elif state_attr('sensor.qcells_cloud', 'inverterType') == "23" %}
X3-MGA-G2
{% else %}
Unknown
{% endif %}
qcells_cloud_inverterstatus:
friendly_name: "QCells Inverter status"
value_template: >-
{% if state_attr('sensor.qcells_cloud', 'inverterStatus') == "100" %}
Wait Mode
{% elif state_attr('sensor.qcells_cloud', 'inverterStatus') == "101" %}
Check Mode
{% elif state_attr('sensor.qcells_cloud', 'inverterStatus') == "102" %}
Normal Mode
{% elif state_attr('sensor.qcells_cloud', 'inverterStatus') == "103" %}
Fault Mode
{% elif state_attr('sensor.qcells_cloud', 'inverterStatus') == "104" %}
Permanent Fault Mode
{% elif state_attr('sensor.qcells_cloud', 'inverterStatus') == "105" %}
Update Mode
{% elif state_attr('sensor.qcells_cloud', 'inverterStatus') == "106" %}
EPS Check Mode
{% elif state_attr('sensor.qcells_cloud', 'inverterStatus') == "107" %}
EPS Mode
{% elif state_attr('sensor.qcells_cloud', 'inverterStatus') == "108" %}
Self-Test Mode
{% elif state_attr('sensor.qcells_cloud', 'inverterStatus') == "109" %}
Idle Mode
{% elif state_attr('sensor.qcells_cloud', 'inverterStatus') == "110" %}
Standby Mode
{% elif state_attr('sensor.qcells_cloud', 'inverterStatus') == "111" %}
Pv Wake Up Bat Mode
{% elif state_attr('sensor.qcells_cloud', 'inverterStatus') == "112" %}
Gen Check Mode
{% elif state_attr('sensor.qcells_cloud', 'inverterStatus') == "113" %}
Gen Run Mode
{% else %}
Unknown status
{% endif %}
qcells_cloud_uploadtime:
friendly_name: "QCells Update time"
value_template: "{{ as_timestamp(state_attr('sensor.qcells_cloud', 'uploadTime')) | timestamp_local }}"
device_class: timestamp
qcells_cloud_batpower:
friendly_name: "QCells Inverter DC Battery power total"
value_template: "{{ state_attr('sensor.qcells_cloud', 'batPower') }}"
unit_of_measurement: "W"
device_class: battery
qcells_cloud_powerdc1 :
friendly_name: "QCells Inverter DC PV power MPPT1"
value_template: "{{ state_attr('sensor.qcells_cloud', 'powerdc1') }}"
device_class: power
unit_of_measurement: "W"
qcells_cloud_powerdc2:
friendly_name: "QCells Inverter DC PV power MPPT2"
value_template: "{{ state_attr('sensor.qcells_cloud', 'powerdc2') }}"
unit_of_measurement: "W"
device_class: power
qcells_cloud_powerdc3:
friendly_name: "QCells Inverter DC PV power MPPT3"
value_template: "{{ state_attr('sensor.qcells_cloud', 'powerdc3') }}"
unit_of_measurement: "W"
device_class: power
qcells_cloud_powerdc4:
friendly_name: "QCells Inverter DC PV power MPPT4"
value_template: "{{ state_attr('sensor.qcells_cloud', 'powerdc4') }}"
unit_of_measurement: "W"
device_class: power
qcells_cloud_batstatus:
friendly_name: "QCells BMS Status"
value_template: >-
{% if state_attr('sensor.qcells_cloud', 'batStatus') == "0" %}
Self Use Mode
{% elif state_attr('sensor.qcells_cloud', 'batStatus') == "1" %}
Force Time Use
{% elif state_attr('sensor.qcells_cloud', 'batStatus') == "2" %}
Back Up Mode
{% elif state_attr('sensor.qcells_cloud', 'batStatus') == "3" %}
Feed-in Priority
{% else %}
Unknown status
{% endif %}
# Adding all possible solar strings to one value
qcells_cloud_powerdc_sum:
friendly_name: "QCells Inverter DC PV power sum"
value_template: "{{ states('sensor.qcells_cloud_powerdc1') | float(default=0) + states('sensor.qcells_cloud_powerdc2') | float(default=0) + states('sensor.qcells_cloud_powerdc3') | float(default=0) + states('sensor.qcells_cloud_powerdc4') | float(default=0) }}"
unit_of_measurement: "W"
device_class: power
# Calculate house load because this is not part of the Cloud result
qcells_cloud_house_load:
friendly_name: QCells Cloud House Load
value_template: "{{ states('sensor.qcells_cloud_feedinpowerm2') | float(default=0) + states('sensor.qcells_cloud_acpower') | float(default=0) - states('sensor.qcells_cloud_feedinpow
er') | float(default=0) }}"
unit_of_measurement: W
device_class: power
# Battery is being charged
qcells_cloud_battery_charge:
friendly_name: QCells Cloud Battery Charge
value_template: >
{% if states('sensor.qcells_cloud_batpower') | float(default=0) > 0 %}
{{ states('sensor.qcells_cloud_batpower') | float(default=0) }}
{% else %}
0
{% endif %}
unit_of_measurement: W
device_class: power
# Battery is being discharged
qcells_cloud_battery_discharge:
friendly_name: QCells Cloud Battery Discharge
value_template: >
{% if states('sensor.qcells_cloud_batpower') | float(default=0) < 0 %}
{{ states('sensor.qcells_cloud_batpower') | float(default=0) | abs }}
{% else %}
0
{% endif %}
unit_of_measurement: W
device_class: power
# Feed to grid
qcells_cloud_grid_feed:
friendly_name: QCells Cloud Grid Feed
value_template: >
{% if states('sensor.qcells_cloud_feedinpower') | float(default=0) > 0 %}
{{ states('sensor.qcells_cloud_feedinpower') | float(default=0) }}
{% else %}
0
{% endif %}
unit_of_measurement: W
device_class: power
# Load from grid
qcells_cloud_grid_load:
friendly_name: QCells Cloud Grid Load
value_template: >
{% if states('sensor.qcells_cloud_feedinpower') | float(default=0) < 0 %}
{{ states('sensor.qcells_cloud_feedinpower') | float(default=0) | abs }}
{% else %}
0
{% endif %}
unit_of_measurement: W
device_class: power
# Q-Save 9.1 --> 8300W usable minus 10% minimum load multiplied by soc
# E.g. 35% soc --> 2614.5 W
qcells_cloud_battery_usable:
friendly_name: QCells Cloud Battery usable
value_template: "{{ 8300 * (max(states('sensor.qcells_cloud_soc') | float(default=0) - 10, 0) / 100) }}"
unit_of_measurement: W
device_class: power
# Solar plus usable battery added
qcells_cloud_solar_plus_battery_total:
friendly_name: QCells Cloud Solar plus Battery total
value_template: "{{ states('sensor.qcells_cloud_powerdc_sum') | float + states('sensor.qcells_cloud_battery_usable') | float }}"
unit_of_measurement: W
device_class: power
The values for batPower and feedinpower return negative values from the cloud call if battery is discharging or house is loading from grid. As I learned these need to be changed to positive values. That’s what I’ve done in my code above.
After that I did add Riemann sum integral helpers (via GUI) for my own calculated values (Solar, House Load, Battery Charge/Discharge and Grid Load/Feed). I did use “left”, “(k)ilo”, “(d)ay” and “decimal=2” as settings. These integrations are added to the corresponding energy dashboard values.