Serial communication and templates (RS-485)

I’m trying to create a read/write communication with an oldschool ventilation unit (Vallox) that uses RS-485 to communicate with control panels. I would like to use my HASS as a additional “control panel”. I have 2 USB-adapters and I have succesfully created a communication link between my PC and Rasp running the vanilla image of Home Assistant that you can download from the site.

Right now I am able to send messages from my PC. For example this would be temperature of the air supply:

01 11 20 5B 93 20

Last byte is the actual reading, one before that is the address and others are constant. I have this configuration now:

sensor:
  - platform: serial
    serial_port: /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0
    baudrate: 9600
  - platform: template
    sensors:
      vallox_tuloilma:
        friendly_name: Vallox Tuloilma
        unit_of_measurement: "°C"
        value_template: "{{ states('sensor.serial_sensor').split(' ')[5] | float }}"

It does work like I planned but now I would like to make it a bit more sophisticated without learning python or anything like that because I would like to keep this quite simple and use out of box features. So the thing I need help in is creating a set of conditions with templates so that I would only read messages beginning with 01 11 20 5B and then I could set few addresses that I am interested in?

Another thing is writing to serial bus for fan speed commands. Is it possible without installing complex addons?

Thanks in advance :grinning:

Still working on this one. My first message was a bit optimistic as I didn’t have the actual USB stick with serial communication attached to my Raspberry Pi. Now it is and I am able to receive the communications with SSH. It looks like this:

~ $ cat /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0
!!!q!q +] ,^ 5!5h!5
 2 3 *-!!!)\!)k!5h!5!!!q!q^C)\!)k!5h!5!!!q!q +] ,^ 5
~ $ 

Doesn’t make much sense like that. But when I convert it to hex with byteswap it starts to make sense to me:

~ $ hexdump -C /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0
00000000  01 11 20 2b 00 5d 01 11  20 2c 00 5e 01 11 20 35  |.. +.].. ,.^.. 5|
00000010  a6 0d 01 11 20 34 a7 0d  01 11 20 32 a3 07 01 11  |.... 4.... 2....|
00000020  20 33 a9 0e 01 11 20 2a  2d 89 01 21 11 00 a3 d6  | 3.... *-..!....|
00000030  01 11 21 a3 01 d7 01 21  11 00 29 5c 01 11 21 29  |..!....!..)\..!)|
00000040  0f 6b 01 21 11 00 35 68  01 11 21 35 a6 0e 01 21  |.k.!..5h..!5...!|
00000050  11 00 a3 d6 01 11 21 a3  01 d7 01 21 11 00 71 a4  |......!....!..q.|
00000060  01 11 21 71 00 a4 01 21  11 00 a3 d6 01 11 21 a3  |..!q...!......!.|
00000070  01 d7 01 21 11 00 29 5c  01 11 21 29 0f 6b 01 21  |...!..)\..!).k.!|
00000080  11 00 35 68 01 11 21 35  a6 0e 01 21 11 00 a3 d6  |..5h..!5...!....|
00000090  01 11 21 a3 01 d7 01 21  11 00 71 a4 01 11 21 71  |..!....!..q...!q|
000000a0  00 a4 01 21 11 00 a3 d6  01 11 21 a3 01 d7 01 21  |...!......!....!|
000000b0  11 00 29 5c 01 11 21 29  0f 6b 01 21 11 00 35 68  |..)\..!).k.!..5h|
000000c0  01 11 21 35 a6 0e 01 21  11 00 a3 d6 01 11 21 a3  |..!5...!......!.|

My question now is that how can I get my serial_sensor to get these values using value templates? For example hex message 01 11 21 35 a6 would be a temperature reading that I want to display in Home assistant. Value A6 is NTC-sensor reading that would convert to decimal and celsius like this: A6=166 (decimal)=22(celsius) according to communication protocol from manufacturer of the unit. I have been trying to study manuals like there is no tomorrow but I need some help to get started as I am a newbie in this kind of programming.

I would have exactly the same use case. I also have a Vallox ventilation system and have always operated it with OpenHAB via a serial adapter until today. Now I have switched to Home Assistant and there is no solution out of the box for the old ventilation system. Have you found a solution in the meantime? Can you share the code?

I did find a readymade solution. The guy who designed it has pretty good instructions in his blog: Guide: Vallox Digit Ventilation to Home Assistant (Part 1/2 – hardware) – Creating Smart Home