Unfortunately I have no programming and templating skills
I have a few thermostatic valves (identified according to their MAC address) that cyclically publish a json to a MQTT topic.
{"trv":"00:1A:22:16:DA:9B","temp":"23.5","offsetTemp":"0.0","valve":"76% open","mode":"manual","boost":"inactive","window":"closed","state":"unlocked","battery":"GOOD"}
I need to publish just the numeric value of “valve” data from the above json to a different topic.
Ie in the case above:
"valve":"76% open"
I need to publish the number 76 on a different topic
The code that I prepared simply publishes the entire “valve” data without any operation.
- alias: eq3mqtt_valves_open_status
description: ''
trigger:
- platform: mqtt
topic: /eq3mqttradout/status
condition: []
action:
service: mqtt.publish
data_template:
topic: "/eq3mqtt/{{ trigger.payload_json.trv }}/openstatus"
payload: "{{ trigger.payload_json.valve }}"
Any help in finding a way to publish just the number would be appreciated.
Thanks