Node Red on RaspberryPi Zero - How to enable MQTT Autodiscover for Sensors

Hi everybody, I’m getting a bit frustrated with mqtt auto discovery. :woozy_face: Maybe there is some ace on here that can help me out.

Current Situation
I run a raspberry zero w to collect sensor data from my heat pump by using node-red.


There is quite a lot of information available from the serial port. This works great!

What I would like to achieve
Since Homeassistant provides mqtt auto discovery, I would like to enable my configuration in node-red to enable that. So far I have read a lot of blogs and installed node-red add-ons, but no luck.

For example this temperature sensor.

The function node on the left returns the temperature value like this
var newMsg = { payload: temperatureValue };

What do I need to configure exactly in node-red to make HA recognise this sensor in the mqtt auto discovery?

I’m sure that mosquito is properly configured already as I have a DTU sensor working fine with it.

Also playing with the inject node did not help.

msg.topic

homeassistant/sensor/aerosmart/120/aktuelleinnentemperatur/config

msg.payload

{
    "name": "Sonstiges Aktuelle Innentemperature",
    "stat_t": "homeassistant/sensor/aerosmart/120/aktuelleinnentemperatur",
    "uniq_id": "aerosmart_120_aktuelleinnentemperatur",
    "dev": {
        "name": "Frischluftheizung",
        "ids": "73722946-9bd0-4fc0-a0c1-ecf6a8036248",
        "cu": "http://10.111.0.30",
        "mf": "Drexel und Weiss",
        "mdl": "Aerosmart m",
        "sw": "1.0"
    }
}

Thanks a lot, Ike.

It doesn't like the 120
homeassistant/sensor/aerosmart/aktuelleinnentemperatur/config

It worked when I did the topic as above

It also works as

Topic: homeassistant/sensor/120/aktuelleinnentemperatur/config

Awesome thanks! That did the trick. :ok_hand:

Hi Ike, could you share your work on the Drexel and Weiss heat pump, I am looking for an integration but haven’t been successful so far!

Thanks, Martin

Sure, i postet a tutorial a few times back. Integration of Aerosmart m fresh air heating system into homeassistant

Of course the node-red stuff evolved and i now use it only on the raspberryies. Rest is Autodiscovery on the homeassistant blue.

1 Like

Thanks Ike, that’s super helpful! Do you also write data to the interface? Ultimately I wanted to adjust target temperatures depending on other conditions in the house (like availability of solar energy)

Not yet, but that should only be a matter of constructing the proper message and send it through homeassistant to node-red. I would need to investigate further, but habe limited time right now. The official docu from Drexel and Weiss should provide some info though.

1 Like

I just ordered a USB A/B cable (and that 90° adapter, thanks for the hint upfront) and can go directly into my home assistant server since this is next to my Drexel and Weiss aerosmart - means I will skip the MQTT part.
Would it be ok for you to share the Node Red implementation?

Thanks, Martin

Of course, should be downloadable here: aerosmartm.json - Google Drive

Awesome, thanks! Will let you know the progress! now I’m eagerly looking forward to getting my cables :clap:

1 Like

Please let me know if you have any findings that could improve the integration. I’m looking into setting values through serial out as well in parallel. It is very hard to find examples. By the way, it is likely that the debug port does not allow for “setting” of values. For this a modbus adapter is probably required.

Sources

Done :smiley: so many thanks for your Node-RED implementation!! It cost me some blood, sweat and tears and some back pain but I managed to integrate my x2 in full :partying_face:

The register reads are straight forward from your example. What I added is a read command - which actually requires to send a command to the address+1 (e.g. if you want to read the room temperature at address 200 from the ventilation system device 130, you send a “130 201”). The ventilation system then sends back the actual temperature from address 201 as well (e.g. 130 201 22300 for 22.3°C).

Consequently (or not…) if you want to write a value into a Read/Write register like the target room temperature at 5016 (of either of the devices 120 (which is the control console), 130, or 140) you need to write to 5016 straight away (e.g. 120 5016 2300 to set the target room temperature to 23°C). That said, writing is working like a charm through the USB connection!

