Integrating Smart HVAC Systems with ESPHome

I recently embarked on an exciting project to integrate my Swegon W3 ventilation system into Home Assistant using ESPHome and the Modbus integration. This journey has been both challenging and rewarding, and I wanted to share my experience with the community in case it can inspire or assist others.

Project Background
My goal was to monitor and control my ventilation system’s performance, including tracking temperatures, humidity levels, and fan speeds. The Swegon W3 is equipped with a Modbus interface, making it a great candidate for integration with ESPHome. I connected the system using an ESP8266 and a low-cost RS485 module.

Challenges Faced
One of the initial hurdles was understanding the Modbus register mappings provided by Swegon. I referenced their documentation extensively and cross-referenced data points to ensure accuracy. Another challenge was configuring the ESPHome setup correctly, especially ensuring the RS485 communication was stable.

Solution and Configuration
After some trial and error, I managed to configure the ESPHome setup successfully. Below is a snippet of my configuration file, which reads various environmental and system parameters from the Swegon unit:

yaml
esphome:
name: swegon-ac-esp8266
esp8266:
board: nodemcuv2
substitutions:
device_name: Swegon W3

api:
encryption:
key: “your_encryption_key”

ota:
password: “your_ota_password”

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password

modbus:
id: modbus1
modbus_controller:
- id: swegon
address: 0x10
modbus_id: modbus1
setup_priority: -10

sensor:
- platform: modbus_controller
modbus_controller_id: swegon
id: fresh_air_temperature
name: “${device_name} Fresh Air Temperature”
address: 6200
register_type: read
value_type: U_WORD
unit_of_measurement: “°C”
accuracy_decimals: 1
filters:
- multiply: 0.1

- platform: modbus_controller
  modbus_controller_id: swegon
  id: supply_air_temperature
  name: "${device_name} Supply Air Temperature"
  address: 6202
  register_type: read
  value_type: U_WORD
  unit_of_measurement: "°C"
  accuracy_decimals: 1
  filters:
    - multiply: 0.1

binary_sensor:
- platform: modbus_controller
modbus_controller_id: swegon
id: defrost_active
name: “${device_name} Defrost Active”
register_type: read
address: 6327
lambda: !lambda |
uint16_t defrost = (data[item->offset] << 8) + data[item->offset+1];
return defrost > 0;

text_sensor:
- platform: modbus_controller
modbus_controller_id: swegon
name: “${device_name} Unit State”
id: unit_state
register_type: read
address: 6300
lambda: !lambda |
uint16_t int_mode = (data[item->offset] << 8) + data[item->offset+1];
std::string mode_str;
switch (int_mode) {
case 0: mode_str = “External stop”; break;
case 1: mode_str = “User stopped”; break;
case 2: mode_str = “Starting”; break;
case 3: mode_str = “Normal”; break;
case 4: mode_str = “Commissioning”; break;
default: mode_str = “Unknown”; break;
}
return mode_str;

Key Learnings

  1. Documentation is Key: Referencing Swegon’s Modbus register documentation was crucial for mapping the correct data points.
  2. Testing and Iteration: I found it essential to test each sensor individually before moving on to the next. This approach helped identify and resolve issues early.
  3. Community Support: While I encountered some roadblocks, the ESPHome and Home Assistant communities were invaluable resources for troubleshooting.

Future Plans
Moving forward, I plan to expand this setup by integrating additional HVAC systems and exploring more advanced automation scenarios. For instance, I’m considering automating fan speeds based on indoor air quality metrics.

Call to Action
If anyone has integrated similar systems or has tips for optimizing Modbus setups, I’d love to hear from you! Let’s continue to push the boundaries of home automation together.

Happy coding and integrating!

Best regards,
[Your Name]