Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT commands List #407

Open
peteshoard opened this issue Oct 7, 2020 · 12 comments
Open

MQTT commands List #407

peteshoard opened this issue Oct 7, 2020 · 12 comments
Labels

Comments

@peteshoard
Copy link

Please could someone point me at a guide to the MQTT commands that can be executed against the 1.3.3 firmware? I happily receive messages but dont know how push commands.

Thanks

@ingeninge
Copy link

To send a message to your board you must form it as a JSON string. Also the IP address of the board must be included in the string. As an example here I'll show how to open the door via mqtt command. I send my messages with mosquitto_pub on linux.
-h is the hostname or IP of the MQTT broker -t topic -m Message to be send.
mosquitto_pub -h Your.MQTT.Broker.IP -t rfid -m '{"doorip":"192.168.2.23","cmd":"opendoor"}'

Commands known by developer version can be found in mqtt.esp:

listusr - List users
getuser - getuser
adduser - Add Users
deletusers - Delete all users
opendoor - Door open

@peteshoard
Copy link
Author

Thanks very much. I managed to get some idea of this from the code, but I couldn't figure out how to add a user with a type and an expiry.

The other thing that took some time to work out was what topic it subscribes too, it seems to be the root topic you add in the MQTT settings.

Appreciate your help.

@pol-henri
Copy link

So whith mqttfx if whe publish on topic "rfid" with the string "opendoor", the door should open right?

@peteshoard
Copy link
Author

Not exactly....

You must publish to the root topic that the board publishes to, this is in the 'topic' setting under 'MQTT Settings".

So if the topic is set to 'tele\esprfid' for example, you will find the results push onto your MQTT queue under the topic 'tele\esprfid\send'

You need to send 2 key value pairs as the message on the root topic as per ingeninge's comment:
Mosquitto_pub -h Your.MQTT.Broker.IP -t tele\esprfid -m '{"doorip":"192.168.2.23","cmd":"opendoor"}'

If you want to do other things then replace "opendoor" with the commands from above, for adding a user you need to include the name and the uid.

@pol-henri
Copy link

Thanks a lot I will try this 👍

@pol-henri
Copy link

i don't know how to fomat message to topic from mqttfx ,
i don't understand

for exemple if i have rfid ip :192.168.2.73 and topic set to "rfidPortail" (without "")

how format message to send opendoor ? using simply mqttfx, can u help me ? thanks a lot

@thehijacker
Copy link

Use MQTT Explorer. Much easier to test mqtt commands.

Download it from here: http://mqtt-explorer.com/

image

I used topic "rfid" in GUI. So I send to this topic json type string:

{"doorip":"10.0.107.50","cmd":"opendoor"}

Where "10.0.107.50" is IP of the ESP-RFID board and command (cmd) is "opendoor". When I click Publish I can hear the relay on board clicking.

Firmware version 1.3.3. Still waiting for my Wiegand RFID receiver, but board is working fine for me. Powering it via 12V DC. Take note. MUST BE DC!!! Bell transformers are not OK. They are AC and will fry the board.

I will have this board in main electrical fuse box where my fuses are. So I ordered a DIN rail power transformator. Long looked for correct one. Finally found perfect ones from MeanWell. Model MDR-20-12 is perfect to power ESP-RFID board and 12V control current for the door lock . Also have MDR-20-24 to power the door lock and two MDR-20-5 to power two wall mounted Android tables that I will use instead of dumb two wire monitors that I currently use.

I hope I helped someone with this information.

@pol-henri
Copy link

thanks for your help , unfortunately when i try to send the payload to topic it won't work for me , but the test button on UI yes ? is not the same function ? is from websocket maebe , also i see there is a list of arguments for topic like " /topic/send " but do the job for me ; thanks a lot for your detaileds explanations

@thehijacker
Copy link

Today I played a bit with my Home Assistant automations. I will use ESP-RFID web GUI only for managing cards. Even that I will maybe some day bring to Home Assistant and I can open the door lock via mqtt. For me it works fine. Here are my current automations:

# variable to save heartbeat date and time
input_datetime:
  esp_rfid_heartbeat:
    name: ESP RFID Heartbeat
    has_date: true
    has_time: true

# Save date/time of last EPS-ID board heart beat
automation:
  - alias: "ESP RFID Save Last Heartbeat"
    trigger:
      platform: mqtt
      topic: rfid/sync
    condition:
      condition: template
      value_template: "{{ trigger.payload_json['type'] == 'heartbeat' }}"
    action:
      service: input_datetime.set_datetime
      data:
        entity_id: input_datetime.esp_rfid_heartbeat
        timestamp: "{{ trigger.payload_json.time }}"
  # Known card, notify me by Telegram
  - alias: "ESP RFID Card Scanned Known"
    trigger:
      platform: mqtt
      topic: rfid/send
    condition:
      condition: template
      value_template: "{{ trigger.payload_json['type'] == 'access' and trigger.payload_json['isKnown'] == 'true' and trigger.payload_json['access'] == 'Always' }}"
    action:
      - service: notify.telegram_andrej
        data:
          message: 'Na vhodu skenirana nova veljavna kartica: {{ trigger.payload_json.username }} ({{ trigger.payload_json.uid }})'
  # Unknow or expired card, notify me by Telegram
  - alias: "ESP RFID Card Scanned Unknown"
    trigger:
      platform: mqtt
      topic: rfid/send
    condition:
      condition: template
      value_template: "{{ trigger.payload_json['type'] == 'access' and (trigger.payload_json['isKnown'] == 'false' or trigger.payload_json['access'] == 'Denied') }}"
    action:
      - service: notify.telegram_andrej
        data:
          message: 'Na vhodu skenirana neznana ali neveljavna kartica: {{ trigger.payload_json.isKnown }} - {{ trigger.payload_json.access }} - {{ trigger.payload_json.user }} ({{ trigger.payload_json.uid }})'
  # User a Zigbee switch to open the door lock (relay on board)
  - alias: 'Switch Sonoff Open Door'
    trigger:
      platform: mqtt
      topic: "zigbee2mqtt/Switch Sonoff"
    condition:
      - condition: template
        value_template: "{{ 'single' == trigger.payload_json.action }}"
    action:
      service: mqtt.publish
      data:
        topic: rfid
        payload: "{\"doorip\":\"10.0.107.50\",\"cmd\":\"opendoor\"}"

You can see what mqtt events I listen and you can see what I send to open the door.

@pol-henri
Copy link

yes is very clear , but don't work for me .. i have another esp-rfid and this time i try to update firmware , the older is updated via UI , but i thing is not perfectly updated (the UI show 1.04)

@roysbike
Copy link

roysbike commented Dec 8, 2020

How to add user over mqtt? I try:
mosquitto_pub -h mqtt.360on.ru -u mqtt -P Aej9eeNgei0e -t rfid-blackcat/accesslist -m '{"doorip":"192.168.1.2","cmd":"adduser","uid":"1234","user":"test","acctype":"1","acctype2":"null","acctype3":"null","acctype4":"null","validuntil":"2145916800"}'

@windy54
Copy link

windy54 commented Feb 28, 2021

Has anyone got an example of a working python script to say open the door using MQTT.
I have got a raspberry pi interfacing to the rfid system and it also acts as a broker.
If I use the command line to send a message via mosquito pub as above the door opens.
When I create a python script to send the message it does not work.
the message looks identical to what I send via the command line, obviously there is something wrong!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants