Beem Energy Solar Power Configuration

Hi, I just want to share with you my configuration for getting the generated power from my Beem Solar panels.
Since there is no local API, alas, I configured a sensor that get the generated power through their (unexposed) remote API.

  - sensor:
      - name: post_data
        state: '{"month":{{now().strftime("%m").lstrip("0")}},"year":{{now().strftime("%Y")}}}'

  - platform: command_line
    command: "curl -X POST -H --location '' --header 'authorization: Bearer ********************' --header 'content-type: application/json; charset=UTF-8' --header 'Accept: */*' --data '{{ states('sensor.post_data') }}'"
    name: "Solar Power"
    scan_interval: 60
    value_template: "{{ value_json[0].wattHour }}"
    unit_of_measurement: W
    unique_id: "Solar Power"

You can get your bearer token inspecting with Chrome their website (a web app in Dart I think): Beem Energy. As for now there is no exposed API and no exposed methos to get the bearer token.

In the API usage you’ll find the POST I’m using above.

1 Like

hi jimbolimbo3,

Thanks a lot for this post, he save me from a big headache I have had since few days. I was struggling with RESTful, Command Line, Template, single or double Quotes, Payload, etc…
I learn a lot but did not succeed.

I made some modifications :

- platform: command_line
  command: 'token=$(curl -X POST -H "Content-Type: application/json" --data-raw "{\"email\":\"%email%\",\"password\":\"%password%\"}" | jq .accessToken) && token=${token//\"} && echo $token'
  name: beem_token
  scan_interval: 3600
- platform: command_line
  command: "curl -X POST -H --location '' --header 'authorization: Bearer '{{ states('sensor.beem_token') }}'' --header 'content-type: application/json; charset=UTF-8' --header 'Accept: */*' --data '{{ states('sensor.post_data') }}'"
  name: total_month
  scan_interval: 60
  value_template: "{{ value_json[0].totalMonth|float/1000 }}"
  unit_of_measurement: kWh
- platform: command_line
  command: "curl -X POST -H --location '' --header 'authorization: Bearer '{{ states('sensor.beem_token') }}'' --header 'content-type: application/json; charset=UTF-8' --header 'Accept: */*' --data '{{ states('sensor.post_data') }}'"
  name: total_day
  scan_interval: 60
  value_template: "{{ value_json[0].totalDay|float/1000 }}"
  unit_of_measurement: kWh
- platform: command_line
  command: "curl -X POST -H --location '' --header 'authorization: Bearer '{{ states('sensor.beem_token') }}'' --header 'content-type: application/json; charset=UTF-8' --header 'Accept: */*' --data '{{ states('sensor.post_data') }}'"
  name: watt_hour
  scan_interval: 60
  value_template: "{{ value_json[0].wattHour|float/1000 }}"
  unit_of_measurement: kWh

first sensor will retrieve the token, you just have to replace %email% and %passsword% with your login and password. He will update the token every hour (I don’t know if it is necessary or not)

the next three will retrieve your data from your beem solar panels in kWh.

thank for your help

1 Like

Hello, i can’t connect with my credentials, the beem_token is permanently null… It works always or it’s finished?

Any ideas?

And how use this measurement with energy dashboard?


in this exact moment it is still working for me. Try to get the token using the website and then use the beem_token sensor. Let me know if it works.

hello @Iceblue256 ,
still working for me.

did you try to connect with this address: Beem Energy in your web brower ?
One advice/clue : my password doesnt contain any special character.

did you test to obtain your token within a terminal ? you can use the module SSH & Web terminal.

I didnt find a solution to integrate in energy dashboard. i have the message : Entity not defined.

Hello @malendure ,
thanks for the sharing i use your code and it’s now very well working,
even with specials caracters in the password !

i had some problems to use your code because of a typo :

a backslash is missing after the email before the quote :


hope this will help others finding this post !


can you check you don’t missed the backslash at the end of the email ?



everything seems ok, except for the post data : {{ states(‘sensor.post_data’) }}

where do you set it ?
if i replace it with {“month”: 5,“year”: 2023}, i get a response, otherwise a 400 error code

thanks for help

If you took the code from Malendure, you should also add the first paragraph of jimbo to define post_data:

  - sensor:
      - name: post_data
        state: '{"month":{{now().strftime("%m").lstrip("0")}},"year":{{now().strftime("%Y")}}}'

