Leer estado dispositivo tuya en S7

Buenas.
Soy nuevo es este mundo.
Pido disculpas si me espreso mal
Estoy intentando leer el estado de apertura de las persianas desde un dispositivo tuya, en un PLC S7.
Quiero recibir el valor en enteros, pero sin éxito.
Lo que se lee en la salida de la función es:
{"data":{"dps":{"1":"stop","2":21},"t":1681406281},"deviceId":"xxxxxxxxxxxxxxxxxxx","deviceName":"Persiana 1"}

Lo que me gustaría leer seria el dps 2:"21" que es el valor de % apertura persiana.

MuchÍsimas gracias

Hello, if it is possible please write in english.

Could you share a screenshot of DB that you are trying to read? Also paste a flow of your code?

if we format a bit

msg.payload: {data: {dps: {1: 'stop', 
                           2: 21
                          },
                     t: 16814068281
                    },
              deviceid: "xxxxxxxxxxxxxxxxxxx",
              deviceName: "Persiana 1"
             }

So, hopefully, you need

let blindOpening = msg.payload.data.dps[2]

Edit
For anyone else reading this, should have been

let blindOpening = msg.payload.data.dps['2']

thanks to @MecatronicaMADE

for pointing this out

1 Like

Good again.
Sorry for not speaking in English.
I am using a translator, in case something is not understood!!! XDD
I'll give you some images
1st is the flow that I have done

In it I have the following:
image

And the result it gives me is:


When what I want is the result of the value "dps:2" which is the opening percentage of the blind.
eg: reading 3 {25}

Thank you very much to all

Hola @jmgimo75 y bienvenido a la comunidad, primero si que es cierto que si posteas en inglés tendrás mejor apoyo. Intente simular el entorno que tienes, y creo que con un nodo change podrías solucionarlo, te comparto el flujo para que lo importes en tu proyecto y lo modifiques a tu gusto.

[{"id":"028265c51778150b","type":"tab","label":"Flow 30","disabled":false,"info":"","env":[]},{"id":"860125e741c73f42","type":"inject","z":"028265c51778150b","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"data\":{\"dps\":{\"1\":\"stop\",\"2\":21},\"t\":1681406281},\"deviceId\":\"xxxxxxxxxxxxxxxxxxx\",\"deviceName\":\"Persiana 1\"}","payloadType":"json","x":730,"y":260,"wires":[["67be7cc9649f1701"]]},{"id":"67be7cc9649f1701","type":"change","z":"028265c51778150b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.data.dps[\"2\"]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":260,"wires":[["1781378dd4cfbb07"]]},{"id":"1781378dd4cfbb07","type":"debug","z":"028265c51778150b","name":"debug 45","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1040,"y":260,"wires":[]}]

Prácticamente lo que haras sera, almacenar en el payload el dato que te interesa, solamente:

msg.payload = msg.payload.data.dps["2"]

Screenshot from 2023-04-15 11-22-30

Espero que pueda ayudar, saludos!