Hi HA community,
I am very new to the topic and I am struggling a bit with creating sensors via
configuration.yaml
I just tried to get information from a local device called “Neoom Beeam” wich is a local device for accessing real time data of my PV system via the REST api.
According to the API Documentation “/api/v1/site/state”
I am trying to get all the basic information from the site/state.
Therefore I tried the curl command
curl -k \
-H "Authorization: Bearer skxxxx" \
-H "Content-Type: application/json" \
http://192.168.0.x/api/v1/site/state
this is the result
{"energyFlow":{"states":[
{"dataPointId":"befa18bd-7c07-5871-90a2-29f1c51fa368","key":"SELF_SUFFICIENCY","value":100,"ts":1718621135003},
{"dataPointId":"2339a8b3-db1e-5b63-9a6f-a11787c8f905","key":"POWER_PRODUCTION","value":7206,"ts":1718633200003},
{"dataPointId":"24a8122b-d2cc-5374-b5b4-bf22f51dd511","key":"POWER_CONSUMPTION","value":null,"ts":1718621100003},
{"dataPointId":"371d81cc-a0b6-510f-b02d-819adbed7011","key":"POWER_GRID","value":-5973,"ts":1718633200003},
{"dataPointId":"6e5e9fcc-f81b-59b7-8a40-93916ed199a0","key":"POWER_STORAGE","value":37,"ts":1718633180002},
{"dataPointId":"ad7c9711-e91c-5a56-85b2-7de4c6a7ad10","key":"ENERGY_PRODUCED","value":18006700,"ts":1718633200003},
{"dataPointId":"db4e07e8-657c-51b5-9f45-ea48c5dd0a9e","key":"ENERGY_CONSUMED","value":null,"ts":1718621100003},
{"dataPointId":"3b327d89-825a-59f7-b956-4ccdd89f125a","key":"ENERGY_IMPORTED","value":4932816.486869225,"ts":1718621100003},
{"dataPointId":"bee32e2c-f01a-5cff-8252-d2f09e06c9dc","key":"ENERGY_EXPORTED","value":7452677.600188415,"ts":1718633200003},
{"dataPointId":"d46d9e71-d227-5295-8ca5-6957472fa111","key":"ENERGY_CHARGED","value":4558500,"ts":1718631955003},
{"dataPointId":"e25f2c9a-25e7-528e-bab2-9f85f51ec440","key":"ENERGY_DISCHARGED","value":3385000,"ts":1718632635004},
{"dataPointId":"6b73c34d-f868-5792-b9d5-ef92348d202f","key":"STATE_OF_CHARGE","value":100,"ts":1718632000002},
{"dataPointId":"d5461d1f-1b80-5aac-9e15-e020a26aebf3","key":"POWER_CONSUMPTION_CALC","value":1270,"ts":1718633200003},
{"dataPointId":"60341e65-6c4b-5424-b091-f4286512cb94","key":"POWER_GRID_REMAINING","value":null,"ts":1718621100003},
{"dataPointId":"2869f5fc-7737-57d3-a64e-c15c7e084c97","key":"ENERGY_CONSUMED_CALC","value":14313338.886680812,"ts":1718633200003}]}
}
Next step → just putting some code in the configuration.yaml
sensor:
- platform: rest
name: Neoom Beeam Energy State
resource: http://192.168.0.x/api/v1/site/state
method: GET
verify_ssl: false
headers:
Authorization: !secret beeam_bearer_token
Content-Type: application/json
value_template: >
{% set state = value_json.energyFlow.states[0] %}
Key: {{ state.key }}, Value: {{ state.value }}, DataPointId: {{ state.dataPointId }}, Timestamp: {{ state.ts }}
json_attributes_path: "$.energyFlow.states"
json_attributes:
- states
scan_interval: 10
template:
- sensor:
- name: "Neoom Autarkie"
unit_of_measurement: "%"
device_class: "power"
state_class: "measurement"
state: >
{% set state_data = state_attr('sensor.neoom_beeam_energy_state', 'states') %}
{% if state_data %}
{{ state_data | selectattr('key', 'eq', 'SELF_SUFFICIENCY') | map(attribute='value') | first | default('unavailable') }}
{% else %}
unavailable
{% endif %}
- name: "Neoom Strom Netz"
unit_of_measurement: "W"
device_class: "energy"
state_class: "measurement"
state: >
{% set state_data = state_attr('sensor.neoom_beeam_energy_state', 'states') %}
{% if state_data %}
{{ state_data | selectattr('key', 'eq', 'POWER_GRID') | map(attribute='value') | first | default('unavailable') }}
{% else %}
unavailable
{% endif %}
But when I look now in the entity state it shows me “unknown”.
Please can you help me.
Thank you very much