Python Script Compilation Error in Ignition - SyntaxError: mismatched input expecting INDENT

Hello everyone,

I'm having trouble with a Python script in Ignition that won't compile. I keep getting a syntax error and I can't figure out what's wrong.

Error Message:

Warning: "Scheduled Script" did not compile!
Parse Error:
File "", line 6
mode_ete = system.tag.readBlocking(["[CRY_FACILITIES]Cernay/BA/nouveau BA/Convecteurs/réglages/mode ETE"])[0].value
^
SyntaxError: mismatched input 'mode_ete' expecting INDENT

My Script:

# Script scheduled pour la gestion des convecteurs
# Récupération des valeurs de configuration

# Lecture du mode ETE (True = été, False = hiver)
mode_ete = system.tag.readBlocking(["[CRY_FACILITIES]Cernay/BA/nouveau BA/Convecteurs/réglages/mode ETE"])[0].value

# Lecture des consignes
consigne_hiver = system.tag.readBlocking(["[CRY_FACILITIES]Cernay/BA/nouveau BA/Convecteurs/réglages/consigne hiver"])[0].value
consigne_ete = system.tag.readBlocking(["[CRY_FACILITIES]Cernay/BA/nouveau BA/Convecteurs/réglages/consigne ete"])[0].value

print("Lecture des parametres reussie:")
print("Mode ETE: " + str(mode_ete))
print("Consigne hiver: " + str(consigne_hiver))
print("Consigne ete: " + str(consigne_ete))

# Definition des convecteurs a gerer
convecteurs = ["17", "18", "14-A"]

# Determination de la consigne et du mode a appliquer
if mode_ete == True:
    consigne_a_appliquer = consigne_ete
    mode_operation = 1
    print("Mode ete active - Consigne: " + str(consigne_ete))
else:
    consigne_a_appliquer = consigne_hiver
    mode_operation = 0
    print("Mode hiver active - Consigne: " + str(consigne_hiver))

# Creation des listes pour l'ecriture groupee
tags_consigne = []
tags_mode_operation = []
tags_mode_ventilation = []
valeurs_consigne = []
valeurs_mode_operation = []
valeurs_mode_ventilation = []

# Preparation des tags pour chaque convecteur
for convecteur in convecteurs:
    tags_consigne.append("[CRY_FACILITIES]Cernay/BA/nouveau BA/Convecteurs/" + convecteur + "/Consigne")
    valeurs_consigne.append(consigne_a_appliquer)
    
    tags_mode_operation.append("[CRY_FACILITIES]Cernay/BA/nouveau BA/Convecteurs/" + convecteur + "/reglages/Operation mode configuration")
    valeurs_mode_operation.append(mode_operation)
    
    tags_mode_ventilation.append("[CRY_FACILITIES]Cernay/BA/nouveau BA/Convecteurs/" + convecteur + "/Mode ventilation")
    valeurs_mode_ventilation.append(3)

# Ecriture des valeurs
system.tag.writeBlocking(tags_consigne, valeurs_consigne)
system.tag.writeBlocking(tags_mode_operation, valeurs_mode_operation)
system.tag.writeBlocking(tags_mode_ventilation, valeurs_mode_ventilation)

print("Script termine - Convecteurs traites: " + str(convecteurs))

Context:

  • This is a scheduled script in Ignition
  • The script is supposed to read configuration values from tags and update multiple heater units

The error message suggests it's expecting an INDENT, but I don't understand why since line 6 is just a simple variable assignment.

Any help would be greatly appreciated!

What is the indentation in regards to the def?

def doSomething(anything):
	param = anything
	print param

You need that first level of indentation for the entire code block.

Select the whole code block (except the top line def) and hit Tab to indent the whole section (if that's the problem).

Tip: right-click on the editor | Appearance | Whitespace will show you tabs and spaces.

Pay close attention when Ignition presents an event editor with an embedded def. This is the modern Ignition approach to custom code, as it has performance advantages. The code must be indented under the def.

Older event scripts show a completely blank editor. In those, event information is exposed as local variables, not as function arguments, and the code is not indented.