diff --git a/rdtech-controller-c3.yaml b/rdtech-controller-c3.yaml index f2b258e..f38f4fa 100644 --- a/rdtech-controller-c3.yaml +++ b/rdtech-controller-c3.yaml @@ -337,6 +337,15 @@ text_sensor: - 60065 -> RD6006P - 60121 -> RD6012 - 60181 -> RD6018 + # Single source of truth for regulation mode; published from cv_mode binary + # sensor (see binary_sensor: section). Use this in lieu of the legacy + # "Constant Voltage" / "Constant Current" binary sensors which are kept for + # backward compatibility but represent the same underlying bit. + - platform: template + id: regulation_mode + name: "Regulation Mode" + icon: "mdi:tune-variant" + update_interval: never binary_sensor: - platform: modbus_controller @@ -370,7 +379,12 @@ binary_sensor: address: 16 register_type: holding bitmask: 0x2 + # Note: "Constant Voltage" and "Constant Current" below are kept for + # backward compatibility. They derive from the same bit and are tautologically + # opposite. Prefer the "Regulation Mode" text_sensor (above in text_sensor:) + # which exposes the mode as "CV" / "CC" directly. - platform: modbus_controller + id: cv_mode modbus_controller_id: powersupply name: "Constant Voltage" address: 17 @@ -378,6 +392,10 @@ binary_sensor: bitmask: 0x1 filters: - invert: + on_state: + then: + - lambda: |- + id(regulation_mode).publish_state(x ? "CV" : "CC"); - platform: modbus_controller modbus_controller_id: powersupply name: "Constant Current" diff --git a/rdtech-controller.yaml b/rdtech-controller.yaml index d87db69..7072968 100644 --- a/rdtech-controller.yaml +++ b/rdtech-controller.yaml @@ -335,6 +335,15 @@ text_sensor: - 60065 -> RD6006P - 60121 -> RD6012 - 60181 -> RD6018 + # Single source of truth for regulation mode; published from cv_mode binary + # sensor (see binary_sensor: section). Use this in lieu of the legacy + # "Constant Voltage" / "Constant Current" binary sensors which are kept for + # backward compatibility but represent the same underlying bit. + - platform: template + id: regulation_mode + name: "Regulation Mode" + icon: "mdi:tune-variant" + update_interval: never binary_sensor: - platform: modbus_controller @@ -368,7 +377,12 @@ binary_sensor: address: 16 register_type: holding bitmask: 0x2 + # Note: "Constant Voltage" and "Constant Current" below are kept for + # backward compatibility. They derive from the same bit and are tautologically + # opposite. Prefer the "Regulation Mode" text_sensor (above in text_sensor:) + # which exposes the mode as "CV" / "CC" directly. - platform: modbus_controller + id: cv_mode modbus_controller_id: powersupply name: "Constant Voltage" address: 17 @@ -376,6 +390,10 @@ binary_sensor: bitmask: 0x1 filters: - invert: + on_state: + then: + - lambda: |- + id(regulation_mode).publish_state(x ? "CV" : "CC"); - platform: modbus_controller modbus_controller_id: powersupply name: "Constant Current"