openapi: 3.0.3
info:
    title: ⚡ Energetics API
    description: >-
        <p> ⚡ Energetics </p>
    version: 1.0.0
    contact:
        name: Golemio Prague Data Platform
        email: golemio@operatorict.cz
        url: https://golemio.cz
servers:
    - url: https://rabin.golemio.cz
      description: Test (development) server
    - url: https://api.golemio.cz
      description: Main (production) server
tags:
    - name: ⚡ Energetics (v2)
      description: 💡 Organizations & measurement devices
paths:
    /v2/energetics/buildings:
        get:
            tags:
                - ⚡ Energetics (v2)
            summary: Get all buildings
            parameters:
                - name: full
                  in: query
                  description: Display full buildings data.
                  required: false
                  schema:
                      type: boolean
                      default: false
                      example: false
            responses:
                "200":
                    description: OK
                    headers:
                        Cache-Control:
                            description: Cache control directive for caching proxies
                            schema:
                                type: string
                                example: public, s-maxage=21600, stale-while-revalidate=60
                    content:
                        application/json:
                            schema:
                                type: array
                                items:
                                    $ref: "#/components/schemas/EnergeticsBuildingShort"

    /v2/energetics/buildings/{id}:
        get:
            tags:
                - ⚡ Energetics (v2)
            summary: Get a building by ID
            parameters:
                - in: path
                  name: id
                  required: true
                  schema:
                      type: number
                      example: 100
            responses:
                "200":
                    description: OK
                    headers:
                        Cache-Control:
                            description: Cache control directive for caching proxies
                            schema:
                                type: string
                                example: public, s-maxage=1800, stale-while-revalidate=60
                    content:
                        application/json:
                            schema:
                                $ref: "#/components/schemas/EnergeticsBuildingFull"

    /v2/energetics/devices:
        get:
            tags:
                - ⚡ Energetics (v2)
            summary: List of measurement devices
            responses:
                "200":
                    description: Success
                    headers:
                        Cache-Control:
                            description: Cache control directive for caching proxies
                            schema:
                                type: string
                                example: public, s-maxage=1800, stale-while-revalidate=60
                    content:
                        application/json:
                            schema:
                                type: array
                                items:
                                    $ref: "#/components/schemas/EnergeticsDevice"
                "401":
                    $ref: "#/components/responses/UnauthorizedError"
                "500":
                    $ref: "#/components/responses/ServerError"

    /v2/energetics/devices/{deviceId}:
        get:
            tags:
                - ⚡ Energetics (v2)
            summary: Measurement device info
            parameters:
                - name: deviceId
                  in: path
                  description: Id of device
                  required: true
                  schema:
                      type: integer
                      format: int32
                      example: 16
            responses:
                "200":
                    description: Success
                    headers:
                        Cache-Control:
                            description: Cache control directive for caching proxies
                            schema:
                                type: string
                                example: public, s-maxage=1800, stale-while-revalidate=60
                    content:
                        application/json:
                            schema:
                                $ref: "#/components/schemas/EnergeticsDevice"
                "401":
                    $ref: "#/components/responses/UnauthorizedError"
                "404":
                    $ref: "#/components/responses/NotFoundError"
                "500":
                    $ref: "#/components/responses/ServerError"

    /v2/energetics/organizations:
        get:
            tags:
                - ⚡ Energetics (v2)
            summary: List of organizations in brief or full format
            parameters:
                - name: full
                  in: query
                  description: Display full organization data.
                  required: false
                  schema:
                      type: boolean
                      default: false
                      example: false
            responses:
                "200":
                    description: Success
                    headers:
                        Cache-Control:
                            description: Cache control directive for caching proxies
                            schema:
                                type: string
                                example: public, s-maxage=1800, stale-while-revalidate=60
                    content:
                        application/json:
                            schema:
                                anyOf:
                                    - type: array
                                      items:
                                          $ref: "#/components/schemas/EnergeticsOrganizationShort"
                                    - type: array
                                      items:
                                          $ref: "#/components/schemas/EnergeticsOrganizationFull"
                "401":
                    $ref: "#/components/responses/UnauthorizedError"
                "500":
                    $ref: "#/components/responses/ServerError"

    /v2/energetics/organizations/{organizationId}:
        get:
            tags:
                - ⚡ Energetics (v2)
            summary: Organization detail
            parameters:
                - name: organizationId
                  in: path
                  description: Id of organization
                  required: true
                  schema:
                      type: integer
                      format: int32
                      example: 1
            responses:
                "200":
                    description: Success
                    headers:
                        Cache-Control:
                            description: Cache control directive for caching proxies
                            schema:
                                type: string
                                example: public, s-maxage=1800, stale-while-revalidate=60
                    content:
                        application/json:
                            schema:
                                $ref: "#/components/schemas/EnergeticsOrganizationFull"
                "400":
                    $ref: "#/components/responses/BadRequestError"
                "401":
                    $ref: "#/components/responses/UnauthorizedError"
                "404":
                    $ref: "#/components/responses/NotFoundError"
                "500":
                    $ref: "#/components/responses/ServerError"

    /v2/energetics/measurements:
        get:
            tags:
                - ⚡ Energetics (v2)
            summary: Measurements
            parameters:
                - name: variable
                  in: query
                  required: false
                  schema:
                      $ref: "#/components/schemas/EnergeticsVariables"
                  description: >-
                      core - Kumulovaný objem [m3]<br />
                      core2 - Kumulovaný přepočítaný objem [Nm3]<br />
                      EFwActi - Odběr činné energie [kWh]<br />
                      EFwActiVT - Odběr činné energie, vysoký tarif [kVArh]<br />
                      ERvReact - Dodávka jalové energie [kVArh]<br />
                      EFwReact - Odběr jalové energie [kVArh]<br />
                      raw - Číselník impulzů [imp]<br />
                      RSSI - Síla signálu [dBm]<br />
                      T - Teplota [°C]<br />
                      CO2 - Koncentrace CO2 [ppm]<br />
                      RH - Relativní vlhkost [%]<br />
                      EFwActiNT - Odběr činné energie, nízký tarif [kVArh]<br />
                      VOC - Míra koncentrace těkavých látek [%]<br />
                      VT - Vysoký tarif [kWh]<br />
                      NT - Nízký tarif [kWh]<br />
                - name: type
                  in: query
                  required: false
                  schema:
                      $ref: "#/components/schemas/EnergeticsTypes"
                  description: >-
                      monthly_reading - hodnoty sčítané po měsících z 15 minutových spotřeb poskytovaných firmou PRE<br />
                      provider_value - data získaná od poskytovatelů energií<br />
                      dotcontrols_value - data získaná ze systémů VisApp firmy DotControls<br />
                - name: addr1
                  in: query
                  required: false
                  schema:
                      type: string
                      example: "2.9"
                - name: addr2
                  in: query
                  required: false
                  schema:
                      type: string
                      example: "PF1"
                - name: dateFrom
                  in: query
                  schema:
                      type: string
                      format: date-time
                      example: 2023-05-01T00:00:00.000Z
                - name: dateTo
                  in: query
                  schema:
                      type: string
                      format: date-time
                      example: 2023-05-02T00:00:00.000Z
                - name: limit
                  in: query
                  description: Limits number of retrieved items.
                  schema:
                      type: integer
                      example: 10000
                - name: offset
                  in: query
                  description: Number of the first items that are skipped.
                  schema:
                      type: integer
                      example: 0
            responses:
                "200":
                    description: Success
                    headers:
                        Cache-Control:
                            description: Cache control directive for caching proxies
                            schema:
                                type: string
                                example: public, s-maxage=1800, stale-while-revalidate=60
                    content:
                        application/json:
                            schema:
                                type: array
                                items:
                                    $ref: "#/components/schemas/EnergeticsMeasurement"
                "400":
                    $ref: "#/components/responses/BadRequestError"
                "401":
                    $ref: "#/components/responses/UnauthorizedError"
                "500":
                    $ref: "#/components/responses/ServerError"

    /v2/energetics/measurements/monthly-reading:
        get:
            tags:
                - ⚡ Energetics (v2)
            summary: Monthly sums of measurements from devices
            parameters:
                - name: addr1
                  in: query
                  description: First part of device address
                  required: true
                  schema:
                      type: string
                      example: "2.9"
                - name: addr2
                  in: query
                  description: Second part of device address
                  required: true
                  schema:
                      type: string
                      example: "PF1"
                - name: variable
                  in: query
                  required: true
                  schema:
                      $ref: "#/components/schemas/EnergeticsVariables"
                  description: >-
                      core - Kumulovaný objem [m3]<br />
                      core2 - Kumulovaný přepočítaný objem [Nm3]<br />
                      EFwActi - Odběr činné energie [kWh]<br />
                      EFwActiVT - Odběr činné energie, vysoký tarif [kVArh]<br />
                      ERvReact - Dodávka jalové energie [kVArh]<br />
                      EFwReact - Odběr jalové energie [kVArh]<br />
                      raw - Číselník impulzů [imp]<br />
                      RSSI - Síla signálu [dBm]<br />
                      T - Teplota [°C]<br />
                      CO2 - Koncentrace CO2 [ppm]<br />
                      RH - Relativní vlhkost [%]<br />
                      EFwActiNT - Odběr činné energie, nízký tarif [kVArh]<br />
                      VOC - Míra koncentrace těkavých látek [%]<br />
                      VT - Vysoký tarif [kWh]<br />
                      NT - Nízký tarif [kWh]<br />
                - name: year
                  in: query
                  description: Year of measurement
                  required: true
                  schema:
                      type: integer
                      format: int32
                      example: 2023
                - name: month
                  in: query
                  description: Month of measurement
                  required: true
                  schema:
                      type: integer
                      format: int32
                      example: 5
            responses:
                "200":
                    description: Success
                    headers:
                        Cache-Control:
                            description: Cache control directive for caching proxies
                            schema:
                                type: string
                                example: public, s-maxage=1800, stale-while-revalidate=60
                    content:
                        application/json:
                            schema:
                                type: array
                                items:
                                    $ref: "#/components/schemas/EnergeticsMeasurement"
                "400":
                    $ref: "#/components/responses/BadRequestError"
                "401":
                    $ref: "#/components/responses/UnauthorizedError"
                "500":
                    $ref: "#/components/responses/ServerError"

