asyncapi: '2.6.0'

#id: 'urn:com:reduxi:p1mqttapi'

#tags:
#  - name: P1
#    description: Description of MQTT 

info:
  title: P1 MQTT API
  version: '1.0'
  #license: 
  #  name: 'Apache 2.0'
  #  url: https://www.apache.org/licenses/LICENSE-2.0.html
  contact: 
    name: Support
    url: https://www.reduxi.eu/contact/
    email: support@reduxi.eu
  
  
  description: >-
    Generated on <a href="https://studio.asyncapi.com/">studio.asyncapi.com</a> with
    <a href="https://mqtt-p1.support.reduxi.eu/asyncapi.yml">YAML file</a>.<br><br>
    Required firmware on P1 is at least version 1.0.14
    

    

defaultContentType: application/json

servers:
  production:
    url: mqtt://broker.example.com
    protocol: mqtt
    description: Example MQTT broker address
    security:
      - username_password: []

channels:
  p1ams/{p1Id}/readouts:
    description: Real-time readouts from electricity meter
    parameters:
      p1Id:
        description: P1 UnitId
        schema:
          type: string
          example: P1000000444IOMM0
    subscribe:
      operationId: readoutOperation
      traits:
        - $ref: '#/components/operationTraits/mqtt'
      message:
        $ref: '#/components/messages/readoutMessage'

components:
  securitySchemes:
    username_password:
      type: userPassword
      description: Username/Password authentication for MQTT broker

  messages:
    readoutMessage:
      messageId: "readoutMessage"
      name: readoutMessage
      title: Readout message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/readoutSchema'

  operationTraits:
    mqtt:
      bindings:
        mqtt:
          qos: 1

  schemas:
    readoutSchema:
      type: object
      properties:
        cosen_name:
          type: string
          description: 'Cosem name, empty if not available'
          example: ''
        voltage_l1:
          type: [number, 'null']
          description: Voltage on phase L1. Null if not available.
          example: 234.4
        voltage_l2:
          type: [number, 'null']
          description: Voltage on phase L2. Null if not available.
        voltage_l3:
          type: [number, 'null']
          description: Voltage on phase L3. Null if not available.
        current_l1:
          type: [number, 'null']
          description: Current on phase L1. Null if not available.
        current_l2:
          type: [number, 'null']
          description: Current on phase L2. Null if not available.
        current_l3:
          type: [number, 'null']
          description: Current on phase L3. Null if not available.
        import_power_active_l1:
          type: [number, 'null']
          description: Active power imported on phase L1. Null if not available.
        import_power_active_l2:
          type: [number, 'null']
          description: Active power imported on phase L2. Null if not available.
        import_power_active_l3:
          type: [number, 'null']
          description: Active power imported on phase L3. Null if not available.
        import_power_active:
          type: [number, 'null']
          description: Total active power imported. Null if not available.
        import_power_reactive_l1:
          type: [number, 'null']
          description: Reactive power imported on phase L1. Null if not available.
        import_power_reactive_l2:
          type: [number, 'null']
          description: Reactive power imported on phase L2. Null if not available.
        import_power_reactive_l3:
          type: [number, 'null']
          description: Reactive power imported on phase L3. Null if not available.
        import_power_reactive:
          type: [number, 'null']
          description: Total reactive power imported. Null if not available.
        export_power_reactive_l1:
          type: [number, 'null']
          description: Reactive power exported on phase L1. Null if not available.
        export_power_reactive_l2:
          type: [number, 'null']
          description: Reactive power exported on phase L2. Null if not available.
        export_power_reactive_l3:
          type: [number, 'null']
          description: Reactive power exported on phase L3. Null if not available.
        export_power_reactive:
          type: [number, 'null']
          description: Total reactive power exported. Null if not available.
        export_power_active_l1:
          type: [number, 'null']
          description: Active power exported on phase L1. Null if not available.
        export_power_active_l2:
          type: [number, 'null']
          description: Active power exported on phase L2. Null if not available.
        export_power_active_l3:
          type: [number, 'null']
          description: Active power exported on phase L3. Null if not available.
        export_power_active:
          type: [number, 'null']
          description: Total active power exported. Null if not available.
        import_energy_active:
          type: [number, 'null']
          description: Total active energy imported. Null if not available.
        import_energy_reactive:
          type: [number, 'null']
          description: Total reactive energy imported. Null if not available.
        export_energy_active:
          type: [number, 'null']
          description: Total active energy exported. Null if not available.
        export_energy_reactive:
          type: [number, 'null']
          description: Total reactive energy exported. Null if not available.
        import_power_active_1:
          type: [number, 'null']
          description: Active power imported (tumbling 1-minute average).
        export_power_active_1:
          type: [number, 'null']
          description: Active power exported (tumbling 1-minute average).
        import_power_active_15:
          type: [number, 'null']
          description: Active power imported (tumbling 15-minute average).
        export_power_active_15:
          type: [number, 'null']
          description: Active power exported (tumbling 15-minute average).
        frequency:
          type: [number, 'null']
          description: Grid frequency in Hz. Null if not available.
          example: null
        off_grid:
          type: [integer, 'null']
          description: Indicator for off-grid status.
          example: null
        error_communication:
          type: integer
          description: Communication error code (0 = no error)
        timestamp:
          type: integer
          description: Unix epoch timestamp of the reading
          example: 1750458188