Greetings fellow HA earthlings… hope you can advise me with my dilemma to create some sensor templates
Background:
I just figured out how to connect to our Heat Recovery Ventilation System (MVHR) using a USB to RS-485 serial adaptor (see post here). I don’t believe its using Modbus though.
After consulting a technical document I found online (link), I can connect a Linux VM using Minicom (terminal emulator) and the settings provided in the manual. I can send it commands and they work successfully. The output looks like this (with the system typically generating a command output every 15 seconds automatically - note none of my efforts to copy/paste commands are listed in this example):
1510+00000
151+00000
1520+00000
152+00000
1540+00000
154+00000
3260+00000
326+00000
0601+00000
060+45505
061+02050
061+02050
(then repeats this output again every 15 seconds).
Progress to date:
So using the vendors technical document and a bit of trial and error, i’ve divised a ‘codebook’ which looks something like this:
Value | Description | Submit/Receive Msg. | Notes |
---|---|---|---|
1510+00000 | Speed 1 off | Submit >>> | |
1510+00001 | Speed 1 on | Submit >>> | |
1520+00000 | Speed 3 off | Submit >>> | |
1520+00001 | Speed 3 on | Submit >>> | |
1540+00000 | Speed 4 off | Submit >>> | |
1540+00001 | Speed 4 on | Submit >>> | |
3260+00000 | Boost off | Submit >>> | |
3260+00001 | Boost on | Submit >>> | |
0301xxxxxx | Thermistor 1 (stale in) | Submit >>> | |
030+00207 | Thermistor 1 (stale in) | Receive <<< | Translates 20.7 Degrees C. |
0311xxxxxx | Thermistor 2 (stale out) | Submit >>> | |
031+00137 | Thermistor 2 (stale out) | Receive <<< | Translates to 13.7 Degrees C. |
0321xxxxxx | Thermistor 2 (fresh in) | Submit >>> | |
032+00107 | Thermistor 2 (fresh in) | Receive <<< | Translates to 10.7 Degrees C. |
0361xxxxxx | Internal Humidity | Submit >>> | |
036+00055 | Internal Humidity | Receive <<< | Translates to 55% Relative Humidity (RH) |
0601xxxxxx | Time Running (hours) since commissioning | Submit >>> | |
060+45482 | Time Running (hours) since commissioning | Receive <<< | 45482 hours = 5.19 years |
3411xxxxxx | Filter remaining time (if all zeros, needs replacing | Needs checking/validation | |
0611xxxxxx | Any errors to report? | Submit >>> | |
061+02050 | Response 1 example | Receive <<< | |
The Goal:
It would be great to build a number of sensors and switches to essentially manage the MVHR unit via serial (RS-485). Below is an incorrect ‘work in progress’ of starting to put these templates together. I need help in how to finish the “Sensor” templates correctly. I just can’t figure out how to tell it to output the last few digits as seperate sensors, which are based on what the 1st part of the message code is (i.e before the “+” delimiter).
EG: 032+00107 is broken down as:
“032+” is the reference for “Fresh in” and the output state/attribute is “10.7°C”
Any feedback greatly appreciated
Sample 1st draft of templates below (i’m aware its incorrect (and not finding the specific ‘if’ syntax):
sensor:
- platform: serial
serial_port: /dev/ttyUSB1
name: MVHR
baudrate: 1200
template:
sensor:
- name: MVHR Temperature (Stale in)
unit_of_measurement: "°C"
state: "{{ states('sensor.MVHR').split('+')[1] | float(default=0) }}"
- name: MVHR Temperature (Stale out)
unit_of_measurement: "°C"
state: "{{ states('sensor.MVHR').split('+')[1] | float(default=0) }}"
- name: MVHR Temperature fresh in)
unit_of_measurement: "°C"
state: "{{ states('sensor.MVHR').split('+')[1] | float(default=0) }}"
- name: MVHR Humidity
unit_of_measurement: "%"
state: "{{ states('sensor.MVHR').split('+')[1] | float(default=0) }}"
- name: MVHR uptime (total)
unit_of_measurement: "h"
state: "{{ states('sensor.MVHR').split('+')[1] | float(default=0) }}"
- name: MVHR Current Speed (1-4)
unit_of_measurement: ""
state: "{{ states('sensor.MVHR').split('+')[1] | float(default=0) }}"
- name: MVHR Boost Status
unit_of_measurement: ""
state: "{{ states('sensor.MVHR').split('+')[1] | float(default=0) }}"
- name: MVHR Summer Bypass Mode (on/off)
unit_of_measurement: ""
state: "{{ states('sensor.MVHR').split(':')[4] | float(default=0) }}"
- name: MVHR Frost Protection Mode (on/off)
unit_of_measurement: ""
state: "{{ states('sensor.MVHR').split(':')[4] | float(default=0) }}"
- name: MVHR Fault Code
unit_of_measurement: ""
state: "{{ states('sensor.MVHR').split(':')[4] | float(default=0) }}"
I haven’t made an attempt to propose a switch example (don’t want to embaress myself further!). Would be great to get a suggestion for such. There may also need to be automations to trigger requests for sensor data such as sensor temperatures etc… but thats for a later date
As above, any constructive pointers and/or feedback greatly appreciated