esprfid / esp-rfid

ESP8266 RFID (RC522, PN532, Wiegand, RDM6300) Access Control system featuring WebSocket, JSON, NTP Client, Javascript, SPIFFS
MIT License
1.37k stars 424 forks source link

Websocket or MQTT with Nodered? #117

Closed Svellem closed 6 years ago

Svellem commented 6 years ago

Has anyone got a working setup with either websocket or MQTT to Nodered? My aim is to send RFID id's to Nodered and use that for various automations.

I am having trouble connecting the Nodered WS client to the websocket server on the ESP-RFID. Testing via a WS client in Chrome and connection and messages are fine.

MQTT is working to some extent. Once a card is read, it will only send another message to the MQTT broker when another RFID card is read. This means you have to continuely swap which card you use in order for an MQTT message to be generated.

I am currently using 0.74 firmware.

Great work Ömer :) @omersiar

omersiar commented 6 years ago

When rfid card is scanned (read) there should be a MQTT publish with the UID of the card, no matter if it is known or not. Once i tested it and it was still working this way,

For websocket working on Node Red first you need to authenticate your client with HTTP Digest and second switch protocols to upgrade to websocket. I do not know if it is doable for Node Red.

Did you encounter any issue with the flashing or first use? Everything went as expected?

magic-tune commented 6 years ago

@Svellem I have a setup with mqtt up and running for 3 weeks now. Can confirm that during my testing the same card worked once in a while. My HomeAutomation did not react on the second message, because the value of the variable did not changed. I solved it by resending a timestap and username to the same topic by my ha. This way i can also display the last entered person.

I dont use Node Red for now, but played a while ago with. Maybe it is a simiular issue.

Svellem commented 6 years ago

@omersiar & @magic-tune Managed to resolve this issue by reapplying mqtt subscription topic on the Home automation/Node red side. Now each event triggers an mqtt message which again triggers subsequent automations. I did not have any luck with websocket within Node red, but I consider it a Node red issue. Thanks for your input :)