Custom Local PDU Service

I have a PDU that let’s me query it with an API. I was hoping to be able to pull that into HA and let me control each of the ports. There’s no current integration, so I’m fine with using the http/json to do so, but I’m having an issue.

I can hit /api/status to get status of all ports. Or /api/status/{port_id} to get the status of a specific port. If I POST to /api/port/{port_id} it will change the power state from Off to On, or On to Off, then give me output with port info.

How can I integrate this into HA?

# curl -X GET http://localhost/api/status
{
  "Circuit Breaker": "Off",
  "Internal Temperature": "30.5 C",
  "Maximum Detected": "1.6",
  "True RMS Current": "0.8",
  "outlets": {
    "1": {
      "unused1": "On"
    },
    "2": {
      "unused2": "On"
    },
    "3": {
      "unused3": "On"
    },
    "4": {
      "unused4": "On"
    },
    "5": {
      "unused5": "On"
    },
    "6": {
      "unused6": "On"
    },
    "7": {
      "unused7": "Off"
    },
    "8": {
      "unused8": "On"
    }
  },
  "tempC": 30.5,
  "tempF": 86.9
}
# curl -X GET http://localhost/api/status/1
{
  "name": "unused1",
  "port_id": 1,
  "state": "On"
}
# curl -X POST http://localhost/api/power/1
{
  "expected_new_state": "Off",
  "name": "unused1",
  "new_state": "Off",
  "port_id": 1,
  "previous_state": "On"
}

I solved this by writing my own integration with the web/api interface.