valloxrs485

package module
v0.0.0-...-57e9d10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

README

Vallox RS485 serial interface module for Go lang

Overview

This module implements Vallox RS485 serial protocol. Currently it can:

  • read temperature reported by device: outside -> incoming -> inside -> outgoing
  • read ventilation fan speed
  • change ventilation fan speed

Made for https://github.com/pvainio/vallox-mqtt Vallox RS485 MQTT gateway for Home Assistant integration

Supported devices

The module has been tested with only one device so far:

  • Vallox Digit SE model 3500 SE made in 2001 (one with old led panel, no lcd panel)

Probably it will support other Vallox models using RS485 serial bus for remote controllers. It is possible that some registers have have changed through time since this device register does not match Vallox documentation.

Use at your own risk! Vallox documentation warns about using incorrect registers or incorrect values may damage the device.

Usage

To write registers (speed) Config.EnableWrite need to be set to true.

Example

package main

import (
	"log"

	valloxrs485 "github.com/pvainio/vallox-rs485"
)

var registers = map[byte]string{
	valloxrs485.FanSpeed:            "Speed",
	valloxrs485.TempIncomingOutside: "Ouside temp",
	valloxrs485.TempIncomingInside:  "Incoming temp",
	valloxrs485.TempOutgoingInside:  "Inside temp",
	valloxrs485.TempOutgoingOutside: "Outgoing temp",
}

func main() {
	cfg := valloxrs485.Config{Device: "/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A901IPIR-if00-port0"}
	vallox, err := valloxrs485.Open(cfg)

	if err != nil {
		log.Fatalf("error opening Vallox device %s: %v", cfg.Device, err)
	}

	for {
		event := <-vallox.Events()

		if !vallox.ForMe(event) {
			// Do not handle values addressed for someone else in the same bus
			continue
		}

		if name, ok := registers[event.Register]; ok {
			log.Printf("Received new value %s = %d", name, event.Value)
		} else {
			log.Printf("Received unidentified value register %d = %d", event.Register, event.Value)
		}
	}
}

Documentation

Overview

Package valloxrs485 implements Vallox RS485 protocol

Index

Constants

View Source
const (
	MsgDomain     = 0x01
	MsgPollByte   = 0x00
	MsgMainboard1 = 0x11
	MsgMainboards = 0x10
	MsgPanel1     = 0x21
	MsgPanels     = 0x20
)
View Source
const (
	RegisterIO07                 byte = 0x07
	RegisterIO08                 byte = 0x08
	RegisterCurrentFanSpeed      byte = 0x29
	RegisterMaxRH                byte = 0x2a
	RegisterCurrentCO2           byte = 0x2b
	RegisterMaximumCO2           byte = 0x2c
	RegisterCO2Status            byte = 0x2d
	RegisterMessage              byte = 0x2e
	RegisterRH1                  byte = 0x2f
	RegisterRH2                  byte = 0x30
	RegisterOutdoorTemp          byte = 0x32
	RegisterExhaustOutTemp       byte = 0x33
	RegisterExhaustInTemp        byte = 0x34
	RegisterSupplyTemp           byte = 0x35
	RegisterFaultCode            byte = 0x36
	RegisterPostHeatingOnTime    byte = 0x55
	RegisterPostHeatingOffTime   byte = 0x56
	RegisterPostHeatingTarget    byte = 0x57
	RegisterFlags02              byte = 0x6d
	RegisterFlags04              byte = 0x6f
	RegisterFlags05              byte = 0x70
	RegisterFlags06              byte = 0x71
	RegisterFireplaceCounter     byte = 0x79
	Register8f                   byte = 0x8f
	Register91                   byte = 0x91
	RegisterStatus               byte = 0xa3
	RegisterPostHeatingSetpoint  byte = 0xa4
	RegisterMaxFanSpeed          byte = 0xa5
	RegisterServiceInterval      byte = 0xa6
	RegisterPreheatingTemp       byte = 0xa7
	RegisterSupplyFanStopTemp    byte = 0xa8
	RegisterDefaultFanSpeed      byte = 0xa9
	RegisterProgram              byte = 0xaa
	RegisterServiceCounter       byte = 0xab
	RegisterBasicHumidity        byte = 0xae
	RegisterBypassTemp           byte = 0xaf
	RegisterSupplyFanSetpoint    byte = 0xb0
	RegisterExhaustFanSetpoint   byte = 0xb1
	RegisterAntiFreezeHysteresis byte = 0xb2
	RegisterCO2SetpointUpper     byte = 0xb3
	RegisterCO2SetpointLower     byte = 0xb4
	RegisterProgram2             byte = 0xb5
)

Registers based on Vallox documentation

