Beem Energy Solar Power Configuration

Hi @mathuieu,

What additional information can you gather?

On my side, I use a Shelly 1 PM micromodule to verify the production. This is the only thing that matter.

Hi @Lennart-Live,

Can you post your configuration.yaml? We can’t help your otherwise.

Hi @malendure,
I connected my Homewizard energy socket to the solar panels powercord and from there i could see that the energy socket also measered solar panels production, so i created a new integration and added it to my energy dashboard. Also works great!

Hello,
Wellll, this also does not help me, because the energy socket shows negative power because it’s returning power from the Beem panels. HA does not understand this… :frowning: What to do next? I’ve tried the code again, but it gives me all these errors. It looks like there is a gap between versions of HA?
This is my version of HA:
Home Assistant 2023.9.1
Supervisor 2023.08.3
Operating System 10.5
Frontend-versie: 20230908.0 - latest

Thank you for all the work it’s been quite helpfull. I’ve had to change a line because it wasn’t working with the secret.

Authorization: Bearer {{ states.sensor.beem_token.state }}

Dear Gurus, Thanks a lot for sharing your brilliant ideas - I learn a lot with this post - that I finally succeed to implement. Partially, in fact, since I have 2 Beem kits, and the text retrieved from the API holds 2 times the different variables:
`
[{
“boxId”:13435,
“name”:null,
“lastAlive”:“2024-03-27T09:18:24.489Z”,
“lastProduction”:“2024-03-27T09:17:00.000Z”,
“serialNumber”:“409151850C05”,
“totalMonth”:16405,
“wattHour”:0,
“totalDay”:0,
“weather”:null
}
,
{
“boxId”:12945,
“name”:“PignonEst”,
“lastAlive”:“2024-03-27T09:19:49.626Z”,
“lastProduction”:“2024-03-27T09:19:00.000Z”,
“serialNumber”:“58BF2539F03D”,
“totalMonth”:15104,
“wattHour”:0,
“totalDay”:0,
“weather”:null
}]

I guess an array is the solution but I have not enough experience in HA.
Should the format for the sensor be the following:
`sensor:
      - name: "beem"
        json_attributes_path: "$[0,1]"
`    
What will be the syntax for the state_attr, for example for wattHour:
`state: "{{ state_attr('sensor.beem','wattHour') | float/1000 }}"`
Best regards

Dear All,
Inspired from [RESTful - Home Assistant], I finally managed to read values from the 2 Beem Energy kits with the following configuration file using ‘beem1’ and ‘beem2’ sensors, instead of ‘beem’, as @malendure proposes:

# 'Beem Energy' Start
template:
- sensor:
  - name: post_data
    state: '{"month":{{now().strftime("%m").lstrip("0")}},"year":{{now().strftime("%Y")}}}'
  - name: boxId1
    device_class: energy
    state_class: total_increasing
    state: "{{ state_attr('sensor.beem1','boxId') | int }}"
    icon: mdi:solar-power  
  - name: total_month1
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing
    state: "{{ state_attr('sensor.beem1','totalMonth') | float/1000 }}"
    icon: mdi:solar-power
  - name: total_day1
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing
    state: "{{ state_attr('sensor.beem1','totalDay') | float/1000 }}"
    icon: mdi:solar-power
  - name: watt_hour1
    unit_of_measurement: "Wh"
    device_class: energy
    state_class: total_increasing
    state: "{{ state_attr('sensor.beem1','wattHour') | float/1000 }}"
    icon: mdi:solar-power
  - name: boxId2
    device_class: energy
    state_class: total_increasing
    state: "{{ state_attr('sensor.beem2','boxId') | int }}"
    icon: mdi:solar-power 
  - name: total_month2
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing
    state: "{{ state_attr('sensor.beem2','totalMonth') | float/1000 }}"
    icon: mdi:solar-power
  - name: total_day2
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing
    state: "{{ state_attr('sensor.beem2','totalDay') | float/1000 }}"
    icon: mdi:solar-power
  - name: watt_hour2
    unit_of_measurement: "Wh"
    device_class: energy
    state_class: total_increasing
    state: "{{ state_attr('sensor.beem2','wattHour') | float/1000 }}"
    icon: mdi:solar-power
rest:
  - resource_template: https://api-x.beem.energy/beemapp/box/summary 
    method: POST
    headers:
      Content-type: application/json
      Authorization: !secret beem_token
    payload: '{"month":3,"year":2024}'
    scan_interval: 60
    sensor:
      - name: "beem1"
        json_attributes_path: "$[0]"
        json_attributes:
          - "boxId"
          - "totalMonth"
          - "wattHour"
          - "totalDay"
        value_template: 'OK'
      - name: "beem2"
        json_attributes_path: "$[1]"
        json_attributes:
          - "boxId"
          - "totalMonth"
          - "wattHour"
          - "totalDay"
        value_template: 'OK'

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

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

# 'Beem Energy' End

Thanks a lot again for sharing your knowledge.

2 Likes

Hello Everyone,
I have a Beem Roof and would like show data of beem app on home assistant.
Beem Energy & Beem Energy looks not working … When I am going on, I only obtain beem logo.
Is it still working at your side ?

Best regards

Hi Charly3944, I had the same with Google Chrome browser but not with Brave browser. Then, I deactivated the Chrome extension “uBlock Origin app” and it works.
Best,
K.

Hi @Klau
Thanks.
I checked and still unable to find bearer code via inspect from Chrome

So, I saved below code on packages/beem.yaml & token well appear in the secret.yaml
But still face to issue as sensor well created in home assistant & sensor doesn’t show any value.

Is it due to bearer code find is not correct ?
or because I have Solar Panel without beem box. (I am with a beem roof + battery)

template:
  - 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
        unique_id: 202408250001

      - 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
        unique_id: 202408250002

      - name: watt_hour
        unit_of_measurement: "Wh"
        device_class: energy
        state_class: total_increasing
        state: "{{ state_attr('sensor.beem','wattHour') | float }}"
        icon: mdi:solar-power
        unique_id: 202408250003

rest:
  - resource_template: https://api-x.beem.energy/beemapp/box/summary
    method: POST
    headers:
      Content-Type: application/json
      Authorization: !secret beem_token
    payload_template: >
      {
        "month": {{ now().month }},
        "year": {{ now().year }}
      }
    scan_interval: 3600
    sensor:
      - name: "beem"
        json_attributes_path: "$[0]"
        json_attributes:
          - "totalMonth"
          - "wattHour"
          - "totalDay"
        value_template: 'OK'

command_line:
  - sensor:
      command: >
        token=$(curl -X POST -H "Content-Type: application/json" --data-raw '{"email":"[email protected]","password":"password"}' https://api-x.beem.energy/beemapp/user/login | jq -r .accessToken) && 
        echo $token && 
        sed -i "s/\(beem_token:\)\(.*\)/\1 Bearer $token/" /config/secrets.yaml
      name: beem_token
      scan_interval: 3600

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

I tried to use postman.co to obtain direct result
POST option on BEEM api website : https://api-x.beem.energy/beemapp/box/summary

Bearer Token set in the Authorization tab & below code on Body tab:

{
    "email": "[email protected]",
    "password": "change by password",
    "month": "9",
    "year": "2024",
    "sensor": [
        {
            "name": "beem",
            "json_attributes_path": "$[0]",
            "json_attributes": [
                "boxId",
                "totalMonth",
                "wattHour",
                "totalDay"
            ],
            "value_template": "OK"
        }
    ]
}

Result is empty : []
I tried to inspect website but didn’t find how to obtain data…