Hi,
I’m new to HA, but I want to create an integration for my solar inverter that exposes some raw data.
With the following configuration I can read the voltage, but I have problems with the “PowerGrid” value because it is returned as unknown.
If its value is greater than zero, it means that the energy is consumed, while if it is less than zero, the energy is sold.
rest:
- resource: "http://192.168.x.y/raw_data"
verify_ssl: false
method: GET
scan_interval: 5
sensor:
- name: "Voltage"
unique_id: "voltage"
device_class: voltage
state_class: measurement
value_template: "{{ value | regex_findall_index('VL1=(\\d+.\\d+)') | float }}"
unit_of_measurement: V
- name: "Grid power"
unique_id: "grid_power"
device_class: energy
state_class: total
value_template: >-
{% set grid_power = regex_findall_index('PowerGrid=(\\d+.\\d+)') | float(0) %}
{% if grid_power > 0 %}
"{{ value | grid_power | float(0) }}"
{% else %}
0
{% endif %}
unit_of_measurement: kWh
- name: "Grid power sold"
unique_id: "grid_power_sold"
device_class: energy
state_class: total
value_template: >-
{% set grid_power_sold = regex_findall_index('PowerGrid=(\\d+.\\d+)') | float(0) %}
{% if grid_power_sold < 0 %}
"{{ value | grid_power_sold | float(0) }}"
{% else %}
0
{% endif %}
unit_of_measurement: kWh
Can anyone tell me what I’m doing wrong or where to find documentation to solve this case?
thanks