JSON REST sensor State unknown BeeClear

Hoi Mario,

Net home assistant aan het draaien, en zou nu ook de beeclear willen gebruiken om de boiler (150L) aan te sturen via 1 van de ShellyPlugs (3500watt,).
Heb je het naar tevredenheid draaien of toch naar de native P1 kabel overgestapt ?

Hi!

De Beeclear geeft alle gegevens netjes door naar de Home Assistant :smile:

Het enige is dat, wanneer ik de Home Assistant herstart/update, de gegevens niet altijd worden opgepakt door Home Assistant. Nu trek ik dan de stekker uit het stopcontact van de BeeClear en steek die er weer in, waarna de gegevens weer netjes in Home Assistant staan.

Een workaround hiervoor zou zijn de BeeClear achter een slimme stekker te hangen en deze uit/aan zetten elke keer wanneer Home Assistant herstart.

Waarom dit gebeurd heb ik niet onderzocht. Inmiddels staat de Home Assistant server weer in de meterkast vlakbij de slimme meter, dus wellicht stap ik in de toekomst weer over naar de P1 kabel :shushing_face:

Oke, bedankt voor je rappe antwoord, die beeclear is ontworpen en gefabriceerd door een oud MTS klasgenootje van me, als je verbeter voorstellen hebt, kan ik die wellicht aan hem doorgeven …
zou jij op 1 op andere manier jouw instructies kunnen delen met mij ?
scheelt mij investeren in andere P1 devices, zou het liever met de beeclear oplossen, en net als bij jou draait HAcore bij mij op een bordje onder mn buro, is wel zo handig als ik die idd niet hoef te verplaatsen ( generic X86 want had ik nog liggen, en PI4 is moeilijk te krijgen momenteel )

Een voorstel wat echt enorm zou helpen: Stop met de API documentatie in word / pdf en gebruik de industrie standaard OpenApi / Swagger om het als onderdeel van de API zelf aan te bieden in HTML. Scheelt ze zelf ook heel veel werk.

I’ve spend a bit of time to get the login to work.
the dummy resource is a good idea, as it also serves as a check if the system is working. Turning off the security isn’t neccesary when using the following method for logging in:

The username and password are encoded in Base64. You can just grab the link from the network-tab in the developer options of your browser while logging in with the ui, no need to encode it yourself.
This will change the dummy into this:

  - scan_interval: 120
    resource: "http://beeclear.local/bc_login?username=[USERNAME BASE64]%3D&password=[PASSWORD BASE64]%3D"
    sensor:
      - name: "BCLoggedIn"
        value_template: "{{ value_json.status }}"

If everything goes well, it should return BCLoggedIn = 200, instead of 400
Please dont share the encoded usernames and passwords, they can be easily decoded

Another thing that I’ve changed is the url it uses to get the data.

beeclear.local/bc_current

gives all the data we want. (It exposes Gas in Liter, The 4 meter value’s in Wh, 3 phase power in W, electricity cost and basically every setting from the settings menu)

This is what I have so far, I could add 3 phase and electricity cost:

Here is my final config for the above picture (it is set up to be used with the home assistant energy menu)

rest:
  - scan_interval: 10
    resource: "http://beeclear.local/bc_current"
    sensor:
      - name: "BCleveren"
        value_template: '{{ value_json["g"] }}'
        unit_of_measurement: W
        state_class: "measurement"
        device_class: power
        force_update: true
      - name: "BCverbruik"
        value_template: '{{ value_json["u"]}}'
        unit_of_measurement: W
        device_class: power
        state_class: "measurement"
        force_update: true
      - name: "BCul"
        value_template: "{{ value_json['ul'] | multiply(0.001) }}"
        unit_of_measurement: kWh
        state_class: "total_increasing"
        device_class: energy
        force_update: true
      - name: "BCuh"
        value_template: "{{ value_json['uh'] | multiply(0.001)  }}"
        unit_of_measurement: kWh
        device_class: energy
        state_class: "total_increasing"
        force_update: true
      - name: "BCgl"
        value_template: "{{ value_json['gl'] | multiply(0.001)  }}"
        unit_of_measurement: kWh
        state_class: "total_increasing"
        device_class: energy
        force_update: true
      - name: "BCgh"
        value_template: "{{ value_json['gh'] | multiply(0.001) }}"
        unit_of_measurement: kWh
        device_class: energy
        state_class: "total_increasing"
        force_update: true
      - name: "BCGasVerbruik"
        value_template: "{{ value_json.gas[0].val }}"
        unit_of_measurement: "l"
        device_class: gas
        state_class: "total_increasing"
        force_update: true
      - name: "BCGasVerbruikM3"
        value_template: "{{ value_json.gas[0].val | multiply(0.001) }}"
        unit_of_measurement: "m³"
        device_class: gas
        state_class: "total_increasing"
        force_update: true
  - scan_interval: 120
    resource: "http://beeclear.local/bc_login [REPLACE THIS]"
    sensor:
      - name: "BCLoggedIn"
        value_template: "{{ value_json.status }}"

Remember: Replace the login url with your own.

1 Like

Hi @Wrobot , I used your solution for a few months now and it worked great. But when upgrading to 2023.4.x it doesn’t work anymore. What could be the reason of this?
Seems it has something to do with authorization, the separate BCLoggedIn call seems not to stay valid for reading out bc_current

Disable authentication as per my post and it should work again.

