Hcalory BLE--Control a Hcalory diesel heater from HA

tl;dr I wrote this custom integration to control Bluetooth-enabled Hcalory diesel heaters.

My partner and I built a greenhouse this summer. It’s great and we love it, but it doesn’t stay warm enough on cold winter nights. I threw an electric heater out there and set up a generic thermostat to control it, but 1500 watts of heat output could only generate a 15 °F temperature delta. That’s fine if it’s 40 °F outside, but less fine when it’s 20 °F. We only have 120V power out there and I didn’t feel like trenching out a 240V line.

Instead, I bought a diesel heater. I did this because I already had some experience with these things (I have a small machine shop that I heat with one), they can pump out a lot of heat (I don’t know if I believe the 8kW rating, but they’re substantially more powerful than a 1500 watt electric heater), and they don’t use much electrical power (they use 1-200 watts to heat up a glow plug, and then they drop down to ~30 watts). With the diesel heater + electric heater, we’re able to hit 40 °F temperature deltas in a drafty, uninsulated greenhouse, meaning we should be able to keep the it above freezing.

I was pretty happy with my heater, but I had two issues with it:

  • The thermostat sucks
    • The temperature sensor is right next to the thing that’s on fire
    • If you want to have your room heated to 60 °F, you’d better set the thermostat to 80 °F or higher, because you’ll end up with a bubble of hot air that’ll throw everything off
  • When using the thermostat, the heater never turns off
    • Instead, the heater drops to its lowest power mode when the thermostat setpoint is reached. This means that the heater is always burning fuel
    • This makes a lot of sense if you’re powering the heater off of a battery, because it takes much more electrical power to heat up a cold glow plug than it does to keep a glow plug warm using flame juice
    • It’s terrible for me because I run my heater off of kerosene which is $7 a gallon at a pump that’s 15 minutes away

These two issues were so aggravating that they drove me to reverse engineer the Bluetooth protocol used by Hcalory and write the custom integration linked above. It unaccountably works! It’s still pretty flakey, but this is my first experience with reverse engineering a Bluetooth protocol, with writing code to interact with devices over Bluetooth, and with writing any sort of code for Home Assistant. A bit of flakiness is to be expected, and I’m pretty pleased with the results.

In retrospect, I do kinda wish I had bought a heater that was compatible with the excellent Afterburner diesel heater controller. It would have taken a lot less time, and an Afterburner board + MQTT is probably muuuuch more reliable than my baling-wire and bubblegum mess. Still, it was fun to learn how to RE Bluetooth stuff, and going this route meant I didn’t have to do any disassembly of my heater.

For any Bluetooth experts out there, I’d love advice on how to improve the reliability of this thing. I have to maintain an active Bluetooth connection to read data off of the heater (the notify channel doesn’t send any data unless you poke the heater, and there are no BLE broadcasts), and that’s proven to be a bit of an issue. Connection reestablishment is mostly handled in the underlying hcalory-control library, but some of it is also done in the integration itself. I’m already using bleak_retry_connector with some really long timeouts, but every now and then the heater just goes dead to the world from the POV of my BLE proxies.

I’d also love to hear people’s thoughts on climate entities. I’m currently using this heater with a generic thermostat that uses the average of 6 H/T sensors to get a more accurate temperature. The thermostat just toggles the switch entity provided by the integration, running the heater at its max power. I came across some other integrations that create a climate entity using external sensors, but those devices seem to be built expecting the external input for what the temperature is. The thermostat built into this heater only reads from the built-in thermometer, so I didn’t think a climate entity made much sense. Am I wrong in thinking that? Or is telling people to just use a generic thermostat fine?

Anyways, this is getting way too long, so I’ll cut myself off here.

Awesome you wrote this. I tried clicking the install add-on and got error.

image

1 Like

Oooops! I am good devloper. Let me take a look…

EDIT: Fixed. When setting up the link, I put the entire Github URI in the repository field. The little redirect thingy assumes HACS integrations are coming from Github, so I just needed to put hcalory-ble in that field.

Getting this error.

Also you need to update your documentation and issue_tracker urls. You show hcalory_ble, when you really need hcalory-ble.

image

Ah, nice catch. I’ll update those. With regards to the screenshot you posted, are you referring to the warning at the bottom of the screen? I honestly haven’t been looking at the logs from the Bluetooth proxy connected to my heater. I should probably check that out.

Also, be aware that this is a really rough integration right now. I’m still running into the occasional glitch, where the entity states just stop getting updated. Debug logs coming from the integration show updates happening normally, so I’m not really sure why the state in Home Assistant gets stuck.

All good. Just want to get connected, maybe i can assist. That said. The btproxy connects to it, but when i add to integration page. it fails saying its already established

Ah, that’s strange. Let me try removing my heater and then add it back.

Yours work?

It did. I’m very puzzled. I deleted it from the integration page, then I restarted Home Assistant for good measure. When HA came back up, I saw the heater show up as a discovered device on the Integrations page. I simply clicked the add button, clicked submit, and then was asked where the device was.

There must be some environmental difference or assumption I’m making that’s causing the problem. Think you could send me the logs from Home Assistant itself? I’m hoping I’ve added enough logging, but if you don’t see anything showing up in the settings->system->logs page related to hcalory or heater then I can make some modifications so the integration screams and shouts about every little thing it’s doing.

Edit: Also, I just want to apologize for this being so jank right now. I’ve been doing software for over a decade, but this is my first time ever writing code for Bluetooth or Home Assistant. It’s a very different type of software development from what I’m used to!

Hmm. I’ve had a lot of reliability issues with this, and it seems like part of it is down to some weird connectivity issues when actually turning the heater completely on or off. It uses a lot more power when doing so, and I wonder if there’s some sort of interference happening. It wouldn’t surprise me if these cheap heaters weren’t very well shielded.

Thanks for this development. I will give it a try and gives you feedback

Unfortunately it doesn’t seems to work with my Vevor diesel heater. I got a connection error when I add the Bluetooth address