Hi Folks,
New to OpenMQTT. Plan on using it to send from radio frequency oil tank sensor (RTL 433) and forward it to my solar/tank monitoring software running on victron’s venus os.
At the moment I use a pi to capture the sensor data via rtl433 and use python to extract the depth data from the sensor. And then calculate the level in litres and remaining % of the tank before forwarding the raw values to the victron MQTT server.
I planned on ditching the pi and going for a lilygo instead. But that would mean i’d need to have some sort of middle man MQTT topic for OpenMQTT to use and then node red on the victron device to take the data from OpenMQTT topic, then perform the formatting and maths and foward to the tank topics on victron device.
My plan was implementing the formatting and multiple topic posting on the lilygo itself. And wondered if there was already a generalised implementation of this?
If not I was tempted to try generalise it myself.
ie have a settings.json file. Where i would store a list of devices that i want to format/calculations to be done before sending to MQTT channels. Something like
{[sensor1: {
"identification element": "data.id"
"identification_method": "equals"
"identification_match": "123456"
"dataExtractKeys": ["data.depth","data.depth","data.battery"]
"dataFormula": [var*4*5,var*4*5/1200,1]
"mqttTopics": ["/W/VictronMQTT/tank/level","/W/VictronMQTT/tank/remaining","/W/VictronMQTT/tank/battery"]
]
}
The logic here when sensor data is received. The program loops through settings.json items. Extracts the identification_element using the keys data.id and if identification method is equals. it’ll say is the contents of data.id equal to 123456 ie the identification_match var. You could then implement other identification methods like contains.
if above identification is true for sensor then we continue
the dataExtract keys, Formula and mqttTopics are all linked. First data is extract from sensor dataExtractKeys the corresponding array formula is appled where var is replaced by the content of dataExtractKeys. Then finally the message is send to
BASETOPIC + /W/VictronMQTT/tank/level
Then the process is looped for the other dataExtractKeys, forumula and topics.
This is my best guess at implementing a generalised format/transformation function into openMQTT. Looking for guidance in terms of does this functionality already exist. And if there’s any flaws/issue with my logic other than thtis adding delay in sensor send times as the code would loop settings.json to check if the sensor data received is a device contained in settings.json