But without selecting on id. I have tried a number of approches but can’t get any to work. Can anyone point me in the direct direction what approach to use ?
The unique id is 2 in the case with two variables and 31 in the case with one variable, thats the one I need to catch to separate what sensor sending data
Thank’s ALL for help. I apologize if I given you the impression that I wan’t you to write code for me ! The suggestions you have given me has pointed me in the right direction and I
will try to solve how to deal with the fact that some sensors have one and others can have.two or more variables. If possible have all variable’s for a sensor belonging to a unit with entities.
Hope code is correct formatted below
- name: "FDRS Node 5 data test"
state_topic: "fdrs/data"
value_template: "{{ (value_json | selectattr('id','eq',5) | list | first).data}}"
Now managed to separate values filtering on id and type and data is nicely incoming BUT another problem now is that values are not sustained, shows up for a second or so and entity is blank until another data arrives from Lora DHT node. Data from mcp23017 Node shows up ok. I suspect it has to do with map(attribute='data') | list | first
#FDRS This text will be hidden
#mcp23017 node
- name: "FDRS Node 31 data"
state_topic: "fdrs/data"
value_template: "{{ (value_json | selectattr('id','eq',31) | list | first).data}}"
#Lora DHT node
- name: "FDRS Node 2 humidity"
state_topic: "fdrs/data"
value_template: "{{ value_json | selectattr('id', 'eq', 2) | selectattr('type', 'eq', 3) | map(attribute='data') | list | first }}"
- name: "FDRS Node 2 temperature"
state_topic: "fdrs/data"
value_template: "{{ value_json | selectattr('id', 'eq', 2) | selectattr('type', 'eq', 1) | map(attribute='data') | list | first }}"
Hi
Maybe I was unclear. Sensor 31 works ok all the time. The problem is with
Sensor 2, sending two variables that briefly shows data and then goes blank until new value arrives. I have tried with an automation ( se below) and it stores the first value but never updates, so this isn’t working.
I think we understood you, and Troon provided you the solution.
If a new value for an id (be it 31 or 2, the idea is the same) is not in the topic payload, just keep the previous value.