jacauc / SunsynkEsphome

Sunsynk Modbus ESPHome code
https://powerforum.co.za/topic/8646-my-sunsynk-8kw-data-collection-setup/
20 stars 2 forks source link

Energy Management Model #6

Closed bcameron21 closed 1 year ago

bcameron21 commented 1 year ago

I don't think this is a binary sesnor, but rather one that returns different values with different meanings. This is my code for it.

  - platform: modbus_controller   # 244 Settings Energy Management Model
    modbus_controller_id: sunsynk
    name: "Energy management model"
    id: sunsynk_energy_model
    register_type: holding
    address: 244
    raw_encode: HEXBYTES
    lambda: |-
      uint16_t value = modbus_controller::word_from_hex_str(x, 0);
      switch (value) {
        case 0: return std::string("Selling First");
        case 1: return std::string("Zero Export and Limit to Load Only");
        case 2: return std::string("Zero Export");
        default: return std::string("Unknown");
      }
      return x;
jacauc commented 1 year ago

The raw_encode setting causes an error. Any suggestions?

image

jacauc commented 1 year ago

Nevermind, I had it in the wrong section of code, will update the git shortly. Thanks for the contribution!