Outils pour utilisateurs

Outils du site


start:esp32:nodered:heure:nr

Date et heure dans Node red

Pour avoir la date du serveur , ICI le raspberry qui sert de serveur Node-Red

Avec le noeud Date/Time Formater

Il faut dans le menu “ Gerer la palette” installer =⇒ node-red-contrib-moment

Dans node-red , mettre les noeuds suivant :

Le noeud "Horodatage"

Intervalle ⇒ 1 secondes si vous voulez afficher les secondes ….

le noeud "Date/Time Formatter" pour la date

=⇒ Input From = Horodatage Output format = DD - MM - YYYY et Output to = msg.mytime

le noeud "Date/Time Formatter" pour l'heure

=⇒ Input From = Horodatage Output format = h - m - s ( en minuscule ) et Output to = msg.mytime

Affichage dans le dashboard

Code javascript

Vous pouvez importer ce code javascript dans un flux Node-Red pour avoir la date et l'heure dans votre dashboard , mais vous pouvez aussi tout refaire à la main en suivant les exemples ci-dessus …

Heure_PI_Node_red.json
[
    {
        "id": "35ba45dfea2add23",
        "type": "moment",
        "z": "cd6db7a86b3ae202",
        "name": "Format date",
        "topic": "",
        "input": "",
        "inputType": "date",
        "inTz": "Europe/Paris",
        "adjAmount": "0",
        "adjType": "hours",
        "adjDir": "add",
        "format": "DD - MM - YYYY",
        "locale": "fr-FR",
        "output": "mytime",
        "outputType": "msg",
        "outTz": "Europe/Paris",
        "x": 530,
        "y": 140,
        "wires": [
            [
                "e5b65527ac9c319f"
            ]
        ]
    },
    {
        "id": "e5b65527ac9c319f",
        "type": "ui_text",
        "z": "cd6db7a86b3ae202",
        "group": "932d398289bfe457",
        "order": 23,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Date",
        "format": "{{msg.mytime}}",
        "layout": "row-spread",
        "className": "",
        "style": false,
        "font": "",
        "fontSize": 16,
        "color": "#000000",
        "x": 850,
        "y": 140,
        "wires": []
    },
    {
        "id": "446e81bd677607f0",
        "type": "inject",
        "z": "cd6db7a86b3ae202",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "1",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 190,
        "y": 180,
        "wires": [
            [
                "35ba45dfea2add23",
                "6eda1c3d5cedd21b"
            ]
        ]
    },
    {
        "id": "70e3312fe2a2ccbb",
        "type": "ui_text",
        "z": "cd6db7a86b3ae202",
        "group": "932d398289bfe457",
        "order": 23,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Heure minutes",
        "format": "{{msg.mytime}}",
        "layout": "row-spread",
        "className": "",
        "style": false,
        "font": "",
        "fontSize": 16,
        "color": "#000000",
        "x": 860,
        "y": 220,
        "wires": []
    },
    {
        "id": "6eda1c3d5cedd21b",
        "type": "moment",
        "z": "cd6db7a86b3ae202",
        "name": "Format heures",
        "topic": "",
        "input": "",
        "inputType": "date",
        "inTz": "Europe/Paris",
        "adjAmount": "0",
        "adjType": "hours",
        "adjDir": "add",
        "format": "h - m - s ",
        "locale": "fr-FR",
        "output": "mytime",
        "outputType": "msg",
        "outTz": "Europe/Paris",
        "x": 540,
        "y": 220,
        "wires": [
            [
                "70e3312fe2a2ccbb"
            ]
        ]
    },
    {
        "id": "503ce05089ffc9a2",
        "type": "comment",
        "z": "cd6db7a86b3ae202",
        "name": "Noeud dans \"Commun\" ==> inject",
        "info": "",
        "x": 140,
        "y": 140,
        "wires": []
    },
    {
        "id": "2ace59f945371216",
        "type": "comment",
        "z": "cd6db7a86b3ae202",
        "name": "Noeud dans \" formats\" ==> Date/time Formatter",
        "info": "",
        "x": 500,
        "y": 80,
        "wires": []
    },
    {
        "id": "b38d4bc26e9e0a95",
        "type": "comment",
        "z": "cd6db7a86b3ae202",
        "name": "Noeud dans \" dashboard\" ==> texte",
        "info": "",
        "x": 920,
        "y": 80,
        "wires": []
    },
    {
        "id": "932d398289bfe457",
        "type": "ui_group",
        "name": "ESP32 ",
        "tab": "868039c03e1e9bab",
        "order": 1,
        "disp": true,
        "width": "10",
        "collapse": false,
        "className": ""
    },
    {
        "id": "868039c03e1e9bab",
        "type": "ui_tab",
        "name": "ESP32_802060",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    }
]
/home/chanteri/www/fablab37110/data/pages/start/esp32/nodered/heure/nr.txt · Dernière modification : 2024/01/23 11:28 de gerardadmin