thank you Mathieu !

hello @mc59 and @mathuieu ,
I’m happy that this is useful.

I did change a bit to be able to use the sensor in Energy dashboard.

- sensor:
  - name: post_data
    state: '{"month":{{now().strftime("%m").lstrip("0")}},"year":{{now().strftime("%Y")}}}'
  - name: total_month
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing
    state: "{{ state_attr('sensor.beem','totalMonth') | float/1000 }}"
    icon: mdi:solar-power
  - name: total_day
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing
    state: "{{ state_attr('sensor.beem','totalDay') | float/1000 }}"
    icon: mdi:solar-power
  - name: watt_hour
    unit_of_measurement: "Wh"
    device_class: energy
    state_class: total_increasing
    state: "{{ state_attr('sensor.beem','wattHour') | float/1000 }}"
    icon: mdi:solar-power

  - resource_template: 
    method: POST
      Content-type: application/json
      Authorization: !secret beem_token
    payload: '{"month":6,"year":2023}'
    scan_interval: 60
      - name: "beem"
        json_attributes_path: "$[0]"
          - "totalMonth"
          - "wattHour"
          - "totalDay"
        value_template: 'OK'

   - sensor:
       command: 'token=$(curl -X POST -H "Content-Type: application/json" --data-raw "{\"email\":\"email\",\"password\":\"password\"}" | jq .accessToken) && token=${token//\"} && echo $token && sed -i "s/\(beem_token:\)\(.*\)/\1 Bearer $token/" /config/secrets.yaml'
       name: beem_token
       scan_interval: 84600

  beem: sed -i "s/\({{cmd}}:\)\(.*\)/\1 '{{ states.sensor.post_data.state|to_json }}'/" /config/configuration.yaml

the hard part was to update the payload every month wihout having to modify manually the config.yaml each time. the only way I found was to create an automation to execute the beem shell command.

alias: beem payload
description: ""
  - platform: time
    at: "00:00:01"
  - condition: template
    value_template: "{{ now().day == 1 }}"
  - service: shell_command.beem
      cmd: payload
  - service: homeassistant.restart
    data: {}
mode: single


Hello @malendure,
thanks for the sharing,

i tried to add this new code but i get the error :
Error loading /config/configuration.yaml: Secret beem_token not defined

i then tried to use the beem_token sensor from the last extract but it’s not working.

where do you define your token in this new version ?

(when it will be working i’ll use a dedicated package configuration file to clean my config.yaml)

i discovered the secrets.yaml file !
after adding manually the token in this file, the error is gone.

but the values are unavaliable, i should have missed something…

hello @mathuieu ,

yes sorry I forgot, I corrected my post.

yes I create a sensor to retrieve my token and store it in the secret.yaml.

it should work now

1 Like


the secret is well set now,
after a reboot everything is working !

i added total_day to the energy dashboard, nice!

thanks again for your work and the sharing !

1 Like

Hi everyone,

I tried to user that code but everytime I execute the shell_command, it completely destroys my configuration.yaml by adding “{“month”:7,“year”:2023}” everywhere.
Do i miss something ? I just copy-paste everything and just changed the email and password values (my password has a “/” in it, maybe that’s the problem ?

Also @mathuieu, how did you add the total_day to Energy dashboard ?

Thanks for your help.

Hi Xerses,

in the energy dashboard config page (/config/energy),
you just have to add the sensor as a solar production value :

for the automation, i didn’t implemented it yet, i change manually the value each month

Hello @Xerses,

No issue with the automtion since 2 month : his role is to replace only the payload in a json format. It does not need your password.

In your case, this means that you don’t copy exactly either the automation or the shell_command. Space are also important.

My password does not contains special character, only number and letter. With your special character, do you test the command to obtain your token?

Post your code if it still doesn’t work.

See ya


i just finished installing Open DTU on a ESP32 board with a NRF24L01+ radio board
and it’s a really better way to get live stats directly from the inverter.
data are locally managed and don’t on Beem servers.

not a electronic specialist but i finally managed to flash correctly the board following the tutorial,
for less than 10€ it’s worthy !
choose one with an external antenna to get better transmission.

Hello there,

I get this error: UndefinedError: ‘value_json’ is undefined