Tek603 Serial oillevel sensor on Homeassistant

Hello,
I have an oil level sensor and would like to capture this via home assistant. This is connected via USB. The device is a Tek603 and outputs serial data via USB. I have already tried to insert it via the configuration YAML but failed. I do not know how to configure it correctly, nor how to find the “value”. Can you please help me?

this is what it looks like now:

  - platform: serial
    serial_port: /dev/ttyusb1
    baudrate: 115200
    Bytesize: 8
    parity: N
    Stopbits: 1
    Xonxoff: false
    Rtscts: true
    Dsrdtr: true
    "
template: 
  sensor:
    - Name: "Heizoeltank stand" 
      unit_of_measurement: 'L'
      Value_template:

Information i got from here: Communication protocol of the Proteus EcoMeter TEK603 – Markus Fritze

I have also seen that there are ready-made Python scripts to send this data to home assistant but unfortunately I don’t know anything about it.

I hope you can help me. Big Thanks!

Long time ago, but I am at the same point. Did you find a solution?

I spent some time today looking into decoding this sensor. The documentation linked above helped, but is also a little confusing and can be simplified when only looking at the live data.
So here’s my try at something more understandable for our use case as far as I could determine from my experiments. The actual live data payload is at byte 12 to 19, most other data is fixed and can be ignored with the exception of the device time, possibly.
All multi-byte numbers are in Big Endian. In our case the largest numbers are 2 bytes or 16 bits long. For manual conversion, multiply the first byte by 256, then add the second byte. In some cases the first byte will be zero, rendering this step trivial.

Byte Index Description Remarks
0-1 Header always “SI
2-3 total length always 0x0016 = 22 for live data
4 command always 0x02 = 2 as we’re only receiving
5 flags always 0x10 = 16 when receiving live data
6 hour hour as set on the receiver device
7 minutes minutes as set on the receiver device
8 seconds seconds as set on the receiver device
9-10 EEPROM Start unused for live data
11-12 EEPROM Stop unused for live data
13 temperature in Fahrenheit + 40 Celsius: ((temperatureF - 40 - 32) / 1.8)
14-15 level in cm
16-17 capacity remaining in liters
18-19 full capacity in liters
20-21 checksum of bytes 0-19 CRC-16/XMODEM

PS: Doing any work on the checksum calculation does not seem important to me at this point. It is meant to protect against faulty data but a short USB connection should not cause any trouble there. Still a nice-to-have feature if we can use it.

PPS: According to the FHEM implementation of this sensor, a temperature value of -40 together with a level of 0 could indicate “no data”. This might be something to keep in mind as well.

My next step will be to try creating some value_template that can actually extract the data we want. According to the serial documentation this should be possible using the right filters. The CRC calculation might not be possible here, but as stated above, I don’t think it matters that much.

After some more reading it seems less likely to me that this is possible purely with the serial yaml configuration. Problems I see so far:

  • Transmission from the sensor does not terminate with a newline, so the read will likely never finish
  • data is in binary, I’m not sure how that would arrive in the process if some sort of ASCII input is the expectation

My best guess is that the reading and converting would have to be done using a custom python script. That should not be a problem in itself, but I have no idea where I would need to place and configure that, yet. Any pointers?

Edit:
Just to be sure I tried the serial configuration and as expected it never returns any value.
AppDaemon seems to be one way of doing what we’re looking for, but it’s a little more work than a simple YAML config. Some pointers can be found here: AppDaemon Serial Setup - AttributeError: module 'serial' has no attribute 'Serial'

I found a solution and it is working now for me.
The serial template in the configuration.yaml will not work, because it is indeed only supporting ascii text (and as mentioned only gives the info after a newline).
The way how it works (beautiful I must say) is via nodered.
This is the first time that I used nodered (I installed it before but never saw the use untill now)
This is how my configuration looks like

The first node connects to the serial port with the right baudrate and sends the byte buffer it receives to the next nodes. It does so after a timeout of 10s. not receiving any new bytes anymore.

The ‘ReadBigEndianCapacity’ Reads the 2 bytes in the buffer and converts them to the left fluid capacity

Same for the temperature (comes in handy) with function ‘ReadTemperature’

With the sensor node, we create a sensor which can be picked up automatically in HomeAssistant. This example is for the capacity censor.

The debug nodes give info with every receiving of data, especially because you only get data once / half an hour it takes a while to be able to debug. I used my other serial port which has an energy meter hooked up, to experiment a bit faster in the first stage of debugging. Have fun !

1 Like