BWT - Best Water Tech­nology - Support

Correct there is a limitation on the frequency, but guess that is something you can live with as the machine is not sending live updates

The problem is, on home assistant startup, it automatically tries to fetch it and causes error.

  - platform: rest
    scan_interval: SECONDS-GO-HERE
    resource_template: https://bwt-real-smarthome-backend.azurewebsites.net/api/Perla/DEVICE-ID-GOES-HERE/waterconsumption?since={{ (now() - timedelta(days = 1)).strftime("%Y-%m-%d") }}
    name: "Water Consumption - Yesterday"
    unique_id: water_consumption_yesterday
    headers:
      content-type: "application/json"
      ApiKey: API-KEY-GOES-HERE
    value_template: "{{ value_json.totalWaterConsumption | float(default=0) }}"
    json_attributes:
      - since

Please replace;

  • SECONDS-GO-HERE: interval to be refreshed in seconds (once in a day should be enough)
  • DEVICE-ID-GOES-HERE: get it from your mobile app
  • API-KEY-GOES-HERE: get it from BWT website

Works like a charm!

1 Like

Do you only use the BWT system for the water consumption sensor?

Ever thought about showing more stuff and controlling Holiday mode (security) with a switch?

Can you somehow integrate the BWT water supply into the energy panel for water consumption?

Hey here is my BWT overview:

See here the config:

Currently trying to integrate the water consumption information for the energy dashboard. See here:

Maybe someone has an idea

1 Like

Thanks for all the infos in this thread.
I am trying to set it up for my BWT Perla using REST API… but get stuck with my config [1]
Configuration seems to be valid, as I do not get an error when running config check in HA.
But no sensors shown in developer tool…

When putting the yaml config snippet into developer tools / template, I get the error “UndefinedError: ‘value_json’ is undefined”

Maybe someone has an idea about the error/missing commands?

[1] #file: /config/sensors.yaml

 - platform: rest
    scan_interval: 3600
    resource: >my-personal-bwt-url<
    name: "BWT Perla"
    headers:
      content-type: "application/json"
      ApiKey: >my-personal-bwt-api-token< 
    value_template: "{{ value_json.stateTitle }}"
    json_attributes:
      - displayName
      - productCode
      - stateTitle
      - stateBody
      - deviceState
      - lastTimeDataReceived
      - remainingAmountOfResourcePercent
      - refillResourceInDays
      - isHolidayModeActive
      - scheduledHolidayModeStart
      - firmwareVersion
      - waterTreatedTotal

Some information from my side.

I am using 2 different endpoints from this API for my Perla Home. It is important that the scan intervals are different, cause there is a rate limiting.
/api/Perla/{productCode}/waterconsumption
​/api​/Perla​/{productCode}

