Publish json sensor data to MQTT via the mqtt.publish service

Hi,
I have just finished building my FireAngel WiSafe2-to-HomeAssistant-Bridge and that works great.

I am now looking for a way to preserve the states of the sensors. Tha author has kindly provided his sensor templates config but as soon as HA is reastarted that data is all gone.

Since I already have a MQTT running and integrated with HA I was thinking about using that to retain the last sensor state.

The FireAngel HA Bridge pumps out data to sensor.fireangeldata and by the looks of it is in json format. During normal operation it contains the heartBeat {"heartBeat":"6"}

, when I press the test button on one of my alarms it contains data of that device: {"device":"F90D04", "model":"E702", "event":"TEST", "result":"PASS", "base":"ON", "battery":"OK"}

Looking at the MQTT integration docs I can see that it is possible to publish sensor data to mqtt via the mqtt.publish service MQTT - Home Assistant

But I’ve been scratching my head I for the life of me I cannot figure out to do that so that when the json contains device info it is then published to say topic of fireangel/_deviceID_

and in the payload it will have the rest of the info i.e. model, event, result, base and battery.

But when the json contains just the heartBeat it is ignored or published to topic fireangel/heartbeat

Any suggestions how to do that?
Thank you