Affectation d'une valeur à une date heure fixe

Hello

via un Flow je récupère des informations JSON :

Dans ce JSON il y a un tableau avec des valeurs datées. Je voudrais avoir des conseils pour récupérer chaque valeur du tableau et les enregistrer dans une entité HA pour la bonne date.heure
en sachant que mon refresh de JSON tourne toutes les minutes mais je n’aurais une entrée dans le tableau que toutes les heures.

c’est possible de positionner une valeur pour une date?
Merci

voici le JSON :

{"earningStats":[{"meanReward":0.001046757,"reward":0.001299519,"timestamp":"2021-03-02T19:00:00Z"},{"meanReward":0.001035767,"reward":0.001338243,"timestamp":"2021-03-02T18:00:00Z"},{"meanReward":0.001022018,"reward":0.001515382,"timestamp":"2021-03-02T17:00:00Z"},{"meanReward":0.000998525,"reward":0.001348513,"timestamp":"2021-03-02T16:00:00Z"},{"meanReward":0.000981026,"reward":0.001107575,"timestamp":"2021-03-02T15:00:00Z"},{"meanReward":0.000974365,"reward":0.001126255,"timestamp":"2021-03-02T14:00:00Z"},{"meanReward":0.000965927,"reward":0.000890483,"timestamp":"2021-03-02T13:00:00Z"},{"meanReward":0.000970365,"reward":0.000882537,"timestamp":"2021-03-02T12:00:00Z"},{"meanReward":0.000975854,"reward":0.000943928,"timestamp":"2021-03-02T11:00:00Z"},{"meanReward":0.000977982,"reward":0.000853559,"timestamp":"2021-03-02T10:00:00Z"},{"meanReward":0.00098687,"reward":0.00118771,"timestamp":"2021-03-02T09:00:00Z"},{"meanReward":0.000971421,"reward":0.000617961,"timestamp":"2021-03-02T08:00:00Z"},{"meanReward":0.001000876,"reward":0.000822992,"timestamp":"2021-03-02T07:00:00Z"},{"meanReward":0.001017047,"reward":0.00097782,"timestamp":"2021-03-02T06:00:00Z"},{"meanReward":0.00102097,"reward":0.001207587,"timestamp":"2021-03-02T05:00:00Z"},{"meanReward":0.001000234,"reward":0.000859285,"timestamp":"2021-03-02T04:00:00Z"},{"meanReward":0.001017853,"reward":0.001287631,"timestamp":"2021-03-02T03:00:00Z"},{"meanReward":0.000979314,"reward":0.00093804,"timestamp":"2021-03-02T02:00:00Z"},{"meanReward":0.000986193,"reward":0.000947346,"timestamp":"2021-03-02T01:00:00Z"},{"meanReward":0.000993962,"reward":0.000961552,"timestamp":"2021-03-02T00:00:00Z"},{"meanReward":0.001002065,"reward":0.000945319,"timestamp":"2021-03-01T23:00:00Z"},{"meanReward":0.00102098,"reward":0.000778028,"timestamp":"2021-03-01T22:00:00Z"},{"meanReward":0.001142456,"reward":0.001101891,"timestamp":"2021-03-01T21:00:00Z"},{"meanReward":0.001183022,"reward":0.001183022,"timestamp":"2021-03-01T20:00:00Z"}],"expectedReward24H":0.03440316,"expectedRewardWeek":0.24082212,"pendingPayouts":[],"succeedPayouts":[{"amount":0.120375903,"approveUUID":"2558b2b2-a694-473a-b28c-3e50a892b5f2","coin":"ETH","createdAt":"2021-02-27T07:16:16.052573Z","meta":"{\"req_data\": {\"coin\": \"ETH\", \"amount\": 120375903, \"end_dt\": \"2021-02-27T06:30:00Z\", \"start_dt\": \"2021-02-23T06:30:00Z\", \"approveUUID\": \"2558b2b2-a694-473a-b28c-3e50a892b5f2\", \"user_address\": \"01a89f1e1912e22c692511f7bb897ce221992f03\"}, \"tx_receipt\": {\"gasUsed\": \"0x5208\", \"blockHash\": \"0xef710ff3894b1187222512293342b62f0bc7cb68a60ee37fd88c258567560c81\", \"transactionHash\": \"0xaf43df4ae8d4a99c253a2da66bb35e38ccbc693f03b67447619bec1c11fdbdb6\"}}","status":"succeed","txHash":"0xaf43df4ae8d4a99c253a2da66bb35e38ccbc693f03b67447619bec1c11fdbdb6","txMeta":"{\"nonce\":\"515223\",\"gas\":100000,\"gasUsed\":21000,\"gasPrice\":3000000000,\"blockHash\":\"0xef710ff3894b1187222512293342b62f0bc7cb68a60ee37fd88c258567560c81\"}","type":"miner_reward","updatedAt":"2021-02-27T08:04:22.382112Z","userAddress":"01a89f1e1912e22c692511f7bb897ce221992f03","uuid":"85537791-a11e-4a85-b636-78234d5597b4"}],"totalPaid":0.466393021,"totalUnpaid":0.083646972}

Je ne suis pas sûr d’avoir compris…
Est ce que c’est ça: a (par exemple) 20:00, tu veux pousser dans HA un truc du genre « A 17:00 c’était 10 », « A 18:00 c’était 20 » et ainsi de suite et recréer une espèce d’historique côté HA comme ça?

Je ne crois pas que ça soit possible.

Par contre, j’ai lu que tu as influxdb. Là, tu peux pousser les infos avec le timestamp et faire ça.

1 J'aime

Oui c’est bien cela. Je veux pouvoir donner une date heure à une valeur.
Si dans HA c’est pas possible, je veux bien l’info pour influxdb.
J’ai essayer le node influxdb in mais pas trouvé la syntax pour insérer le timestamp

Il y a un exemple dans la doc du noeud influxdb node-red-contrib-influxdb (node) - Node-RED qui est celui-là:

[{"id":"5c9146f5.b7e808","type":"function","z":"7ef0246b.8ad69c","name":"multiple readings","func":"msg.payload = [\n    [{\n        numValue: 10,\n        randomValue: Math.random()*10,\n        strValue: \"message1\",\n        time: new Date(\"2015-12-28T19:41:13Z\").getTime()\n    },\n    {\n        tag1:\"sensor1\",\n        tag2:\"device2\"\n    }],\n    [{\n        numValue: 20,\n        randomValue: Math.random()*10,\n        strValue: \"message2\",\n        time: new Date(\"2015-12-28T19:41:14Z\").getTime()\n    },\n    {\n        tag1:\"sensor1\",\n        tag2:\"device2\"\n    }]\n];\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":320,"wires":[["8c35e62.2fc3e18"]]},{"id":"64ce4703.e9c158","type":"inject","z":"7ef0246b.8ad69c","name":"","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":false,"topic":"","payload":"","payloadType":"date","x":176,"y":320,"wires":[["5c9146f5.b7e808"]]},{"id":"8c35e62.2fc3e18","type":"influxdb out","z":"7ef0246b.8ad69c","influxdb":"97a42112.cc31e","name":"","measurement":"test","precision":"","retentionPolicy":"","database":"","retentionPolicyV18Flux":"","org":"","bucket":"","x":770,"y":320,"wires":[]},{"id":"97a42112.cc31e","type":"influxdb","hostname":"192.168.0.112","port":"8086","protocol":"http","database":"telegraf","name":"","usetls":false,"tls":"","influxdbVersion":"1.x"}]

J’avais testé il y a quelques temps ça marche. Il faut adapter à ton cas.

1 J'aime

merci je vais regarder