heatpump

module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2022 License: Apache-2.0

README

Chiltrix CX34 dashboard software

This project is used to communicate with a hydronic heating system that uses the Chiltrix CX34 air-to-water heat pump. The components of the system are as follows:

  1. A Raspberry Pi.

  2. The Chiltrix CX34 heat pump chiller. The Pi communicates with the chiller using using serial communication, which is used natively by the CX34 to talk with its controller per the wiring diagram and ProtoAir FPA-W44 manual.

  3. A USB-to-RS484 dongle that connects the Raspberry Pi to the Chiltrix. This device should show up as /dev/ttyUSB0.

  4. Optional DS18B20 temperature sensors, which can now be bought for about $2 each. Several temperature sensors can be connected to single GPIO port on the Pi. I followed this guide to get up and running and then wrote the github.com/gonzojive/heatpump/tempsensor Go package to read the sensor values.

screenshot of dashboard as of 2020/12/24

There is also work in progress Google Home integration, which allows setting the temperature of the fan coil units from the Google Home app. You can also say commands like:

  • "Set the temperature to 72 degrees"
  • "Set the fan speed to low"

screenshot of dashboard as of 2020/12/24

Implementation notes

This project is written in Go.

Setup

Software installation

Install go on the Raspberry Pi according to the official instructions.

Install the collector binary as of the latest version:

go install github.com/gonzojive/heatpump/cmd/cx34collector@latest github.com/gonzojive/heatpump/cmd/cx34install@latest

Install the systemd service so the service runs at boot.

sudo `which cx34install`

Inspect the logs with

journalctl -u cx34collector.service

CX34 control

General development tips

Wiring

The Chiltrix uses RS485 to communicate with its controller. I have a USB-to-RS484 with a ch340T chip and pins labelbed "A / D+" and "B / D-".

TODO: more info

ssh access with password login disabled

My ~/.ssh/config has a section like

Host waterpi
    HostName 192.168.86.22
    User pi

and the Pi's ~/.ssh/authorized_hosts and /etc/ssh/sshd_config has a section with

# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication no

sshfs

Mounting the Raspberry Pi's OS can be helpful for developing on a workstation. I followed this guide and ran these commands:

sudo mkdir /mnt/waterpi
sudo chown <YOUR_USERNAME> /mnt/waterpi
sudo sshfs -o "allow_other,default_permissions,IdentityFile=/home/<YOUR_USERNAME>/.ssh/id_rsa" pi@192.168.86.22:/ /mnt/waterpi

Fan coil unit control and scheduling

There is a gRPC server that can be started for getting and setting fan coil state. Run this command on the fan coil unit:

go run fancoil/cmd/fancoil_status/fancoil_status.go --alsologtostderr --start-server --grpc-port 8083

You can then run the scheduler on the device:

go run fancoil/cmd/fancoil_schedule/fancoil_schedule.go --alsologtostderr --fancoil-service localhost:8083

Cloud services

For the Google Home app integration to work, some cloud-hosted services are needed. These can be deployed as follows:

1) Build and push docker images

(optional): Build the docker images used to run all of the services. This is also done automatically by a Cloud Build hook that is triggered by pushes to main, but it can be useful for pushing local images.

./cloud/deployment/cloudbuild/image-pusher/push-all-images.sh

2) Update the images referenced by the Terraform config

Terraform is used to deploy the Cloud Run images based on the contents of cloud/deployment/terraform/environments/infra-dev/image-versions.json, which is pulled into the main terraform config cloud/deployment/terraform/environments/infra-dev/main.tf.

To update the pinned version of the images, run the following:

bazel run --run_under="cd $PWD &&" //cmd/cloud/update-image-versions -- --alsologtostderr --input "cloud/deployment/terraform/environments/infra-dev/image-versions.json" --output "cloud/deployment/terraform/environments/infra-dev/image-versions.json"

Directories

