MQTT client?

  • hi, I know how to install and configure mosquitto, but I don't know how to link them together through doorpi.ini.
    I'm thinking the following simple scenario:

    • visitor presses button A -> DoorPI publishes MQTT topic (based on button A) to the MQTT server
    • landlord publishes MQTT topic (through MQTT server) -> DoorPI open/closes IO

    thanks

  • Install a mqtt-client:
    "sudo pip install paho-mqtt


    create a script directory:
    "mkdir /home/doorpi/mqtt"


    create the script:
    "nano /home/doorpi/mqtt/ring.py"


    edit your doorpi.ini:



    Code
    1. [EVENT_OnKeyPressed_prodsystem.0]
    2. 10 = take_snapshot:http://localhost:9000/?action=snapshot
    3. 20 = mailto:xxx@xxx.de,Mailversand mit Bild,Das ist das Bild als Mailtext,true
    4. 30 = url_call:http://xxx:xxx/set/javascript.0.DoorPi.States.Ring?value=true&event=doorpi&subscribe=1
    5. add this --->>> 40 = os_execute:python /home/doorpi/mqtt/ring.py

    restart doorpi.

  • Hi katsaplias,
    i have write a MQTT-SingelAction Unit.


    Create the File in the DoorPi SingleAction-Folder(/usr/local/lib/python*/dist-package/DoorPi*/doorpi/action/SingleAction/mqtt.py).


    You can use with:


    [EVENT_OnStartup]
    10=mqtt:192.168.*.*,1883,doorpi/action/startup,true


    or


    [EVENT_OnKeyPressed_prodsystem.0]
    10=mqtt:192.168.*.*,1883,doorpi/action/ring1,true,false


    or


    [EVENT_****]
    10=mqtt:192.168.*.*,1883,doorpi/message,this is a message from doorpi !


    ---------------------------------------------------
    mqtt:hostname,port,message,kind1,kind2


    action with kind2 changes after 2 seconds kind1 with kind2
    action without kind2, only sends kind1

    Gruß
    Wal


    Kaum macht man es richtig, funktioniert es auch !

    Einmal editiert, zuletzt von Wal ()