rest:
  - resource_template: !secret bwt_waterconsumption_url
    headers:
      content-type: "application/json"
      ApiKey: !secret bwt_token
    scan_interval: 86400
    timeout: 45
    sensor:
      - name: bwt_water_consumption_yesterday
        value_template: "{{ value_json.totalWaterConsumption | float(default=0) | round(0) }}"
        unit_of_measurement: "L"
        device_class: water
        icon: mdi:water
        #state_class: total
        #last_reset: {{ now() }}

  - resource: !secret bwt_url
    scan_interval: 3540
    timeout: 45
    headers:
      content-type: "application/json"
      ApiKey: !secret bwt_token
    sensor:
      - name: "bwt_state_title"
        value_template: "{{ value_json.stateTitle }}"
        #friendly_name: "Status"
      - name: "bwt_status"
        value_template: >
          {% if is_state('sensor.bwt_state_title','Alles OK!') %}
            ok
          {% elif is_state('sensor.bwt_state_title','unknown') %}
            ok
          {% elif is_state('sensor.bwt_state_title','None') %}
            ok
          {% elif is_state('sensor.bwt_state_title','Warnung') %}
            warning
          {% elif is_state('sensor.bwt_state_title','Vorrat Regeneriermittel niedrig') %}
            warning
          {% else %}
            error
          {% endif %}
      - name: "bwt_display_name"
        value_template: "{{ value_json.displayName }}"
        #friendly_name: "Anzeigename"
        json_attributes:
          - displayName
      - name: "bwt_state_body"
        #friendly_name: "State Body"
        value_template: "{{ value_json.stateBody }}"
        json_attributes:
          - stateBody
      - name: "bwt_remaining_amount_of_resource_percent"
        #friendly_name: "Perla Tabs Vorrat %"
        value_template: "{{ value_json.remainingAmountOfResourcePercent }}"
        device_class: humidity
        unit_of_measurement: "%"
      - name: "bwt_refill_resource_in_days"
        #friendly_name: "Perla Tabs Vorrat-Tage"
        value_template: "{{ value_json.refillResourceInDays }}"
        unit_of_measurement: "days"
      - name: "bwt_water_treated_total"
        #friendly_name: "Gesamtverbrauch"
        value_template: "{{ value_json.waterTreatedTotal }}"
        unit_of_measurement: "L"
        device_class: water
        state_class: total
        icon: "mdi:water-pump"
      - name: "bwt_last_time_data_received"
        #friendly_name: "Letzte Aktualisierung"
        value_template: "{{ value_json.lastTimeDataReceived }}"
        icon: "mdi:calendar-clock"
        device_class: timestamp
      - name: "bwt_water_treated_total_m3"
        unit_of_measurement: "m³"
        value_template: "{{ ( states('sensor.bwt_water_treated_total') | float / 1000 ) | round(3) }}"
        icon: "mdi:water-pump"
        device_class: water
        state_class: total
    binary_sensor:
      - name: "bwt_is_holiday_mode_active"
        #friendly_name: "Urlaubsmodus"
        value_template: "{{ value_json.isHolidayModeActive }}"

Known issues:

  • Water consumption not working in energy dashboard see my other threads
  • Not all warnings and errors are known, because there are not documented.

Sorry for the most likely stupid question… but where, in which file, did you put in your shown above?
I am asking as your code starts with

rest:
  - resource_template:

and mine, inside the file /config/sensors.yaml starts with

  - platform: rest
    resource_template:

In configuration.yaml new REST structure:

Hi, i have used this setup, and it works, but only once on HA bootup? Then it will never fetch data again.
Do you have issues with this?

No it works fine, can you share your config?

Hi again, sorry for the late answer, i actually think i fixed it, thanks :slight_smile:

After a break I will re try to set up this again. But I can not find out what the required code for authentification when setting up the integration is?
Could somebody please give me a hint. I tried everything (product code, API, the code I got from btw, which is working to get web access) nothing worked.

Second problem is, on the azure page from BWT, entering my product ID is resulting in authentification error.
I am sure, the product code ist correct (checked locally an in app)

I got the product code from the info section on the device and the (api key) you get here: Benutzerprofil - SmartHomeBWT (bwt-real-smarthome-backend.azurewebsites.net)

afterwards you can try the APi via swagger UI here: Swagger - SmartHomeBWT (bwt-real-smarthome-backend.azurewebsites.net)

For those who will use the read only interface of the current beta firmare 2.0209+:

Today I got the latest update for my device (I have asked for).
In addition I got the official documentation of the internal API in german (without any problem - the support is responsive and supported me best - Thanks for that!).

Using the documentation, it was totally easy to fastly implement a rest sensor with 4 important values - for my usage.
Lessons learned:

  1. Enable API locally
  2. Use basic authentication with user:<local_password> on local IP Address and Port 8080 (no ssl)

My current configuration partly recycled ideas stated here before (thanks) - and yes there are some improvements possible:

rest.yaml:
- resource: http://<ip-address>:8080/api/GetCurrentData
  authentication: basic
  username: "user"
  password: "<local_password>"
  scan_interval: 60
  sensor:
    - name: "BWT Aqua Perla"
      unique_id: "bwt_aqua_perla"
      #value_template: "{{ value_json['ShowError'] }}"
      value_template: >
          {% if is_state_attr("sensor.bwt_aqua_perla", "ShowError", 0) %}
            OK (blau)
          {% elif is_state_attr("sensor.bwt_aqua_perla", "ShowError", 1) %}
            Warnung (gelb)
          {% elif is_state_attr("sensor.bwt_aqua_perla", "ShowError", 2) %}
            Fehler (rot)
          {% else %}
            Error (Fehler unklar)
          {% endif %}
      json_attributes:
      - "CurrentFlowrate_l_h"
      - "FirmwareVersion" #: "2.0209"
      - "RegenerativLevel"
      - "RegenerativRemainingDays"
      - "RegenerativSinceSetup_g"
      - "ShowError"
      - "WaterSinceSetup_l" 
      - "WaterTreatedCurrentDay_l" 
      - "WaterTreatedCurrentMonth_l"
      - "WaterTreatedCurrentYear_l"
      # .....

    - name: "bwt_remaining_amount_of_resource_percent"
      unique_id: bwt_remaining_amount_of_resource_percent
      value_template: "{{ value_json['RegenerativLevel'] }}"
      unit_of_measurement: "%"
    - name: "bwt_refill_resource_in_days"
      unique_id: bwt_refill_resource_in_days
      value_template: "{{ value_json['RegenerativRemainingDays'] }}"
      unit_of_measurement: "d"
      #device_class: duration #leads to display issues
    - name: "bwt_water_treated_total"
      unique_id: bwt_water_treated_total
      value_template: "{{ value_json['WaterSinceSetup_l'] }}"
      unit_of_measurement: "L"
      device_class: water
      state_class: total
      icon: "mdi:water-pump"
    - name: "bwt_water_treated_total_m3"
      unique_id: bwt_water_treated_total_m3
      unit_of_measurement: "m³"
      value_template: "{{ ( states('sensor.bwt_water_treated_total') | float(default=1) / 1000 ) | round(3) }}"
      icon: "mdi:water-pump"
      device_class: water
      state_class: total

If somebody try the firmware 2.0203 - be aware that there are spaces in the json key names …

3 Likes

Hi @S-Przybylski ,
I’m on beta FW 2.207. Unfortunately, I’m not very familiar with yaml. I guess, you grated a new file “rest.yaml”?!
How did you link this to the configuration?

Do I have to change this to 2.0207 as this is my fw version, or is this just for informative purposes?

Thanks for sharing!

I got feedback from BWT that this way will not work anymore. They provided a beta fw with local api access.

  1. I have used the following detail in configuration.yaml to relocate rest configuration into a dedicated file
    configuration.yaml:
rest: !include rest.yaml

Otherwise you could directly insert the yaml part I have published into the configuration.yaml file:
configuration.yaml:

rest:
  - resource: http://<ip-address>:8080/api/GetCurrentData
    authentication: basic
  ...

Note: You have to add two spaces in front of each line

  1. #: "2.0209" is a comment in my configuration. You do not need to adapt anything here.

I asked the german support to update my device to latest firmware. Please consider do the same, because they have changed several names of the provided values in between.

Don’t forget to enable the API. Then you are able to test the connectivity first by using curl on Windows CMD prompt:

curl -u user:<local_password> http://<local_ip-address>:8080/api/GetCurrentData

The <local_password> was initially send to you while registering the device.

Compare the provided values and add the rest config into Home Assistant configuration.yaml or rest.yaml, reboot … and check if the values are present using the developer tools menu (2-3 min later) …

This solution works without any cloud API. If I understand the support of BWT correctly, this will remain in the future firmware independent what the cloud API will provide. Currently the local API is only read-only!

How to interpret the values:
Interestingly I believe that nearly all values shows the troughput at 0dH! Due to the fact that the water is mixed with the unthreated water at the end again (to get the desired dH level), the total throughput is higher then these values.
There is one additional figure, which seems to show this: “BlendedWaterSinceSetup_l” in FW 209
Hope that helps

1 Like

Thanks! The api is working so far. I created (paste & edit) a rest.yaml with your details. Unfortunately, this yaml stuff is not mine…
This is what my configuration.yaml looks like. The rest.yaml is in the same folder.

Checking the yaml code delivers this cryptic (at least to me) message:

I checked the output via curl. json attribute names are the same.

Edit: Found the problem. I had to remove this line inside the rest.yaml