Path Synopsis
cloud
acls
Package acls is the main library used by cloud services to authenticate clients and check that they have access to named resources.
Package acls is the main library used by cloud services to authenticate clients and check that they have access to named resources.
acls/deviceauth
Package deviceauth is a library for obtaining credentials on an IoT device for authenticating with some of the cloud services like StateService and CommandQueueService.
Package deviceauth is a library for obtaining credentials on an IoT device for authenticating with some of the cloud services like StateService and CommandQueueService.
acls/server2serverauth
Package server2serverauth is used for sending gRPC requests between Google Cloud hosted services (like Cloud Run instances).
Package server2serverauth is used for sending gRPC requests between Google Cloud hosted services (like Cloud Run instances).
google/server/fulfilment
Package fulfillment implements a server that responds to Google Smart Home "fulfilment" requests.
Package fulfillment implements a server that responds to Google Smart Home "fulfilment" requests.
httpendpoint
Package httpendpoint is an OAuth 2 server for operating a home's fan coil units using Google Asistant.
Package httpendpoint is an OAuth 2 server for operating a home's fan coil units using Google Asistant.
queue/queueclient
Package queueclient provides a rich client library wrapping the gRPC client for CommandQueueService.
Package queueclient provides a rich client library wrapping the gRPC client for CommandQueueService.
queue/queueserver
Package queueserver implements a gRPC service run on a (cloud) server that relays Pub/Sub messages to IoT devices.
Package queueserver implements a gRPC service run on a (cloud) server that relays Pub/Sub messages to IoT devices.
secrets
Package secrets is a utility library for retrieving secrets from Google Secret Manager.
Package secrets is a utility library for retrieving secrets from Google Secret Manager.
stateservice
Package stateservice implements a centralized IoT device state storage service.
Package stateservice implements a centralized IoT device state storage service.
cmd
authservice
Program authservice starts the AuthService.
Program authservice starts the AuthService.
cloud-listener
Program cloud-listener subscribes to pub/sub thermostat commands and dispatches them to the fancoil service.
Program cloud-listener subscribes to pub/sub thermostat commands and dispatches them to the fancoil service.
cloud/http-endpoint
Program http-endpoint is an OAuth 2 server for operating a home's fan coil units using Google Asistant.
Program http-endpoint is an OAuth 2 server for operating a home's fan coil units using Google Asistant.
cloud/update-image-versions
Program update-image-versions generates a JSON file that resolves docker image names to digests.
Program update-image-versions generates a JSON file that resolves docker image names to digests.
cx34collector
Program cx34collector collects information from the Chiltrix CX34 heat pump and logs it to a database.
Program cx34collector collects information from the Chiltrix CX34 heat pump and logs it to a database.
cx34dash
Program cx34runs a dashboard that displays information about a CX34 heat pump.
Program cx34runs a dashboard that displays information about a CX34 heat pump.
cx34install
Program cx34install installs a systemd service for cx34collector according to https://www.raspberrypi.org/documentation/linux/usage/systemd.md.
Program cx34install installs a systemd service for cx34collector according to https://www.raspberrypi.org/documentation/linux/usage/systemd.md.
protocol-analyzer
Program waterpi reads temperature sensors.
Program waterpi reads temperature sensors.
queueserver
Program queueserver is a cloud-hosted service for sending commands to IoT devices.
Program queueserver is a cloud-hosted service for sending commands to IoT devices.
reverse-proxy
Program reverse-proxy forwards all http traffic from this process to a remote url.
Program reverse-proxy forwards all http traffic from this process to a remote url.
stateservice
Program stateservice starts a controller.StateService intende to be hosted in Google Cloud.
Program stateservice starts a controller.StateService intende to be hosted in Google Cloud.
Package cx34 provides a client for working with the Chiltrix CX34 heat pump.
Package cx34 provides a client for working with the Chiltrix CX34 heat pump.
Package dashboard runs a web dashboard that displays information about a CX34 heat pump.
Package dashboard runs a web dashboard that displays information about a CX34 heat pump.
Package db implements a database for storing the history of the state of the CX34
Package db implements a database for storing the history of the state of the CX34
Package fancoil communicates with a Heat Transfer Products (and presumably Chiltrix) fan coil unit.
Package fancoil communicates with a Heat Transfer Products (and presumably Chiltrix) fan coil unit.
cmd/fancoil_status
Program fancoil_status prints out the status of any connected fan coil.
Program fancoil_status prints out the status of any connected fan coil.
Package linuxserial provides utilitis for working with serial devices in Linux.
Package linuxserial provides utilitis for working with serial devices in Linux.
Package mdtable helps construct markdown tables.
Package mdtable helps construct markdown tables.
Package omron assists in deciphering omron communication protocol message.
Package omron assists in deciphering omron communication protocol message.
proto
Package tempsensor provides an API for reading DS18B20-based temperature sensors.
Package tempsensor provides an API for reading DS18B20-based temperature sensors.
Package units contains float64 wrappers with unit semantics relevant to the CX34 heat pump (flow rate, temperature, etc).
Package units contains float64 wrappers with unit semantics relevant to the CX34 heat pump (flow rate, temperature, etc).
util
bazelrunfiles
Package bazelrunfiles helps read runtime data files for programs built using Bazel.
Package bazelrunfiles helps read runtime data files for programs built using Bazel.
cmdutil
Package cmdutil contains utilities for writing CLIs.
Package cmdutil contains utilities for writing CLIs.
grpcserverutil
Package grpcserverutil contains utilities for running gRPC servers.
Package grpcserverutil contains utilities for running gRPC servers.
lockutil
Package lockutil provides a sync.Lock implementation that ensures a certain interval of time has passed since the last time a lock was acquired.
Package lockutil provides a sync.Lock implementation that ensures a certain interval of time has passed since the last time a lock was acquired.
modbusutil
Package modbusutil provides a wrapper around a modbus.Client that allows locking the client.
Package modbusutil provides a wrapper around a modbus.Client that allows locking the client.
must
Package must contains generic functions for ensuring a function is called that returns a nil error.
Package must contains generic functions for ensuring a function is called that returns a nil error.

Jump to

Keyboard shortcuts

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