Since i was looking for this integration I ended up here. This integration will not work for multiple reasons.
- You cannot divide Watt by 1000 and call it KWh, that’s not how it works.
- The URL get requests in the config often gets NO output response in the measurements array which will be resolved when using the history parameters.
So the configuration above is a starting point but does not work. I spend some time researching and getting it to work so: Here is the fully working configuration for BeeClear and Home assistant running in HASS 7.5 hoping to save people some time and effort.
First step: Disable the API security on the beeclear since their API works but the authentication mechanism is unsuitable for stateless integration. Request the following URL in your browser to disable it.
http://beeclear.local/bc_security?set=off
If your DNS is not set up properly, replace beeclear.local for the IP address of the beeclear device.
Next up the config for the rest polling. I’m still playing with the timing. 10 seconds interval seems excessive so you might change the scan interval and play with the duration get parameter here. In the end the wattage will be converted to KWh anyway with a formula.
rest:
- scan_interval: 10
resource: "http://beeclear.local/bc_getVal?type=elekw&duration=10"
sensor:
- name: "BCleveren"
value_template: '{{ value_json.meetwaarden[0].val[0].leveren }}'
unit_of_measurement: W
state_class: 'measurement'
device_class: power
force_update: true
- name: "BCverbruik"
value_template: '{{ value_json.meetwaarden[0].val[0].verbruik }}'
unit_of_measurement: W
device_class: power
state_class: 'measurement'
force_update: true
- name: "BCLaagTarief"
value_template: '{{ value_json.setting.tarief.elekLaag }}'
unit_of_measurement: "€"
device_class: monetary
- name: "BCHoogTarief"
value_template: '{{ value_json.setting.tarief.elekHoog }}'
unit_of_measurement: "€"
device_class: monetary
- resource: "http://beeclear.local/bc_getVal?type=gas&duration=3599&period=hour"
sensor:
- name: "BCGasVerbruik"
value_template: '{{ value_json.meetwaarden[0].val[0].gas }}'
unit_of_measurement: 'l'
device_class: gas
force_update: true
- name: "BCGasVerbruikM3"
value_template: '{{ value_json.meetwaarden[0].val[0].gas | multiply(0.001) }}'
unit_of_measurement: 'm³'
device_class: gas
force_update: true
Since beeclear submits W and not KWh we need to use the home assistant virtual sensors to do the conversion. Add the following sensors.
sensor:
- platform: integration
source: sensor.bcleveren
name: bcleverenKWH
unit_prefix: k
round: 2
- platform: integration
source: sensor.bcverbruik
name: bcverbruikKWH
unit_prefix: k
round: 2
Only thing i didn’t get working is the gas consumption without customizing it. Add the following to your customization.yaml. If anyone has a better solution, let me know.
sensor.bcgasverbruikm3:
state_class: total_increasing
last_reset: '1970-01-01T00:00:00+00:00'
Next configure these sensors in your energy dashboard and you are done.
Small update
For some reason beeclear after a while returns invalid json for me. It is random but it shows as the following entries in the logfile
value_json is undefined when rendering
The reason is the json returned by Beeclear is invalid and cannot be parsed due to some kind of unicode character in the ‘user’ field due to some kind of session timeout or something. Clearing the cache and restarting will fix this.
"user":"",
Since the beeclear project seems dead I tried fixing it and found a way to avoid this. Just add a dummy resource to your configuration
- scan_interval: 10
resource: "http://beeclear.local/bc_login"
sensor:
- name: "BCLoggedIn"
value_template: '{{ value_json.status }}'
This will return an error message but also fixes the next call to beclear to just return in the json
user:""
My final working config in the configuration.yaml file is
rest:
- scan_interval: 60
resource: "http://beeclear.local/bc_getVal?type=elekw&duration=60"
sensor:
- name: "BCleveren"
value_template: '{{ value_json["meetwaarden"][0].val[0]["leveren"] }}'
unit_of_measurement: W
state_class: 'measurement'
device_class: power
force_update: true
- name: "BCverbruik"
value_template: '{{ value_json["meetwaarden"][0].val[0]["verbruik"] }}'
unit_of_measurement: W
device_class: power
state_class: 'measurement'
force_update: true
- scan_interval: 60
resource: "http://beeclear.local/bc_getVal?type=gas&duration=3599&period=hour"
sensor:
- name: "BCGasVerbruik"
value_template: '{{ value_json.meetwaarden[0].val[0].gas }}'
unit_of_measurement: 'l'
device_class: gas
force_update: true
- name: "BCGasVerbruikM3"
value_template: '{{ value_json.meetwaarden[0].val[0].gas | multiply(0.001) }}'
unit_of_measurement: 'm³'
device_class: gas
force_update: true
- scan_interval: 120
resource: "http://beeclear.local/bc_login"
sensor:
- name: "BCLoggedIn"
value_template: '{{ value_json.status }}'