Skip to content

Multidatastream creation gives error 400. Property 'unitOfMeasurements' must be non-NULL #49

@yaroslavtsevam

Description

@yaroslavtsevam

The code below gives error. ERROR:root:Creating MultiDatastream failed with status-code 400, Property 'unitOfMeasurements' must be non-NULL.


import frost_sta_client as fsc
uplink_data_example =  {'deduplicationId': 'd7fa29e4-9278-4930-85da-061f058c8bd8', 'time': '2025-08-14T17:51:23.556259682+00:00', 'deviceInfo': {'tenantId': '52f14cd4-c6f1-4fbd-8f87-4025e1d49242', 'tenantName': 'ChirpStack', 'applicationId': '7c3f2d19-f944-4174-90d5-92d01cdc5b41', 'applicationName': 'TT-Cyber', 'deviceProfileId': 'e73da284-f29c-491f-87ba-8f3189e35b36', 'deviceProfileName': 'TT-Cyber', 'deviceName': '8123A057', 'devEui': 'ac1f09fffe0d6ccf', 'deviceClassEnabled': 'CLASS_A', 'tags': {}}, 'devAddr': '01999cae', 'adr': True, 'dr': 5, 'fCnt': 3, 'fPort': 2, 'confirmed': False, 'data': 'Z6AjgQY/MQQAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==', 'rxInfo': [{'gatewayId': 'fc97314547544166', 'uplinkId': 42933, 'nsTime': '2025-08-14T17:51:23.345709465+00:00', 'rssi': -94, 'snr': 11.8, 'channel': 2, 'location': {'latitude': 65.6497228, 'longitude': 67.501316475984694}, 'context': 'ECvQwQ==', 'metadata': {'region_config_id': 'eu868', 'region_common_name': 'EU868'}, 'crcStatus': 'CRC_OK'}], 'txInfo': {'frequency': 868500000, 'modulation': {'lora': {'bandwidth': 125000, 'spreadingFactor': 7, 'codeRate': 'CR_4_5'}}}}
service_url_ex = "http://some_url/frost/v1.1"
service = fsc.SensorThingsService(service_url_ex)
serial_num =  uplink_data_example['deviceInfo']['deviceName']
thing_id = "TTCyberSN" + serial_num
ds_id    = f"MDSTTC{serial_num}Meteo"
ds_name  = f"mds_ttc_sn_{serial_num}_meteo"
thing_id = "TTCyberSN" + serial_num
tt_thing = service.things().find(id=thing_id)
sns_meteo= service.sensors().find(id="SnsTTCMeteo")
op_unix  = service.observed_properties().find(id="OPUnixTime")
op_airtemp= service.observed_properties().find(id="OPAirTempCel")
op_airrh = service.observed_properties().find(id="OPAirRH")
op_airvpd= service.observed_properties().find(id="OPAirVPD")
mds_meteo= fsc.MultiDatastream(
    id=ds_id,
    name=ds_name,
    description="TTCyber meteorological data (air temperature, RH, VPD)",
    observation_type="http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_ComplexObservation",
    multi_observation_data_types = [
        "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement",
        "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement",
        "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement",
        "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement"
    ],
    unit_of_measurements=[
        fsc.UnitOfMeasurement(name="Seconds",  symbol="s",   definition="Unix time"),
        fsc.UnitOfMeasurement(name="Celsius",  symbol="°C",  definition="Air temperature"),
        fsc.UnitOfMeasurement(name="Percent",  symbol="%",   definition="Relative humidity"),
        fsc.UnitOfMeasurement(name="kPa",      symbol="kPa", definition="Vapour Pressure Deficit")
    ],
    thing = tt_thing,
    sensor = sns_meteo,
    observed_properties = [op_unix, op_airtemp, op_airrh, op_airvpd]
)
service.create(mds_meteo)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions