Hey, first of all in order to make sure you dont have to blackout the key evertime you can use and
headers:
Content-Type: application/json
User-Agent: SunLit/1.5.3 (iOS)
Authorization: !secret sunlit_token
and in the secrets.yaml file you need to add:
sunlit_token: "Bearer ey...DA"
Furthermore, I have integrated the MPPTs myself and noticed that the payload needs to include the following:
payload: '{"spaceId": 99999, "deviceId": 99999}'
so my new sensors.yaml looks like this:
- platform: rest
name: "SunLit SoC"
resource: "https://api.sunlitsolar.de/rest/v1.5/space/index"
method: POST
headers:
Content-Type: application/json
User-Agent: SunLit/1.5.3 (iOS)
Authorization: !secret sunlit_token
payload: '{"spaceId": 99999}'
value_template: "{{ value_json.content.battery.batteryLevel }}"
json_attributes:
- content
unit_of_measurement: "%"
scan_interval: 180
- platform: rest
name: "SunLit MPPT"
resource: "https://api.sunlitsolar.de/rest/v1.1/statistics/static/device"
method: POST
headers:
Content-Type: application/json
User-Agent: SunLit/1.5.3 (iOS)
Authorization: !secret sunlit_mppt_token
payload: '{"spaceId": 99999, "deviceId": 99999}'
value_template: "{{ value_json.content.batteryMppt1Data.batteryMpptInPower }}"
json_attributes:
- content
unit_of_measurement: "W"
device_class: "power"
scan_interval: 180
and my templates.yaml looks like this:
- sensor:
- name: "MPPT 1 Spannung"
unique_id: mppt1_voltage
unit_of_measurement: "V"
icon: mdi:flash
state: >
{% set attr = state_attr('sensor.sunlit_mppt', 'content') %}
{% if attr and 'batteryMppt1Data' in attr %}
{{ attr['batteryMppt1Data']['batteryMpptInVol'] }}
{% else %}
0
{% endif %}
- name: "MPPT 1 Strom"
unique_id: mppt1_current
unit_of_measurement: "A"
icon: mdi:current-dc
state: >
{% set attr = state_attr('sensor.sunlit_mppt', 'content') %}
{% if attr and 'batteryMppt1Data' in attr %}
{{ attr['batteryMppt1Data']['batteryMpptInCur'] }}
{% else %}
0
{% endif %}
- name: "MPPT 1 Leistung"
unique_id: mppt1_power
unit_of_measurement: "W"
device_class: power
icon: mdi:power
state: >
{% set attr = state_attr('sensor.sunlit_mppt', 'content') %}
{% if attr and 'batteryMppt1Data' in attr %}
{{ attr['batteryMppt1Data']['batteryMpptInPower'] }}
{% else %}
0
{% endif %}
- name: "MPPT 2 Spannung"
unique_id: mppt2_voltage
unit_of_measurement: "V"
icon: mdi:flash
state: >
{% set attr = state_attr('sensor.sunlit_mppt', 'content') %}
{% if attr and 'batteryMppt2Data' in attr %}
{{ attr['batteryMppt2Data']['batteryMpptInVol'] }}
{% else %}
0
{% endif %}
- name: "MPPT 2 Strom"
unique_id: mppt2_current
unit_of_measurement: "A"
icon: mdi:current-dc
state: >
{% set attr = state_attr('sensor.sunlit_mppt', 'content') %}
{% if attr and 'batteryMppt2Data' in attr %}
{{ attr['batteryMppt2Data']['batteryMpptInCur'] }}
{% else %}
0
{% endif %}
- name: "MPPT 2 Leistung"
unique_id: mppt2_power
unit_of_measurement: "W"
device_class: power
icon: mdi:power
state: >
{% set attr = state_attr('sensor.sunlit_mppt', 'content') %}
{% if attr and 'batteryMppt2Data' in attr %}
{{ attr['batteryMppt2Data']['batteryMpptInPower'] }}
{% else %}
0
{% endif %}
- name: "MPPT Batterie 1 Leistung"
unique_id: mppt_batt1_power
unit_of_measurement: "W"
device_class: power
icon: mdi:power
state: >
{% set attr = state_attr('sensor.sunlit_mppt', 'content') %}
{% if attr and 'battery1MpptData' in attr %}
{{ attr['battery1MpptData']['batteryMpptInPower'] }}
{% else %}
0
{% endif %}
- name: "MPPT Batterie 2 Leistung"
unique_id: mppt_batt2_power
unit_of_measurement: "W"
device_class: power
icon: mdi:power
state: >
{% set attr = state_attr('sensor.sunlit_mppt', 'content') %}
{% if attr and 'battery2MpptData' in attr %}
{{ attr['battery2MpptData']['batteryMpptInPower'] }}
{% else %}
0
{% endif %}
Your errors indicate that either:
- The REST API is not returning data
- The template is accessing attributes that don’t exist
To verify what you’re actually getting back from the API:
Go to:
Developer Tools → Templates
Enter this:
{{ state_attr('sensor.sunlit_bk215_soc', 'content') }}
- If it returns
None
, the API call failed or returned no JSON - If it returns a dictionary, check what keys exist – e.g.
batterySoc
,inputPowerTotal
, etc.