Change source for outdoor temperature global variables

This commit is contained in:
2025-03-23 04:51:53 -04:00
parent 4b4fab1907
commit 0eae1369a3

View File

@ -1577,13 +1577,12 @@
"label": true "label": true
}, },
"nodes": [ "nodes": [
"274be2385ae894ce",
"dcc947fe66b6342b", "dcc947fe66b6342b",
"15f7382daddb4b3e" "15f7382daddb4b3e"
], ],
"x": 34, "x": 34,
"y": 999, "y": 999,
"w": 632, "w": 452,
"h": 82 "h": 82
}, },
{ {
@ -33484,27 +33483,6 @@
[] []
] ]
}, },
{
"id": "274be2385ae894ce",
"type": "api-render-template",
"z": "3e4ba157b540d183",
"g": "385f03591bc34bcc",
"name": "",
"server": "9e87348d.9c1c48",
"version": 0,
"template": "{% set temps = [\n states.sensor.kdfi_temperature,\n states.sensor.pirateweather_temperature,\n states.sensor.openweathermap_temperature,\n states.sensor.myradar_temperature\n] %}\n{% set sensor = temps | selectattr('state','ne','unavailable') | selectattr('state','ne','unknown') | map(attribute='entity_id') | list | first %}\n{{ states(sensor) | float }}\n",
"resultsLocation": "temperature",
"resultsLocationType": "msg",
"templateLocation": "",
"templateLocationType": "none",
"x": 320,
"y": 1040,
"wires": [
[
"15f7382daddb4b3e"
]
]
},
{ {
"id": "dcc947fe66b6342b", "id": "dcc947fe66b6342b",
"type": "inject", "type": "inject",
@ -33527,7 +33505,7 @@
"y": 1040, "y": 1040,
"wires": [ "wires": [
[ [
"274be2385ae894ce" "15f7382daddb4b3e"
] ]
] ]
}, },
@ -33537,14 +33515,14 @@
"z": "3e4ba157b540d183", "z": "3e4ba157b540d183",
"g": "385f03591bc34bcc", "g": "385f03591bc34bcc",
"name": "Set Global Variables", "name": "Set Global Variables",
"func": "const temp = msg.temperature\n\nglobal.set('outdoorTemp.tempInt',parseInt(temp))\nglobal.set('outdoorTemp.tempFloat',parseFloat(temp))\nglobal.set('outdoorTemp.tempStr',temp)\n\nnode.status({fill:\"green\",shape:\"dot\",text:temp})", "func": "const states = global.get('homeassistant.homeAssistant.states')\nconst temp = states['weather.iron_nerd_weather_station'].attributes.temperature\n\nglobal.set('outdoorTemp.tempInt',parseInt(temp))\nglobal.set('outdoorTemp.tempFloat',parseFloat(temp))\nglobal.set('outdoorTemp.tempStr',temp)\n\nnode.status({fill:\"green\",shape:\"dot\",text:`Int: ${parseInt(temp)} | Float: ${parseFloat(temp)} | Str: ${temp}`})",
"outputs": 0, "outputs": 0,
"timeout": "", "timeout": "",
"noerr": 0, "noerr": 0,
"initialize": "", "initialize": "",
"finalize": "", "finalize": "",
"libs": [], "libs": [],
"x": 540, "x": 360,
"y": 1040, "y": 1040,
"wires": [] "wires": []
}, },