ostrya / PresencePublisher

An Android MQTT client that regularly publishes messages to notify about the device's presence
MIT License
79 stars 12 forks source link

Configured send message #63

Open Gidrogen opened 1 year ago

Gidrogen commented 1 year ago

Hi, Is there any way to add my key to the json message?

{
  "chargingState": "DISCHARGING",
  "plugState": "N/A",
  "connectedWifi": "N/A",
  "geoLocation": "N/A",
  "batteryLevel": 90,
  "currentTimestamp": 1691093107,
  "nextScheduledTimestamp": 1691093167,
  "nextAlarmclockTimestamp": 1691132640,
"myKey":"My Static Value"
}
ostrya commented 1 year ago

At the moment, this is not possible. What would be your use-case? If it's a different value per phone, why not let the phones post to different topics? Or do you want to regularly change the value?

Gidrogen commented 1 year ago

Use case: A bash script forwards my mqtt messages to the corresponding telegram chat. So I want to pass the ID number. Also, I would like to pass the device name in the message body, which is much more convenient. I can't change the bash script to parse mqtt topics.

ostrya commented 1 year ago

If it's just about the device name, how about just adding a data field DEVICE_NAME that is resolved from the device's name as configured in "Settings" - "About the phone" - "Device name" (starting from Android 7.1) or the device's Bluetooth name in older devices?

ostrya commented 1 week ago

Does the new device name help with your use case? Or do you really need a freely configurable field?