components:
    responses:
        UnauthorizedError:
            description: API key is missing or invalid
            content:
                application/json; charset=utf-8:
                    schema:
                        type: object
                        properties:
                            error_message:
                                type: string
                                example: Unauthorized
                            error_status:
                                type: number
                                example: 401
                            error_info:
                                type: string
        NotFoundError:
            description: Record not found
            content:
                application/json; charset=utf-8:
                    schema:
                        type: object
                        properties:
                            error_message:
                                type: string
                                example: Not fount
                            error_status:
                                type: number
                                example: 404
                            error_info:
                                type: string
                                example: "Record with id 1 not fount"
        BadRequestError:
            description: Bad request
            content:
                application/json; charset=utf-8:
                    schema:
                        type: object
                        properties:
                            error_message:
                                type: string
                                example: Bad request
                            error_status:
                                type: number
                                example: 400
                            error_info:
                                type: string
                                example: '{"limit":{"location":"query","param":"limit","value":"-2","msg":"Invalid value"}}'
        ServerError:
            description: Server error
            content:
                application/json; charset=utf-8:
                    schema:
                        type: object
                        properties:
                            error_message:
                                type: string
                                example: Server error
                            error_status:
                                type: number
                                example: 500
                            error_info:
                                type: string

    schemas:
        EnergeticsBuildingShort:
            type: object
            properties:
                id:
                    type: number
                name:
                    type: string
                building_address_code:
                    type: string
                link:
                    type: string
        EnergeticsBuildingFull:
            type: object
            properties:
                id:
                    type: number
                name:
                    type: string
                    nullable: true
                main_use:
                    type: string
                    nullable: true
                method_of_protection:
                    type: string
                    nullable: true
                address:
                    type: object
                    properties:
                        city:
                            type: string
                            nullable: true
                        country:
                            type: string
                            nullable: true
                        house_number:
                            type: string
                            nullable: true
                        mail:
                            type: string
                            nullable: true
                        phone:
                            type: string
                            nullable: true
                        street:
                            type: string
                            nullable: true
                        web_address:
                            type: string
                            nullable: true
                    nullable: true
                allotment_number:
                    type: string
                    nullable: true
                beds_count:
                    type: number
                    nullable: true
                building_address_code:
                    type: string
                    nullable: true
                building_envelope:
                    type: object
                    properties:
                        filling_of_hole:
                            type: object
                            properties:
                                area:
                                    type: number
                                    nullable: true
                                construction:
                                    type: string
                                    nullable: true
                                technical_condition:
                                    type: string
                                    nullable: true
                                year_of_adjustment:
                                    type: string
                                    nullable: true
                            nullable: true
                        floor_of_the_lowest_heated_floor:
                            type: object
                            properties:
                                area:
                                    type: number
                                    nullable: true
                                construction:
                                    type: string
                                    nullable: true
                                year_of_adjustment:
                                    type: string
                                    nullable: true
                                technical_condition:
                                    type: string
                                    nullable: true
                                thermal_insulation:
                                    type: string
                                    nullable: true
                            nullable: true
                        roof:
                            type: object
                            properties:
                                area:
                                    type: number
                                    nullable: true
                                construction:
                                    type: string
                                    nullable: true
                                technical_condition:
                                    type: string
                                    nullable: true
                                thermal_insulation:
                                    type: string
                                    nullable: true
                                year_of_adjustment:
                                    type: string
                                    nullable: true
                            nullable: true
                        side_wall:
                            type: object
                            properties:
                                area:
                                    type: number
                                    nullable: true
                                heat_insulation:
                                    type: string
                                    nullable: true
                                prevailing_construction:
                                    type: string
                                    nullable: true
                                technical_condition:
                                    type: string
                                    nullable: true
                                year_of_adjustment:
                                    type: string
                                    nullable: true
                            nullable: true
                    nullable: true
                label:
                    type: string
                    nullable: true
                built_up_area:
                    type: number
                    nullable: true
                classrooms_count:
                    type: number
                    nullable: true
                csu_code:
                    type: string
                    nullable: true
                current_note:
                    type: string
                    nullable: true
                description:
                    type: string
                    nullable: true
                employees_count:
                    type: number
                    nullable: true
                energetic_management:
                    type: string
                    nullable: true
                energy_audits:
                    type: object
                    properties:
                        created_at:
                            type: string
                            nullable: true
                        ea_registration_number:
                            type: string
                            nullable: true
                        energy_audit:
                            type: string
                            nullable: true
                    nullable: true
                eno_id:
                    type: string
                    nullable: true
                fuel_and_energy:
                    type: object
                    properties:
                        coal:
                            type: boolean
                            nullable: true
                        czt:
                            type: boolean
                            nullable: true
                        electricity:
                            type: boolean
                            nullable: true
                        gas:
                            type: boolean
                            nullable: true
                        other:
                            type: boolean
                            nullable: true
                        oze:
                            type: boolean
                            nullable: true
                    nullable: true
                heated_bulding_volume:
                    type: number
                    nullable: true
                ku_code:
                    type: string
                    nullable: true
                location:
                    type: object
                    nullable: true
                    properties:
                        type:
                            type: string
                            example: "Point"
                        coordinates:
                            $ref: "#/components/schemas/Point"
                    required:
                        - coordinates
                        - type
                link:
                    type: string
                oze_energy_production:
                    type: object
                    properties:
                        heat_pump:
                            type: string
                            nullable: true
                        integrated_turbines_wind_energy:
                            type: string
                            nullable: true
                        solar_energy_photothermal:
                            type: string
                            nullable: true
                        solar_energy_photovoltaic:
                            type: string
                            nullable: true
                    nullable: true
                penb:
                    type: object
                    properties:
                        building_envelope:
                            type: number
                            nullable: true
                        building_envelope_category:
                            type: string
                            nullable: true
                        cooling:
                            type: number
                            nullable: true
                        cooling_category:
                            type: string
                            nullable: true
                        heating:
                            type: number
                            nullable: true
                        heating_category:
                            type: string
                            nullable: true
                        humidity_adjustment:
                            type: number
                            nullable: true
                        humidity_adjustment_category:
                            type: string
                            nullable: true
                        issue_date:
                            type: string
                            nullable: true
                        lighting:
                            type: number
                            nullable: true
                        lighting_category:
                            type: string
                            nullable: true
                        penb_number:
                            type: number
                            nullable: true
                        primary_non_renewable_energy:
                            type: number
                            nullable: true
                        primary_non_renewable_energy_category:
                            type: string
                            nullable: true
                        total_building_envelope_area:
                            type: number
                            nullable: true
                        total_energy_reference_area:
                            type: number
                            nullable: true
                        total_provided_energy:
                            type: number
                            nullable: true
                        total_provided_energy_category:
                            type: string
                            nullable: true
                        ventilation:
                            type: number
                            nullable: true
                        ventilation_category:
                            type: string
                            nullable: true
                        volume_factor_of_av_shape:
                            type: string
                            nullable: true
                        warm_water:
                            type: number
                            nullable: true
                        warm_water_category:
                            type: string
                            nullable: true
                    nullable: true
                registration_unit:
                    type: string
                    nullable: true
                secondary_use:
                    type: string
                    nullable: true
                students_count:
                    type: number
                    nullable: true
                technical_equipment:
                    type: object
                    properties:
                        cooling:
                            type: object
                            properties:
                                cooling_area_percentage:
                                    type: number
                                    nullable: true
                                cooling_system:
                                    type: string
                                    nullable: true
                                technical_condition:
                                    type: string
                                    nullable: true
                                year:
                                    type: string
                                    nullable: true
                            nullable: true
                        heating:
                            type: object
                            properties:
                                heat_percentage:
                                    type: number
                                    nullable: true
                                heating_system:
                                    type: string
                                    nullable: true
                                main_source_of_heat:
                                    type: string
                                    nullable: true
                                secondary_source_of_heat:
                                    type: string
                                    nullable: true
                                technical_condition:
                                    type: string
                                    nullable: true
                                year:
                                    type: string
                                    nullable: true
                            nullable: true
                        hot_water:
                            type: object
                            properties:
                                hot_water_source:
                                    type: string
                                    nullable: true
                                predominant_way_of_heating_tv:
                                    type: string
                                    nullable: true
                                technical_condition:
                                    type: string
                                    nullable: true
                                year:
                                    type: string
                                    nullable: true
                            nullable: true
                        humidity_adjustment:
                            type: object
                            properties:
                                humidity_adjustment:
                                    type: string
                                    nullable: true
                                technical_condition:
                                    type: string
                                    nullable: true
                                year:
                                    type: string
                                    nullable: true
                            nullable: true
                        lighting:
                            type: object
                            properties:
                                lighting:
                                    type: string
                                    nullable: true
                                measurement_method:
                                    type: string
                                    nullable: true
                                other_technological_elements:
                                    type: string
                                    nullable: true
                                technical_condition:
                                    type: string
                                    nullable: true
                                year:
                                    type: string
                                    nullable: true
                            nullable: true
                        ventilation:
                            type: object
                            properties:
                                technical_condition:
                                    type: string
                                    nullable: true
                                ventilation:
                                    type: string
                                    nullable: true
                                year:
                                    type: string
                                    nullable: true
                            nullable: true
                    nullable: true
                waste_and_emissions:
                    type: object
                    properties:
                        operating_co2_emissions:
                            type: string
                            nullable: true
                        solid_waste_production:
                            type: string
                            nullable: true
                        sox_emissions:
                            type: string
                            nullable: true
                        tied_co2_emissions:
                            type: string
                            nullable: true
                    nullable: true
                weekend_opening_hours:
                    type: string
                    nullable: true
                opening_hours:
                    type: string
                    nullable: true
                year_of_construction:
                    type: number
                    nullable: true
        EnergeticsAddress:
            type: object
            properties:
                street:
                    type: string
                    nullable: true
                house_number:
                    type: string
                    nullable: true
                city:
                    type: string
                    nullable: true
                country:
                    type: string
                    nullable: true
                mail:
                    type: string
                    nullable: true
                phone:
                    type: string
                    nullable: true
                web_address:
                    type: string
                    nullable: true
            additionalProperties: false
        EnergeticsDevice:
            type: object
            properties:
                id:
                    type: integer
                    format: int32
                addr:
                    type: string
                    nullable: true
                description:
                    type: string
                    nullable: true
                meter_number:
                    type: string
                    nullable: true
                meter_index:
                    type: integer
                    format: int32
                    nullable: true
                location_number:
                    type: string
                    nullable: true
                location_description:
                    type: string
                    nullable: true
                include_in_evaluation:
                    type: string
                    nullable: true
                meter_type:
                    type: string
                    nullable: true
                category:
                    type: string
                    nullable: true
                unit:
                    type: string
                    nullable: true
                replaced_meter_id:
                    type: string
                    nullable: true
                deleted:
                    type: string
                    nullable: true
                building_id:
                    type: integer
                    format: int32
                    nullable: true
            additionalProperties: false
        EnergeticsOrganizationFull:
            type: object
            properties:
                id:
                    type: integer
                    format: int32
                name:
                    type: string
                    nullable: true
                label:
                    type: string
                    nullable: true
                category:
                    type: string
                    nullable: true
                created_by_id:
                    type: string
                    nullable: true
                grafana_url:
                    type: string
                    nullable: true
                address:
                    $ref: "#/components/schemas/EnergeticsAddress"
                responsible_user:
                    type: array
                    items:
                        $ref: "#/components/schemas/EnergeticsUser"
                    nullable: true
                buildings:
                    type: array
                    items:
                        $ref: "#/components/schemas/EnergeticsBuildingShort"
                    nullable: true
                link:
                    type: string
                    nullable: true
            additionalProperties: false
        EnergeticsOrganizationShort:
            type: object
            properties:
                id:
                    type: integer
                    format: int32
                name:
                    type: string
                    nullable: true
                link:
                    type: string
                    nullable: true
            additionalProperties: false
        EnergeticsUser:
            type: object
            properties:
                name:
                    type: string
                    nullable: true
                last_name:
                    type: string
                    nullable: true
                position:
                    type: string
                    nullable: true
                phone:
                    type: string
                    nullable: true
                mail:
                    type: string
                    nullable: true
                company:
                    type: string
                    nullable: true
            additionalProperties: false
        Point:
            title: Point
            type: array
            minItems: 2
            maxItems: 2
            items:
                type: number
                format: float
            example:
                - 14.4633
                - 50.07827
        EnergeticsMeasurement:
            type: object
            properties:
                time:
                    type: string
                    format: date-time
                value:
                    type: string
                addr:
                    type: string
                meter:
                    type: string
                    nullable: true
                type:
                    $ref: "#/components/schemas/EnergeticsTypes"
                var:
                    $ref: "#/components/schemas/EnergeticsVariables"
            additionalProperties: false
        EnergeticsVariables:
            type: string
            example: core2
            enum:
                - core
                - core2
                - EFwActi
                - EFwActiVT
                - ERvReact
                - EFwReact
                - raw
                - T
                - CO2
                - RH
                - EFwActiNT
                - VOC
            description: >-
                core - Kumulovaný objem [m3]<br />
                core2 - Kumulovaný přepočítaný objem [Nm3]<br />
                EFwActi - Odběr činné energie [kWh]<br />
                EFwActiVT - Odběr činné energie, vysoký tarif [kVArh]<br />
                ERvReact - Dodávka jalové energie [kVArh]<br />
                EFwReact - Odběr jalové energie [kVArh]<br />
                raw - Číselník impulzů [imp]<br />
                RSSI - Síla signálu [dBm]<br />
                T - Teplota [°C]<br />
                CO2 - Koncentrace CO2 [ppm]<br />
                RH - Relativní vlhkost [%]<br />
                EFwActiNT - Odběr činné energie, nízký tarif [kVArh]<br />
                VOC - Míra koncentrace těkavých látek [%]<br />
                VT - Vysoký tarif [kWh]<br />
                NT - Nízký tarif [kWh]<br />
        EnergeticsTypes:
            type: string
            example: provider_value
            enum:
                - monthly_reading
                - provider_value
                - dotcontrols_value
            description: >-
                monthly_reading - hodnoty sčítané po měsících z 15 minutových spotřeb poskytovaných firmou PRE<br />
                provider_value - data získaná od poskytovatelů energií<br />
                dotcontrols_value - data získaná ze systémů VisApp firmy DotControls<br />
