Here is my updated code
rest:
- resource: http://IP-Adress/api/v1/site/state # BEAAM API URL
headers:
Authorization: "Bearer sk_beaam_xxxxx" #Put your bearer token here, but do not delete Bearer at the beginning
Content-Type: "application/json"
method: GET
scan_interval: 10 # Intervall für API-Aufrufe in Sekunden
sensor:
# Stromverbrauch (aktuelle Leistung in Watt)
- name: "neoom_power_consumption"
unique_id: "power_consumption"
#value_template: "{{ value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_CONSUMPTION') | map(attribute='value') | first }}"
value_template: "{{ (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_PRODUCTION') | map(attribute='value') | first * -1) if (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_PRODUCTION') | map(attribute='value') | first) < 0 else (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_PRODUCTION') | map(attribute='value') | first) }}"
unit_of_measurement: "W"
device_class: power
state_class: measurement
icon: "mdi:LightningBoltOutline"
# Stromnetz (aktueller Netzbezug)
- name: "neoom_power_grid_input"
unique_id: "power_grid_input"
#value_template: "{{ value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_GRID') | map(attribute='value') | first }}"
value_template: "{{ (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_GRID') | map(attribute='value') | first) * -1 if (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_GRID') | map(attribute='value') | first) < 0 else (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_GRID') | map(attribute='value') | first) }}"
unit_of_measurement: "Wh"
device_class: energy
state_class: total
icon: "mdi:TransmissionTower"
# Stromnetz (aktuelle Einspeisung)
- name: "neoom_power_grid_output"
unique_id: "power_grid_output"
#value_template: "{{ value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_GRID') | map(attribute='value') | first }}"
#value_template: "{{ (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_GRID') | map(attribute='value') | first) * -1 if (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_GRID') | map(attribute='value') | first) < 0 else (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_GRID') | map(attribute='value') | first) }}"
value_template: "{{ (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_GRID') | map(attribute='value') | first * -1) if (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_GRID') | map(attribute='value') | first) < 0 else 0 }}"
unit_of_measurement: "Wh"
device_class: energy
state_class: total
icon: "mdi:TransmissionTower"
# Batteriespeicher Output (aktuelle Leistung in Watt)
- name: "neoom_storage_output"
unique_id: "storage_output"
#value_template: "{{ value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_STORAGE') | map(attribute='value') | first }}"
value_template: "{{ 0 if (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_STORAGE') | map(attribute='value') | first) < 0 else (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_STORAGE') | map(attribute='value') | first) }}"
unit_of_measurement: "Wh"
device_class: energy
state_class: total
icon: "mdi:BatteryArrowDownOutline"
# Energie entladen (Entnahme aus dem Speicher in Wh)
- name: "neoom_energy_discharged"
unique_id: "energy_discharged"
value_template: "{{ value_json['energyFlow']['states'] | selectattr('key', 'eq', 'ENERGY_DISCHARGED') | map(attribute='value') | first }}"
unit_of_measurement: "Wh"
device_class: energy
state_class: total_increasing
icon: "mdi:BatteryArrowDownOutline"
# Batteriespeicher Input (aktuelle Leistung in Watt)
- name: "neoom_storage_input"
unique_id: "storage_input"
#value_template: "{{ value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_STORAGE') | map(attribute='value') | first }}"
#value_template: "{{ (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_STORAGE') | map(attribute='value') | first * -1) if (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_STORAGE') | map(attribute='value') | first) < 0 else (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_STORAGE') | map(attribute='value') | first) }}"
value_template: "{{ (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_STORAGE') | map(attribute='value') | first * -1) if (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_STORAGE') | map(attribute='value') | first) < 0 else 0 }}"
unit_of_measurement: "Wh"
device_class: energy
state_class: total
icon: "mdi:BatteryArrowUpOutline"
# Energie geladen (gespeicherte Energie in Wh)
- name: "neoom_energy_charged"
unique_id: "energy_charged"
value_template: "{{ value_json['energyFlow']['states'] | selectattr('key', 'eq', 'ENERGY_CHARGED') | map(attribute='value') | first }}"
unit_of_measurement: "Wh"
device_class: energy
state_class: total_increasing
icon: "mdi:BatteryArrowUpOutline"
# Energie produziert (gesamte erzeugte Energie in Wh)
- name: "neoom_energy_produced"
unique_id: "energy_produced"
value_template: "{{ value_json['energyFlow']['states'] | selectattr('key', 'eq', 'ENERGY_PRODUCED') | map(attribute='value') | first }}"
unit_of_measurement: "Wh"
device_class: energy
state_class: total_increasing
icon: "mdi:SolarPowerVariant"
# Energie verbraucht (gesamter Verbrauch in Wh)
- name: "neoom_energy_consumed"
unique_id: "energy_consumed"
value_template: "{{ (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'ENERGY_CONSUMED') | map(attribute='value') | first * -1) if (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'ENERGY_CONSUMED') | map(attribute='value') | first) < 0 else (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'ENERGY_CONSUMED') | map(attribute='value') | first) }}"
unit_of_measurement: "Wh"
device_class: energy
state_class: total_increasing
icon: "mdi:HomeLightningBoltOutline"
# Energie importiert (gesamter Import aus dem Netz in Wh)
- name: "neoom_energy_imported"
unique_id: "energy_imported"
#value_template: "{{ value_json['energyFlow']['states'] | selectattr('key', 'eq', 'ENERGY_IMPORTED') | map(attribute='value') | first | round(2) }}"
value_template: "{{ (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'ENERGY_IMPORTED') | map(attribute='value') | first * -1) if (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'ENERGY_IMPORTED') | map(attribute='value') | first) < 0 else (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'ENERGY_IMPORTED') | map(attribute='value') | first) | round(2) }}"
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
icon: "mdi:TransmissionTowerImport"
# Energie exportiert (gesamte Einspeisung ins Netz in Wh)
- name: "neoom_energy_exported"
unique_id: "energy_exported"
#value_template: "{{ value_json['energyFlow']['states'] | selectattr('key', 'eq', 'ENERGY_EXPORTED') | map(attribute='value') | first * -1 }}"
value_template: "{{ (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'ENERGY_EXPORTED') | map(attribute='value') | first * -1) if (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'ENERGY_EXPORTED') | map(attribute='value') | first) < 0 else (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'ENERGY_EXPORTED') | map(attribute='value') | first) }}"
unit_of_measurement: "Wh"
device_class: energy
state_class: total_increasing
icon: "mdi:TransmissionTowerExport"
# Ladezustand des Speichers in %
- name: "neoom_state_of_charge"
unique_id: "state_of_charge"
value_template: "{{ value_json['energyFlow']['states'] | selectattr('key', 'eq', 'STATE_OF_CHARGE') | map(attribute='value') | first }}"
unit_of_measurement: "%"
device_class: battery
state_class: measurement
icon: "mdi:BatteryHeartVariant"
# Selbstversorgung (Selbstversorgungsrate in %)
- name: "neoom_self_sufficiency"
unique_id: "self_sufficiency"
value_template: "{{ value_json['energyFlow']['states'] | selectattr('key', 'eq', 'SELF_SUFFICIENCY') | map(attribute='value') | first }}"
unit_of_measurement: "%"
device_class: power
state_class: measurement
icon: "mdi:LightningBoltCircle"
# PV Leistung aktuell (Leistung in kWh)
- name: "neoom_power_production"
unique_id: "power_production"
#value_template: "{{ value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_PRODUCTION') | map(attribute='value') | first }}"
value_template: "{{ (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_PRODUCTION') | map(attribute='value') | first) if (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_PRODUCTION') | map(attribute='value') | first) > 0 else 0 }}"
unit_of_measurement: "kWh"
device_class: energy
state_class: total
icon: "mdi:SolarPanel"
# Errechneter Stromverbrauch (Leistung in kWh)
- name: "neoom_power_consumption_calc"
unique_id: "power_consumption_calc"
value_template: "{{ (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_CONSUMPTION_CALC') | map(attribute='value') | first * -1) if (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_CONSUMPTION_CALC') | map(attribute='value') | first) < 0 else (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'POWER_CONSUMPTION_CALC') | map(attribute='value') | first) }}"
unit_of_measurement: "kWh"
device_class: energy
state_class: measurement
icon: "mdi:SolarPanel"
# Errechneter Energieverbrauch (gesamter Verbrauch in Wh)
- name: "neoom_energy_consumed_cal"
unique_id: "energy_consumed_calc"
#value_template: "{{ value_json['energyFlow']['states'] | selectattr('key', 'eq', 'ENERGY_CONSUMED') | map(attribute='value') | first }}"
value_template: "{{ (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'ENERGY_CONSUMED_CALC') | map(attribute='value') | first * -1) if (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'ENERGY_CONSUMED_CALC') | map(attribute='value') | first) < 0 else (value_json['energyFlow']['states'] | selectattr('key', 'eq', 'ENERGY_CONSUMED_CALC') | map(attribute='value') | first) }}"
unit_of_measurement: "Wh"
device_class: energy
state_class: measurement
icon: "mdi:HomeLightningBoltOutline"