[Résolu] Petit script ne fonctionne plus après ma maj 2023.2

Forum dédié aux problématiques concernant les scripts pour DomoticZ.
Entourez votre code et les logs avec les balises nommées code grâce au bouton <\>.
Georges Orwell
Messages : 32
Inscription : 30 avr. 2015, 09:46

[Résolu] Petit script ne fonctionne plus après ma maj 2023.2

Message par Georges Orwell »

Bonjour,

J'ai un petit script très simple qui ne fonctionne plus après la maj 2023.2.
Quelqu'un peut-il me dire pourquoi.
Ce script passe la consigne de mes vannes thermostatiques à 15 °C lorsqu'elles reçoivent une autre consigne.
Cela permet de ne pas les faire manœuvrer et donc consommer lorsque le chauffage est éteint en été.

Code : Tout sélectionner

local Temperature_SP = 'Bureau'
local Temperature_SP1 = 'Salon télé'
local Temperature_SP2 = 'Salon'
local Temperature_SP3 = 'SDB bas'
local Temperature_SP4 = 'Chambre Emma'
local Temperature_SP5 = 'SDB haut'
local Temperature_SP6 = 'Chambre parents'



commandArray = {}

local iThermostatSetPoint = tonumber( otherdevices_svalues[Temperature_SP] )
local iThermostatSetPoint1 = tonumber( otherdevices_svalues[Temperature_SP1] )
local iThermostatSetPoint2 = tonumber( otherdevices_svalues[Temperature_SP2] )
local iThermostatSetPoint3 = tonumber( otherdevices_svalues[Temperature_SP3] )
local iThermostatSetPoint4 = tonumber( otherdevices_svalues[Temperature_SP4] )
local iThermostatSetPoint5 = tonumber( otherdevices_svalues[Temperature_SP5] )
local iThermostatSetPoint6 = tonumber( otherdevices_svalues[Temperature_SP6] )

if (otherdevices['Consigne thermostats été']=='On' and iThermostatSetPoint > 15)  then
        commandArray={['UpdateDevice']='268|0|15'}
end  

if (otherdevices['Consigne thermostats été']=='On' and iThermostatSetPoint1 > 15)  then
        commandArray={['UpdateDevice']='258|0|15'}
end

if (otherdevices['Consigne thermostats été']=='On' and iThermostatSetPoint2 > 15)  then
        commandArray={['UpdateDevice']='264|0|15'}
end

if (otherdevices['Consigne thermostats été']=='On' and iThermostatSetPoint3 > 15)  then
        commandArray={['UpdateDevice']='256|0|15'}
end

if (otherdevices['Consigne thermostats été']=='On' and iThermostatSetPoint4 > 15)  then
        commandArray={['UpdateDevice']='266|0|15'}
end

if (otherdevices['Consigne thermostats été']=='On' and iThermostatSetPoint5 > 15)  then
        commandArray={['UpdateDevice']='260|0|15'}
end

if (otherdevices['Consigne thermostats été']=='On' and iThermostatSetPoint6 > 15)  then
        commandArray={['UpdateDevice']='262|0|15'}
end

return commandArray
Le message d'erreur est:

2023-07-23 14:10:25.476 Error: EventSystem: in Consigne été: [string "local Temperature_SP = 'Bureau'..."]:21: attempt to compare number with nil

Je ne comprends pas pourquoi la valeur est nulle.

Merci pour votre aide.

Georges
Dernière modification par Georges Orwell le 25 juil. 2023, 14:45, modifié 1 fois.
Keros
Messages : 6638
Inscription : 23 juil. 2019, 20:57

Re: Petit script ne fonctionne plus après ma maj 2023.2

Message par Keros »

Je te propose de regarder le petit guide Aide au débogage que j'ai écrit (lien dans ma signature) : l'idée est de trouver quel élément te renvoie une valeur nulle.
Comment bien utiliser le forum : Poser une question, Mettre un script, un fichier, une image ou des logs
Mes petits guides : Débuter en programmation, Le débogage, Le choix de matériel, Les sauvegardes
Ma présentation - Mes Tutos
Georges Orwell
Messages : 32
Inscription : 30 avr. 2015, 09:46

Re: Petit script ne fonctionne plus après ma maj 2023.2

Message par Georges Orwell »

Bonjour,

Suite au bon conseil de Keros, j'ai cherché quelles valeurs renvoyaient nul en ajoutant des "print" dans mon script.
Etrangement alors que les lignes sont les mêmes, certaines renvoyaient nul alors que d'autres non.
Encore plus étrange lorsque j'ai nettoyé le script et effacé quelques lignes vides, le script s'est remis à fonctionner !
Je soupçonne donc simplement un petit bug.

Georges
Répondre