Skip to content

Instantly share code, notes, and snippets.

@vytautasgimbutas
Forked from cliftonc/README.md
Created May 6, 2021 19:34
Show Gist options
  • Save vytautasgimbutas/df71fabd87218cfe708c7c26b6a105f6 to your computer and use it in GitHub Desktop.
Save vytautasgimbutas/df71fabd87218cfe708c7c26b6a105f6 to your computer and use it in GitHub Desktop.
Brink Flair 300 via Modbus

This is the setup I am using to publish events for my Brink Flair 300 heat recovery unit. I have a Raspberry Pi 3, with an RS485>USB, connected to the 2 & 3 pin of the X15 input of the HRU. The flow in Node-Red talks locally to the device via modbus, and then connects to an mqtt server that is used for further connection to Home Assistant, this appears to be the most robust solution.

I used this USB stick: Rpi RS485 USB, but I think any of them will work. You do not need to buy the super expensive 'digital adapter' and the app, and with this setup you also do not need the super expensive RF bridge and connectors (though will likely want some physical alternative to this setup to turn it on / off if needed).

It currently provides temperature, set fan speed, actual fan speed, binary sensors for max, medium, normal (same as the 4-way RF switch) and inputs for speed (50-300, +50, -50). I also have another flow connecting this to the output of my air sensor, so when the air quality drops or it detects us cooking it turns the ventilation on!

Huge thanks to https://github.com/sirjackal/brink-modbus as this was essential in making it all work and getting the steer towards Modbus being the way to connect.

Connection to Brink Flair

Use the 2 & 3 connections to the red X15 (note that mine came with a removable red plug already in it - so I just needed to connect it).

brink

Example in Home Assistant

small

large

Home Assistant Config:


sensor:
  - platform: mqtt
    unique_id: "ventilation/supply_temperature"
    name: "Ventilation Supply Temperature"
    state_topic: "ventilation/supply_temperature"
    unit_of_measurement: "°C"
    value_template: "{{ value }}"
  - platform: mqtt
    unique_id: "ventilation/outside_temperature"
    name: "Ventilation Outside Temperature"
    state_topic: "ventilation/outside_temperature"
    unit_of_measurement: "°C"
    value_template: "{{ value }}"
  - platform: mqtt
    unique_id: "ventilation/flow_speed"
    name: "Ventilation Flow Speed"
    state_topic: "ventilation/flow_speed"
    unit_of_measurement: "m3"
    value_template: "{{ value }}"
  - platform: mqtt
    unique_id: "ventilation/set_flow_speed"
    name: "Ventilation Set Flow Speed"
    state_topic: "ventilation/set_flow_speed"
    unit_of_measurement: "m3"
    value_template: "{{ value }}"
binary_sensor:
  - platform: mqtt
    unique_id: "ventilation/speed_normal"
    name: "Ventilation Normal Speed"
    payload_on: "on"
    payload_off: "off"
    state_topic: "ventilation/speed_normal"
    value_template: "{{ value_json.payload }}"
  - platform: mqtt
    unique_id: "ventilation/speed_medium"
    name: "Ventilation Medium Speed"
    payload_on: "on"
    payload_off: "off"
    state_topic: "ventilation/speed_medium"
    value_template: "{{ value_json.payload }}"
  - platform: mqtt
    unique_id: "ventilation/speed_max"
    name: "Ventilation Max Speed"
    payload_on: "on"
    payload_off: "off"
    state_topic: "ventilation/speed_max"
    value_template: "{{ value_json.payload }}"
switch:
  - platform: mqtt
    unique_id: fan_max_switch
    name: "Ventilation"
    state_topic: "ventilation/speed_max"
    command_topic: "ventilation/air_flow"
    payload_on: 300
    payload_off: 50
    state_on: "on"
    state_off: "off"
    optimistic: false
    qos: 0
    retain: true

