dataChange Firebase with web component

Hi everyone,

I'm try to use the Firebase dataChange with web componente, i was following the post here, but i had no sucess.

Let me explain my application.

I've an esp32 getting some data from some switches and sensors, the esp32 send it to Firebase and i need to keep the app (when its openned) updated.
I tried to use the main functions in ai2 to firebase purpose like store, get and dataChange events, but that blocks save the string and the integer variables with "" "" and this stuff doesnt work when i get it in esp32 code, so i used the web component because if i want so save an integer it saves an integer without any sh1t.

I'm looking for a tutorial that explain all the metod to use the dataChange with web component, the event patch and get i already got it.

thanks.

What didn't work with the dataChanged method? (which I took more or less directly from Firebase's own video tutorial by David East)

let me show my blocks.

Here is function to set the html/java script, i just copy the script from the tutorial i said last post, the .html file is in media files and the variable fileLocation is "http://localhost/".

The initializer screen call the function above.
blocks (3)

And here i trying to get the values, it isn't done, i just built this blocks to see if it was working but i've got nothing in values return.

Is it right or i doing wrong?

The only difference I can see is that you are not using the uid of the user in your webviewString?

No i'm not, because my firebase bucket dont use the uid as a child of main path.

with my blocks above if i change manually the data in Firebase the app in companion should update my label("lbStatusSistema") with value, right?

It should return ALL firebase data if you change something in the path...

Anyway, I've got nothing... :expressionless:

Has any method to check if the script is working?

Here is, I believe the original video

and an updated one (not watched it yet)

Also, try changing data from your app, as opposed to on the firebase console.

1 Like

Got it...

I just change the "head" script in the html file to:

<head>
  <script src="https://www.gstatic.com/firebasejs/7.14.2/firebase-app.js"></script>
  <script src="https://www.gstatic.com/firebasejs/7.14.2/firebase-auth.js"></script>
  <script src="https://www.gstatic.com/firebasejs/7.14.2/firebase-database.js"></script>
</head>

In the guide mentioned HERE, the head script references dont work.

Now its working fine, second video you send should help me to get the specific child node that was changed.

thanks

1 Like

Good to here, I will update my guide to include use of later/latest js.

2 Likes

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