sensor.Red_Input_1_wh
sensor.Blue_Input_3_wh
sensor.White_Input_2_wh
3phase iotawatt ct inputs above.
These are from my friends Iotawatt. I think he’s reversed them as positive numbers are grid import, negative are grid export. I tried chatgpt to code up something to invert the numbers and then split the positives and negatives (import n export to grid). The furtherest I got on chatgpt was both imp/exp sensors read the same value. Any ideas? Coding isn’t my area. Considering CT’s go negative and positive, I’m unsure why HA only reads positives. Thanks for any help.
- sensor:
# Red Import Energy (track only positive values)
name: Red Import Energy Positive
unique_id: sensor.red_import_positive
state_class: total_increasing
unit_of_measurement: "Wh"
device_class: energy
state: >
{% set value = states('sensor.Red_Input_1_wh') | float %}
{% if states('sensor.Red_Input_1_wh') not in ['unknown', 'unavailable'] %}
{% if value >= 0 %}
{{ value }} # Only positive values for import
{% else %}
0 # Ignore negative values (export)
{% endif %}
{% else %}
unavailable
{% endif %}
icon: mdi:transmission-tower
- sensor:
# Red Export Energy (track only negative values)
name: Red Export Energy Positive
unique_id: sensor.red_export_positive
state_class: total_increasing
unit_of_measurement: "Wh"
device_class: energy
state: >
{% set value = states('sensor.Red_Input_1_wh') | float %}
{% if states('sensor.Red_Input_1_wh') not in ['unknown', 'unavailable'] %}
{% if value < 0 %}
{{ value | abs }} # Convert negative to positive for export
{% else %}
0 # Ignore positive values (import)
{% endif %}
{% else %}
unavailable
{% endif %}
icon: mdi:transmission-tower
- sensor:
# Blue Import Energy (track only positive values)
name: Blue Import Energy Positive
unique_id: sensor.blue_import_positive
state_class: total_increasing
unit_of_measurement: "Wh"
device_class: energy
state: >
{% set value = states('sensor.Blue_Input_3_wh') | float %}
{% if states('sensor.Blue_Input_3_wh') not in ['unknown', 'unavailable'] %}
{% if value >= 0 %}
{{ value }} # Only positive values for import
{% else %}
0 # Ignore negative values (export)
{% endif %}
{% else %}
unavailable
{% endif %}
icon: mdi:transmission-tower
- sensor:
# Blue Export Energy (track only negative values)
name: Blue Export Energy Positive
unique_id: sensor.blue_export_positive
state_class: total_increasing
unit_of_measurement: "Wh"
device_class: energy
state: >
{% set value = states('sensor.Blue_Input_3_wh') | float %}
{% if states('sensor.Blue_Input_3_wh') not in ['unknown', 'unavailable'] %}
{% if value < 0 %}
{{ value | abs }} # Convert negative to positive for export
{% else %}
0 # Ignore positive values (import)
{% endif %}
{% else %}
unavailable
{% endif %}
icon: mdi:transmission-tower
- sensor:
# White Import Energy (track only positive values)
name: White Import Energy Positive
unique_id: sensor.white_import_positive
state_class: total_increasing
unit_of_measurement: "Wh"
device_class: energy
state: >
{% set value = states('sensor.White_Input_2_wh') | float %}
{% if states('sensor.White_Input_2_wh') not in ['unknown', 'unavailable'] %}
{% if value >= 0 %}
{{ value }} # Only positive values for import
{% else %}
0 # Ignore negative values (export)
{% endif %}
{% else %}
unavailable
{% endif %}
icon: mdi:transmission-tower
- sensor:
# White Export Energy (track only negative values)
name: White Export Energy Positive
unique_id: sensor.white_export_positive
state_class: total_increasing
unit_of_measurement: "Wh"
device_class: energy
state: >
{% set value = states('sensor.White_Input_2_wh') | float %}
{% if states('sensor.White_Input_2_wh') not in ['unknown', 'unavailable'] %}
{% if value < 0 %}
{{ value | abs }} # Convert negative to positive for export
{% else %}
0 # Ignore positive values (import)
{% endif %}
{% else %}
unavailable
{% endif %}
icon: mdi:transmission-tower