.json to tags error

Hello everyone,

Here’s my problem. I want the content of a .json file to automatically feed a tag using a scheduled task.

Here is my .json file:

{"timestamp": "2025-09-04T16:16:40+02:00", "topic": "data/moxa-tbedb1004623", "payload": "{"hostname":"moxa-tbedb1004623","ip":"10.228.68.197","lat":43.343553800,"lon":5.364255933,"signal":{"rssi":-68.00,"rsrq":-18.00,"rsrp":-100.00,"snr":13.40},"data":{}}"}

Here is my code in the project library (read_json):

import json

def lireDerniereCoordonnees(file_path = "/var/lib/ignition/data/mqtt_data_json/data_moxa-tbedb1004623.json"):
    with open(file_path, "r") as f:
        lignes = f.readlines()
        print("Nombre de lignes lues :", len(lignes))  # debug
        if not lignes:
            return None, None
        derniere = lignes[-1].strip()
        print("Dernière ligne :", derniere)  # debug
        obj = json.loads(derniere)
        payload = json.loads(obj["payload"])
        lat = payload.get("lat")
        lon = payload.get("lon")
        print("Lat/Lon :", lat, lon)  # debug
        return lat, lon

Here is the content of my scheduled task:

def onScheduledEvent():
    import read_json

    lat, lon = read_json.lireDerniereCoordonnees()

    if lat is not None and lon is not None:
        system.tag.writeBlocking(
            [
                "[default]MQTT_Tags/SMDB/Edge_Node_tbedb1004623/Centri/Metadata/Latitude_Edge",
                "[default]MQTT_Tags/SMDB/Edge_Node_tbedb1004623/Centri/Metadata/Longitude_Edge"
            ],
            [lat, lon]
        )

However, when I run a test via the Ignition terminal, here’s the result:

Traceback (most recent call last):
  File "", line 3, in 
  File "module:read_json", line 0, in lireDerniereCoordonnees
IOError: [Errno 2] No such file or directory: '/var/lib/ignition/data/mqtt_data_json/data_moxa-tbedb1004623.json'

So I have a file access problem on my Linux PC.
I already granted all rights to my .json.

Is it an issue somewhere in my script? Or an authorization problem?
What should I do?

Thanks in advance!

Your error would imply to me that the file doesn’t exist. Try verifying whether it does by running this:

import os
file_path = "/var/lib/ignition/data/mqtt_data_json/data_moxa-tbedb1004623.json" print(os.path.exists(file_path))

Please reply with the response.