Advertisement
Michele_Mercuri

flows.json

Mar 1st, 2024
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 13.07 KB | Software | 0 0
  1. [
  2.     {
  3.         "id": "92c3441fccf0c72a",
  4.         "type": "tab",
  5.         "label": "Tesla PV DLM",
  6.         "disabled": false,
  7.         "info": "",
  8.         "env": []
  9.     },
  10.     {
  11.         "id": "5eae9844675693c3",
  12.         "type": "function",
  13.         "z": "92c3441fccf0c72a",
  14.         "name": "Kw PV",
  15.         "func": "// Inizio con acquisire i dati di potenza dei vari sensori di inverter wallbox prelievo da rete e invio in rete\nvar power1 = global.get('homeassistant.homeAssistant.states[\"sensor.input_power\"].state');\nvar power2 = global.get('homeassistant.homeAssistant.states[\"sensor.wallbox_em_channel_1_power\"].state');\nvar power3 = global.get('homeassistant.homeAssistant.states[\"sensor.active_power\"].state');\nvar power4 = global.get('homeassistant.homeAssistant.states[\"sensor.pv_to_grid_kwp\"].state');\n\nlet w1 = parseFloat(power1);\nlet w2 = parseFloat(power2);\nlet w3 = parseFloat(power3);\nlet w4 = parseFloat(power4);\n\n// calcolo la potenza da fotovoltaico disponibile al netto dei consumi della casa \nlet y = w1 - w3 + w4 + w2;\n\n// acquisisco il dato del voltaggio corrente che servira per il calcolo della potenza moltiplicandolo per gli ampere \nvar power5 = global.get('homeassistant.homeAssistant.states[\"sensor.grid_voltage\"].state');\nlet w5 = parseFloat(power5);\n\n\nlet x = 1; // Inizio la sequenza con x = 1 per trovare il valore da settare in ampere per la tesla\n\nwhile (x * w5 < y) {\n    x++;\n}\n\nif (x * w5 > y) {\n    x--; // Preseguo fino a quando supera y e quindi diminuisco x di una unità\n}\n\nif (x < 1) {\n    x = 1; // Mi assicuro che il valore minimo di x sia 1\n}\n\nmsg.payload = x; // Setto il valore di x come payload del messaggio e lo passo al nodo successivo\nreturn msg;\n",
  16.         "outputs": 1,
  17.         "timeout": 0,
  18.         "noerr": 0,
  19.         "initialize": "",
  20.         "finalize": "",
  21.         "libs": [],
  22.         "x": 350,
  23.         "y": 160,
  24.         "wires": [
  25.             [
  26.                 "9ae92e887891e4b7"
  27.             ]
  28.         ]
  29.     },
  30.     {
  31.         "id": "9ae92e887891e4b7",
  32.         "type": "api-call-service",
  33.         "z": "92c3441fccf0c72a",
  34.         "name": "Set Amp Value",
  35.         "server": "1c37c350.3f926d",
  36.         "version": 5,
  37.         "debugenabled": true,
  38.         "domain": "number",
  39.         "service": "set_value",
  40.         "areaId": [],
  41.         "deviceId": [],
  42.         "entityId": [
  43.             "number.charging_amps"
  44.         ],
  45.         "data": "{\"value\": payload}",
  46.         "dataType": "jsonata",
  47.         "mergeContext": "",
  48.         "mustacheAltTags": false,
  49.         "outputProperties": [],
  50.         "queue": "none",
  51.         "x": 460,
  52.         "y": 220,
  53.         "wires": [
  54.             [
  55.                 "6d3e633a6d4a37e1"
  56.             ]
  57.         ]
  58.     },
  59.     {
  60.         "id": "6d3e633a6d4a37e1",
  61.         "type": "switch",
  62.         "z": "92c3441fccf0c72a",
  63.         "name": "",
  64.         "property": "payload",
  65.         "propertyType": "msg",
  66.         "rules": [
  67.             {
  68.                 "t": "eq",
  69.                 "v": "error",
  70.                 "vt": "msg"
  71.             },
  72.             {
  73.                 "t": "else"
  74.             }
  75.         ],
  76.         "checkall": "true",
  77.         "repair": false,
  78.         "outputs": 2,
  79.         "x": 650,
  80.         "y": 220,
  81.         "wires": [
  82.             [
  83.                 "ba2a67a88932fc6e"
  84.             ],
  85.             [
  86.                 "b84537dbce56c0b4"
  87.             ]
  88.         ]
  89.     },
  90.     {
  91.         "id": "ba2a67a88932fc6e",
  92.         "type": "delay",
  93.         "z": "92c3441fccf0c72a",
  94.         "name": "Repeat on error",
  95.         "pauseType": "delay",
  96.         "timeout": "5",
  97.         "timeoutUnits": "seconds",
  98.         "rate": "1",
  99.         "nbRateUnits": "1",
  100.         "rateUnits": "second",
  101.         "randomFirst": "1",
  102.         "randomLast": "5",
  103.         "randomUnits": "seconds",
  104.         "drop": false,
  105.         "allowrate": false,
  106.         "outputs": 1,
  107.         "x": 520,
  108.         "y": 100,
  109.         "wires": [
  110.             [
  111.                 "5eae9844675693c3"
  112.             ]
  113.         ]
  114.     },
  115.     {
  116.         "id": "023d82e4c90c607e",
  117.         "type": "function",
  118.         "z": "92c3441fccf0c72a",
  119.         "name": "Check PV Kw",
  120.         "func": "// Ottengo i valori di potenza dai sensori in Home Assistant\nvar power1 = global.get('homeassistant.homeAssistant.states[\"sensor.input_power\"].state');\nvar power2 = global.get('homeassistant.homeAssistant.states[\"sensor.wallbox_em_channel_1_power\"].state');\nvar power3 = global.get('homeassistant.homeAssistant.states[\"sensor.active_power\"].state');\nvar power4 = global.get('homeassistant.homeAssistant.states[\"sensor.pv_to_grid_kwp\"].state');\n\nlet w1 = parseFloat(power1);\nlet w2 = parseFloat(power2);\nlet w3 = parseFloat(power3);\nlet w4 = parseFloat(power4);\n\n// Calcolo la somma delle potenze per avere il netto da fotovoltiaco\nlet y = w1 - w3 + w4 + w2;\n\n// Ottengo il valore di tensione di rete\nvar power5 = global.get('homeassistant.homeAssistant.states[\"sensor.grid_voltage\"].state');\nlet w5 = parseFloat(power5);\n\n// Ottengo lo stato degli ampere settati in Tesla\nvar ampere1 = global.get('homeassistant.homeAssistant.states[\"number.charging_amps\"].state');\nlet a1 = parseFloat(ampere1);\n\n// Calcolo il valore della potenza di 1 ampere\nlet x = w5 * 1;\n\n// Calcolo la differenza tra potenza residua e 1 ampere\nlet z = y - x;\n\n// Verifico le condizioni e setto il payload\nif (z > 0 && z > x) {\n    msg.payload = 1; // Se z è maggiore di zero e maggiore di x, imposto payload a 1, cioè ho potenza disponibile e devo aumentare gli ampere di Tesla\n} else if (z > 0 && z < x) {\n    msg.payload = 0; // Se z è maggiore di zero e minore di x, imposto payload a 0, cioè non ho potenza sufficente per aumentare di 1 ampere la carica di Tesla\n} else if (z < 0 && a1 === 1) {\n    msg.payload = 0; // Se z è minore di zero e a1 è 1, imposto payload sempre a 0, ho potenza netta da PV negativa ma ampere Tesla è già 1 e quindi non posso diminuirlo ulteriormente\n} else {\n    msg.payload = 1; // ho potenza netta da pv negativa e quindi devo ridurre ampere Tesla\n}\n\nreturn msg;",
  121.         "outputs": 1,
  122.         "timeout": 0,
  123.         "noerr": 0,
  124.         "initialize": "",
  125.         "finalize": "",
  126.         "libs": [],
  127.         "x": 880,
  128.         "y": 200,
  129.         "wires": [
  130.             [
  131.                 "a9a0d4f71b0df33c"
  132.             ]
  133.         ]
  134.     },
  135.     {
  136.         "id": "b84537dbce56c0b4",
  137.         "type": "delay",
  138.         "z": "92c3441fccf0c72a",
  139.         "name": "Delay",
  140.         "pauseType": "delay",
  141.         "timeout": "5",
  142.         "timeoutUnits": "seconds",
  143.         "rate": "1",
  144.         "nbRateUnits": "1",
  145.         "rateUnits": "second",
  146.         "randomFirst": "1",
  147.         "randomLast": "5",
  148.         "randomUnits": "seconds",
  149.         "drop": false,
  150.         "allowrate": false,
  151.         "outputs": 1,
  152.         "x": 670,
  153.         "y": 280,
  154.         "wires": [
  155.             [
  156.                 "023d82e4c90c607e"
  157.             ]
  158.         ]
  159.     },
  160.     {
  161.         "id": "a9a0d4f71b0df33c",
  162.         "type": "switch",
  163.         "z": "92c3441fccf0c72a",
  164.         "name": "",
  165.         "property": "payload",
  166.         "propertyType": "msg",
  167.         "rules": [
  168.             {
  169.                 "t": "eq",
  170.                 "v": "0",
  171.                 "vt": "num"
  172.             },
  173.             {
  174.                 "t": "eq",
  175.                 "v": "1",
  176.                 "vt": "num"
  177.             }
  178.         ],
  179.         "checkall": "true",
  180.         "repair": false,
  181.         "outputs": 2,
  182.         "x": 910,
  183.         "y": 360,
  184.         "wires": [
  185.             [
  186.                 "12231880eba72e9a"
  187.             ],
  188.             [
  189.                 "d85fb9a663ec890c"
  190.             ]
  191.         ]
  192.     },
  193.     {
  194.         "id": "12231880eba72e9a",
  195.         "type": "delay",
  196.         "z": "92c3441fccf0c72a",
  197.         "name": "Delay",
  198.         "pauseType": "delay",
  199.         "timeout": "5",
  200.         "timeoutUnits": "seconds",
  201.         "rate": "1",
  202.         "nbRateUnits": "1",
  203.         "rateUnits": "second",
  204.         "randomFirst": "1",
  205.         "randomLast": "5",
  206.         "randomUnits": "seconds",
  207.         "drop": false,
  208.         "allowrate": false,
  209.         "outputs": 1,
  210.         "x": 890,
  211.         "y": 260,
  212.         "wires": [
  213.             [
  214.                 "023d82e4c90c607e"
  215.             ]
  216.         ]
  217.     },
  218.     {
  219.         "id": "c1a4eb5bcf897556",
  220.         "type": "trigger-state",
  221.         "z": "92c3441fccf0c72a",
  222.         "name": "Tesla Charger ON",
  223.         "server": "1c37c350.3f926d",
  224.         "version": 4,
  225.         "inputs": 0,
  226.         "outputs": 2,
  227.         "exposeAsEntityConfig": "",
  228.         "entityId": "switch.charger",
  229.         "entityIdType": "exact",
  230.         "debugEnabled": false,
  231.         "constraints": [
  232.             {
  233.                 "targetType": "this_entity",
  234.                 "targetValue": "",
  235.                 "propertyType": "current_state",
  236.                 "propertyValue": "new_state.state",
  237.                 "comparatorType": "is",
  238.                 "comparatorValueDatatype": "str",
  239.                 "comparatorValue": "on"
  240.             },
  241.             {
  242.                 "targetType": "this_entity",
  243.                 "targetValue": "",
  244.                 "propertyType": "previous_state",
  245.                 "propertyValue": "old_state.state",
  246.                 "comparatorType": "is",
  247.                 "comparatorValueDatatype": "str",
  248.                 "comparatorValue": "off"
  249.             }
  250.         ],
  251.         "customOutputs": [],
  252.         "outputInitially": false,
  253.         "stateType": "str",
  254.         "enableInput": false,
  255.         "exposeToHomeAssistant": false,
  256.         "haConfig": [
  257.             {
  258.                 "property": "name",
  259.                 "value": ""
  260.             },
  261.             {
  262.                 "property": "icon",
  263.                 "value": ""
  264.             }
  265.         ],
  266.         "x": 110,
  267.         "y": 80,
  268.         "wires": [
  269.             [
  270.                 "3f70a3d940f291bb"
  271.             ],
  272.             []
  273.         ]
  274.     },
  275.     {
  276.         "id": "3f70a3d940f291bb",
  277.         "type": "api-current-state",
  278.         "z": "92c3441fccf0c72a",
  279.         "name": "Tesla is at Home",
  280.         "server": "1c37c350.3f926d",
  281.         "version": 3,
  282.         "outputs": 2,
  283.         "halt_if": "home",
  284.         "halt_if_type": "str",
  285.         "halt_if_compare": "is",
  286.         "entity_id": "device_tracker.location_tracker",
  287.         "state_type": "str",
  288.         "blockInputOverrides": false,
  289.         "outputProperties": [
  290.             {
  291.                 "property": "payload",
  292.                 "propertyType": "msg",
  293.                 "value": "",
  294.                 "valueType": "entityState"
  295.             },
  296.             {
  297.                 "property": "data",
  298.                 "propertyType": "msg",
  299.                 "value": "",
  300.                 "valueType": "entity"
  301.             }
  302.         ],
  303.         "for": "0",
  304.         "forType": "num",
  305.         "forUnits": "minutes",
  306.         "override_topic": false,
  307.         "state_location": "payload",
  308.         "override_payload": "msg",
  309.         "entity_location": "data",
  310.         "override_data": "msg",
  311.         "x": 140,
  312.         "y": 160,
  313.         "wires": [
  314.             [
  315.                 "5eae9844675693c3"
  316.             ],
  317.             []
  318.         ]
  319.     },
  320.     {
  321.         "id": "d85fb9a663ec890c",
  322.         "type": "api-current-state",
  323.         "z": "92c3441fccf0c72a",
  324.         "name": "if on Charger",
  325.         "server": "1c37c350.3f926d",
  326.         "version": 3,
  327.         "outputs": 2,
  328.         "halt_if": "on",
  329.         "halt_if_type": "str",
  330.         "halt_if_compare": "is",
  331.         "entity_id": "switch.charger",
  332.         "state_type": "str",
  333.         "blockInputOverrides": false,
  334.         "outputProperties": [
  335.             {
  336.                 "property": "payload",
  337.                 "propertyType": "msg",
  338.                 "value": "",
  339.                 "valueType": "entityState"
  340.             },
  341.             {
  342.                 "property": "data",
  343.                 "propertyType": "msg",
  344.                 "value": "",
  345.                 "valueType": "entity"
  346.             }
  347.         ],
  348.         "for": "0",
  349.         "forType": "num",
  350.         "forUnits": "minutes",
  351.         "override_topic": false,
  352.         "state_location": "payload",
  353.         "override_payload": "msg",
  354.         "entity_location": "data",
  355.         "override_data": "msg",
  356.         "x": 330,
  357.         "y": 360,
  358.         "wires": [
  359.             [
  360.                 "5eae9844675693c3"
  361.             ],
  362.             []
  363.         ]
  364.     },
  365.     {
  366.         "id": "1c37c350.3f926d",
  367.         "type": "server",
  368.         "name": "Home Assistant",
  369.         "version": 5,
  370.         "addon": true,
  371.         "rejectUnauthorizedCerts": true,
  372.         "ha_boolean": "y|yes|true|on|home|open",
  373.         "connectionDelay": true,
  374.         "cacheJson": true,
  375.         "heartbeat": false,
  376.         "heartbeatInterval": "30",
  377.         "areaSelector": "id",
  378.         "deviceSelector": "id",
  379.         "entitySelector": "id",
  380.         "statusSeparator": "at: ",
  381.         "statusYear": "hidden",
  382.         "statusMonth": "short",
  383.         "statusDay": "numeric",
  384.         "statusHourCycle": "h23",
  385.         "statusTimeFormat": "h:m",
  386.         "enableGlobalContextStore": true
  387.     }
  388. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement