Skip to content

Instantly share code, notes, and snippets.

@MDJoerg
Created July 17, 2024 01:02
Show Gist options
  • Save MDJoerg/0113a1940761838b08d080b50fcc88da to your computer and use it in GitHub Desktop.
Save MDJoerg/0113a1940761838b08d080b50fcc88da to your computer and use it in GitHub Desktop.
Maxxisun.app API to MQTT bridge (MaxxiCharge battery storage)

Maxxisun is a german vendor of the MaxxiCharge systems - balcony power plant systems with zero feed-in.

This flow calls the API behind the maxxisun.app and forward the results to a MQTT broker. With this you can master your smarthome project like creating dashboards or storing data in a influx database.

You have to change:

  • replace your personal Bearer token
  • upload the server certificate
  • modify your mqtt server and topic

See the comment node for further information.

Additional tips: You can use this flow without a MQTT server and forward the response direct to a graphical dashboard.

If your system uses a PowerOpti smartmeter sensor you can use the official PowerFox API too for enhancing additional data.

Have fun!

[
{
"id": "429e56466fc0ca6e",
"type": "inject",
"z": "87fe543b93444457",
"name": "10 sec trigger",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "10",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 180,
"y": 180,
"wires": [
[
"a31d36f0bb016f48"
]
]
},
{
"id": "a31d36f0bb016f48",
"type": "http request",
"z": "87fe543b93444457",
"name": "Call Maxxisun.app API ",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "https://maxxisun.app:3000/api/last",
"tls": "798787818db54cea",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [
{
"keyType": "other",
"keyValue": "Authorization",
"valueType": "other",
"valueValue": "Bearer <insert_your_token>"
},
{
"keyType": "other",
"keyValue": "Origin",
"valueType": "other",
"valueValue": "https://maxxisun.app"
},
{
"keyType": "other",
"keyValue": "Referer",
"valueType": "other",
"valueValue": "https://maxxisun.app/"
},
{
"keyType": "other",
"keyValue": "User-Agent",
"valueType": "other",
"valueValue": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0"
},
{
"keyType": "other",
"keyValue": "Accept",
"valueType": "other",
"valueValue": "application/json, text/plain, */*"
},
{
"keyType": "other",
"keyValue": "Accept-Language",
"valueType": "other",
"valueValue": "de,en-US;q=0.7,en;q=0.3"
},
{
"keyType": "other",
"keyValue": "Accept-Encoding",
"valueType": "other",
"valueValue": "gzip, deflate, br, zstd"
}
],
"x": 460,
"y": 180,
"wires": [
[
"4827eaeed7e8f5b1",
"4f66fd67ea72ae99"
]
]
},
{
"id": "4827eaeed7e8f5b1",
"type": "debug",
"z": "87fe543b93444457",
"name": "Maxxisun Request",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 770,
"y": 240,
"wires": []
},
{
"id": "4f66fd67ea72ae99",
"type": "mqtt out",
"z": "87fe543b93444457",
"name": "MQTT: iot/maxxisun/state",
"topic": "iot/maxxisun/state",
"qos": "",
"retain": "true",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "cf66559d24028e47",
"x": 790,
"y": 180,
"wires": []
},
{
"id": "a0c0fe692e1ebc9a",
"type": "comment",
"z": "87fe543b93444457",
"name": "required preparations",
"info": "# Get authorization\n - Login to https://maxxisun.app\n - Open the developer tools (F12)\n - Enter the tab \"network analysis\"\n - Search for GET request to maxxisun.app:300\n - Select one of these lines\n - Visit the header lines\n - Search for \"Authorization Bearer\"\n - Copy the \"Bearer xxxx\" Text\n - Insert or replace this string in the node \"Call maxxisun.app API\" as header line \"Authorization\"\n\n# Install certificate\n - download the certificate from https://maxxisun.app as *.crt\n - upload the certificate in node \"Call maxxisun.app API\" as CA server certificate\n - Test the api call with the \"inject\" node\n\n# Test\n- use the \"inject\" node to test the API\n- activate the \"debug\" node and visit debug messages\n\n",
"x": 460,
"y": 120,
"wires": []
},
{
"id": "4b09799107027315",
"type": "comment",
"z": "87fe543b93444457",
"name": "Change MQTT server and topic",
"info": "",
"x": 810,
"y": 120,
"wires": []
},
{
"id": "798787818db54cea",
"type": "tls-config",
"name": "",
"cert": "",
"key": "",
"ca": "",
"certname": "",
"keyname": "",
"caname": "maxxisun.app.crt",
"servername": "",
"verifyservercert": false,
"alpnprotocol": ""
},
{
"id": "cf66559d24028e47",
"type": "mqtt-broker",
"name": "MQTT Broker",
"broker": "192.168.1.1",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "iot/nodered/State",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "ONLINE",
"birthMsg": {},
"closeTopic": "iot/nodered/State",
"closeQos": "0",
"closeRetain": "false",
"closePayload": "SHUTDOWN",
"closeMsg": {},
"willTopic": "iot/nodered/State",
"willQos": "0",
"willRetain": "false",
"willPayload": "OFFLINE",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
}
]
@MDJoerg
Copy link
Author

MDJoerg commented Aug 16, 2024 via email

@FrankyASS74
Copy link

FrankyASS74 commented Aug 22, 2024

Hi Helmut, hi Jörg,

for HA you need to add some code in configuration.yaml
Here is mine:

mqtt:
    sensor:
    - name: "maxxisun"
      state_topic: "iot/maxxisun/state"
      value_template: "{{ value_json.deviceId }}"
      json_attributes_topic: "iot/maxxisun/state"




#Maxxisun Template Sensoren 
  - sensor:
      - name: "maxxisun_soc"
        unit_of_measurement: "%"
        device_class: "battery"
        state_class: "measurement"
        state: > 
            {{ state_attr('sensor.maxxisun', 'SOC') }}
  - sensor:        
      - name: "PV Ertrag"
        unique_id: "PV-Ertrag-Maxxicharge"
        unit_of_measurement: "W"
        device_class: "energy"
        state_class: "measurement"
        state: > 
            {{ state_attr('sensor.maxxisun', 'PV_power_total') }}            

The sensors need to be in section "template:"

Hope that helps. You can also see german community Photovoltaik where some help is also shared. Also here in Simon42 community

Many success
BR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment