Phnix fan coil modbus ESP integration

Hi to everyone

I have managed to integrate my Phnix fancoil to home assistant via it’s MODbus and ESPHome wirelessly.

You will need

  1. ESP8266 or ESP32 board (Wemos D1 mini is the one I use here.)
  2. RS485/TTL converter
  3. a 120Ω resistor conected in parallel to terminate the modbus side. (my RS485/TTL converter had one onboard).

Basic usage and setup of ESP boards and connections are not included in this post, I suppose that you will get around it from other sources or you already know a few bits.

The reason I am posting it is for others to avoid going through the same as me writing the code.
Keep in mind I am not an expert and there may be better ways, but thats how I did it and it works absolutely perfect.

Make sure to change accordignly:
ESP board type.
Naming of the entitites.
And any other that is personal info like replacing the wifi and SSID with your own wifi’s credentials.

Here is the Code that you need.

esphome:
  name: phnix-modbus-controller
  friendly_name: phnix-modbus-controller

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "**************************************"
    
ota:
  - platform: esphome
    id: my_ota
    password: "************************"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Phnix-Modbus-Controller"
    password: "12345678"

captive_portal:

web_server:
  port: 80

uart:
  id: mod_bus
  tx_pin: GPIO13
  rx_pin: GPIO12
  baud_rate: 9600
  stop_bits: 1

modbus:
  send_wait_time: 100ms
  id: phnix_fancoil
      
modbus_controller:
  - id: phnix
    ## the Modbus device addr
    address: 15
    modbus_id: phnix_fancoil
    setup_priority: -10
    update_interval: 15s



text_sensor:
  - platform: template
    id: living_room_fancoil_mode_text
    name: "Living Room Fancoil Mode text"

  - platform: template
    id: living_room_fan_speed_text
    name: "Living Room Fan Speed"

number:

  - platform: modbus_controller
    modbus_controller_id: phnix
    name: "Living Room Fancoil On/Off"
    address: 28301
    register_type: holding
    value_type: U_WORD
    use_write_multiple: True
    entity_category: config
    min_value: 0
    max_value: 1
    step: 1
    mode: slider 
    icon: "mdi:toggle-switch"

  - platform: modbus_controller
    modbus_controller_id: phnix
    name: "Living Room Cool Temperature"
    id: living_room_fancoil_cool_temperature
    address: 28310
    value_type: S_WORD
    use_write_multiple: True
    entity_category: config
    min_value: 16
    max_value: 30
    step: 1
    multiply: 10
    mode: slider
                
  - platform: modbus_controller
    modbus_controller_id: phnix
    name: "Living Room Heat Temperature"
    id: living_room_fancoil_heat_temperature
    address: 28311
    value_type: S_WORD
    use_write_multiple: True
    entity_category: config
    min_value: 16
    max_value: 30
    step: 1
    multiply: 10
    mode: slider

  - platform: modbus_controller
    modbus_controller_id: phnix
    name: "Living Room Set Fan Speed"
    id: living_room_fancoil_fan_speed
    address: 28303
    value_type: S_WORD
    use_write_multiple: True
    entity_category: config
    min_value: 2
    max_value: 6
    step: 1
    mode: slider

  - platform: modbus_controller
    modbus_controller_id: phnix
    name: "Living Room Mode Set"
    id: living_room_fancoil_mode_set
    address: 28302
    value_type: S_WORD
    use_write_multiple: True
    entity_category: config
    min_value: 0
    max_value: 4
    step: 1
    mode: slider

sensor:
  - platform: modbus_controller
    modbus_controller_id: phnix
    id: living_room_fancoil_mode
    name: Living Room Fancoil Mode
    address: 28302
    register_type: holding
    value_type: U_WORD
    #entity_category: config
    on_value:
      then:
        - lambda: |-
            int state = id(living_room_fancoil_mode).state;
            std::string text;
            if (state == 0) {
              text = "Auto";
            } else if (state == 1) {
              text = "Cooling";
            } else if (state == 2) {
              text = "Dehumidifier";
            } else if (state == 3) {
              text = "Fan Only";
            } else if (state == 4) {
              text = "Heating";
            } else {
              text = "UNKNOWN";
            }
            id(living_room_fancoil_mode_text).publish_state(text);

  - platform: modbus_controller
    modbus_controller_id: phnix
    id: living_room_fan_speed
    name: Living Room Fan Speed
    address: 46803
    register_type: read
    value_type: U_WORD
    on_value:
      then:
        - lambda: |-
            int state = id(living_room_fan_speed).state;
            std::string text;
            if (state == 0) {
              text = "Off";
            } else if (state == 1) {
              text = "Ultra Low";
            } else if (state == 2) {
              text = "Low";
            } else if (state == 3) {
              text = "Medium";
            } else if (state == 4) {
              text = "High";
            } else if (state == 5) {
              text = "Top Speed";
            } else if (state == 6) {
              text = "Auto";  
            } else {
              text = "UNKNOWN";
            }
            id(living_room_fan_speed_text).publish_state(text);

  - platform: modbus_controller
    modbus_controller_id: phnix
    name: "Living Room Fancoil Air Temperature"
    address: 46801
    unit_of_measurement: "°C" 
    register_type: read
    value_type: S_WORD
    accuracy_decimals: 0
    filters:
    - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: phnix
    name: "Living Room Fancoil Coil Temperature"
    address: 46802
    unit_of_measurement: "°C" 
    register_type: read
    value_type: S_WORD
    accuracy_decimals: 0
    filters:
    - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: phnix
    name: "Living Room Fan RPM"
    address: 46804
    unit_of_measurement: "RPM" 
    register_type: read
    value_type: S_WORD
    accuracy_decimals: 0

  - platform: wifi_signal
    name: "WiFi Signal Sensor"
    id: wifi_signal_db
    update_interval: 60s
    entity_category: "diagnostic"

  - platform: copy # Reports the WiFi signal strength in %
    source_id: wifi_signal_db
    name: "WiFi Signal Percent"
    filters:
      - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
    unit_of_measurement: "Signal %"
    entity_category: "diagnostic"

switch:
- platform: modbus_controller
  modbus_controller_id: phnix
  name: "Living Room Fancoil On/Off"
  address: 28301
  register_type: holding
  use_write_multiple: True
  icon: "mdi:toggle-switch"

For any questions fell free to reply.
Attached the PHNIX modbus info coming from the main dealer in Greece. (extremely helpful.)

2 Likes

nice work @blacknass ! I’ve done the same with some EW11 (https://www.aliexpress.com/i/32916950283.html) and Modbus integration, so I’ve made a thermostat for each fan coil. Works like a charm!

1 Like