based on below code am fetching uid data from RFID tag(Hardware Device) through mqtt broker but it is not storing in database
import paho.mqtt.client as mqtt
class iot(models.Model):
_name = 'iot.iot'
name = fields.Char()
uid=fields.Char()
global mqttc
mqttc = mqtt.Client("python_pub")
mqttc.connect("172.16.73.4", 1883)
mqttc.publish("light", "light subscribed")
print "mqtt"
def on_message(client, userdata, message):
print("message received ", str(message.payload.decode("utf-8")))
global uid
uid=str(message.payload.decode("utf-8"))
mqttc.on_message = on_message
mqttc.loop_start()
mqttc.subscribe("sub")
In on_message method self object not available so give me suggestion how to store uid data in database
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
3329
Views
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up