Conseils pour la finalisation d un scenario pendant les tarifs tempo " jours Rouges "

Les id de mes virtuels sont 16933 et 16934 et l id stge qui récupère l info est le 7139

donc tu mets 7139 à la place de 2404

ouais c est bon je l avais déja fait :+1: :wink:

Le plus simple serait de nous montrer ce que tu as fait au lieu de coller une image de l’exemple et nous dire c okay

Car du coup on ne voit pas le reel mis en place et ca fait perdre un temps et une energie de dingue

bon je vous rebalance mon scenario de chauffe pour les jours rouges et j attends demain avant de vous embêter… :wink:
La patience a ces limites …?! :rofl: :joy:

désolé
voila le code:
Normalement tu dois me mettre 20/20 l ami

#!/usr/bin/python3
# ##settings

# AUTEUR : Noyax37
 # #SITE : 
 # #VERSION : 1.0
 # #DATE : 2021-10-25

#DEFINITION DE LA SIGNIFICATION DES BITS
#VOIR DOC ENEDIS POUR SIGNIFICATION DE CHAQUE MESSAGE https://www.enedis.fr/media/2035/download
def switch_mot1(argument):
	switcher = {
		0: "Ferme",
		1: "Ouvert",
	}
	return switcher.get(argument, "Invalide")

def switch_mot2(argument):
	switcher = {
		0: "Ferme",
		1: "Ouvert sur surpuissance",
		2: "ouvert sur surtension",
		3: "Ouvert sur delestage",
		4: "Ouvert sur ordre CPL ou Euridis",
		5: "Ouvert sur surchauffe avec I > Imax",
		6: "Ouvert sur surchauffe avec I < Imax",
	}
	return switcher.get(argument, "Invalide")

def switch_mot3(argument):
	switcher = {
		0: "Ferme",
		1: "Ouvert",
	}
	return switcher.get(argument, "Invalide")

def switch_mot4(argument):
	switcher = {
		0: "Toujours a 0",
		1: "Anormal",
	}
	return switcher.get(argument, "Invalide")

def switch_mot5(argument):
	switcher = {
		0: "Pas de surtension",
		1: "Surtension",
	}
	return switcher.get(argument, "Invalide")

def switch_mot6(argument):
	switcher = {
		0: "Pas de depassement",
		1: "Depassement en cours",
	}
	return switcher.get(argument, "Invalide")

def switch_mot7(argument):
	switcher = {
		0: "Consommateur",
		1: "Producteur",
	}
	return switcher.get(argument, "Invalide")

def switch_mot8(argument):
	switcher = {
		0: "Positive",
		1: "Negative",
	}
	return switcher.get(argument, "Invalide")

def switch_mot9(argument):
	switcher = {
		0: "Ventile sur index 1",
		1: "Ventile sur index 2",
		2: "Ventile sur index 3",
		3: "Ventile sur index 4",
		4: "Ventile sur index 5",
		5: "Ventile sur index 6",
		6: "Ventile sur index 7",
		7: "Ventile sur index 8",
		8: "Ventile sur index 9",
		9: "Ventile sur index 10",
	}
	return switcher.get(argument, "Invalide")

def switch_mot10(argument):
	switcher = {
		0: "Ventile sur index 1",
		1: "Ventile sur index 2",
		2: "Ventile sur index 3",
		3: "Ventile sur index 4",
	}
	return switcher.get(argument, "Invalide")

def switch_mot11(argument):
	switcher = {
		0: "Correct",
		1: "Degrade",
	}
	return switcher.get(argument, "Invalide")

def switch_mot12(argument):
	switcher = {
		0: "Historique",
		1: "Standard",
	}
	return switcher.get(argument, "Invalide")

def switch_mot13(argument):
	switcher = {
		0: "Non utilise",
		1: "Non utilise",
	}
	return switcher.get(argument, "Invalide")

def switch_mot14(argument):
	switcher = {
		0: "Desactivee",
		1: "Activee sans secu",
		2: "Invalide",
		3: "Activee avec secu",
	}
	return switcher.get(argument, "Invalide")

def switch_mot15(argument):
	switcher = {
		0: "New/unlock",
		1: "New/lock",
		2: "Registered",
		3: "Invalide",
	}
	return switcher.get(argument, "Invalide")

def switch_mot16(argument):
	switcher = {
		0: "Non synchro",
		1: "synchro",
	}
	return switcher.get(argument, "Invalide")

def switch_mot17(argument):
	switcher = {
		0: "Pas d'annonce",
		1: "Bleu",
		2: "Blanc",
		3: "Rouge",
	}
	return switcher.get(argument, "Invalide")