Great tip using that url, came back because the gas call is sometimes not working and found your suggestion.

I’ve polished your config for my own use and added the costs so you can feed those to the energy dashboard as well.

rest:
  - scan_interval: 10
    resource: "http://beeclear.local/bc_current"
    sensor:
      - name: "BCleveren"
        value_template: '{{ value_json["g"] }}'
        unit_of_measurement: W
        state_class: "measurement"
        device_class: power
        force_update: true
      - name: "BCverbruik"
        value_template: '{{ value_json["u"]}}'
        unit_of_measurement: W
        device_class: power
        state_class: "measurement"
        force_update: true
      - name: "BCVerbruikLaag"
        value_template: "{{ value_json['ul'] | multiply(0.001) }}"
        unit_of_measurement: kWh
        state_class: "total_increasing"
        device_class: energy
        force_update: true
      - name: "BCVerbruikHoog"
        value_template: "{{ value_json['uh'] | multiply(0.001)  }}"
        unit_of_measurement: kWh
        device_class: energy
        state_class: "total_increasing"
        force_update: true
      - name: "BCLeveringLaag"
        value_template: "{{ value_json['gl'] | multiply(0.001)  }}"
        unit_of_measurement: kWh
        state_class: "total_increasing"
        device_class: energy
        force_update: true
      - name: "BCLeveringHoog"
        value_template: "{{ value_json['gh'] | multiply(0.001) }}"
        unit_of_measurement: kWh
        device_class: energy
        state_class: "total_increasing"
        force_update: true
      - name: "BCGasVerbruik"
        value_template: "{{ value_json.gas[0].val }}"
        unit_of_measurement: "l"
        device_class: gas
        state_class: "total_increasing"
        force_update: true
      - name: "BCGasVerbruikM3"
        value_template: "{{ value_json.gas[0].val | multiply(0.001) }}"
        unit_of_measurement: "m³"
        device_class: gas
        state_class: "total_increasing"
        force_update: true
      - name: "BCTariefGas"
        value_template: "{{ value_json.setting.tarief.gas }}"
        unit_of_measurement: "€/m³"
        force_update: true
      - name: "BCTariefElekHoog"
        value_template: "{{ value_json.setting.tarief.elekHoog }}"
        unit_of_measurement: "€/kWh"
        force_update: true
      - name: "BCTariefElekLaag"
        value_template: "{{ value_json.setting.tarief.elekLaag }}"
        unit_of_measurement: "€/kWh"
        force_update: true

The REST api keeps giving problems that it just won’t reply after a random period of time. Because finally there is a new firmware with usable MQTT integration we don’t need it any more.

Just configure the MQTT to push the data to your Home Assistant MQTT broker

In the Beeclear UI: settings->advanced->mqtt

  • hostname is your home assistant server
  • port probably 1883 if you use mosquito
  • user / password need to be configured in your broker. If you use Mosquito you can add dedicated logins for this by editing the mosquito broker config (settings->add-ons->mosquitto broker->config->three dots on top->edit yaml) and put something like this (only the login part with username / password should be extra to your config):
logins:
  - username: beeclear
    password: yourpasswordhere
require_certificate: false
certfile: fullchain.pem
keyfile: privkey.pem
customize:
  active: false
  folder: mosquitto
  • the topic text in the config is used as part of “state_topic” in home assistant. I used ‘dsmr’ but feel free to use something else.
  • restarttime 10 works fine so far
  • you do not need the raw telegram (put to NO)

Now in your config.yaml put the following:

mqtt:
  sensor:
    - state_topic: "dsmr/electricity_currently_delivered_Watts"
      name: "bcmqtt_verbruik"
      unit_of_measurement: "W"
      state_class: "measurement"
      device_class: power
    - state_topic: "dsmr/electricity_currently_returned_Watts"
      name: "bcmqtt_leveren"
      unit_of_measurement: "W"
      state_class: "measurement"
      device_class: power      
    - state_topic: "dsmr/electricity_delivered_normal_Wh"
      name: "bcmqtt_VerbruikHoog"
      unit_of_measurement: "kWh"
      state_class: "total_increasing"
      device_class: energy
    - state_topic: "dsmr/electricity_delivered_low_Wh"
      name: "bcmqtt_VerbruikLaag"
      unit_of_measurement: "kWh"
      state_class: "total_increasing"
      device_class: energy
    - state_topic: "dsmr/electricity_returned_normal_Wh"
      name: "bcmqtt_LeveringHoog"
      unit_of_measurement: "kWh"
      state_class: "total_increasing"
      device_class: energy
    - state_topic: "dsmr/electricity_returned_low_Wh"
      name: "bcmqtt_LeveringLaag"
      unit_of_measurement: "kWh"
      state_class: "total_increasing"
      device_class: energy
    - state_topic: "dsmr/gas_meter_m3"
      name: "bcmqtt_GasVerbruikM3"
      unit_of_measurement: "m³"
      state_class: "total_increasing"
      device_class: gas

Have fun!

1 Like

Wow that works pretty well, thanks for the info!

I’m just not seeing “dsmr/gas_meter_m3”
Tested for a couple of days with MQTT explorer, but it just won’t appear, all the others do…
I do see the gas value in the raw telegram when I enable that…

0-2:24.2.1(231208105504W)(01627.289*m3)

would it be possible to use that as an input for “bcmqtt_GasVerbruikM3”
(the 0-2:24.2.1 part always seems to be the same)?