View Source
const (
	IO08FlagSummerMode      byte = 0x02
	IO08FlagErrorRelay      byte = 0x04
	IO08FlagMotorIn         byte = 0x08
	IO08FlagPreheating      byte = 0x10
	IO08FlagMotorOut        byte = 0x20
	IO08FlagFireplaceSwitch byte = 0x40
)

Flags of variable 08

View Source
const (
	FanSpeed1 byte = 0x01
	FanSpeed2 byte = 0x03
	FanSpeed3 byte = 0x07
	FanSpeed4 byte = 0x0f
	FanSpeed5 byte = 0x1f
	FanSpeed6 byte = 0x3f
	FanSpeed7 byte = 0x7f
	FanSpeed8 byte = 0xff
)

Fan speeds

View Source
const (
	CO2Sensor1 byte = 0x02
	CO2Sensor2 byte = 0x04
	CO2Sensor3 byte = 0x08
	CO2Sensor4 byte = 0x10
	CO2Sensor5 byte = 0x20
)

Status flags of variable 2d

View Source
const (
	FaultSupplyAirSensorFault     byte = 0x05
	FaultCarbonDioxideAlarm       byte = 0x06
	FaultOutdoorSensorFault       byte = 0x07
	FaultExhaustAirInSensorFault  byte = 0x08
	FaultWaterCoilFreezing        byte = 0x09
	FaultExhaustAirOutSensorFault byte = 0x0a
)

Status flags of variable 36

View Source
const (
	Flags2CO2HigherSpeedReq   byte = 0x01
	Flags2CO2LowerSpeedReq    byte = 0x02
	Flags2RHLowerSpeedReq     byte = 0x04
	Flags2SwitchLowerSpeedReq byte = 0x08
	Flags2CO2Alarm            byte = 0x40
	Flags2CellFreezeAlarm     byte = 0x80
)
View Source
const (
	Flags4WaterCoilFreezing byte = 0x10
	Flags4Master            byte = 0xf0
)
View Source
const (
	Flags6RemoteControl           byte = 0x10
	Flags6ActivateFireplaceSwitch byte = 0x20
	Flags6FireplaceFunction       byte = 0x40
)
View Source
const (
	StatusFlagPower       byte = 0x01
	StatusFlagCO2         byte = 0x02
	StatusFlagRH          byte = 0x04
	StatusFlagHeatingMode byte = 0x08
	StatusFlagFilter      byte = 0x10
	StatusFlagHeating     byte = 0x20
	StatusFlagFault       byte = 0x40
	StatusFlagService     byte = 0x80
)

Status flags of variable a3

View Source
const (
	ProgramFlagAutomaticHumidity byte = 0x10
	ProgramFlagBoostSwitch       byte = 0x20
	ProgramFlagWater             byte = 0x40
	ProgramFlagCascadeControl    byte = 0x80
)
View Source
const (
	Flags5PreheatingStatus byte = 0xf0
)
View Source
const (
	IO07FlagReheating byte = 0x20
)

Flags of variable 08

View Source
const (
	Program2FlagMaximumSpeedLimit byte = 0x01
)
View Source
const RHDivider = 2.04
View Source
const RHOffset = 51
View Source
const TimeDivider = 2.5

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Device file for rs485 device
	Device string
	// RemoteClientId is the id for this device in Vallox rs485 bus
	RemoteClientId byte
	// Enable writing to Vallox regisers, default false
	EnableWrite bool
	// Logge for debug, default no logging
	LogDebug *log.Logger
}

Config foo

type Event

type Event struct {
	Time        time.Time   `json:"time"`
	Source      byte        `json:"source"`
	Destination byte        `json:"destination"`
	Register    byte        `json:"register"`
	RawValue    byte        `json:"raw"`
	Value       interface{} `json:"value"`
}

type Vallox

type Vallox struct {
	// contains filtered or unexported fields
}

func Open

func Open(cfg Config) (*Vallox, error)

Open opens the rs485 device specified in Config

func (Vallox) Events

func (vallox Vallox) Events() chan Event

Events returns channel for events from Vallox bus

func (Vallox) ForMe

func (vallox Vallox) ForMe(e Event) bool

ForMe returns true if event is addressed for this client

func (Vallox) Query

func (vallox Vallox) Query(register byte)

Query queries Vallox for register

func (Vallox) SetDefaultFanSpeed

func (vallox Vallox) SetDefaultFanSpeed(speed byte)

SetDefaultFanSpeed changes default speed of ventilation fan

func (Vallox) SetMaxFanSpeed

func (vallox Vallox) SetMaxFanSpeed(speed byte)

SetMaxFanSpeed changes maximum speed of ventilation fan

func (Vallox) SetSpeed

func (vallox Vallox) SetSpeed(speed byte)

SetSpeed changes speed of ventilation fan

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL