Firebase Realtime Database and node-red

Last few days were trying to manage my Firebase Realtime Database from node-red. So installed the node-red-contrib-firebase, what a disaster, crashed all my test flows. But the alarm bells should have rung as it were last maintained 5 years back (How do we get these out date nodes banned?)

As I only had 3/4 of my test flows backed up, I had to rebuild them before I have forgotten what they were. :shushing_face:

Then I created the flow below to mange my database.

You need to replace [PROJECT_ID] with your DB link.

PUT data into Firestore Realtime Database, this will delete all existing
recorders from that specific field and these records in the field

The URL in the http request is:
https://[PROJECT_ID].firebaseio.com/devices.json

Get all data from Firestore Realtime Database

The URL in the http request is:
https://[PROJECT_ID].firebaseio.com/devices.json

Patch data to Firestore Realtime Database

This is the same as adding a recorded to your database.

The URL in the http request is:
https://[PROJECT_ID].firebaseio.com/devices.json

The a msg.method of PATCH as the standard http node does not support it

Delete data to Firestore Realtime Database

With this you can delete a recorded from your data base

The URL in the http request is:
https://[PROJECT_ID].firebaseio.com/devices.json/devices/77764BB5A6B5F88.json

Update This is the same as adding a recorded to your database, but we are updating a recorded

The URL in the http reqest is:
https://[PROJECT_ID].firebaseio.com/devices/77764BB5A6B5F55.json

The msg. have a msg.method of PATCH as the standard http node does not support it

Delete all data from Firestore Realtime Database

With this you can delete a recorded from your data base

The URL in the http request is:
https://[PROJECT_ID].firebaseio.com/devices.json

[{"id":"820c51ab63c4493a","type":"tab","label":"Firebase Realtime Database","disabled":false,"info":"","env":[]},{"id":"92f04ede22ee2a66","type":"http request","z":"820c51ab63c4493a","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://[PROJECT_ID].firebaseio.com/devices.json","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"headers":[],"x":510,"y":240,"wires":[["9f3d479491a0bb76"]]},{"id":"9f3d479491a0bb76","type":"debug","z":"820c51ab63c4493a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":240,"wires":[]},{"id":"49bd70750d2f9fdd","type":"inject","z":"820c51ab63c4493a","name":"GET","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":240,"wires":[["92f04ede22ee2a66"]]},{"id":"93d061e0498525fa","type":"inject","z":"820c51ab63c4493a","name":"PATCH","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":360,"wires":[["50dbbff67715232c"]]},{"id":"5a130ea2caa97db8","type":"http request","z":"820c51ab63c4493a","name":"","method":"use","ret":"obj","paytoqs":"ignore","url":"https://[PROJECT_ID].firebaseio.com/devices.json","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"headers":[],"x":510,"y":360,"wires":[["9b16037d9eb04146"]]},{"id":"50dbbff67715232c","type":"change","z":"820c51ab63c4493a","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"77764BB5A6B5F55\":{\"allwaysArmed\":false,\"battery\":12.3,\"claimed\":false,\"deviceName\":\"aac\",\"dischargeCoun\":0,\"email\":\"j@123.co.za\",\"startHour\":0,\"startMin\":0,\"stopHour\":0,\"stopMin\":0,\"timedArmed\":false}}","tot":"json"},{"t":"set","p":"method","pt":"msg","to":"PATCH","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":360,"wires":[["5a130ea2caa97db8"]]},{"id":"9b16037d9eb04146","type":"debug","z":"820c51ab63c4493a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":360,"wires":[]},{"id":"c50c6595895eadf3","type":"inject","z":"820c51ab63c4493a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":500,"wires":[["704d11615c598b7f"]]},{"id":"704d11615c598b7f","type":"http request","z":"820c51ab63c4493a","name":"","method":"DELETE","ret":"obj","paytoqs":"ignore","url":"https://[PROJECT_ID].firebaseio.com/devices.json/devices/77764BB5A6B5F88.json","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"headers":[],"x":510,"y":500,"wires":[["ba519b85773ab754"]]},{"id":"ba519b85773ab754","type":"debug","z":"820c51ab63c4493a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":500,"wires":[]},{"id":"8516a4c571ac478a","type":"comment","z":"820c51ab63c4493a","name":"GET Realtime Database","info":"**Get** all data from Firestore Realtime Database\n\nThe URL in the http request is:\n                               https://[PROJECT_ID].firebaseio.com/devices.json","x":170,"y":180,"wires":[]},{"id":"8adabfa31780073d","type":"comment","z":"820c51ab63c4493a","name":"PATCH Realtime Database","info":"**Patch** data to Firestore Realtime Database\n\nThis is the same as adding a recorded to your database.\n\nThe URL in the http request is:\n                               https://[PROJECT_ID].firebaseio.com/devices.json\n\nThe a msg.method of PATCH as the standard http node does not support it","x":170,"y":300,"wires":[]},{"id":"92f40e0bfdeb5662","type":"comment","z":"820c51ab63c4493a","name":"Delete Realtime Database","info":"**Delete** data to Firestore Realtime Database\n\nWith this you can delete a recorded from your data base\n\nThe URL in the http request is:\n                               https://[PROJECT_ID].firebaseio.com/devices.json/devices/77764BB5A6B5F88.json\n","x":170,"y":440,"wires":[]},{"id":"0735819e149b313f","type":"comment","z":"820c51ab63c4493a","name":"PUT Realtime Database","info":"**PUT** data into Firestore Realtime Database, this will delete all existing\n recorders from that specific field and these records in the field \n\nThe URL in the http request is:\n                               https://[PROJECT_ID].firebaseio.com/devices.json","x":170,"y":40,"wires":[]},{"id":"a5525bc8998006b2","type":"inject","z":"820c51ab63c4493a","name":"Put","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":100,"wires":[["2a0bfafca0ddbe63"]]},{"id":"6aa44031689dba05","type":"http request","z":"820c51ab63c4493a","name":"","method":"PUT","ret":"obj","paytoqs":"ignore","url":"https://[PROJECT_ID].firebaseio.com/devices.json","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"headers":[],"x":510,"y":100,"wires":[["b87898f70c735939"]]},{"id":"2a0bfafca0ddbe63","type":"change","z":"820c51ab63c4493a","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"77764BB5A6B5F77\":{\"allwaysArmed\":false,\"battery\":12.3,\"claimed\":false,\"deviceName\":\"aac\",\"dischargeCoun\":0,\"email\":\"j@123.co.za\",\"startHour\":0,\"startMin\":0,\"stopHour\":0,\"stopMin\":0,\"timedArmed\":false},\"77764BB5A6B5F88\":{\"allwaysArmed\":false,\"battery\":12.3,\"claimed\":false,\"deviceName\":\"aac\",\"dischargeCoun\":0,\"email\":\"j@123.co.za\",\"startHour\":0,\"startMin\":0,\"stopHour\":0,\"stopMin\":0,\"timedArmed\":false},\"77764BB5A6B5F99\":{\"allwaysArmed\":false,\"battery\":12.3,\"claimed\":false,\"deviceName\":\"aac\",\"dischargeCoun\":0,\"email\":\"j@123.co.za\",\"startHour\":0,\"startMin\":0,\"stopHour\":0,\"stopMin\":0,\"timedArmed\":false}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":100,"wires":[["6aa44031689dba05"]]},{"id":"b87898f70c735939","type":"debug","z":"820c51ab63c4493a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":100,"wires":[]},{"id":"a65883e4f3907416","type":"inject","z":"820c51ab63c4493a","name":"PATCH","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":620,"wires":[["3a0a2bb85316e59e"]]},{"id":"07fceecb854da7ad","type":"http request","z":"820c51ab63c4493a","name":"","method":"use","ret":"obj","paytoqs":"ignore","url":"https://[PROJECT_ID].firebaseio.com/devices/77764BB5A6B5F55.json","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"headers":[],"x":510,"y":620,"wires":[["2dc39afe7b3c690f"]]},{"id":"3a0a2bb85316e59e","type":"change","z":"820c51ab63c4493a","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"allwaysArmed\":\"post\"}","tot":"json"},{"t":"set","p":"method","pt":"msg","to":"PATCH","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":620,"wires":[["07fceecb854da7ad"]]},{"id":"2dc39afe7b3c690f","type":"debug","z":"820c51ab63c4493a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":620,"wires":[]},{"id":"96a5efa70869b21f","type":"comment","z":"820c51ab63c4493a","name":"Update a record Realtime Database","info":"**Update** This is the same as adding a recorded to your database, but we are updating a recorded\n\nThe URL in the http reqest is:\n                               https://[PROJECT_ID].firebaseio.com/devices/77764BB5A6B5F55.json\n\nThe msg. have a msg.method of PATCH as the standard http node does not support it","x":200,"y":560,"wires":[]},{"id":"2b64abd6f38bd260","type":"inject","z":"820c51ab63c4493a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":740,"wires":[["88e1ab1d6735fc9f"]]},{"id":"88e1ab1d6735fc9f","type":"http request","z":"820c51ab63c4493a","name":"","method":"DELETE","ret":"obj","paytoqs":"ignore","url":"https://[PROJECT_ID].firebaseio.com/devices.json","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"headers":[],"x":510,"y":740,"wires":[["25ba9507bda5d0ed"]]},{"id":"25ba9507bda5d0ed","type":"debug","z":"820c51ab63c4493a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":740,"wires":[]},{"id":"21b3d4f919cff2cb","type":"comment","z":"820c51ab63c4493a","name":"Delete Realtime Database","info":"**Delete** all data from Firestore Realtime Database\n\nWith this you can delete a recorded from your data base\n\nThe URL in the http request is:\n                              https://[PROJECT_ID].firebaseio.com/devices.json","x":170,"y":680,"wires":[]}]

WARNNING this post can be edit at any time :smiling_imp: :smiling_imp:

Installing a node is most unlikely to have damaged your flows, unless it was intentionally malicious. Had you asked for help then we would almost certainly have been able to get it sorted.

To indicate that it is no good (the readme on the node's github page does say that it no longer works) you can rate it at 1 star on its page on the node red flows site.

@ScheepersJohan, I may have something of interest to you, I have begun a new project : node-red-contrib-firebase-realtime-database

This project has three nodes:

  • A path subscription node (sends a message when a value changes)
  • A node that retrieves data from the database of the desired path
  • A node for adding/modifying data to the database (SET, PUSH, UPDATE and REMOVE)

Currently the authentication methods are Anonymous and Email.
Should soon arrive the Custom Token with Secret method.

Very strang then, only happened when I installed and used the node. When I removed the node from my flow and deleted it, I could only restore my flows. Why don't you give it try for us?

Thanks, let me have a look.

Why? What is the point? Did you keep a copy of the .node-red folder when it was failing? If so then restore that and tell us what symptom you see.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.