valloxrs485

package module
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: GPL-3.0 Imports: 9 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 (
	DeviceMulticast       = 0x10
	DeviceMain            = 0x11
	RemoteClientMulticast = 0x20
)
View Source
const (
	// Reading and writing fan speed
	FanSpeed byte = 0x29

	// Registers Vallox is broadcasting temperatures
	TempIncomingOutside byte = 0x58
	TempOutgoingInside  byte = 0x5a
	TempIncomingInside  byte = 0x5b
	TempOutgoingOutside byte = 0x5c

	// Registers for newer protocol
	TempIncomingOutsideNew byte = 0x32
	TempOutgoingInsideNew  byte = 0x34
	TempIncomingInsideNew  byte = 0x35
	TempOutgoingOutsideNew byte = 0x33

	RhHighest          byte = 0x2a
	Co2HighestHighByte byte = 0x2b
	Co2HighestLowByte  byte = 0x2c
	Rh1                byte = 0x2f
	Rh2                byte = 0x30
)

Some known registers

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       int16     `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) 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