I have an automation + scripts that trigger a read of all (relevant) registers every minute, since the x2 only sends a select number of registers at unpredictable times which wasn’t very satisfying.

Would not call the implementation super pretty :wink: but it works - using helpers to store the values coming from the x2, template sensors for read-only registers, button entities in Node-RED to trigger the read requests and the writes.

I am not sure if I need this, but I am sending each command twice (with a delay element that triggers 100ms after the initial one again) - I thing that the first command does not always go through, so this is a work-around…

I will do some clean-up and make it a bit more shareable and I am obviously happy to do so!

Many thanks again, your work (and the one of the others you mentioned) was really encouraging.

Here my current dashboard:

…and some eye powder from Node-RED:

1 Like

Thats great news! Happy that you got it running. Looking forward to the write part. :slight_smile: Thats what i’m missing.

hello everybody,
i was looking for a convenient way to monitor my aerosmart x² for years now… you guys actually did it!
i’ve already set up a raspi zero w2 with node red and started configuring and reading the values but as far is i see there could be a way to not start from 0 ?

would you please be so kind and share your latest configuration?
that would be so very much appreciated!
thank you in advance :slight_smile:

Great to see that others benefit too! :slight_smile:
The Node-Red flows i use, can be found here: aerosmartm.json - Google Drive

wow thx! that looks like a lot of work!
i’m already able to fetch some of the important values and i reconfigured the mqtt broker to work with my mosquitto homeassistant appliance… i can see my x² in homeassistant - i can’t believe it :slight_smile:

BUT…
most of the values do not fit :frowning:
my x² is configured to serve 2 homes at the same time and D&W needed 4 years to finalize a new version of the software that’s able to handle that without crashing from time to time…

so it seems everything is a little bit different here… i have some sort of “virtual devices” - i guess most of my data flows via 350

the question is - how do i figure out what is what ? i’m afraid i need to call d&w … again ^^

The way i started was adding a debug node to the serial node and monitored the output. The hope is that you would find some differentiator. I cannot help further, as i do not have this scenario.

thx! i’ve already done that … unfortunately the numbers make little sense in most cases …
i’m actually going to call d&w and ask if they have some sort of datasheet for the new version they’ve installed on our device.

oh and just in case @mliebl finds this thread again… i’d be very interested in your changes too :slight_smile:
(if i have created something useful i will of course post it here - but i guess this will take some time)

x2_plus.txt

This file contains all of the modbus parameters for the x² plus heatpump.
Now this is getting somewhere. (a lot of the parameters are wrong because of the software update a few years ago)

do you have any idea how to request those parameters?
Screenshot_20221201_175837

injecting a msg {payload: “120 201”} as martin suggested doesn’t seem to work (i guess i’m doing it wrong…)
the x² responds … but with whatever it likes… sometimes it delivers the date, sometimes values that aren’t even in the list i attached.

i found out one interesting thing to mention… in the serialport settings i needed to add \n to every line i send. THEN i can receive the wanted values but only if i send the request exactly 10 times… only after 10requests it will send me the new value and until then i get the last requested value… as if it didn’t realize that my request message is already finished.

GitHub - mliebl73/DrexelWeiss_x2 here is martins implementation :slight_smile: thx a million!

i figured out why my x² read requests behaved so weird. i had to go to “settings”, “betriebsparameter” and activate the “Modbus RTU” protokoll in there (on my d&w control panel)… now i can read every sensor whenever i want…


with the help of @mliebl’s git repository (thx again) i finally made some progress :slight_smile:

you need to install “node-red-contrib-home-assistant-websocket” nodes in order to have a convenient way create a flow that is not only able to create sensors but also control buttons

this is the current state of the flow


and this is a screenshot of the entities the flow automatically creates

well here you’ll find the flow.json file which you can directly import into node-red

there is absolutely no need to create any configuration .yaml files for HomeAssistant… no scripts, no helpers, no automations! :scream:

ok - you need to install the mosquitto mqtt broker addon :wink:
but beyond than that it’s just a matter of importing the flows.json file…

good luck, have fun!
:slight_smile: :partying_face:

1 Like