asyncapi: 3.0.0
info:
  title: Smart City Martinique — MQTT Sensors
  description: |
    Spécification AsyncAPI pour les topics MQTT des capteurs IoT de Martinique.
    Importer dans Microcks pour mocker les messages MQTT automatiquement.
  version: 1.0.0
  contact:
    name: Digitribe
    url: https://digitribe.fr

defaultContentType: application/json

servers:
  mqtt:
    host: mqtt.digitribe.fr
    port: 1883
    protocol: mqtt
    description: Broker MQTT de production

channels:
  city/sensors/traffic/{id}:
    address: city/sensors/traffic/{id}
    messages:
      trafficData:
        $ref: '#/components/messages/TrafficPayload'
    parameters:
      id:
        schema:
          type: string
          pattern: 'traffic_\d{3}'

  city/sensors/airquality/{id}:
    address: city/sensors/airquality/{id}
    messages:
      airQualityData:
        $ref: '#/components/messages/AirQualityPayload'
    parameters:
      id:
        schema:
          type: string
          pattern: 'airquality_\d{3}'

  city/sensors/parking/{id}:
    address: city/sensors/parking/{id}
    messages:
      parkingData:
        $ref: '#/components/messages/ParkingPayload'
    parameters:
      id:
        schema:
          type: string
          pattern: 'parking_\d{3}'

  city/sensors/noise/{id}:
    address: city/sensors/noise/{id}
    messages:
      noiseData:
        $ref: '#/components/messages/NoisePayload'
    parameters:
      id:
        schema:
          type: string
          pattern: 'noise_\d{3}'

  city/sensors/weather/{id}:
    address: city/sensors/weather/{id}
    messages:
      weatherData:
        $ref: '#/components/messages/WeatherPayload'
    parameters:
      id:
        schema:
          type: string
          pattern: 'weather_\d{3}'

  city/sensors/light/{id}:
    address: city/sensors/light/{id}
    messages:
      lightData:
        $ref: '#/components/messages/LightPayload'
    parameters:
      id:
        schema:
          type: string
          pattern: 'light_\d{3}'

components:
  messages:
    TrafficPayload:
      name: TrafficPayload
      title: Traffic Sensor Data
      summary: Données de trafic urbain
      payload:
        type: object
        required: [id, type, name, lat, lon, timestamp]
        properties:
          id:
            type: string
            example: traffic_000
          type:
            type: string
            const: traffic
          name:
            type: string
            example: Carrefour Central
          lat:
            type: number
            example: 14.604572
          lon:
            type: number
            example: -61.242213
          location:
            type: object
            properties:
              lat:
                type: number
              lon:
                type: number
          vehicle_count:
            type: number
            description: Nombre de véhicules/minute
            example: 52
          average_speed_kmh:
            type: number
            example: 35.5
          congestion_level:
            type: number
            minimum: 0
            maximum: 5
            example: 2.1
          occupancy_percent:
            type: number
            example: 65.2
          battery_level:
            type: integer
            example: 85
          timestamp:
            type: string
            format: date-time
            example: '2026-05-03T01:10:48.327077+00:00'

    AirQualityPayload:
      name: AirQualityPayload
      title: Air Quality Sensor Data
      summary: Données de qualité de l'air
      payload:
        type: object
        required: [id, type, name, lat, lon, timestamp]
        properties:
          id:
            type: string
            example: airquality_003
          type:
            type: string
            const: airquality
          name:
            type: string
            example: Quartier Bonde
          lat:
            type: number
          lon:
            type: number
          pm25_ugm3:
            type: number
            example: 22.9
          pm10_ugm3:
            type: number
            example: 46.6
          no2_ugm3:
            type: number
            example: 16.9
          o3_ugm3:
            type: number
            example: 95.1
          co_mgm3:
            type: number
            example: 2.0
          temperature_celsius:
            type: number
            example: 27.4
          humidity_percent:
            type: integer
            example: 86
          battery_level:
            type: integer
            example: 94
          timestamp:
            type: string
            format: date-time

    ParkingPayload:
      name: ParkingPayload
      title: Parking Sensor Data
      summary: Données de disponibilité parking
      payload:
        type: object
        required: [id, type, name, lat, lon, timestamp]
        properties:
          id:
            type: string
            example: parking_006
          type:
            type: string
            const: parking
          name:
            type: string
            example: Parking Rivière-Saleé
          lat:
            type: number
          lon:
            type: number
          total_spots:
            type: number
            example: 339.8
          available_spots:
            type: number
            example: 70.0
          occupancy_percent:
            type: number
            example: 91.8
          turnover_per_hour:
            type: number
            example: 12.2
          battery_level:
            type: integer
            example: 82
          timestamp:
            type: string
            format: date-time

    NoisePayload:
      name: NoisePayload
      title: Noise Level Sensor Data
      payload:
        type: object
        required: [id, type, name, lat, lon, timestamp]
        properties:
          id:
            type: string
          type:
            type: string
            const: noise
          name:
            type: string
          lat:
            type: number
          lon:
            type: number
          noise_level_db:
            type: number
            example: 68.5
          noise_category:
            type: string
            enum: [quiet, moderate, loud, very_loud]
          peak_db:
            type: number
            example: 85.2
          battery_level:
            type: integer
          timestamp:
            type: string
            format: date-time

    WeatherPayload:
      name: WeatherPayload
      title: Weather Station Data
      payload:
        type: object
        required: [id, type, name, lat, lon, timestamp]
        properties:
          id:
            type: string
          type:
            type: string
            const: weather
          name:
            type: string
          lat:
            type: number
          lon:
            type: number
          temperature_celsius:
            type: number
            example: 29.5
          humidity_percent:
            type: integer
            example: 78
          wind_speed_kmh:
            type: number
            example: 15.3
          pressure_hpa:
            type: number
            example: 1013.2
          rain_mm:
            type: number
            example: 0.0
          uv_index:
            type: integer
            example: 8
          battery_level:
            type: integer
          timestamp:
            type: string
            format: date-time

    LightPayload:
      name: LightPayload
      title: Street Light Data
      payload:
        type: object
        required: [id, type, name, lat, lon, timestamp]
        properties:
          id:
            type: string
          type:
            type: string
            const: light
          name:
            type: string
          lat:
            type: number
          lon:
            type: number
          brightness_lux:
            type: number
            example: 45000
          status:
            type: string
            enum: [on, off, dimmed, auto]
          power_consumption_w:
            type: number
            example: 250.5
          battery_level:
            type: integer
          timestamp:
            type: string
            format: date-time
