Anyway to create an entity from a global variable?

I have a global variable that takes the humidity from the downstairs thermostat and adds 10 to it. I would like to be able to view this value in one of my view “pages” in HA. But I would need it to be an entity.

Is this possible? (and yes I know i could just view the thermostat humidity entity and +10 in my head, lol)

You can just use a Template Sensor along the lines of:

{{ states("myothersensor") | float(0) + 10 }}
1 Like

And if you want it from NR, then look at the sensor node. It creates a sensor in HA for you and you provide the data from your flow

I’d like to keep in NR if possible. Can you show me how I would provide the data from my flow to the sensor node. I started to config the sensor node but dont even know if what I put in so far is right.

[{"id":"c1f94c493d475aa6","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"d27f8c5cd5e68cb1","type":"inject","z":"c1f94c493d475aa6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":135,"y":120,"wires":[["1fc4454d388a0f8a"]]},{"id":"1fc4454d388a0f8a","type":"api-current-state","z":"c1f94c493d475aa6","name":"","server":"ab3e2c53.e3491","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.thermostat_t6_humidity","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":525,"y":120,"wires":[["f39c46635ff69be2"]]},{"id":"f39c46635ff69be2","type":"change","z":"c1f94c493d475aa6","name":"Set master_bathroom_humidity_value to home humidity + 10","rules":[{"t":"set","p":"master_bathroom_humidity_value","pt":"global","to":"msg.payload+10","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1035,"y":120,"wires":[[]]},{"id":"31b6b168d8897667","type":"ha-sensor","z":"c1f94c493d475aa6","name":"Humidity global sensor","entityConfig":"0d9da44376ba82b6","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1450,"y":120,"wires":[[]]},{"id":"ab3e2c53.e3491","type":"server","name":"AvilaSmartHome","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"0d9da44376ba82b6","type":"ha-entity-config","server":"ab3e2c53.e3491","deviceConfig":"","name":"Humidity global","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Humidity global"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":"humidity"},{"property":"unit_of_measurement","value":"%"},{"property":"state_class","value":"measurement"}],"resend":false,"debugEnabled":false}]

Will you use Global elsewhere?
If not, you don’t need to define Global.
If you need, you can set it directly in the Current state.

Edit: I made a new global and now its working. Its almost as if something else in node red keeps writing to that original global without doing to +10 math

@walberjunior I can not get the sensor to show the value of the global. It keeps showing 55, which is the value of my downstairs thermostat (t6 humidity). But the global is that value (55) + 10. So the sensor should be 65.

Not sure what I am doing wrong.

[{"id":"c1f94c493d475aa6","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"d27f8c5cd5e68cb1","type":"inject","z":"c1f94c493d475aa6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":135,"y":120,"wires":[["1fc4454d388a0f8a"]]},{"id":"1fc4454d388a0f8a","type":"api-current-state","z":"c1f94c493d475aa6","name":"","server":"ab3e2c53.e3491","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.thermostat_t6_humidity","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":410,"y":120,"wires":[["f39c46635ff69be2"]]},{"id":"f39c46635ff69be2","type":"change","z":"c1f94c493d475aa6","name":"Set master_bathroom_humidity_value to home humidity + 10","rules":[{"t":"set","p":"master_bathroom_humidity_value","pt":"global","to":"msg.payload+10","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":120,"wires":[[]]},{"id":"ac4e0c06e430e6bf","type":"inject","z":"c1f94c493d475aa6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":135,"y":240,"wires":[["a883b7a4f76f604e"]]},{"id":"0d262cc83ceedd4e","type":"ha-sensor","z":"c1f94c493d475aa6","name":"Humidity global sensor","entityConfig":"0d9da44376ba82b6","version":0,"state":"master_bathroom_humidity_value","stateType":"global","attributes":[],"inputOverride":"allow","outputProperties":[],"x":715,"y":240,"wires":[[]]},{"id":"a883b7a4f76f604e","type":"api-current-state","z":"c1f94c493d475aa6","name":"","server":"ab3e2c53.e3491","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.thermostat_t6_humidity","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"master_bathroom_humidity_value","propertyType":"global","value":"","valueType":"entityState"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":415,"y":240,"wires":[["0d262cc83ceedd4e"]]},{"id":"ab3e2c53.e3491","type":"server","name":"AvilaSmartHome","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"0d9da44376ba82b6","type":"ha-entity-config","server":"ab3e2c53.e3491","deviceConfig":"","name":"Humidity global","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Humidity global"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":"humidity"},{"property":"unit_of_measurement","value":"%"},{"property":"state_class","value":"measurement"}],"resend":false,"debugEnabled":false}]

But why are you using global? Why not just use the payload?

@walberjunior

The payload of what? The t6 humidity sensor? But that would be 55. I want it to be 65. (55+10)

Flow and global only make sense if you need the information in another “block” of nodes or if you are going to use another flow (tab)

[{"id":"c1f94c493d475aa6","type":"tab","label":"Set Global Here","disabled":false,"info":"","env":[]},{"id":"2bd00463ee37a8a4","type":"group","z":"c1f94c493d475aa6","name":"With Payload only","style":{"label":true},"nodes":["b5b215d6a2e44df7","878a916c743d7ab5"],"x":214,"y":79,"w":532,"h":82},{"id":"5c4f3aaa4cbb03b4","type":"group","z":"c1f94c493d475aa6","g":"839db5320ff66e35","name":"Set Flow","style":{"label":true,"color":"#ff0000"},"nodes":["76d07ced6f3b97ec"],"x":194,"y":279,"w":272,"h":82},{"id":"59b801b8ab4ca07c","type":"group","z":"c1f94c493d475aa6","g":"839db5320ff66e35","name":"Get the flow here","style":{"label":true,"color":"#ff0000"},"nodes":["f39c46635ff69be2","d27f8c5cd5e68cb1","0df06f8edac7af27"],"x":194,"y":379,"w":1152,"h":82},{"id":"839db5320ff66e35","type":"group","z":"c1f94c493d475aa6","name":"With flow","style":{"label":true,"label-position":"n","color":"#ff0000"},"nodes":["5c4f3aaa4cbb03b4","59b801b8ab4ca07c"],"x":168,"y":253,"w":1204,"h":234},{"id":"984766aa47405ced","type":"group","z":"c1f94c493d475aa6","name":"With global","style":{"label":true,"label-position":"n","color":"#ff0000"},"nodes":["253a85d49ce292b9","c288d43f21c60750"],"x":168,"y":553,"w":1204,"h":234},{"id":"253a85d49ce292b9","type":"group","z":"c1f94c493d475aa6","g":"984766aa47405ced","name":"Set Global","style":{"label":true,"color":"#ff0000"},"nodes":["7d3ae0064cd0566d"],"x":194,"y":579,"w":272,"h":82},{"id":"c288d43f21c60750","type":"group","z":"c1f94c493d475aa6","g":"984766aa47405ced","name":"This group needs to be in another tab (to make sense of using Global)","style":{"label":true,"color":"#ff0000","stroke":"#ff0000","label-position":"ne"},"nodes":["3d3fca809abc63e4","2c730f51bdd5568d","b447da0f0ef3f846"],"x":194,"y":679,"w":1152,"h":82},{"id":"b5b215d6a2e44df7","type":"ha-sensor","z":"c1f94c493d475aa6","g":"2bd00463ee37a8a4","name":"Humidity global sensor","entityConfig":"0d9da44376ba82b6","version":0,"state":"msg.payload+10","stateType":"jsonata","attributes":[],"inputOverride":"allow","outputProperties":[],"x":620,"y":120,"wires":[[]]},{"id":"878a916c743d7ab5","type":"server-state-changed","z":"c1f94c493d475aa6","g":"2bd00463ee37a8a4","name":"","server":"ab3e2c53.e3491","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":350,"y":120,"wires":[["b5b215d6a2e44df7"]]},{"id":"f39c46635ff69be2","type":"change","z":"c1f94c493d475aa6","g":"59b801b8ab4ca07c","name":"Set master_bathroom_humidity_value to home humidity + 10","rules":[{"t":"set","p":"master_bathroom_humidity_value","pt":"flow","to":"msg.payload+10","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":420,"wires":[["0df06f8edac7af27"]]},{"id":"76d07ced6f3b97ec","type":"server-state-changed","z":"c1f94c493d475aa6","g":"5c4f3aaa4cbb03b4","name":"","server":"ab3e2c53.e3491","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"master_bathroom_humidity_value","propertyType":"flow","value":"","valueType":"triggerId"}],"x":330,"y":320,"wires":[[]]},{"id":"d27f8c5cd5e68cb1","type":"inject","z":"c1f94c493d475aa6","g":"59b801b8ab4ca07c","name":"You need som trigger to update the sensor","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":400,"y":420,"wires":[["f39c46635ff69be2"]]},{"id":"0df06f8edac7af27","type":"ha-sensor","z":"c1f94c493d475aa6","g":"59b801b8ab4ca07c","name":"Humidity global sensor","entityConfig":"0d9da44376ba82b6","version":0,"state":"msg.payload+10","stateType":"jsonata","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1220,"y":420,"wires":[[]]},{"id":"7d3ae0064cd0566d","type":"server-state-changed","z":"c1f94c493d475aa6","g":"253a85d49ce292b9","name":"","server":"ab3e2c53.e3491","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"master_bathroom_humidity_value","propertyType":"flow","value":"","valueType":"triggerId"}],"x":330,"y":620,"wires":[[]]},{"id":"3d3fca809abc63e4","type":"change","z":"c1f94c493d475aa6","g":"c288d43f21c60750","name":"Set master_bathroom_humidity_value to home humidity + 10","rules":[{"t":"set","p":"master_bathroom_humidity_value","pt":"global","to":"msg.payload+10","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":720,"wires":[["b447da0f0ef3f846"]]},{"id":"2c730f51bdd5568d","type":"inject","z":"c1f94c493d475aa6","g":"c288d43f21c60750","name":"You need som trigger to update the sensor","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":400,"y":720,"wires":[["3d3fca809abc63e4"]]},{"id":"b447da0f0ef3f846","type":"ha-sensor","z":"c1f94c493d475aa6","g":"c288d43f21c60750","name":"Humidity global sensor","entityConfig":"0d9da44376ba82b6","version":0,"state":"msg.payload+10","stateType":"jsonata","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1220,"y":720,"wires":[[]]},{"id":"0d9da44376ba82b6","type":"ha-entity-config","server":"ab3e2c53.e3491","deviceConfig":"","name":"Humidity global","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Humidity global"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":"humidity"},{"property":"unit_of_measurement","value":"%"},{"property":"state_class","value":"measurement"}],"resend":false,"debugEnabled":false},{"id":"ab3e2c53.e3491","type":"server","name":"AvilaSmartHome","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

You will need to edit the entities if you want to use this flow

Ok, I am picking up what your throwing down! I am only using the current global in one place, so maybe it is overkill.

1 Like

Yes.

And you don’t need to create several servers

Thats from importing other peoples flows. Just havent deleted it, lol

@walberjunior

Wait! Now I remember why I had to create a global. Because I cant directly compared two sensors in a state node.

So I cant compare sensor.bathroom_humidity to sensor.humidity_global. I could only compare it to global.humidity_global

If you linked the nodes, select msg and write payload in the Box

You are a very wise man. Thanks!

Is that what you’re trying to do?

[{"id":"c1f94c493d475aa6","type":"tab","label":"Set Global Here","disabled":false,"info":"","env":[]},{"id":"878a916c743d7ab5","type":"server-state-changed","z":"c1f94c493d475aa6","name":"t6","server":"33803899.487d48","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.cama_quarto_humidity","entityidfiltertype":"exact","outputinitially":false,"state_type":"num","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":330,"y":120,"wires":[["a803393146e26d7b","3885758c14a7e879"]]},{"id":"a803393146e26d7b","type":"ha-sensor","z":"c1f94c493d475aa6","name":"Humidity global","entityConfig":"5f922578a37f9566","version":0,"state":"msg.payload+10","stateType":"jsonata","attributes":[],"inputOverride":"allow","outputProperties":[{"property":"payload","propertyType":"msg","value":"msg.payload+10","valueType":"jsonata"}],"x":640,"y":120,"wires":[["bf646ab52f3cd761","881c60c8752b3e71"]]},{"id":"bf646ab52f3cd761","type":"api-current-state","z":"c1f94c493d475aa6","name":"Too high?","server":"33803899.487d48","version":3,"outputs":2,"halt_if":"payload","halt_if_type":"msg","halt_if_compare":"gt","entity_id":"sensor.aparador_humidity","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":900,"y":120,"wires":[["42f43ef258464dac"],["671a478a97b714c7"]]},{"id":"42f43ef258464dac","type":"debug","z":"c1f94c493d475aa6","name":"shower > t6 + 10","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1230,"y":80,"wires":[]},{"id":"671a478a97b714c7","type":"debug","z":"c1f94c493d475aa6","name":"shower < t6 + 10","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1230,"y":140,"wires":[]},{"id":"3885758c14a7e879","type":"debug","z":"c1f94c493d475aa6","name":"t6","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":490,"y":260,"wires":[]},{"id":"881c60c8752b3e71","type":"debug","z":"c1f94c493d475aa6","name":"global","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":770,"y":260,"wires":[]},{"id":"33803899.487d48","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"5f922578a37f9566","type":"ha-entity-config","server":"33803899.487d48","deviceConfig":"","name":"Humidity global","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Humidity global"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false}]