sensor:
- platform: mqtt
unique_id: "ventilation/supply_temperature"
name: "Ventilation Supply Temperature"
state_topic: "ventilation/supply_temperature"
unit_of_measurement: "°C"
value_template: "{{ value }}"
- platform: mqtt
unique_id: "ventilation/outside_temperature"
name: "Ventilation Outside Temperature"
state_topic: "ventilation/outside_temperature"
unit_of_measurement: "°C"
value_template: "{{ value }}"
- platform: mqtt
unique_id: "ventilation/flow_speed"
name: "Ventilation Flow Speed"
state_topic: "ventilation/flow_speed"
unit_of_measurement: "m3"
value_template: "{{ value }}"
- platform: mqtt
unique_id: "ventilation/set_flow_speed"
name: "Ventilation Set Flow Speed"
state_topic: "ventilation/set_flow_speed"
unit_of_measurement: "m3"
value_template: "{{ value }}"
binary_sensor:
- platform: mqtt
unique_id: "ventilation/speed_normal"
name: "Ventilation Normal Speed"
payload_on: "on"
payload_off: "off"
state_topic: "ventilation/speed_normal"
value_template: "{{ value_json.payload }}"
- platform: mqtt
unique_id: "ventilation/speed_medium"
name: "Ventilation Medium Speed"
payload_on: "on"
payload_off: "off"
state_topic: "ventilation/speed_medium"
value_template: "{{ value_json.payload }}"
- platform: mqtt
unique_id: "ventilation/speed_max"
name: "Ventilation Max Speed"
payload_on: "on"
payload_off: "off"
state_topic: "ventilation/speed_max"
value_template: "{{ value_json.payload }}"
switch:
- platform: mqtt
unique_id: fan_max_switch
name: "Ventilation"
state_topic: "ventilation/speed_max"
command_topic: "ventilation/air_flow"
payload_on: 300
payload_off: 50
state_on: "on"
state_off: "off"
optimistic: false
qos: 0
retain: true
[
{
"id":"61755636.844f88",
"type":"tab",
"label":"Living Area",
"disabled":false,
"info":""
},
{
"id":"720e809d.ed139",
"type":"modbus-read",
"z":"61755636.844f88",
"name":"Supply Temperature",
"topic":"",
"showStatusActivities":false,
"logIOActivities":false,
"showErrors":false,
"unitid":"20",
"dataType":"InputRegister",
"adr":"4036",
"quantity":"1",
"rate":"1",
"rateUnit":"m",
"delayOnStart":false,
"startDelayTime":"",
"server":"9270f483.3edde8",
"useIOFile":false,
"ioFile":"",
"useIOForPayload":false,
"emptyMsgOnFail":false,
"x":170,
"y":100,
"wires":[
[
],
[
"4f132360.b4a2ec"
]
]
},
{
"id":"1cccf2a4.6b6bdd",
"type":"mqtt out",
"z":"61755636.844f88",
"name":"",
"topic":"ventilation/supply_temperature",
"qos":"",
"retain":"",
"broker":"1b1e9157.0451ff",
"x":690,
"y":100,
"wires":[
]
},
{
"id":"4f132360.b4a2ec",
"type":"change",
"z":"61755636.844f88",
"name":"",
"rules":[
{
"t":"set",
"p":"payload",
"pt":"msg",
"to":"$round(msg.payload.data[0]/10,1)\t",
"tot":"jsonata"
}
],
"action":"",
"property":"",
"from":"",
"to":"",
"reg":false,
"x":420,
"y":100,
"wires":[
[
"1cccf2a4.6b6bdd"
]
]
},
{
"id":"8cc7472a.b9b3d8",
"type":"mqtt out",
"z":"61755636.844f88",
"name":"",
"topic":"ventilation/outside_temperature",
"qos":"",
"retain":"",
"broker":"1b1e9157.0451ff",
"x":690,
"y":240,
"wires":[
]
},
{
"id":"1a6cdbbe.9c4a24",
"type":"change",
"z":"61755636.844f88",
"name":"",
"rules":[
{
"t":"set",
"p":"payload",
"pt":"msg",
"to":"$round(msg.payload.data[0]/10,1)\t",
"tot":"jsonata"
}
],
"action":"",
"property":"",
"from":"",
"to":"",
"reg":false,
"x":420,
"y":240,
"wires":[
[
"8cc7472a.b9b3d8"
]
]
},
{
"id":"57495b84.6dcf24",
"type":"modbus-read",
"z":"61755636.844f88",
"name":"Outside Temperature",
"topic":"",
"showStatusActivities":false,
"logIOActivities":false,
"showErrors":false,
"unitid":"20",
"dataType":"InputRegister",
"adr":"4046",
"quantity":"1",
"rate":"1",
"rateUnit":"m",
"delayOnStart":false,
"startDelayTime":"",
"server":"9270f483.3edde8",
"useIOFile":false,
"ioFile":"",
"useIOForPayload":false,
"emptyMsgOnFail":false,
"x":180,
"y":240,
"wires":[
[
],
[
"1a6cdbbe.9c4a24"
]
]
},
{
"id":"f5f4a63f.912878",
"type":"mqtt in",
"z":"61755636.844f88",
"name":"Air Flow",
"topic":"ventilation/air_flow",
"qos":"2",
"datatype":"utf8",
"broker":"1b1e9157.0451ff",
"x":120,
"y":580,
"wires":[
[
"2ebb3f58.2a4e5"
]
]
},
{
"id":"8c91642d.716a78",
"type":"modbus-read",
"z":"61755636.844f88",
"name":"Flow Speed",
"topic":"",
"showStatusActivities":false,
"logIOActivities":false,
"showErrors":false,
"unitid":"20",
"dataType":"InputRegister",
"adr":"4042",
"quantity":"1",
"rate":"5",
"rateUnit":"s",
"delayOnStart":false,
"startDelayTime":"",
"server":"9270f483.3edde8",
"useIOFile":false,
"ioFile":"",
"useIOForPayload":false,
"emptyMsgOnFail":false,
"x":150,
"y":340,
"wires":[
[
],
[
"49b645c0.5346dc"
]
]
},
{
"id":"1ae9143b.306cac",
"type":"mqtt out",
"z":"61755636.844f88",
"name":"",
"topic":"ventilation/flow_speed",
"qos":"",
"retain":"",
"broker":"1b1e9157.0451ff",
"x":660,
"y":340,
"wires":[
]
},
{
"id":"49b645c0.5346dc",
"type":"change",
"z":"61755636.844f88",
"name":"Set Flow Speed",
"rules":[
{
"t":"set",
"p":"payload",
"pt":"msg",
"to":"msg.payload.data[0]",
"tot":"jsonata"
}
],
"action":"",
"property":"",
"from":"",
"to":"",
"reg":false,
"x":380,
"y":340,
"wires":[
[
"1ae9143b.306cac"
]
]
},
{
"id":"bbc52552.f5b068",
"type":"mqtt in",
"z":"61755636.844f88",
"name":"Air Flow Up",
"topic":"ventilation/air_flow_up",
"qos":"2",
"datatype":"utf8",
"broker":"1b1e9157.0451ff",
"x":130,
"y":660,
"wires":[
[
"8f6dad8b.0fe15"
]
]
},
{
"id":"19188630.29e82a",
"type":"mqtt in",
"z":"61755636.844f88",
"name":"Air Flow Down",
"topic":"ventilation/air_flow_down",
"qos":"2",
"datatype":"utf8",
"broker":"1b1e9157.0451ff",
"x":140,
"y":740,
"wires":[
[
"11ef7c32.1e1cb4"
]
]
},
{
"id":"8f6dad8b.0fe15",
"type":"change",
"z":"61755636.844f88",
"name":"Add Speed",
"rules":[
{
"t":"set",
"p":"payload",
"pt":"msg",
"to":"$min([$flowContext('speed')+50,300])\t",
"tot":"jsonata"
}
],
"action":"",
"property":"",
"from":"",
"to":"",
"reg":false,
"x":330,
"y":660,
"wires":[
[
"2ebb3f58.2a4e5"
]
]
},
{
"id":"11ef7c32.1e1cb4",
"type":"change",
"z":"61755636.844f88",
"name":"Drop Speed",
"rules":[
{
"t":"set",
"p":"payload",
"pt":"msg",
"to":"$max([$flowContext('speed')-50,50])\t",
"tot":"jsonata"
}
],
"action":"",
"property":"",
"from":"",
"to":"",
"reg":false,
"x":330,
"y":740,
"wires":[
[
"2ebb3f58.2a4e5"
]
]
},
{
"id":"7cdeed74.8dd7a4",
"type":"function",
"z":"61755636.844f88",
"name":"Store Speed",
"func":"var speed = msg.payload;\nvar speedSetting = 'normal';\nflow.set('speed', speed)\nif (speed >= 150) {\n speedSetting = 'medium';\n}\nif (speed === 300) {\n speedSetting = 'max';\n}\nreturn { payload: speedSetting };",
"outputs":1,
"noerr":0,
"initialize":"",
"finalize":"",
"x":630,
"y":500,
"wires":[
[
"c6eaf3a8.a784c"
]
]
},
{
"id":"18799ec0.a2c261",
"type":"modbus-read",
"z":"61755636.844f88",
"name":"Set Flow Speed",
"topic":"",
"showStatusActivities":false,
"logIOActivities":false,
"showErrors":false,
"unitid":"20",
"dataType":"InputRegister",
"adr":"4031",
"quantity":"1",
"rate":"5",
"rateUnit":"s",
"delayOnStart":false,
"startDelayTime":"",
"server":"9270f483.3edde8",
"useIOFile":false,
"ioFile":"",
"useIOForPayload":false,
"emptyMsgOnFail":false,
"x":160,
"y":460,
"wires":[
[
],
[
"3f784458.59c1cc"
]
]
},
{
"id":"3f784458.59c1cc",
"type":"change",
"z":"61755636.844f88",
"name":"Set Flow Speed",
"rules":[
{
"t":"set",
"p":"payload",
"pt":"msg",
"to":"msg.payload.data[0]",
"tot":"jsonata"
}
],
"action":"",
"property":"",
"from":"",
"to":"",
"reg":false,
"x":380,
"y":460,
"wires":[
[
"7cdeed74.8dd7a4",
"bf904aa6.1d1f48"
]
]
},
{
"id":"bf904aa6.1d1f48",
"type":"mqtt out",
"z":"61755636.844f88",
"name":"",
"topic":"ventilation/set_flow_speed",
"qos":"",
"retain":"",
"broker":"1b1e9157.0451ff",
"x":680,
"y":440,
"wires":[
]
},
{
"id":"c6eaf3a8.a784c",
"type":"switch",
"z":"61755636.844f88",
"name":"Switch Type",
"property":"payload",
"propertyType":"msg",
"rules":[
{
"t":"eq",
"v":"normal",
"vt":"str"
},
{
"t":"eq",
"v":"medium",
"vt":"str"
},
{
"t":"eq",
"v":"max",
"vt":"str"
}
],
"checkall":"true",
"repair":false,
"outputs":3,
"x":810,
"y":500,
"wires":[
[
"96b351a9.1671e",
"c6f87409.423468",
"ab7d39fb.44db08"
],
[
"18669241.41cbae",
"c6f87409.423468",
"97080657.caeb18"
],
[
"18669241.41cbae",
"96b351a9.1671e",
"204894a1.6b58dc"
]
]
},
{
"id":"382ecb3a.3e2bd4",
"type":"mqtt out",
"z":"61755636.844f88",
"name":"Normal",
"topic":"ventilation/speed_normal",
"qos":"",
"retain":"",
"broker":"1b1e9157.0451ff",
"x":1280,
"y":360,
"wires":[
]
},
{
"id":"d961de3e.ee334",
"type":"mqtt out",
"z":"61755636.844f88",
"name":"Medium",
"topic":"ventilation/speed_medium",
"qos":"",
"retain":"",
"broker":"1b1e9157.0451ff",
"x":1280,
"y":460,
"wires":[
]
},
{
"id":"28c61ab0.d190b6",
"type":"mqtt out",
"z":"61755636.844f88",
"name":"Max",
"topic":"ventilation/speed_max",
"qos":"",
"retain":"",
"broker":"1b1e9157.0451ff",
"x":1270,
"y":540,
"wires":[
]
},
{
"id":"18669241.41cbae",
"type":"change",
"z":"61755636.844f88",
"name":"Normal Off",
"rules":[
{
"t":"set",
"p":"payload",
"pt":"msg",
"to":"off",
"tot":"str"
}
],
"action":"",
"property":"",
"from":"",
"to":"",
"reg":false,
"x":1070,
"y":340,
"wires":[
[
"382ecb3a.3e2bd4"
]
]
},
{
"id":"96b351a9.1671e",
"type":"change",
"z":"61755636.844f88",
"name":"Medium Off",
"rules":[
{
"t":"set",
"p":"payload",
"pt":"msg",
"to":"off",
"tot":"str"
}
],
"action":"",
"property":"",
"from":"",
"to":"",
"reg":false,
"x":1070,
"y":440,
"wires":[
[
"d961de3e.ee334"
]
]
},
{
"id":"c6f87409.423468",
"type":"change",
"z":"61755636.844f88",
"name":"Max Off",
"rules":[
{
"t":"set",
"p":"payload",
"pt":"msg",
"to":"off",
"tot":"str"
}
],
"action":"",
"property":"",
"from":"",
"to":"",
"reg":false,
"x":1060,
"y":549,
"wires":[
[
"28c61ab0.d190b6"
]
]
},
{
"id":"204894a1.6b58dc",
"type":"change",
"z":"61755636.844f88",
"name":"Max On",
"rules":[
{
"t":"set",
"p":"payload",
"pt":"msg",
"to":"on",
"tot":"str"
}
],
"action":"",
"property":"",
"from":"",
"to":"",
"reg":false,
"x":1060,
"y":580,
"wires":[
[
"28c61ab0.d190b6"
]
]
},
{
"id":"97080657.caeb18",
"type":"change",
"z":"61755636.844f88",
"name":"Medium On",
"rules":[
{
"t":"set",
"p":"payload",
"pt":"msg",
"to":"on",
"tot":"str"
}
],
"action":"",
"property":"",
"from":"",
"to":"",
"reg":false,
"x":1070,
"y":471,
"wires":[
[
"d961de3e.ee334"
]
]
},
{
"id":"ab7d39fb.44db08",
"type":"change",
"z":"61755636.844f88",
"name":"Normal On",
"rules":[
{
"t":"set",
"p":"payload",
"pt":"msg",
"to":"on",
"tot":"str"
}
],
"action":"",
"property":"",
"from":"",
"to":"",
"reg":false,
"x":1070,
"y":370,
"wires":[
[
"382ecb3a.3e2bd4"
]
]
},
{
"id":"2ebb3f58.2a4e5",
"type":"modbus-write",
"z":"61755636.844f88",
"name":"Air Flow",
"showStatusActivities":true,
"showErrors":true,
"unitid":"20",
"dataType":"HoldingRegister",
"adr":"8002",
"quantity":"1",
"server":"9270f483.3edde8",
"emptyMsgOnFail":false,
"keepMsgProperties":false,
"x":620,
"y":580,
"wires":[
[
],
[
]
]
},
{
"id":"1702ff05.241cd1",
"type":"modbus-write",
"z":"61755636.844f88",
"name":"Set Mode",
"showStatusActivities":false,
"showErrors":false,
"unitid":"20",
"dataType":"HoldingRegister",
"adr":"8000",
"quantity":"1",
"server":"9270f483.3edde8",
"emptyMsgOnFail":false,
"keepMsgProperties":false,
"x":320,
"y":820,
"wires":[
[
],
[
]
]
},
{
"id":"f4eac99b.f9c888",
"type":"inject",
"z":"61755636.844f88",
"name":"Set Mode",
"props":[
{
"p":"payload"
}
],
"repeat":"",
"crontab":"",
"once":false,
"onceDelay":0.1,
"topic":"",
"payload":"2",
"payloadType":"str",
"x":120,
"y":820,
"wires":[
[
"1702ff05.241cd1"
]
]
},
{
"id":"9270f483.3edde8",
"type":"modbus-client",
"name":"Ventilation",
"clienttype":"serial",
"bufferCommands":true,
"stateLogEnabled":true,
"queueLogEnabled":true,
"tcpHost":"127.0.0.1",
"tcpPort":"502",
"tcpType":"DEFAULT",
"serialPort":"/dev/ttyUSB0",
"serialType":"RTU-BUFFERD",
"serialBaudrate":"19200",
"serialDatabits":"8",
"serialStopbits":"1",
"serialParity":"even",
"serialConnectionDelay":"500",
"unit_id":"20",
"commandDelay":"10",
"clientTimeout":"1000",
"reconnectOnTimeout":true,
"reconnectTimeout":"2000",
"parallelUnitIdsAllowed":false
},
{
"id":"1b1e9157.0451ff",
"type":"mqtt-broker",
"name":"HomeAssistant",
"broker":"192.168.178.207",
"port":"1883",
"clientid":"",
"usetls":false,
"compatmode":false,
"keepalive":"60",
"cleansession":true,
"birthTopic":"",
"birthQos":"0",
"birthPayload":"",
"closeTopic":"",
"closeQos":"0",
"closePayload":"",
"willTopic":"",
"willQos":"0",
"willPayload":""
}
]
#!/usr/bin/env python3
import minimalmodbus
import math
instrument = minimalmodbus.Instrument ('/dev/ttyUSB0', 20) # port name, slave address (in decimal)
instrument.serial.baudrate = 19200 # Baud
instrument.serial.bytesize = 8
instrument.serial.parity = minimalmodbus.serial.PARITY_EVEN
instrument.serial.stopbits = 1
instrument.serial.timeout = 0.5 # seconds
instrument.mode = minimalmodbus.MODE_RTU # rtu or ascii mode
instrument.clear_buffers_before_each_transaction = True
value = instrument.read_register (8001, 0, 3, False) # Registernumber, number of decimals, function code
switchPositionEnum = {0: 'absence', 1: 'low', 2: 'medium', 3: 'high'}
print ('Power level:', value, '(' + switchPositionEnum [value] + ')')
value = instrument.read_register (4036, 0, 4, True)
print ('Supply temperature:', value / 10, 'C')
value = instrument.read_register (4046, 0, 4, True)
print ('Drain temperature:', value / 10, 'C')
value = instrument.read_register (4023, 0, 4, False)
print ('Inlet pressure:', value / 10, 'Pa')
value = instrument.read_register (4024, 0, 4, False)
print ('Outlet pressure:', value / 10, 'Pa')
value = instrument.read_register (4031, 0, 4, False)
print ('Set inlet air volume:', value, 'm3')
value = instrument.read_register (4032, 0, 4, False)
print ('Current inlet air volume:', value, 'm3')
value = instrument.read_register (4041, 0, 4, False)
print ('Output air volume set:', value, 'm3')
value = instrument.read_register (4042, 0, 4, False)
print ('Current air outlet volume:', value, 'm3')
value = instrument.read_register (6100, 0, 3, False)
bypassModeEnum = {0: 'automatic', 1: 'closed', 2: 'open'}
print ('Bypass mode:', bypassModeEnum [value])
value = instrument.read_register (4050, 0, 4, False)
bypassStateEnum = {0: 'initialize', 1: 'open', 2: 'closed', 3: 'open', 4: 'closed', 255: 'error'}
print ('Bypass status:', bypassStateEnum [value])
value = instrument.read_register (4100, 0, 4, False)
filterStateEnum = {0: 'clean', 1: 'spinavy'}
print ('Filter status:', filterStateEnum [value])
value = instrument.read_register (4060, 0, 4, False)
preheaterStateEnum = {0: 'initialize', 1: 'inactive', 2: 'active', 3: 'test mode'}
print ('Preheat status:', preheaterStateEnum [value])
value = instrument.read_register (4061, 0, 4, False)
print ('Preheat performance:', value, '%')
value = instrument.read_register (6033, 0, 3, False)
imbalanceEnum = {0: 'not allowed', 1: 'allowed'}
print ('Unbalanced:', imbalanceEnum [value])
value = instrument.read_register (6035, 0, 3, False)
print ('Supply unbalance:', value, '%')
value = instrument.read_register (6036, 0, 3, False)
print ('Deduction unbalance:', value, '%')
value = instrument.read_register (6000, 0, 3, False)
print ('Flow rate level 0 (absence):', value, 'm3')
value = instrument.read_register (6001, 0, 3, False)
print ('Flow rate level 1 (low):', value, 'm3')
value = instrument.read_register (6002, 0, 3, False)
print ('Flow rate level 2 (middle):', value, 'm3')
value = instrument.read_register (6003, 0, 3, False)
print ('Flow rate level 3 (high):', value, 'm3')
value = instrument.read_register (4115, 0, 4, False)
print ('Apply filter:', math.floor (value / 24), 'days')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment