I created template sensors to have individual sensors for grid import/export current and wattage as I wanted to have an entity showing the current "overproduction" (which will never go below zero) only.
I wanted to share this here. No rocket science but maybe someone else needs it. I fiddled around an hour to get this because I am still quite unfamiliar with templating and HAs yaml config.
Please note, I renamed the unique ids from ampere_ to ampereiq to have a cleaner naming scheme.
These are power (wattage):
# Power Import/ Export calculated sensors
template:
- trigger:
- platform: state
entity_id:
- sensor.ampere_iq_powermeter_realpower
sensor:
- name: Ampere iQ Grid Import Power
unique_id: ampere_iq_grid_import_power
device_class: energy
state_class: measurement
unit_of_measurement: "W"
state: >-
{% if float(states( 'sensor.ampere_iq_powermeter_realpower' )) < 0 %}
{{ float(states( 'sensor.ampere_iq_powermeter_realpower' )) * -1 }}
{% else %}
0
{% endif %}
- trigger:
- platform: state
entity_id:
- sensor.ampere_iq_powermeter_realpower
sensor:
- name: Ampere iQ Grid Export Power
unique_id: ampere_iq_grid_export_power
device_class: energy
state_class: measurement
unit_of_measurement: "W"
state: >
{% if float(states( 'sensor.ampere_iq_powermeter_realpower' )) > 0 %}
{{ float(states( 'sensor.ampere_iq_powermeter_realpower' )) }}
{% else %}
0
{% endif %}
And these are Current (Amperes) - But this requires the actual grid voltage, which I did not find in Ampere iQ Data. Maybe it is available on modbus... In these tempaltes I am taking another sensor for this value which I have in my setup already.
- trigger:
- platform: state
entity_id:
- sensor.ampere_iq_powermeter_realpower
sensor:
- name: Ampere iQ Grid Import Current
unique_id: ampere_iq_grid_import_current
device_class: energy
state_class: measurement
unit_of_measurement: "A"
state: >-
{% if float(states( 'sensor.ampere_iq_powermeter_realpower' )) < 0 %}
{{ (float(states( 'sensor.ampere_iq_powermeter_realpower' )) * -1) / float(states( 'sensor.rackusv_eingangsspannung' )) }}
{% else %}
0
{% endif %}
- trigger:
- platform: state
entity_id:
- sensor.ampere_iq_powermeter_realpower
sensor:
- name: Ampere iQ Grid Export Current
unique_id: ampere_iq_grid_export_current
device_class: energy
state_class: measurement
unit_of_measurement: "A"
state: >
{% if float(states( 'sensor.ampere_iq_powermeter_realpower' )) > 0 %}
{{ float(states( 'sensor.ampere_iq_powermeter_realpower' )) / float(states( 'sensor.rackusv_eingangsspannung' )) }}
{% else %}
0
{% endif %}
Maybe @dboeni wants to integrate these sensors into his HA AddOn also (which I am using for the modbus part - works great so far!)
I created template sensors to have individual sensors for grid import/export current and wattage as I wanted to have an entity showing the current "overproduction" (which will never go below zero) only.
I wanted to share this here. No rocket science but maybe someone else needs it. I fiddled around an hour to get this because I am still quite unfamiliar with templating and HAs yaml config. Please note, I renamed the unique ids from ampere_ to ampereiq to have a cleaner naming scheme.
These are power (wattage):
And these are Current (Amperes) - But this requires the actual grid voltage, which I did not find in Ampere iQ Data. Maybe it is available on modbus... In these tempaltes I am taking another sensor for this value which I have in my setup already.
Maybe @dboeni wants to integrate these sensors into his HA AddOn also (which I am using for the modbus part - works great so far!)