def switch_mot19(argument):
	switcher = {
		0: "Pas de preavis",
		1: "Preavis PM1",
		2: "Preavis PM2",
		3: "Preavis PM3",
	}
	return switcher.get(argument, "Invalide")

# DECLARATION DES VARIABLES
apikey = "eJLYNgQZbg1ktdHLu9rccbYwrI5BL4nilN0JvKCs4dUPsqXRcLEGvWbfKwRjpmum" # mettre ici votre cle API trouvee dans réglages/systeme/configuration puis aller dans API et prendre 'clé API'
ip_jeedom = "192.168.1.12"
apikey_jeedom = "wTZZlhU27iDhF7q0nua70D2C9btGyNa5yy0ykfhrU4LrDaXRe99HYgCyZsjR7Qta" #mettre ici la clé API que vous trouverez au même endroit que apikey mais prendre 'clé API virtuel'

# ID DES COMMANDES SOUS JEEDOM
idinfo = []
idSTGE = 7139 #id ou trouver le code STGE du linky
idinfo = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16933,16934] #id de la commande où aller mettre les traductions de STGE17 et 18



# IMPORTATION DES LIBRAIRIES
import sys
import requests

# ON RECUPERE LES DONNEES STGE
stgehex = requests.get("http://"+ip_jeedom+"/core/api/jeeApi.php?apikey="+apikey+"&type=cmd&id="+ str(idSTGE)).text

stgebin = bin(int(stgehex, 16)) #on traduit le message hexa en binaire
stgebin = stgebin [2::] #on supprime le 0b au debut du message binaire
bits = [stgebin]
longueur = len(stgebin)
#on stocke tous les bits unitairement
for i in range(32):
	if i > longueur - 1: 
		bits += '0' #on complete avec des zeros jusqu a 32 bits
	else:
		bits += [stgebin[longueur -1 -i:longueur -i]]
#print ('bits 2 ', bits)


message = [switch_mot1(int(bits[1]))]
message += [switch_mot2(int(bits[4]+bits[3]+bits[2],2))]
message += [switch_mot3(int(bits[5]))]
message += [switch_mot4(int(bits[6]))]
message += [switch_mot5(int(bits[7]))]
message += [switch_mot6(int(bits[8]))]
message += [switch_mot7(int(bits[9]))]
message += [switch_mot8(int(bits[10]))]
message += [switch_mot9(int(bits[14]+bits[13]+bits[12]+bits[11],2))]
message += [switch_mot10(int(bits[16]+bits[15],2))]
message += [switch_mot11(int(bits[17]))]
message += [switch_mot12(int(bits[18]))]
message += [switch_mot13(int(bits[19]))]
message += [switch_mot14(int(bits[21]+bits[20],2))]
message += [switch_mot15(int(bits[23]+bits[22],2))]
message += [switch_mot16(int(bits[24]))]
message += [switch_mot17(int(bits[26]+bits[25],2))]
message += [switch_mot17(int(bits[28]+bits[27],2))]
message += [switch_mot19(int(bits[30]+bits[29],2))]
message += [switch_mot19(int(bits[32]+bits[31],2))]
#print ('message', message)
#print ('test bin ', int(bits[2]+bits[1],2))

for i in range(16,18):
	requests.get("http://"+ip_jeedom+"/core/api/jeeApi.php?plugin=virtual&apikey="+apikey_jeedom+"&type=event&id="+str(idinfo[i])+"&value="+str(message[i]))
#test

C pas dire dire ok jai fait !

Pour voir le souci on doit voir ce que tu as fait.
Excuse moi mais qd tu me dis c bon j’ai fait c ok, j’ai plus qu’un doute.

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16933,16934

Y a pas un zero en trop ? C pas la position 16 et 17 ?

c est pas cool la…lol
Je veux bien que j ai étais un peu vite et peut être un peu confus dans mes explications mais en finalité c est pas trop mal pour un NOOB :wink:
J ai en infos « pas d annonce » donc normalement c est good !Après je testerai lorsque j aurai activé Tempo

j ai remplacé les données de notre ami Noyax par les miens !

Je suis sur telzphone pas facile de voir et compter !

ok ça c’est bon, dans les 2 champs? Normalement celui du jour, le 17 doit être à bleu

lol je ne me permettrai pas dans ma position et vu mon expérience de t envoyer une torpille
:rofl: :joy:

La couleur du demain n est pas le 17 ?

