kotope/valloxesp

ESPHome and native API

Opened this issue · 82 comments

This is actually two questions:
Should this work with esphome?
What would it require to use valloxesp with the esphome/home-assistant native api?

Hi,

  • It does not work with ESPHome, only native Arduino + Home Assistant custom component.

  • To make it work with ESPHome a full rewrite would be required -> all the code has to be done through ESPHome configuration. I'm not that familiar with ESPHome so I can't guarantee if this could even be made work with ESPHome, since the hardware requires a custom protocol to work with Vallox Modbus.

It looks to me, according to this guide, like you can use any cpp/arduino code with esphome - the point being that people don't need to rewrite code written for other frameworks. I don't mean to push you - only make sure you are aware of this.

I accept the answer - of course. I had a look at your code and it looks really nice. Awesome work. Thank you for this project. I have ordered the components and intend to test it soon.

EDIT: Here's one example of a functioning arduino component integrated with (or wrapped into?) esphome.

Thanks for the info, after all ESPHome might be suitable for this also. Most probably would need to rewrite the .ino part of the code, but that should not be too big of a deal.

However, more work might need to be done to get rid of the custom_component along with that. I might have a look at this at some point, if I have time, but can't promise anything :-)

Actually I am currently trying to write a custom climate component in ESPhome by mostly copy/pasting your code.
So far after half a day I have the code working and it's updating a custom sensor with the fan speed (for testing basic functionality..).

However during that I noticed that the lastRetryLoop variable within void Vallox::loop() is never updated? I might be missing something but it looks like it stays 0 and thus the condition (now - lastRetryLoop > RETRY_INTERVAL) is true each time thus running the retryLoop() each time.

