fredlcore / BSB-LAN

LAN/WiFi interface for Boiler-System-Bus (BSB) and Local Process Bus (LPB) and Punkt-zu-Punkt Schnittstelle (PPS) with a Siemens® controller used by Elco®, Brötje® and similar heating systems
222 stars 84 forks source link

[BUG] Home Assistant #513

Closed proasnet closed 1 year ago

proasnet commented 1 year ago

Before submitting a bug report, please make sure that you have checked chapter 14 of the manual ("Problems and their Possible Causes"). Most problems that are reported to us can be solved by going through the solutions provided there.

BSB-LAN Version 3.0.1-20221101130752

Architecture Arduino Due

Bus system BSB

Describe the bug Read MQTT data in Home Assistant, because integration from @liudger not working now, I tried add an easy sensor. IP adress of broker, username and password is right. Device ID and prefix is as default BSB-LAN

To Reproduce Steps to reproduce the behavior:

  1. Go to manual, chapter 8.11
  2. Click on configuration.yaml and edit
  3. paste
    sensor:
    - platform: mqtt
    state_topic: "bsb-lan/8310"
    name: BSB-LAN flow temperature
    unit_of_measurement: °C
    device_class: temperature

    This is not valid configuration. I tried a new format

    mqtt:
    sensor:
    - name: "BSB-LAN flow temperature"
      state_topic: "bsb-lan/8310"
      unit_of_measurement: "°C"
      device_class: temperature
  4. See state of entity, is still unknown in both cfgs

Logs LOG from MQTT Broker in HA: 2022-11-12 15:52:18: New connection from 192.168.0.150:51415 on port 1883.

State by BSB Lan http://192.168.0.150/8310 8310.0 Diagnostics producer - Boiler temp actual value: 37.7 °C

Additional context I am doing some bad, but I dont know what...

proasnet commented 1 year ago

I tried this, and not working too.

rest:
  sensor:
    - name: "BSB-LAN status"
      resource: http://192.168.0.150/JQ=700,1600,8000,8003,6705,710,712,720,721,1610,1612,5400
      method: POST
      username:
      password:
      scan_interval: 60
      value_template: "{{ value_json['6705'].value }}"
      json_attributes:
        - "700"
        - "1600"
        - "6705"
        - "8000"
        - "8003"
        - "710"
        - "712"
        - "720"
        - "721"
        - "1610"
        - "1612"
        - "5400"

The check configuration in HA return this Invalid config for [rest]: [resource] is an invalid option for [rest]. Check: rest->rest->0->sensor->0->resource. (See /config/configuration.yaml, line 40).

If I try use resource url in browser, I get this

<html><body>
<!--StartFragment--><li class="tabs-menu-item json is-active" role="presentation"><span class="devtools-tab-line"></span></li><li class="tabs-menu-item rawdata " role="presentation"><span class="devtools-tab-line"></span></li><span class="devtools-tab-line"></span><div id="json-panel" style="visibility: visible; height: 100%;" class="tab-panel-box" role="tabpanel" aria-labelledby="json-tab"><div class="tab-panel json"><div class="jsonPanelBox tab-panel-inner"><div class="toolbar"></div></div></div></div><div class="toolbar"><div class="devtools-separator"></div><div class="devtools-searchbox"><input class="searchBox devtools-filterinput" placeholder="Filtr JSON" value=""></div></div><div class="panelContent">

  |  
-- | --
700 |  
name | "Operating mode"
dataType_name | "ENUM"
dataType_family | "ENUM"
error | 0
value | "1"
desc | "Automatic"
dataType | 1
readonly | 0
readwrite | 0
unit | ""
710 |  
name | "Comfort setpoint "
dataType_name | "TEMP"
dataType_family | "VALS"
error | 0
value | "21.0"
desc | ""
precision | 0.1
dataType | 0
readonly | 0
readwrite | 0
unit | "°C"
712 |  
name | "Room temp reduced setpoint"
dataType_name | "TEMP"
dataType_family | "VALS"
error | 0
value | "17.0"
desc | ""
precision | 0.1
dataType | 0
readonly | 0
readwrite | 0
unit | "°C"
720 |  
name | "Heating curve slope"
dataType_name | "FP02"
dataType_family | "VALS"
error | 0
value | "1.32"
desc | ""
precision | 0.01
dataType | 0
readonly | 0
readwrite | 0
unit | ""
721 |  
name | "Heating curve parallel displacement"
dataType_name | "TEMP"
dataType_family | "VALS"
error | 0
value | "-1.0"
desc | ""
precision | 0.1
dataType | 0
readonly | 0
readwrite | 0
unit | "°C"
1600 |  
name | "Operating mode"
dataType_name | "ENUM"
dataType_family | "ENUM"
error | 0
value | "1"
desc | "On"
dataType | 1
readonly | 0
readwrite | 0
unit | ""
1610 |  
name | "DHW temperature nominal setpoint"
dataType_name | "TEMP"
dataType_family | "VALS"
error | 0
value | "60.0"
desc | ""
precision | 0.1
dataType | 0
readonly | 0
readwrite | 0
unit | "°C"
1612 |  
name | "DHW temperature reduced setpoint"
dataType_name | "TEMP"
dataType_family | "VALS"
error | 0
value | "35.0"
desc | ""
precision | 0.1
dataType | 0
readonly | 0
readwrite | 0
unit | "°C"
6705 |  
name | "Internal value of diagnostic code"
dataType_name | "UINT"
dataType_family | "VALS"
error | 0
value | "0"
desc | ""
precision | 1
dataType | 0
readonly | 1
readwrite | 1
unit | ""
8000 |  
name | "Status heating circuit 1"
dataType_name | "ENUM"
dataType_family | "ENUM"
error | 0
value | "114"
desc | "Heating mode Comfort"
dataType | 1
readonly | 1
readwrite | 1
unit | ""
8003 |  
name | "Status DHW"
dataType_name | "ENUM"
dataType_family | "ENUM"
error | 0
value | "100"
desc | "Charged, reduced temperature"
dataType | 1
readonly | 1
readwrite | 1
unit | ""

</div><!--EndFragment-->
</body>
</html>
1coderookie commented 1 year ago

I think that's my bad - there was a PR about this HA example for the german language version of the manual with some changes but I didn't made the changes within the english version yet :( Sorry!! :( Could you please try the examples from the german version of the manual? You'll find it here: https://1coderookie.github.io/BSB-LPB-LAN/kap08.html#811-home-assistant Thanks

1coderookie commented 1 year ago

..I now adjusted the english version: https://1coderookie.github.io/BSB-LPB-LAN_EN/chap08.html#811-home-assistant

You probably need to refresh the page - if the code is displayed in different colours now, it's the changed version: Bildschirmfoto von 2022-11-12 17-58-30

proasnet commented 1 year ago
mqtt:
  sensor:
    - state_topic: "bsb-lan/8310"
      name: BSB-LAN flow temperature
      unit_of_measurement: °C
      device_class: temperature

obrazek

proasnet commented 1 year ago

obrazek

1coderookie commented 1 year ago

I guess that means it doesn't work..? Sorry, but I can't help with that any further, I don't know anything about HA. Maybe @tiger42 , @GSzabados or @liudger knows the solution for this? And/or maybe you can find help in the belonging thread within the home assistant forum? https://community.home-assistant.io/t/bsb-lan-integration/113501/108

mirkolenz commented 1 year ago

Are you by any chance using version 2.2 of bsblan? I was faced with the same issue: My sensors were not updating. After some troubleshooting I found out that since the new release, parameters are published only under their new „float id“. For instance, parameter 700 would be published under 700.00. This is currently not documented (at least to my knowledge).

1coderookie commented 1 year ago

It's only one following ".0", so it's e.g. 700.0 - yes, that may be the reason! And yes, I didn't yet mentioned the ".0" yet within the manual, that's right - sorry for that, I'll take care about it asap.. But: There's a note at the beginning of the chapter 8 that users have to check stuff like that by their own when it comes down to using the examples, cuz those aren't written by me, they were given to me by other users.. :( Anyway - did you get it working at the end @mirkolenz ? I think it should also be possible with e.g. 700 instead of 700.0, cuz in that case it will just query all possible 700.x - but maybe I'm wrong..

1coderookie commented 1 year ago

..about the sensors: I recently added new screenshots where the .0/.1/.2 etc are visible (DHT22 still missing tho). But also here: if you just query the sensor number (e.g. 20200) w/o the following .0/.1 etc then it should give you all the possible values/endings anyway. Just if you want to query a specific value from that summarized output, let's say from 20200.1, then you'd have to query that one specifically. Bildschirmfoto von 2022-11-12 19-26-51

GSzabados commented 1 year ago

Install MQTT Explorer addon to be able to see what MQTT messages HA receives from BSB-LAN.

mirkolenz commented 1 year ago

And yes, I didn't yet mentioned the ".0" yet within the manual, that's right - sorry for that, I'll take care about it asap.. But: There's a note at the beginning of the chapter 8 that users have to check stuff like that by their own when it comes down to using the examples, cuz those aren't written by me, they were given to me by other users.. :(

I really did not intend to insult you in any way, sorry if it came across differently. I am extremely happy with the documentation of this project and found it to be one of the best of a "hobby project" I worked with. With that in mind, I was just surprised that these changes between the versions were not yet documented 😄 Keep up your great work!

I think it should also be possible with e.g. 700 instead of 700.0, cuz in that case it will just query all possible 700.x - but maybe I'm wrong..

In MQTT you only subscribe to a certain topic. It seems to be the case that currently BSB-LAN only publishes the parameters to the "long" float address and not the shorter one. Personally I think that this is sufficient.

It's only one following ".0", so it's e.g. 700.0 - yes, that may be the reason!

This I also what I thought initially, but that did not work in my case. After upgrading I first wondered why my states are no longer updating in Home Assistant. Upon investigation, I observed a large amount of dropped messages on my broker. Eventually, I then found out that you have to subscribe to 700.00 with two trailing zeros. I have this running in my setup for the past weeks and just verified on my broker that I do not get messages on 700.0 and 700. I uploaded a screenshot, maybe this is helpful for others.

Screenshot-2022-11-12T19-33-24
proasnet commented 1 year ago

What usage is recomended? Plain Text, JSON or rich JSON for this example? Could this be the cause of the problem? I tried all three variants but without effect

proasnet commented 1 year ago

It look that only status... obrazek

1coderookie commented 1 year ago

I really did not intend to insult you in any way, sorry if it came across differently. I am extremely happy with the documentation of this project and found it to be one of the best of a "hobby project" I worked with. With that in mind, I was just surprised that these changes between the versions were not yet documented smile Keep up your great work!

No, don't worry, I didn't get it that way! But you're right, it's still missing and I need to change that asap.. Oh, and thanks for the flowers! ;)

I think it should also be possible with e.g. 700 instead of 700.0, cuz in that case it will just query all possible 700.x - but maybe I'm wrong..

In MQTT you only subscribe to a certain topic. It seems to be the case that currently BSB-LAN only publishes the parameters to the "long" float address and not the shorter one. Personally I think that this is sufficient.

Hmm, ok, that's kinda weird.. I don't really know anything about MQTT tho, but there was just a user who reported a query using mosquitto and he only used the 1010 w/o the trailing .0 or even .00 and it worked (with the most recent version, so he wasn't referring to an old version)..

It's only one following ".0", so it's e.g. 700.0 - yes, that may be the reason!

This I also what I thought initially, but that did not work in my case. After upgrading I first wondered why my states are no longer updating in Home Assistant. Upon investigation, I observed a large amount of dropped messages on my broker. Eventually, I then found out that you have to subscribe to 700.00 with two trailing zeros. I have this running in my setup for the past weeks and just verified on my broker that I do not get messages on 700.0 and 700. I uploaded a screenshot, maybe this is helpful for others.

@fredlcore and/or @dukess Do you know why it is like that..?

1coderookie commented 1 year ago

@proasnet So did you already try using .0 or .00 after the parameter number?

proasnet commented 1 year ago

Yes, now I have theese in cfg

mqtt:
  sensor:
    - state_topic: "bsb-lan/8310.0"
      name: BSB-LAN flow temperature
      unit_of_measurement: °C
      device_class: temperature

No effect

1coderookie commented 1 year ago

..and 8310.00?

mirkolenz commented 1 year ago

Do you know why it is like that..?

@1coderookie It could also be the case that I have some "strange" configuration that causes this behavior. I once had a bug in BSB-LAN that was caused by a special combination of enabled and disabled functions.

1coderookie commented 1 year ago

@mirkolenz Well, but then it would be a bug and that shouldn't happen anyway.. ;)

@proasnet I dunno which heating system you have, but did you make sure beforehand using the webinterface if you have 8310 anyway?

mirkolenz commented 1 year ago

@1coderookie That is right :)

@proasnet What log interval did you set up in your config. I think the explorer/client will only show messages/topics that have been published since it has been connected to the broker. If you for example have an interval of one hour, no topic would be shown to you.

1coderookie commented 1 year ago

@proasnet What log interval did you set up in your config. I think the explorer/client will only show messages/topics that have been published since it has been connected to the broker. If you for example have an interval of one hour, no topic would be shown to you.

Oh yeah, that's right! @proasnet So if you aren't actively 'polling' with your broker and you didn't change the default loginterval of BSB-LAN, then you'd have to wait 60min/3600sec! So: either poll or change the loginterval within the webconfig of BSB-LAN..

proasnet commented 1 year ago

Yes, I have a value 8310.0 Diagnostics producer - Boiler temp actual value: 41.5 °C Here is only one decimal place. I tried this

mqtt:
  sensor:
    - state_topic: "bsb-lan/8310.00"
      name: BSB-LAN flow temperature
      unit_of_measurement: °C
      device_class: temperature

and no effect too. Yes, I have a 3600s. I try set 30, wait a moment please. This is a right!

proasnet commented 1 year ago

So, in explorer I see obrazek but status of entity still unknown json status is live now, every 30s is more datas

GSzabados commented 1 year ago

json status is live now, every 30s is more datas

I use plain text.

1coderookie commented 1 year ago

Nice! And you used "8830" as shown in the screenshot or what exactly?

fredlcore commented 1 year ago

Just one clarification regarding queries without the decimal point (i.e. 700 instead of 700.0 or 700.00): BSB-LAN is doing a numerical comparison. So if you query 700 it's numerically the same as 700.0, but not as 700.1. So querying 700 will only return the value of parameter 700, which is the same as 700.0, but it will not query 700.1 and following. You have to specifically query these because usually these also have a different meaning and are only logically put next to each other by the heater.

How each home automation system interprets the parameter numbers and what form it requires is a bit difficult to say because it depends on the way these parameters are queried. And this is only partly in our responsibility because it may depend on how any module or plugin deals with this. For example, if a module or plugin is still working with BSB-LAN v3.0 but internally only uses integer numbers (i.e. 700 instead of 700.0), then there may be problems with parameters such as 700.1.

On the other hand, I have not checked if all our way of connecting to the outside world (MQTT, JSON, plain HTTP requests) all use the same format. So it may be that one way uses or even requires a certain number format compared to the other. If anyone of you has clearly identified a discrepancy here, we will certainly try to fix it, or if not possible, mention the different ways of addressing the parameters in the manual.

mirkolenz commented 1 year ago

The major difference seems to be that @proasnet used a JSON payload. So you also need to update your home assistant config to handle these JSON values correctly with a value template.

In my setup, I use the plain text format and thus subscribe to a different topic for each sensor.

proasnet commented 1 year ago

Here is more parameters, on screenshot you see only one moment. I changed it to plain text, and see theese. obrazek refresh now every 30sec

mirkolenz commented 1 year ago

@fredlcore That all makes sense. So it could be the case that the MQTT integration is handling the numerical data differently. If for example I send a payload of 700 to the bsblan topic (i.e., request a status update), I get a response only on bsblan/700.00. But as I said this could also be caused by some configuration combinations on my side.

fredlcore commented 1 year ago

@mirkolenz: Could you specify again through which way you only were able to query parameters using two trailing digits? For now, I could only think of one trailing digit being required, not two. But if I know where to look, I'll look into it.

proasnet commented 1 year ago

but the result in the entity is still the same and the value is unknown

mirkolenz commented 1 year ago

@proasnet I would assume that this is caused by a mismatch of the topic. In your home assistant config, you have bsb-lan, but the explorer shows BSB-LAN. In MQTT, the capitalization matters if I remember correctly. If that does not help, you could try adding the following line to your sensor config:

value_template: "{{value | float}}"

tiger42 commented 1 year ago

@mirkolenz: Could you specify again through which way you only were able to query parameters using two trailing digits? For now, I could only think of one trailing digit being required, not two. But if I know where to look, I'll look into it.

The code that works in HA is this:

mqtt:
  sensor:
  - state_topic: "bsb-lan/8700.00"
    name: BSB-LAN Außentemperatur
    unit_of_measurement: °C
    device_class: temperature

That makes sense, as the topics in MQTT are always strings, not integers or floats. And as you can see in MQTT Explorer, the topics have two digits: image So if the topic is for example "bsb-lan/8700.00", you have to query it exactly like that, 8700 or 8700.0 or 8700.00000 won't work.

tiger42 commented 1 year ago

@proasnet I would assume that this is caused by a mismatch of the topic. In your home assistant config, you have bsb-lan, but the explorer shows BSB-LAN. In MQTT, the capitalization matters if I remember correctly. If that does not help, you could try adding the following line to your sensor config:

Capitalization in fact matters! In my BSB-LAN instance I've set the topic to lowercase letters for example, because uppercase in MQTT looks kind of awkward... But the default setting, if you haven't changed it, is "BSB-LAN" (uppercase).

mirkolenz commented 1 year ago

@fredlcore For all log parameters that I define in BSB-LAN (e.g., 700), the values are only exposed at an address with two trailing zeros (e.g., 700.00). All publishing options work as intended though, so publishing the payload S700=1 to the topic bsblan works just as well as S700.00=1 or S700.0=1. So the only area where this "bug" occurs is on the topics that one can subscribe to: bsblan/700 and bsblan/700.0 do not receive any values, only bsblan/700.00.

1coderookie commented 1 year ago

@tiger42 Thanks for that info, so I'll adjust your examples for the manual asap..

@fredlcore Thanks for the clearification about 700/700.0 and .1 etc..

proasnet commented 1 year ago

Yes, this working

mqtt:
  sensor:
  - state_topic: "bsb-lan/8700.00"
    name: BSB-LAN Außentemperatur
    unit_of_measurement: °C
    device_class: temperature

And in BSB Lan web I changed BSB-LAN to bsb-lan

proasnet commented 1 year ago

obrazek

mirkolenz commented 1 year ago

Great to hear that!

proasnet commented 1 year ago

obrazek

proasnet commented 1 year ago

Thank you. Tomorow I try add more sensors, and how set room temperature and mode of system, if will work. Good night

1coderookie commented 1 year ago

Great! Thanks to everybody for helping out! :+1:

GSzabados commented 1 year ago

Thank you. Tomorow I try add more sensors, and how set room temperature and mode of system, if will work. Good night

I tried to make a MQTT input select for mode selection, but I couldn't figure out how to use the select to change the right MQTT topic and keep the select at the same state. I spent hours with it to figure out and tried all the options what was possible, but either it did not change the mode or it reverted back immediately through the select to the previous mode.

If you figure out, please share it how it works for you.

mirkolenz commented 1 year ago

@GSzabados There you go:

mqtt:
  select:
    - name: Boiler operating mode
      unique_id: some_id
      state_topic: "bsblan/700.00"
      command_topic: "bsblan"
      availability_topic: "bsblan/status"
      # Example value: 1 - Automatic
      value_template: >
        {% set mapping = {0: 'Protection', 1: 'Automatic', 2: 'Reduced', 3: 'Comfort'} %}
        {% set idx = value.split() | first | int %}
        {{ mapping[idx] }}
      # Example payload: S700=1
      command_template: >
        {% set mapping = {'Protection': 0, 'Automatic': 1, 'Reduced': 2, 'Comfort': 3} %}
        S700={{ mapping[value] }}
      options:
        - Automatic
        - Comfort
        - Away
        - Eco
      icon: mdi:list-box

Please note that the specific available modes may be unique to your heating device.

GSzabados commented 1 year ago

BSB-LAN Version 3.0.1-20221101130752

@1coderookie, if I understand correctly the new version is working already and distributed as well on request?

1coderookie commented 1 year ago

What do you mean by 'distributed as well on request'? Yes, v3.x is up now, but there were major changes which you need to pay attention to if you want to upgrade (also the trailing .0 which was mentioned above btw)! We discussed some of that here: https://github.com/fredlcore/BSB-LAN/discussions/482 So if you want to update, you should make a complete new install without using any old files (like config.h or whatever). Then you'd need a specific custom_defs.h file from @fredlcore for your system to get access to the parameters your controller has to offer. Check out the manual (chap 2 and 3.3), there you'll find the infors.

1coderookie commented 1 year ago

@mirkolenz So there S700={{ mapping[value] }} it works without the .00??

dukess commented 1 year ago

Hi, it is a bug, i think. If this problem appears when used plain format, i can propose this solution (i hope it help): in file BSB_LAN/include/mqtt_handler.h replace lines

  } else {
    MQTTTopic.concat(String(param));
  }

with this fragment:

  } else {
    if(roundf(param * 10) != roundf(param) * 10)
      MQTTTopic.concat(String(param, 1));
    else
      MQTTTopic.concat(String(param,0));
  }

If the parameter is an integer, it will be passed without a separator and zero. Otherwise, one decimal place will be printed.

GSzabados commented 1 year ago

Please note that the specific available modes may be unique to your heating device.

Thanks! And how does Away and Eco selects Reduced and Protection? Actually I need to convert all of those to the old German phrases,

options:
           - "0 - Schutzbetrieb"
           - "1 - Automatik"
           - "2 - Reduziert"
           - "3 - Komfort"
mirkolenz commented 1 year ago

@1coderookie Yes exactly! That was what I tried to say in my response earlier:

For all log parameters that I define in BSB-LAN (e.g., 700), the values are only exposed at an address with two trailing zeros (e.g., 700.00). All publishing options work as intended though, so publishing the payload S700=1 to the topic bsblan works just as well as S700.00=1 or S700.0=1. So the only area where this "bug" occurs is on the topics that one can subscribe to: bsblan/700 and bsblan/700.0 do not receive any values, only bsblan/700.00.

So the bug only affects subscriptions, but nu publishing operations.