Bon par contre un petit, « félicitation », « j ai été un peu médisant »; « tu as géré », sa ferai zizir…?! :upside_down_face:

non, le 17 c’est aujourd’hui et le 18 demain

issu de teleinfo

des fois je me gourre aussi :wink:

Bon je vous montrerai mon scenario demain matin; je vais vous laisser respirer ce soir
Merci beaucoup pour vote patience et votre aide :star_struck: :heart_eyes:
Je vous souhaite une agréable soirée :upside_down_face: :upside_down_face:

Perso je l’ai fait en php dans le bloc script d’un scenario. Il y a sans doute plus élégant / performant, je ne suis pas un pro du php (je ne suis pas en pro en programmation de toutes façons) mais ça fonctionne nickel

$tags = $scenario->getTags(); // récuperation des tag

$hexbis = hexdec($tags['#registre_entree#']);
$scenario->setLog('DEBUG après base_convert : '.$hexbis);

$tags['#sec#'] = $hexbis & 1;
$scenario->setLog('DEBUG sec = '.$tags['#sec#']);
$hexbis = $hexbis >> 1;

$tags['#orga_coupure#'] = $hexbis & 7;
$scenario->setLog('DEBUG orga_coupure = '.$tags['#orga_coupure#']);
$hexbis = $hexbis >> 3;

$tags['#cache_bornes#'] = $hexbis & 1;
$scenario->setLog('DEBUG cache_bornes = '.$tags['#cache_bornes#']);
$hexbis = $hexbis >> 2;

$tags['#surtension#'] = $hexbis & 1;
$scenario->setLog('DEBUG surtension = '.$tags['#surtension#']);
$hexbis = $hexbis >> 1;

$tags['#depassement#'] = $hexbis & 1;
$scenario->setLog('DEBUG depassement = '.$tags['#depassement#']);
$hexbis = $hexbis >> 1;

$tags['#producteur#'] = $hexbis & 1;
$scenario->setLog('DEBUG producteur = '.$tags['#producteur#']);
$hexbis = $hexbis >> 1;

$tags['#energie_negative#'] = $hexbis & 1;
$scenario->setLog('DEBUG energie_negative = '.$tags['#energie_negative#']);
$hexbis = $hexbis >> 1;

$tags['#index_fournisseur#'] = $hexbis & 15;
$scenario->setLog('DEBUG index_fournisseur = '.$tags['#index_fournisseur#']);
$hexbis = $hexbis >> 4;

$tags['#index_distributeur#'] = $hexbis & 3;
$scenario->setLog('DEBUG index_distributeur = '.$tags['#index_distributeur#']);
$hexbis = $hexbis >> 2;

$tags['#horloge_degrade#'] = $hexbis & 1;
$scenario->setLog('DEBUG horloge_degrade = '.$tags['#horloge_degrade#']);
$hexbis = $hexbis >> 1;

$tags['#tic_standard#'] = $hexbis & 1;
$scenario->setLog('DEBUG tic_standard = '.$tags['#tic_standard#']);
$hexbis = $hexbis >> 2;

$tags['#com_euridis#'] = $hexbis & 3;
$scenario->setLog('DEBUG com_euridis = '.$tags['#com_euridis#']);
$hexbis = $hexbis >> 2;

$tags['#statut_cpl#'] = $hexbis & 3;
$scenario->setLog('DEBUG statut_cpl = '.$tags['#statut_cpl#']);
$hexbis = $hexbis >> 2;

$tags['#synchro_cpl#'] = $hexbis & 1;
$scenario->setLog('DEBUG scynchro_cpl = '.$tags['#synchro_cpl#']);
$hexbis = $hexbis >> 1;

$tags['#aujourdhui#'] = $hexbis & 3;
$scenario->setLog('DEBUG aujourdhui = '.$tags['#aujourdhui#']);
$hexbis = $hexbis >> 2;

$tags['#demain#'] = $hexbis & 3;
$scenario->setLog('DEBUG demain = '.$tags['#demain#']);
$hexbis = $hexbis >> 2;


$tags['#preavis_pm#'] = $hexbis & 3;
$scenario->setLog('DEBUG preavis_pm = '.$tags['#preavis_pm#']);
$hexbis = $hexbis >> 2;

$tags['#pointe_mobile#'] = $hexbis & 3;
$scenario->setLog('DEBUG pointe_mobile = '.$tags['#pointe_mobile#']);

$scenario->setTags($tags);

ensuite avec un bloc action → event, on peut mettre a jour n’importe quel info virtuel (ou chez moi la commande #DEMAIN# de mon compteur sur le plug-in téléinfo)