How to get value from mqtt json to mqtt sensor

I try to get Minute (3) value from there:

Device00 = #0:00/1:38/2:20/3:10/4:0/5:0.00/6:0.00/7:0/8:180.50/9:70.00/10:50.00/11:0/12:0/13:0/14:0#

- name: "Device"
  state_topic: "Device00"
  
- name: "Minute"
  state_topic: "Device00"
  value_template: '{{ value_json.3 }}'
  json_attributes_topic: "Device00"

I try like this but not working:

image

Can anyone help me, thank you very much

That’s not JSON. Do you mean you’re trying to extract the 10 from here?

#0:00/1:38/2:20/3:10/4:0/5:0.00/6:0.00/7:0/8:180.50/9:70.00/10:50.00/11:0/12:0/13:0/14:0#
----------------^^^^

If so:

- name: "Minute"
  state_topic: "Device00"
  value_template: "{{ (value.split('/')|select('search','^3:')|first).split(':')[1] }}"

I have searched for the item starting with 3:, but if you know it’s always going to be the fourth item, you can use the simpler:

  value_template: "{{ value.split('/')[3].split(':')[1] }}"

1 Like

oh, great, thank you, it worked
image

I want to change the data, how do I do that?

code in arduino

String Topic_send_pub = "Device"+ID;
String Topic_recv_sub = "device"+ID;

I want to increase or decrease numbers 38 and 20 (1) and (2)

Device00 = #0:00/1:38/2:20/3:10/4:0/5:0.00/6:0.00/7:0/8:180.50/9:70.00/10:50.00/11:0/12:0/13:0/14:0#


I don’t understand the code in configuration.yaml
I use Google translate, Thank you very much

I don’t understand your question.

Do you want to change these numbers in the Arduino device or in Home Assistant?