Creating a new UPS device

Hello there! I’m very new here, please correct me if needed.
I have a Socomec Masterys BC+ UPS that I’d like to monitor with Homeassistant.

It exposes a simple XML structure with all the parameters so it was pretty easy to add all the sensors as below (I’m adding the configuration as it may help others):

rest:
  - resource: http://10.50.0.140/xml/data.xml
    sensor:
      - name: "UPS Output Lr"
        value_template: "{{value_json.root.M.uM000}}"
        unit_of_measurement: "%"
      - name: "UPS Output S"
        value_template: "{{value_json.root.M.uM004}}"
        unit_of_measurement: "kVA"
        device_class: apparent_power
      - name: "UPS Output P"
        value_template: "{{value_json.root.M.uM005}}"
        unit_of_measurement: "kW"
        device_class: power
      - name: "UPS Output Lr1"
        value_template: "{{value_json.root.M.uM001}}"
        unit_of_measurement: "%"
      - name: "UPS Output Lr2"
        value_template: "{{value_json.root.M.uM002}}"
        unit_of_measurement: "%"
      - name: "UPS Output Lr3"
        value_template: "{{value_json.root.M.uM003}}"
        unit_of_measurement: "%"
      - name: "UPS Output S1"
        value_template: "{{value_json.root.M.uM048}}"
        unit_of_measurement: "kVA"
        device_class: apparent_power
      - name: "UPS Output S2"
        value_template: "{{value_json.root.M.uM049}}"
        unit_of_measurement: "kVA"
        device_class: apparent_power
      - name: "UPS Output S3"
        value_template: "{{value_json.root.M.uM050}}"
        unit_of_measurement: "kVA"
        device_class: apparent_power
      - name: "UPS Output P1"
        value_template: "{{value_json.root.M.uM051}}"
        unit_of_measurement: "kW"
        device_class: power
      - name: "UPS Output P2"
        value_template: "{{value_json.root.M.uM052}}"
        unit_of_measurement: "kW"
        device_class: power
      - name: "UPS Output P3"
        value_template: "{{value_json.root.M.uM053}}"
        unit_of_measurement: "kW"
        device_class: power
      - name: "UPS Output V1"
        value_template: "{{value_json.root.M.uM010}}"
        unit_of_measurement: "V"
        device_class: voltage
      - name: "UPS Output V2"
        value_template: "{{value_json.root.M.uM011}}"
        unit_of_measurement: "V"
        device_class: voltage
      - name: "UPS Output V3"
        value_template: "{{value_json.root.M.uM012}}"
        unit_of_measurement: "V"
        device_class: voltage
      - name: "UPS Output U12"
        value_template: "{{value_json.root.M.uM054}}"
        unit_of_measurement: "V"
        device_class: voltage
      - name: "UPS Output U23"
        value_template: "{{value_json.root.M.uM055}}"
        unit_of_measurement: "V"
        device_class: voltage
      - name: "UPS Output U31"
        value_template: "{{value_json.root.M.uM056}}"
        unit_of_measurement: "V"
        device_class: voltage
      - name: "UPS Output I1"
        value_template: "{{value_json.root.M.uM006}}"
        unit_of_measurement: "A"
        device_class: current
      - name: "UPS Output I2"
        value_template: "{{value_json.root.M.uM007}}"
        unit_of_measurement: "A"
        device_class: current
      - name: "UPS Output I3"
        value_template: "{{value_json.root.M.uM008}}"
        unit_of_measurement: "A"
        device_class: current
      - name: "UPS Output Fr"
        value_template: "{{value_json.root.M.uM013}}"
        unit_of_measurement: "Hz"
      - name: "UPS Batt Vbat"
        value_template: "{{value_json.root.M.uM016}}"
        unit_of_measurement: "V"
      - name: "UPS Batt Ibat"
        value_template: "{{value_json.root.M.uM018}}"
        unit_of_measurement: "A"
        device_class: current
      - name: "UPS Batt Temp"
        value_template: "{{value_json.root.M.uM026}}"
        unit_of_measurement: "°C"
        device_class: temperature
      - name: "UPS Batt Cap %"
        value_template: "{{value_json.root.M.uM022}}"
        unit_of_measurement: "%"
      - name: "UPS Batt Cap"
        value_template: "{{value_json.root.M.uM023}}"
        unit_of_measurement: "Ah"
      - name: "UPS Batt BuT"
        value_template: "{{value_json.root.M.uM024}}"
        unit_of_measurement: "min"
      - name: "UPS Input V1"
        value_template: "{{value_json.root.M.uM033}}"
        unit_of_measurement: "V"
        device_class: voltage
      - name: "UPS Input V2"
        value_template: "{{value_json.root.M.uM033}}"
        unit_of_measurement: "V"
        device_class: voltage
      - name: "UPS Input V3"
        value_template: "{{value_json.root.M.uM034}}"
        unit_of_measurement: "V"
        device_class: voltage
      - name: "UPS Input U12"
        value_template: "{{value_json.root.M.uM036}}"
        unit_of_measurement: "V"
        device_class: voltage
      - name: "UPS Input U23"
        value_template: "{{value_json.root.M.uM037}}"
        unit_of_measurement: "V"
        device_class: voltage
      - name: "UPS Input U31"
        value_template: "{{value_json.root.M.uM038}}"
        unit_of_measurement: "V"
        device_class: voltage
      - name: "UPS Input I1"
        value_template: "{{value_json.root.M.uM064}}"
        unit_of_measurement: "A"
        device_class: current
      - name: "UPS Input I2"
        value_template: "{{value_json.root.M.uM065}}"
        unit_of_measurement: "A"
        device_class: current
      - name: "UPS Input I3"
        value_template: "{{value_json.root.M.uM066}}"
        unit_of_measurement: "A"
        device_class: current
      - name: "UPS Input P1"
        value_template: "{{value_json.root.M.uM067}}"
        unit_of_measurement: "kW"
        device_class: power
      - name: "UPS Input P2"
        value_template: "{{value_json.root.M.uM068}}"
        unit_of_measurement: "kW"
        device_class: power
      - name: "UPS Input P3"
        value_template: "{{value_json.root.M.uM069}}"
        unit_of_measurement: "kW"
        device_class: power
      - name: "UPS Input Fr"
        value_template: "{{value_json.root.M.uM035}}"
        unit_of_measurement: "Hz"
        device_class: frequency
      - name: "UPS Bypass V1"
        value_template: "{{value_json.root.M.uM039}}"
        unit_of_measurement: "V"
        device_class: voltage
      - name: "UPS Bypass V2"
        value_template: "{{value_json.root.M.uM040}}"
        unit_of_measurement: "V"
        device_class: voltage
      - name: "UPS Bypass V3"
        value_template: "{{value_json.root.M.uM041}}"
        unit_of_measurement: "V"
        device_class: voltage
      - name: "UPS Bypass U12"
        value_template: "{{value_json.root.M.uM043}}"
        unit_of_measurement: "V"
        device_class: voltage
      - name: "UPS Bypass U23"
        value_template: "{{value_json.root.M.uM044}}"
        unit_of_measurement: "V"
        device_class: voltage
      - name: "UPS Bypass U31"
        value_template: "{{value_json.root.M.uM045}}"
        unit_of_measurement: "V"
        device_class: voltage
      - name: "UPS Bypass Fr"
        value_template: "{{value_json.root.M.uM042}}"
        unit_of_measurement: "Hz"
        device_class: frequency

I now would like to “group” these sensor in a single device called “UPS” or something, that I can put in some room just for cleanliness. How can I do that?

Thank you!

Does NUT (Network UPS Tools) support your UPS? If so - that would be a better route to go - there is a native NUT integration that will package up all the available entities/sensors/etc nicely.

1 Like

Unfortunately NUT doesn’t support it.

I’m planning to use it as a server to poweroff the PCs in my network.

As far as I know there is no way to create (or even add onto) “devices” in yaml; they can only exist due to integrations and/or discovery. I’ll be following in case someone knows a way.

Short of writing your own custom integration, one workaround might be to use a lightweight collection agent like Telegraf to get and parse your xml/json data, and forward it to HA via MQTT. HA’s built-in MQTT integration supports device creation if you use the right topics.

You can create devices with node red.

Single sensors are working fine so I do not have a real need to group them into a device. It would have been nice but I prefer not to install other tools to accomplish this.

Thank you all for your answers, I’ll be listening for other ideas.