[Configuration] Pakedge/Control4 P20 and P20E Integration

Hi All,

Thought I would post this in case anyone else sets their eyes on a cheap P20 or P20E on eBay (or already has one) and wants to integrate it with Home Assistant.

With the assistance of Emzi there is now support for monitoring and controlling all 20 outlets, the two current reading groups, the system uptime, the temperature and the optional humidity sensor if installed.

Demo: https://youtube.com/shorts/jkQ3FH9xix8

switch:
  - platform: snmp
    name: PDU Outlet 1
    host: <YOUR PDU'S IP ADDRESS>
    community: private
    baseoid: 1.3.6.1.4.1.39221.3.2.1.1.0
    payload_on: 1
    payload_off: 0
  
  - platform: snmp
    name: PDU Outlet 2
    host: <YOUR PDU'S IP ADDRESS>
    community: private
    baseoid: 1.3.6.1.4.1.39221.3.2.1.2.0
    payload_on: 1
    payload_off: 0
  
  - platform: snmp
    name: PDU Outlet 3
    host: <YOUR PDU'S IP ADDRESS>
    community: private
    baseoid: 1.3.6.1.4.1.39221.3.2.1.3.0
    payload_on: 1
    payload_off: 0  
    
  - platform: snmp
    name: PDU Outlet 4
    host: <YOUR PDU'S IP ADDRESS>
    community: private
    baseoid: 1.3.6.1.4.1.39221.3.2.1.4.0
    payload_on: 1
    payload_off: 0
    
  - platform: snmp
    name: PDU Outlet 5
    host: <YOUR PDU'S IP ADDRESS>
    community: private
    baseoid: 1.3.6.1.4.1.39221.3.2.1.5.0
    payload_on: 1
    payload_off: 0
    
  - platform: snmp
    name: PDU Outlet 6
    host: <YOUR PDU'S IP ADDRESS>
    community: private
    baseoid: 1.3.6.1.4.1.39221.3.2.1.6.0
    payload_on: 1
    payload_off: 0
    
  - platform: snmp
    name: PDU Outlet 7
    host: <YOUR PDU'S IP ADDRESS>
    community: private
    baseoid: 1.3.6.1.4.1.39221.3.2.1.7.0
    payload_on: 1
    payload_off: 0
    
  - platform: snmp
    name: PDU Outlet 8
    host: <YOUR PDU'S IP ADDRESS>
    community: private
    baseoid: 1.3.6.1.4.1.39221.3.2.1.8.0
    payload_on: 1
    payload_off: 0
    
  - platform: snmp
    name: PDU Outlet 9
    host: <YOUR PDU'S IP ADDRESS>
    community: private
    baseoid: 1.3.6.1.4.1.39221.3.2.1.9.0
    payload_on: 1
    payload_off: 0
    
  - platform: snmp
    name: PDU Outlet 10
    host: <YOUR PDU'S IP ADDRESS>
    community: private
    baseoid: 1.3.6.1.4.1.39221.3.2.1.10.0
    payload_on: 1
    payload_off: 0
    
  - platform: snmp
    name: PDU Outlet 11
    host: <YOUR PDU'S IP ADDRESS>
    community: private
    baseoid: 1.3.6.1.4.1.39221.3.2.1.11.0
    payload_on: 1
    payload_off: 0
    
  - platform: snmp
    name: PDU Outlet 12
    host: <YOUR PDU'S IP ADDRESS>
    community: private
    baseoid: 1.3.6.1.4.1.39221.3.2.1.12.0
    payload_on: 1
    payload_off: 0
    
  - platform: snmp
    name: PDU Outlet 13
    host: <YOUR PDU'S IP ADDRESS>
    community: private
    baseoid: 1.3.6.1.4.1.39221.3.2.1.13.0
    payload_on: 1
    payload_off: 0
    
  - platform: snmp
    name: PDU Outlet 14
    host: <YOUR PDU'S IP ADDRESS>
    community: private
    baseoid: 1.3.6.1.4.1.39221.3.2.1.14.0
    payload_on: 1
    payload_off: 0
    
  - platform: snmp
    name: PDU Outlet 15
    host: <YOUR PDU'S IP ADDRESS>
    community: private
    baseoid: 1.3.6.1.4.1.39221.3.2.1.15.0
    payload_on: 1
    payload_off: 0
    
  - platform: snmp
    name: PDU Outlet 16
    host: <YOUR PDU'S IP ADDRESS>
    community: private
    baseoid: 1.3.6.1.4.1.39221.3.2.1.16.0
    payload_on: 1
    payload_off: 0
    
  - platform: snmp
    name: PDU Outlet 17
    host: <YOUR PDU'S IP ADDRESS>
    community: private
    baseoid: 1.3.6.1.4.1.39221.3.2.1.17.0
    payload_on: 1
    payload_off: 0
    
  - platform: snmp
    name: PDU Outlet 18
    host: <YOUR PDU'S IP ADDRESS>
    community: private
    baseoid: 1.3.6.1.4.1.39221.3.2.1.18.0
    payload_on: 1
    payload_off: 0
    
  - platform: snmp
    name: PDU Outlet 19
    host: <YOUR PDU'S IP ADDRESS>
    community: private
    baseoid: 1.3.6.1.4.1.39221.3.2.1.19.0
    payload_on: 1
    payload_off: 0
    
  - platform: snmp
    name: PDU Outlet 20
    host: <YOUR PDU'S IP ADDRESS>
    community: private
    baseoid: 1.3.6.1.4.1.39221.3.2.1.20.0
    payload_on: 1
    payload_off: 0

sensor:
  - platform: snmp
    name: PDU Uptime
    host: <YOUR PDU'S IP ADDRESS>
    baseoid: 1.3.6.1.2.1.1.3.0
    value_template: >-
        {% set total_secs = (value | int) / 100 %}
        {% set days = total_secs / 60 / 60 / 24 %}
        {% set hours = (days - (days | int)) * 24 %}
        {% set mins = (hours - (hours | int)) * 60 %}
        {% set secs = ((mins - (mins | int)) * 60) %}
        {{ days | int }}d {{ hours | int }}h {{ mins | int }}m {{ secs | int }}s
    
  - platform: snmp
    name: PDU Group A Current
    host: <YOUR PDU'S IP ADDRESS>
    baseoid: 1.3.6.1.4.1.39221.3.1.3.0
    device_class: current
    unit_of_measurement: A
    value_template: "{{ value | float / 1000 }}"
    
  - platform: snmp
    name: PDU Group B Current
    host: <YOUR PDU'S IP ADDRESS>
    baseoid: 1.3.6.1.4.1.39221.3.1.4.0
    device_class: current
    unit_of_measurement: A
    value_template: "{{ value | float / 1000 }}"

  - platform: snmp
    name: PDU System Temperature
    host: <YOUR PDU'S IP ADDRESS>
    baseoid: 1.3.6.1.4.1.39221.3.1.5.0
    device_class: temperature
    unit_of_measurement: "°C"
    value_template: "{{ value | float / 100 }}"

  # This requires an external RH sensor to be installed
  #- platform: snmp
  #  name: PDU System Relative Humidity
  #  host: <YOUR PDU'S IP ADDRESS>
  #  baseoid: 1.3.6.1.4.1.39221.3.1.7.0
  #  device_class: humidity
  #  unit_of_measurement: "%"

You’ll need to ensure SNMP is enabled on your PDU and that the two communities are set to public and private (unless you wish to change those in the YAML)

Hope this helps someone!