Ok, So you post this to an MQTT Topic…
And then is that MQTT topic Auto discovered? I feel like you aren’t reading my response and giving the least amount of information.
- Do you have a configuration for this device?
- Is it discovered?
Seeing that these 2 questions somehow escape your mind, I will offer a solution that I think will work.
Configure (Not Discover) the mqtt sensor. Use this configuration for the sensor. BTW, this is literally the example in the documentation doing exactly what you want.
- platform: mqtt
name: "Timer 1"
state_topic: "tele/sonoff/sensor"
value_template: "{{ value_json.Timer1.Arm }}"
json_attributes_topic: "tele/sonoff/sensor" #< ----- CHANGE THIS TO YOUR DEVICE TOPIC.
json_attributes_template: "{{ value_json.Timer1 | tojson }}"
It will create a sensor: sensor.timer_1
that will contain the state equal to the arm value. and the attributes will be: arm, mode, time, window, days, repeat, output, and action.
So if you want to create any separate sensor with that information, you’ll make a template sensor using the following code, but changing the attribute.
- platform: template
sensors:
time_1_mode:
friendly_name: Timer 1 Mode
value_template: "{{ state_attr('sensor.timer_1','Mode') }}"