Ok, here's a cobbled together version that might need some improvement.
However it's working fine for me now.
How to install:

  • Drop Vallox.h into the esphome folder.
  • copy content of Vallox.yaml into your esphome config for your device (you might want to adjust the pins for the UART (serial connection), i'm currently testing/using a different esp8266 board (nodemcuv2)

Vallox_esphome.zip

Actually I am currently trying to write a custom climate component in ESPhome by mostly copy/pasting your code. So far after half a day I have the code working and it's updating a custom sensor with the fan speed (for testing basic functionality..).

However during that I noticed that the lastRetryLoop variable within void Vallox::loop() is never updated? I might be missing something but it looks like it stays 0 and thus the condition (now - lastRetryLoop > RETRY_INTERVAL) is true each time thus running the retryLoop() each time.

lastRetryLoop is being used on mode setters only. It is set as current time and will be cleared right once we got reply for our request. This ensures that the setters are always working even in case of transport failure.
Of course there can be bugs, need to debug a bit to see if there's something odd in there once I get back from vacation.

And thanks for making ESPHome version! I'm sure some will make big use of that :-)
You can of course fork my repository and keep maintaining the ESPHome version yourself if you like to.

Ok, here's a cobbled together version that might need some improvement. However it's working fine for me now. How to install:

* Drop Vallox.h into the esphome folder.

* copy content of Vallox.yaml into your esphome config for your device (you might want to adjust the pins for the UART (serial connection), i'm currently testing/using a different esp8266 board (nodemcuv2)

Vallox_esphome.zip

I'm using this now. As far as I can test it seems to work perfectly.

@kotope , considering that your blog might come up as one of the top hits when looking for a solution to control a vallox unit, it might be great if you could somehow also include it in your repo.. (also, I'm lazy :D)
If there is any question about the license (it's mostly your code anyways....), any changes done by me are public domain.

@kotope , considering that your blog might come up as one of the top hits when looking for a solution to control a vallox unit, it might be great if you could somehow also include it in your repo.. (also, I'm lazy :D)
If there is any question about the license (it's mostly your code anyways....), any changes done by me are public domain.

Right, I will add your ESPHome implementation to the repository and add a small text to the blog, once I get back home from a small vacation trip.
I will also mention your github name as contributor.

@github-k8n I just want to say thank you.

@kotope There are a few things still to fix, like a debug statements that were left in, proper formatting and some small issue where home assistant is showing it being turned on again after a few minutes when it was turned off via automation.. so if you can include that in the repo i can then send pull requests later for it (don't have that much time at the moment to completely fix it now ..)

One small note on usage i forgot to mention:
When using an ESP-01 make sure you do NOT include the "logger:" component.
(otherwise it will log debug output to the serial connection which is the same as the RS485 connection used there and cause the connection to fail and there seems to be no way of telling esphome to only log via API)
Thus, when debugging use some other ESP board with separate GPIOs.

According to esphome docs you can use UART0_SWAP.

Just created a branch for ESPHome implementation (https://github.com/kotope/valloxesp/tree/esphome)

ok, so now it should be hopefully be cleaned up, included the UART0_SWAP option, the off mode works fine, speed sensor is now also reporting 0 when ventilation is off .. #18

@MarkoPaasila as you might be at the moment the only other person using that code, let me know if you notice any issues or problems :)

I'm currently running the uponor branch because of my older machine, but I'll try this out soon.

Ok tested. I included the changes from the uponor branch and it all works.
When hvac_mode is turned off, the fans really turn off, speed is reported as 0, and only the control panel displays the previous speed. That is obviously out of scope for this project.
Turning the fans back on also works.

Can I somehow get the logger output to show raw hex values from communication both ways?

One thing that seems missing is reading the RH value.

Tried to add the RH values in #19

However I can't test as I don't have the sensors installed.

Will check later to see how if logging could be added if needed

First test no results. I'll have to check my files as I have combined lines from esphome and uponor branches... I'll be back.

It doesn't return the RH.

Hi together, sorry to be a little late.. but im making my way through.
i have already installed a ESP8266 D1 Mini nearby my Vallox for measuring my Water Flow - so my idea was to add the readings
and the sensors to my "old" ESP
so i purchased only the RS485 to TTL, made all the installations and the power suply trough the ESP8266 hardware ready to go!
Afterwards i wanted to go furthermore: i followed your hints:
#* Drop Vallox.h into the esphome folder.

  • copy content of Vallox.yaml into your esphome config for your device (you might want to adjust the pins for the UART (serial connection), i'm currently testing/using a different esp8266 board (nodemcuv2)#

I reconfigured your pins to mine and tried to flash the wohle thing - but im getting some errors:
no matching funtion fo call to ...

what im missing ---- there is no going furthermore.
Sorry for bad english... its a little bit rusty... :-)

You did add the Vallox.h file from here into your esphome directory?
https://github.com/kotope/valloxesp/tree/esphome/esphome

Can you paste your esphome config?
Can you paste the full log/error you are getting when trying to compile in esphome?

wow. nearly too fast:
i updated my vallox.h with your new one... connected sucessfully.... thank you very much!!!
settings

`"Code"esphome:
name: "wasseruhr-esp"
friendly_name: Wasseruhr
#Vallox
includes:
- Vallox.h

esp8266:
board: esp01_1m

Enable logging

logger:
#Vallox
baud_rate: 0

Enable Home Assistant API

api:
encryption:
key: "xxx"

ota:

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password

Enable fallback hotspot (captive portal) in case wifi connection fails

ap:
ssid: "xxx"
password: "xxx"
#Vallox
uart:
id: uart_bus
tx_pin: GPIO4
rx_pin: GPIO3
baud_rate: 9600
#Vallox

captive_portal:
globals:

  • id: total_pulses
    type: int
    restore_value: false
    initial_value: '0'
    binary_sensor:
  • platform: gpio
    id: internal_pulse_counter
    pin:
    number: GPIO5
    mode: INPUT_PULLUP
    name: "Impuls"
    filters:
    • delayed_on: 40ms
      on_press:
      then:
      • lambda: id(total_pulses) += 1;

#Vallox

  • platform: template
    id: vallox_switch_active
    name: vallox_switch_active
  • platform: template
    id: vallox_heating
    name: vallox_heating
  • platform: template
    id: vallox_on
    name: vallox_on
  • platform: template
    id: vallox_fault
    name: vallox_fault
  • platform: template
    id: vallox_rh_mode
    name: vallox_rh_mode
  • platform: template
    id: vallox_service_needed
    name: vallox_service_needed
  • platform: template
    id: vallox_summer_mode
    name: vallox_summer_mode
  • platform: template
    id: vallox_motor_in
    name: vallox_motor_in
  • platform: template
    id: vallox_motor_out
    name: vallox_motor_out
  • platform: template
    id: vallox_front_heating
    name: vallox_front_heating

sensor:

  • platform: template
    name: "Wasserverbrauch"
    device_class: water
    unit_of_measurement: "m³"
    state_class: "total_increasing"
    icon: "mdi:fire"
    accuracy_decimals: 2
    lambda: |-
    return id(total_pulses) * 0.01;
    ESP_LOGD("Wasserzähler TAG", "Pulse bisher: %d", id(total_pulses));

#Vallox

temperature sensors

  • platform: template
    id: vallox_outside
    name: vallox_outside
    device_class: temperature
    unit_of_measurement: "°C"
    accuracy_decimals: 0
  • platform: template
    id: vallox_inside
    name: vallox_inside
    device_class: temperature
    unit_of_measurement: "°C"
    accuracy_decimals: 0
  • platform: template
    id: vallox_incoming
    name: vallox_incoming
    device_class: temperature
    unit_of_measurement: "°C"
    accuracy_decimals: 0
  • platform: template
    id: vallox_exhaust
    name: vallox_exhaust
    device_class: temperature
    unit_of_measurement: "°C"
    accuracy_decimals: 0

misc sensors

  • platform: template
    id: vallox_speed
    name: vallox_speed
    accuracy_decimals: 0
  • platform: template
    id: vallox_default_fan_speed
    name: vallox_default_fan_speed
    accuracy_decimals: 0
  • platform: template
    id: vallox_service_period
    name: vallox_service_period
    unit_of_measurement: "months"
    accuracy_decimals: 0
  • platform: template
    id: vallox_service_counter
    name: vallox_service_counter
    unit_of_measurement: "months"
    accuracy_decimals: 0
  • platform: template
    id: vallox_heat_target
    name: vallox_heat_target
    device_class: temperature
    unit_of_measurement: "°C"
    accuracy_decimals: 0
  • platform: template
    id: vallox_rh1
    name: vallox_rh1
    device_class: humidity
  • platform: template
    id: vallox_rh2
    name: vallox_rh2
    device_class: humidity

diagnostics

  • platform: template
    id: vallox_diag_retries
    name: vallox_diag_retries
    entity_category: diagnostic
    accuracy_decimals: 0
    unit_of_measurement: " "
  • platform: uptime
    id: vallox_diag_uptime
    name: vallox_diag_uptime
    entity_category: diagnostic
    unit_of_measurement: "s"
    accuracy_decimals: 0
    number:
  • platform: template
    id: vallox_t_heat_recovery
    name: vallox_t_heat_recovery
    device_class: temperature
    entity_category: config
    unit_of_measurement: "°C"
    min_value: 0
    max_value: 20
    step: 1
    set_action:
    then:
    lambda: |-
    auto ptr = const_castcustom::CustomClimateConstructor&(id(my_vallox)).get_climate(0);
    static_cast<Vallox*>(ptr)->setHeatRecoveryBypassTemp(x);
    text_sensor:
  • platform: template
    id: vallox_switch_type
    name: vallox_switch_type
    climate:
  • platform: custom
    id: my_vallox
    lambda: |-
    auto my_vallox = new Vallox(id(uart_bus),
    id(vallox_outside),
    id(vallox_inside),
    id(vallox_incoming),
    id(vallox_exhaust),
    id(vallox_speed),
    id(vallox_default_fan_speed),
    id(vallox_service_period),
    id(vallox_service_counter),
    id(vallox_heat_target),
    id(vallox_rh1),
    id(vallox_rh2),
    id(vallox_diag_retries),
    id(vallox_t_heat_recovery),
    id(vallox_switch_type),
    id(vallox_switch_active),
    id(vallox_heating),
    id(vallox_on),
    id(vallox_fault),
    id(vallox_rh_mode),
    id(vallox_service_needed),
    id(vallox_summer_mode),
    id(vallox_motor_in),
    id(vallox_motor_out),
    id(vallox_front_heating)
    );
    App.register_component(my_vallox);
    return {my_vallox};
    climates:
    • name: "Vallox Climate""Code"`

no furthermore errors while installing! will report as soon as i got time from my wife! Thanks very much!

Seems like i installed the wrong Vallox.h file!

Happy to hear that it is working.

(When pasting code maybe use the "Code" feature above the text box, otherwise it becomes unreadable... :)

Small note, I heard about home assistant discontinuing the possibility to mark a sensor as "unavailable" by sending NaN as the value. Thus, if you don't have humidity sensors installed it could be that they might need to be commented out in the future (multiple lines in Vallox.h and Vallox.yaml) ... if anyone ever experiences issues around that let me know. (I don't have humidity sensors so I can't really test there..)

i tried to put it in with "Code" < > (by editing) but somehow i think the outgoing Format from my ESPHome integration in HomeAssistant wont give out the correct coding.

Somehow im getting furthermore errors - i tried to change the RX/TX Pins - Then i got more infos in my Dashboard but at least there are more than only a few without the right readings / writings

grafik

so i shot the first log of my esp:
logs_wasseruhr-esp_logs.txt
the second log is with changed RX/TX Pins - less correct readings and also missing entrys
so to get rid of the [21:26:11][W][component:214]: Component <unknown> took a long time for an operation (0.80 s). [21:26:11][W][component:215]: Components should block for at most 20-30ms.
i rewrote the whole yaml file and added on nearly every sensor a
" update_interval: 60s" argument... but also here no better readings... and the errors aren´t gone.

(by the way i have already installed 1 Rh (humidity) sensor.

I tested also to give my ORINALLY installed Controller (FDB 382) a other Bus Adress (i changed it to 2) because so you wont get a bus error... but also no positive changings...

Question here: is it nececary that ther are both RS485 to TTL LED´s are blinking? they only blink vise versa when im changing RX/TX?

Thanks in advance for your help!

You can try debugging UART https://esphome.io/components/uart.html#debugging ... to see if you actually get any data when you do something like changing the speed (via the "normal" (hardware) control panel, i.e. not vial HA/ESP).

I would also recommend to use a separate esp for vallox to see if everything works as expected. after that you can try to add a pulsemeter sensor or whatever you want to add there... (especially if you still have hardware issues?)

Finally I am currently in the process of completely redoing this integration as an external module (way easier to integrate that way) , but probably will not help in your case (the old integration is working fine for me..)

Ok, here is the new version. Just create a folder "external_components" in your esphome directory and extract the file there.. alternatively you can include external components directly from github.
@kotope , ideally if you just replace everything in the esphome branch with the content, then it can be pointed to directly according to https://esphome.io/components/external_components.html

Example yaml is included in the archive file

vallox_external_component.tar.gz

kotope commented

Thank you @github-k8n for the ESPHome support and helping people with this issue! 👍

I agree that it would be ideal for the ESPHome branch to contain only the ESPHome support.

Would you mind sending a pull request of this external component support for the ESPHome branch? As discussed earlier I'm currently only using the MQTT way and custom_component so I can't really test if before pushing to the branch :-)

Created #33 ... i think it still contained some previous small changes as i didn't sync the branch correctly before, but that should become irrelevant as those files were deleted anyways.. (i don't use git very often ...)

Ok, next attempt... #34

@sleepymaxx , you can give the rewrite a chance. Because it is using normal esphome UART definition, you can specify your pins there, maybe it helps.
See https://github.com/kotope/valloxesp/blob/esphome/example_vallox.yaml , you shouldn't need to copy any files, just use the external component part and the rest as written , it should use the files from the correct branch here.

If it doesn't work you can also uncomment the debug part in the UART. (maybe with "after: bytes: 6" instead of 1)..

Hi sorry for my late reply -family silvester + work as firefighter... so a little to less time these days.. -- i will try your workaround maybe today latest tomorrow.. i have to reassemble my whole esp and to make some changings in the hardwiring... i will post all writings and all logs as soon as possibile
Thank you again for your great work (in advance ;-) )

Good evening and a haapy new year.
Installed all
got all sensors in my Home Assistant but without any relevant data inside of it.

Tested: changing RX / TX (pin change)
Tested: external components copied locally
Tested: external components integrated by source over github
Tested: debug code on and off

Results: Every sensors dont give any relevant data ()
Results: the lights on the module are flashing in low mode..

My vallox is already working fine over the vallox original FDB 382
log of my esp run is attached.
Thanks in advance...
logs_wasseruhr-esp_run(2).txt

In your log it shows that you have serial logging enabled
[17:29:01][W][uart.arduino_esp8266:127]: You're using the same serial port for logging and the UART component. Please disable logging over the serial port by setting logger->baud_rate to 0.

Please disable local serial logging by adding the following to your devices yaml file:

logger:
  baud_rate: 0

Oh, and I guess you should also define "devicename" in your yaml :) .. i just copied that from my config..
In your case you could add this to your yaml:

substitutions:
  devicename: wasseruhr-esp

Good evening, substitutions: is a order wich is not allowed in Home Assistant.. so here no better results

Can you paste (as file) your yaml config for the esp device and I'll send back the correct config?

Here you go:
Config of Wasseruhr yaml: (had to rename it becaus of lack of support of uploading .yaml files so only exchange .txt with .yaml) to txt.:
wasseruhr-esp.txt
Latest logfile... :
logs_wasseruhr-esp_logs(1).txt

According to the log, the data is being sent but we do not receive any answer.
My guess is that something is wrong with the cabling.
Logs show:
TX Pin: GPIO3
RX Pin: GPIO1
You are sure that you connected them correctly to GPIO3 and GPIO1? (if you have them connected elsewhere then you can just specify the GPIO instead of using the RX/TX definitions which are device-dependent)
Maybe try reversing them to see if things improve
(typically if you connect devices you connect TX -> RX and RX -> TX , don't remember if here it was really TX -> TX as in kotope's description.... )

As for the rest, if you don't use substitutions (not sure why it wouldn't work for you, remeber we are talking about esphome, not HA substitutions.. https://esphome.io/guides/configuration-types.html#substitutions ) just name the sensors according to your taste.
Attached is the yaml file with some small changes (debug after 6 bytes makes it easier to read and changing the names of the sensors)
wasseruhr-esp.txt

correct i used GPIO1 TX and GPIO3 RX (and tested also vise versa)
grafik
okay will test if the GPIO commands will funct.
the naming of the sensors will have time... so when there is all funcioning i will go for the names and kill the old data of the wrong ones ;-)

Reg the RS485 module, you should see it quickly blinking if some data is transmitted.
Also I recommend to just connect it to the connectors on top of the device (see page 12 on the lower left here: https://vallox.de/wp-content/uploads/2023/09/BA_ValloPlus-350SE_2015-03.pdf ), it is less fiddly than playing around in the controller.. not sure if you already did it that way ..
(also make sure you have A and B connected correctly and not reversed, maybe try reversing on that side too..?)

Good evening,
Changed my yaml according to your recommendations afterwards
Tried the following:
[TX (Vallox) to TX (RS485) and RX (Vallox) to RX (RS485)]
& [TX (Vallox) to RX (RS485)and RX (Vallox) to TX (RS485)]

i changed in both configurations also the naming in the Yaml file for Tests: tx_pin: GPIO1 rx_pin: GPIO3 and tx_pin: TX rx_pin: RX

i changed in every configurations the RX/TX (RS485) to ESP pins:

Also i remembered the problem mentioned here and tested this configuration with both options mentioned above:
I tested also to give my ORINALLY installed Controller (FDB 382) a other Bus Adress (i changed it to 2) because so you wont get a bus error... but also no positive changings...

Results: either the RX or the TX led of my RS485 module are blinking (accordingly to connected pins from my ESP8266 D1mini) and the logfile is putting out very much (uart debugs):
logs_wasseruhr-esp_run(3).txt
in this moment i have no more ideas... perhaps my RS485 module is broken (but if its so it shoudn´t blink)?

Don't :D

Does the RS485 blink quickly in bursts? or just slow on/off ...
If any data is received you should see the bursts coming in .. also if you change anything (increase temperature or change fan speed on the originally installed controller) you should see additional quick flickering of the led

Thus, my suggestion:
Try completely without the esp, just connect the RS485 modules (make again sure that A and B are connected correct and the module has power (GND and VCC)
you should then see the RX led blinking quickly every few seconds from the data the mainboard is sending out...
(and as mentioned, I would not play around inside the original controller, just use the connectors on top...)

quickly in bursts with pauses of around 2-5s sec. (the pauses are always the same length also as the bursts... )

  • no the bursts are always only on one of the two leds - no flickering or anything else while changing any value on the original FDB382
  • tomorrow i will test your new configuration but i think (nearly know) that there will be no flickering or anything like that.... (while testting i made conections like this)
    ps: SORRY for too dumb questions

If it is still connected to the ESP then the bursts are from the esp, that is good. However we do not see any data from the RS485 bus which means that there is something wrong there

Maybe try reversing A and B on the RS485 side of the module...... the TX/RX side of things is clearly working ...)

(if you have an oscilloscope you could check the a/b lines for signals without anything connected other than the original controller...)

qvr commented

Hmm, I had a feature ready for the esphome branch to reset the service counter via esphome integration, but I now see that @github-k8n 's PR#34 has basically removed my previously merged features (#27 and #29). Was this intended?

Basically did a complete rewrite to clean it up and make it work better (as external module etc..) I can have a look tomorrow at the previous merges to integrate them...

Added retry logic in #35

As for the number components, i'm a bit at a loss how to integrate them in the external component (as optional subcomponent).. maybe @qvr has more input there ..

qvr commented

Haven't tried, but I think the number / button / other possible configurations could be done in the same component, as "Actions".

Example from a core component here:
https://github.com/esphome/esphome/blob/dev/esphome/components/pzemdc/sensor.py#L67-L78
and then it would be used from the yaml definition like this:
https://esphome.io/components/sensor/pzemdc.html#pzemdc-reset-energy-action

And if your device doesn't have those features, you'd just leave it out from the yaml definition, but it would still be a part of the component.

My reset service counter feature for the old custom component is here: qvr@c62d884 - that's a button that would look like this in HA:
image

qvr commented

...and the SDC30 component is a good example on how to register an action that can take value from the number sensor:
https://github.com/esphome/esphome/blob/dev/esphome/components/scd30/sensor.py#L122-L134
https://esphome.io/components/sensor/scd30.html#manual-calibration

I'd welcome a PR for the climate.py file. (and everything else of course).

The actual part inside the vallox.cpp and vallox.h where it controls the device is quite simple once you have defined the control() and publish_state() somehow...

TBH I can't completely wrap my head around how the buttons/numbers are defined correctly as subcomponents, thus if you can make it work on that side, I'd be more than happy to adjust the code that actually does things :)

Keep in mind that we would need to have at least a "name" suboption like for the sensors (don't want to hardcode those), optionally maybe a default value (for the number component). The example in the peacefair is one level too high i think, it is a component of the top config itself..

in my opinion it should look like this to set up in the config yaml file:

heat_bypass:                   # full section optional
  name: vallox heat bypass   # required if option is enabled
  default: 23                      # optional for this section

reset_service_counter:               # section optional
  name: vallox reset service counter         # required if this section is enabled

(While it is great to have everything controllable that can be controlled, my personal requirements don't really include changing the interval or resetting the counter at the moment ... that's what I can do with the controller when I change the filter.... so my enthusiasm to put too much effort into this is somewhat limited...)

qvr commented

The button / number sensors would not be subcomponents, they would be separate entities in the yaml definition that you would leave out if not using them. They would just call the actions of the vallox component.

The yaml would look much like this currently does, but call the component actions instead of doing the custom class instantiation calls they now do:
https://github.com/qvr/valloxesp/blob/c62d88434d989e33d081634fbf5b4d72a9464e54/esphome/Vallox.yaml#L89-L115

It's -25 C currently here, so I cant comfortably go breaking my current ventilation automations right now. Hopefully there were no other users using those features that you didn't need...

I guess at that temperature you probably don't want to enable/change summer bypass mode anyways :)

The config was intentionally kept as subcomponents of the climate: configuration, so having them partially below the other main parts like "number" or "binary_sensor" etc. was not the goal, instead having all below the "climate:" block which is the main required "type" of this device and has some optional controls/sensors.
See for example the sprinkler integration for example of number components (however there it is one level too deep, below valves)

To be more specific the "multiplier_number" part of the sprinkler is basically exactly how we would need to configure it.

So now i have to make a update of all (your great) work and have to say Thank You!

Late reply because i did a new install with a new RS485 of the whole thing - and after replugging my Vallox went do Death- (i accidently switched the +/ - output from the buck converter to the ESP8266 D1 mini) First i thougt my whole Vallox died later i thougt i killed my FDB382 - finally and luckily it only was the 800mA fuse inside the Vallox.

After shock pause ----- + finding my error and Replacing the fuse i replugged and vóila all your Work runs fine.

[(Here i Recommend for anyone who´s doing this in future to explicit and always go from RX to RX to RXD0 pins on all boards also to go from TX ot TX to TXD0 and from + to the Ground(strange chinese icons) to the Ground on your ESP) as this ist the right understanding of a ModBUS]

Got all my sensors an so on running fine in Home Assistant will try to rename and integrate it correctly into my Home Assistant the next days.
Last but not least there are some errors in the ESP-Home Logs. if you have the time for explaining or any idea of getting lost of the errors i will apreciate this very much.

[17:25:29][W][component:214]: Component vallox.climate took a long time for an operation (0.08 s).
[17:25:29][W][component:215]: Components should block for at most 20-30ms.

ESP-HOME - Log without DEBUG:
logs_wasseruhr-esp_run(4).txt

ESP-HOME - Log with DEBUG:
logs_wasseruhr-esp_run(5).txt

Actual. ESP Config:
wasseruhr - esp.yaml.txt

Thank you again for your great work!

Glad to hear it's working :) If i remember correctly I also had to change the fuse once, seems the ones from the factory are prone to issues... (or maybe I also let the wrong wires touch ... who knows :D )

As for the "error", those are warnings, not errors, introduced in recent ESPHome versions that just mention that the component took "too long" to do its thing... basically when getting the data, evalutating it etc.. that took around 80ms in your case.

Basically the idea is to ensure that other components (wifi, logging, etc) have a chance to run as well (more of an issue with esp8266, with an esp32 the wifi part is done on the other CPU core...)

TL;DR: You can ignore that, shouldn't affect functionality...

R: You can ignore that, shouldn't affect functio

Right! Thanks again for your great work!

Ok, finally some progress. I got the number components to work.
Next button press, hopefully I can finish it soon.

Small question to @qvr , which components are still missing in your opinion other than heat_bypass (number) and reset_service_counter (button) ?

@qvr , version with heat bypass control now in pull request, button will follow later..
#38

Now with setting to select the switch type and also fault details (variable 0x36) as text output
#40

Hello and thanks for the great work!

There are couple features I would like to see implemented into the ESPHome version:

  • Activation of the switch (button)
  • Setting the fan speed (number)

Hello and thanks for the great work!

There are couple features I would like to see implemented into the ESPHome version:

* Activation of the switch (button)

* Setting the fan speed (number)

So just to verify, you want the fan speed as a separate control (i.e. duplicated from its current place in the climate control), right? Any specific reason for that?

So just to verify, you want the fan speed as a separate control (i.e. duplicated from its current place in the climate control), right? Any specific reason for that?

Sorry, I meant the default fan speed. My Vallox behaves like this:
When changing the current fan speed directly on the device control panel it reverts back to the default fan speed after a while. I suspect it is because of the humidity sensor is controlling the fan speed.

Ok, added maximum and minimum/default fan speed controls.
(fan_speed_max and fan_speed_min)
(fan_speed_default sensor technically not necessary anymore but keeping for backwards compatibility right now.)

#41

(Switch button works here too now, waiting for this pull request to be accepted then doing another pull request adding the switch button probably tomorrow)

Switch button now added in #46

@kotope please merge :)

@HannuK0 please let me know if everything works as expected.

(Switch button works immediately but at the moment it could take up to 30 seconds until the switch binary sensor reflects the fact that the switch is active after you press the button in HA, not sure if that is the same if you press on the device itself but it is not pressing enough for me to investigate as the switch action can't be stopped and thus I don't want to play with it too much as it always takes time until i can test it again... )

If the (up to 30sec) delay of the sensor is an issue for you please let me know..

Hi again, im till today celebrating your great work... Thanks a lot!

But again im running into issues:
I have installed two Humidity sensors and a CO² Sensor - they are working really fine in the integrated Vallox Display .. and from time to time also in HA.... (mostly once in the month... ) so a little bad.

In the original integrated Vallox steering module the CO² sensor is polled only from time to time (i think somehow between 40sec. to 1 minute or so) between these times you can access the steering and only read the last value of humidity +CO² ### **AND WHILE CLAULATING THE HUMIDITY STATUS ** the Original steering module can´t be acessed or even the inputs won´t be noticed.

So i had the following idea:
(Accordingly to my former mentioned issues:
#[[17:25:29][W][component:214]: Component vallox.climate took a long time for an operation (0.08 s).#
#[17:25:29][W][component:215]: Components should block for at most 20-30ms.]#
and the Behavior of the Original Vallox humidity display i think the Steering is outlasted by calculating the CO² measurement and cant be accessed. So also if i pull any information while the CO² calculating is done these information can´t be read out of the Vallox.

So my question here is: Is there a way to interrupt the outreadings when the calculating is done or can we give more time for the UART Bus to wait for the information..... also i tried to change the polling time by home assistant - sadly without a positive change...

If it´s too much work please forget about it... the integration is working too fine and im using the measurements of the integrated sensors in pretty much of my other automations... (its only some kind of luxury problem so i can get much more consistent graphic outreadings and a better understanding of my house... )

Thanks for your answer...

I know that there are still some issues. I was thinking about maybe re-doing the whole data reading/writing logic to make it as some kind of state machine so that I can properly react to different scenarios (the different timings that are specified in the documentation to the protocol etc.)
However as you might have noticed that is a kind of "nice to have" and I am a bit too lazy at the moment (it is probably just too hot ...).

Just as some kind of "success story" If you want to know your humidity I can really recommend the xiaomi BT thermometers (there are bundles with just a few of them available if you don't want to go all in, but make sure that they are the same, basically look if the display looks exactly the same):
https://www.kaufland.de/product/445201238/
then flash them with custom firmware (use OTA in Chrome) (the original firmware would also work with Home Assistant but it is WAAY to slow to send updates (like 5 min vs 10 seconds)
https://github.com/pvvx/ATC_MiThermometer#readme
then integrate them into Home Assistant using the BTHome integration.
BUT be careful, the latest firmware doesn't seem to work anymore for flashing ... maybe try to get some "old stock"
(see more on this on the github link above)
You can also use simple ESP32 with ESPhome as bluetooth proxy so you have good reception if they are too far away for BLE to reach your Home Assistant.

(Got a bunch of them, one in every room and with hte custom firmware they are quick to react even with 0.01°C changes, so pretty cheap in total)

That way you can also check the humidity changes for example in the bathroom and increase the ventilation even if the overall humidity is not increasing that much.. (you can use the derivative helper sensor in HA to show you when the humidity changes quickly)

For the CO2 sensor I don't have a nice easy and cheap solution unfortunately ... but maybe when it gets colder maybe I can find some time to revisit this ... :)

TL;DR Maybe at some point in the future or maybe someone else can submit some pull request ...

All the time you are way much to fast for me.... - so i hope you will enjoy the great weather around you as long as possible... ;-) so i will wait with much patience if there will come some workaround.... as mentioned its only a luxury problem.

Your tips about other sensors are great and a very good idea!
... but i by myself am always looking for the maximum effort getting of the minimal used extra things...

Thank you again and have a nice end of summer... (we are also enjoing the great weather these days... )

Hello,

I got this up and running using D1 mini. But when I try to change the fan speed (with fan speed min slider) I can only increase the fan speed. Decreasing does not do anything.

Btw, I enabled a webserver on D1 mini so I can test this.
image

How can I decrease the fan speed? Vallox fan speed max does not do anything. Maybe I am misunderstanding something here :D

My yaml looks like this:

esphome:
  name: "vallox"
  friendly_name: "Vallox"

esp8266:
  board: esp01_1m

# Enable logging
logger:
  level: DEBUG

# Enable Home Assistant API
api:

external_components:
## only needed if you copy code locally into your esphome directory, see https://esphome.io/components/external_components.html#external-components-local
# - source:
#     type: local
#     path: components
#   components: [ vallox ]
## recommended, just point to the appropriate branch
  - source: github://kotope/valloxesp@esphome
    components: [ vallox ]

# Allow Over-The-Air updates
ota:
  platform: esphome

# Allow provisioning Wi-Fi via serial
improv_serial:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  
# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
  manual_ip:
    static_ip: 192.168.1.28
    gateway: 192.168.1.1
    subnet: 255.255.255.0

captive_portal:

# Status LED
status_led:
  pin: 
    number: GPIO2
    inverted: True

# To have a "next url" for improv serial
web_server:
  include_internal: True

switch:
  - platform: restart
    name: "Restart"
    id: device_restart

uart:
  id: uart_bus
  tx_pin: GPIO3
  rx_pin: GPIO1
  baud_rate: 9600
  data_bits: 8
  parity: NONE
  stop_bits: 1
  #debug:
  #  direction: BOTH
  #  dummy_receiver: false
  #  after:
  #    bytes: 1

climate:
  - platform: vallox
    name: vallox climate
    uart_id: uart_bus

    visual:
      min_temperature: 15
      max_temperature: 25

    # I don't have any heating element built in so it is just the heat exchanger and ventilation
    # Thus, I enable the heat exchanger for "heating", basically by setting WRG bypass to 00 (i.e. summer mode at 0°C)
    # and use heating_mode to control the bypass status (when heating_mode is on the heat exchanger turns on too, it can't be individually controlled)
    # See ValloxVentilation::control function for details

    # All sensors/controls below are optional and can be added or left off, if you add a sensor/control, name is a required setting
    # activate selected switch type function (fireplace/boost)
    switch:
      name: vallox switch
    # sensor for current fan speed (is also visible as custom fan mode in climate component)
    fan_speed:
      name: vallox fan speed
    # ** DEPRECATED, use fan_speed_min number instead, keeping for backwards compatibility now **  default fan speed (minimum fan speed)
    fan_speed_default:
      name: vallox fan speed default
    # Maximum fan speed (control / number)
    fan_speed_max:
      name: vallox fan speed max
    # Minimum/Default fan speed (control / number) (same value as fan_speed_default but with control)
    fan_speed_min:
      name: vallox fan speed min
    # temperature target, basically not used in my scenario other than having an indication for Home Assistant automations what temperature I would like to have (separate logic could be used with hystereses to heat/cool based on inside temperature and outside temperature)
    temperature_target:
      name: vallox temperature target
    # outside temperature
    temperature_outside:
      name: vallox temperature outside
    # inside temperature
    temperature_inside:
      name: vallox temperature inside
    # temperature of the exhaust (outgoing after heat exchanger (if active))
    temperature_outgoing:
      name: vallox temperature outgoing
    # temperature of the incoming air (incoming after heat exchanger (if active))
    temperature_incoming:
      name: vallox temperature incoming
    # what type of action can be triggered using the momentary switch (fireplace/boost)  Kamin/Stoßlüftungstaster
    switch_type:
      name: vallox switch type
    # Whether the ventilation is turned on
    status_on:
      name: vallox status on
    # Incoming motor running
    status_motor_in:
      name: vallox status motor in
    # outgoing motor running (gets disabled for example if you use switch_type fireplace)
    status_motor_out:
      name: vallox status motor out
    # the service interval (shown in months)
    service_period:
      name: vallox service period
    # the remaining months in this service interval
    service_remaining:
      name: vallox service remaining
    # gets active if you are past the service interval (you can reset the interval it in the menu of the control)
    service_needed:
      name: vallox service needed
    # if the switch (fireplace/boost) is currently active (boost might not make much sense if you already control the fan speed via Home Assistant, fireplace might be useful to disable the outgoing motor for 15 min)
    switch_active:
      name: vallox switch active
    # Heating element (i guess, don't have one built in)
    heating:
      name: vallox heating
    # heating mode (enabling this also disables any bypass aka summer_mode, see my comment on top)
    heating_mode:
      name: vallox heating mode
    # Another heating element (i guess, don't have one built in)
    front_heating:
      name: vallox front heating
    # whether the heat exchanger is bypassed (i.e. outside air comes in directly), aka WRG bypass
    summer_mode:
      name: vallox summer mode
    # Some problem with the device i guess?
    problem:
      name: vallox problem
    # heat bypass temperature (control / number)
    heat_bypass:
      name: vallox heat bypass
    # reset service_remaining months to service_period value (control / button)
    service_reset:
      name: vallox service reset
    # description of fault (if any)
    fault_condition:
      name: vallox fault condition
    # select switch type (boost/fireplace), same as switch_type but selectable (switch_type is only a sensor) (control / select)
    switch_type_select:
      name: vallox switch type select

Another question, how can I get everything visible in HA? I can't see any sensors etc anywhere?
image

The min and max are just that, minimum and maximum fan speeds. (I typically keep those as 1 and 8 respectively)

The option to set the fan speed is part of the climate control (see "Lüftermodus" below):

grafik

As for why it doesn't show up that seems to be a generic Home Assistant/ESPHome question...
You can try to re-add it. Go to integrations, esphome, remove the device (just there, not in the ESPHome dashboard), then add it again (should get automatically detected)

NICE! That was the trick. Very BIG thank you! :D
image

@sleepymaxx
I now did a complete overhaul of the code, basically making it non-blocking (read byte by byte and do non-blocking waiting for checksum responses etc..

Before I update the code though I would like to address the issues that you were facing with the CO2 sensor.

Would you be able to test the code if I send it to you or upload it here as zip file?

Also same request to anyone using this, if anyone is using an esp01_1m (or similar low performance esp8266) could you test my new code? Just let me know here.
(i switched to a new device basically an esp32-s3 zero combined with part of an Elfin-EW11 which makes it a very small footprint and my old setup seems to "work" (i.e. not crashing :D) but the rs485 seems to have some issue where it is not receiving anything and I don't want to troubleshoot my retired device)

If anyone wants to test the new code see https://codeberg.org/k8n/vallox
or just use the following source as external component (yaml file should be mostly the same)
(don't want to update the code here, at least not before extensive testing in case someone is referencing it directly in their setup) @sleepymaxx or anyone else, as mentioned, would be happy for any feedback especially things like the humidity or CO2 sensors as I can't test that myself...

  - source:
      type: git
      url: https://codeberg.org/k8n/vallox
      ref: v1.0.0
    components: [ vallox ]

I gave it a test on a ESP32, but I'm not getting any communication. However I didn't succeed with the original valloxesp code on a ESP32 either. I'll see if I have a spare ESP01 to test this.

It works for me on an ESP32 (even with esp-idf framework), maybe you have some issues with the RS485 communication itself?
Do you see receiving light blinking on the rs485 board? Do you see data coming in when you enable debug?
(you can remove all vallox components and just configure UART with the correct parameters and dummy receiver to see if there is any activity received on the bus)
https://esphome.io/components/uart.html#debugging
baud_rate: 9600
data_bits: 8
parity: NONE
stop_bits: 1
(and of course your TX/RX pins, make sure they are not reversed)

Also some tip: you can connect with the box on top of the device rather than the remote. (easier to connect with the bigger screw terminals)
(A, B, -, +, M (ground))
grafik

Right. The led is blinking, but I'm not getting any communication over UART. I don't have the opportunity to do any more troubleshooting at the moment, but will get back once I do!

if just "THE" led is blinking when you use this code then this probably just means that it is trying to send to the bus.
Typically there should be a second LED (one for sending, one for receiving), and ideally both should be blinking.
(i.e. even without the esp and just ground/vcc connected to the RS485 module you should get some blinking ..)