gonzojive / heatpump

Tools for communicating with the Chiltrix CX34 heat pump using a Raspberry Pi
Apache License 2.0
6 stars 2 forks source link

Write to CX34 #25

Open sodabrew opened 1 year ago

sodabrew commented 1 year ago

~It doesn't look like there's currently any code to write to the CX34?~ I wasn't looking at tip of main, it's right there: https://github.com/gonzojive/heatpump/blame/main/cx34/cx34.go#L147 what's the intended difference vs. https://github.com/gonzojive/heatpump/blame/main/cx34/cx34.go#L168 ?

I want to modulate the loop temperature to stay close to the building target temp so that I can keep air handler circulation fans running at low speed most of the time without overshooting. Home Assistant's Thermostat widget has a PID control algorithm and has a hook to switch from Heat to AC. So my goal here would be an HTTP interface:

Ok, so there's a gRPC interface! A little command line gRPC client would be awesome for local testing. gRPC probably fine for embedding into an HA module.

gonzojive commented 1 year ago

Holy cow, a user!

Look around the markdown files for instructions about how to use grpcui. I think there is also a command line version of that (grpccli maybe?).

sodabrew commented 1 year ago

Following up from https://github.com/gonzojive/heatpump/issues/24#issuecomment-1525080163, I changed the capitalization of cx34.setHeatingTemp to SetHeatingTemp, and duplicated the method for SetCoolingTemp and SetDomesticHotWaterTemp and voila! Thanks again for the fantastic jumping-off point. I'm basically just doing CLI ergonomics, the core comms protocol is all there already.

heatpump@heatpump:~/chilcmd $ ./chilcmd -set-cooling-temp 60f -unit 1
Summary for CX34 unit 1:
  Mode: Cooling
  COP: 0.00 (stopped)
  Power: 0.00 Watts
  Outdoor Temp: 54.14 °F
  Active Target Temp: 62.60 °F             <<< BEFORE
  Heating Target Temp: 87.80 °F
  Inlet Temp: 59.00 °F
  Outlet Temp: 56.66 °F
  Pump Speed: 0.01 l/s
  Useful Heat Rate: 0.1329kg/s * -1.3°K * 4kJ/(kg * °K) = -691J/s = -0.69kW
Setting cooling target temp to 60.00°F     <<< WRITE TO DEVICE

heatpump@heatpump:~/chilcmd $ ./chilcmd -unit 1
Summary for CX34 unit 1:
  Mode: Cooling
  COP: 0.00 (stopped)
  Power: 0.00 Watts
  Outdoor Temp: 54.14 °F
  Active Target Temp: 60.80 °F             <<< AFTER
  Heating Target Temp: 87.80 °F
  Inlet Temp: 59.36 °F
  Outlet Temp: 56.66 °F
  Pump Speed: 0.01 l/s
  Useful Heat Rate: 0.1329kg/s * -1.5°K * 4kJ/(kg * °K) = -798J/s = -0.80kW
sodabrew commented 1 year ago

I posted up my CLI at https://github.com/sodabrew/chilctl -- reusing your cx34 and units modules and adding a new CLI interface. I'd be glad to put up PRs for the changes to the cx34 module! Let me know if you're interested in adding a CLI here, I would be glad if the end result is merging everything back in.

gonzojive commented 1 year ago

Nice!

I plan to eventually rework this library a bit. Adding a CLI like the one you wrote would be a nice addition.

I tended to use grpcui for most interaction after launching the collector.