Read the statement by Michael Teeuw here.
Electricity Bill Module Development
-
@sdetweil Hahahaha true that!
Kinda fixed it guided by your recommendations but the thing is that I’m still getting the same output:
Here the code:

-
-
hmm, actually it does help. I’ll be testing around and tell you when I get it to work!
Anyways your help was a huge pilar to keep myself going with this, much thanks brother💝 -
Does it help if I tell you that I got everything on my onstart function of the node_helper file?
-
@SopaMaruchan never done it in start.
I usually wait til the module sends it’s 1st request
-
@SopaMaruchan I’m realizing that my my receiveSocketNotification is not being triggered on my MM-Module file:

I logged some text after calling receiveSocketNotification function but there’s no output on console.node_helper:

-
@SopaMaruchan if the send fails like that, not sent
-
@SopaMaruchan
let self=thishas to be inside the getBill() function
otherwise it could be set wrong… -
@SopaMaruchan maybe for debug
inside the request() callback function,
do a
console.log(JSON.stringify(self, null,2))
to see what ‘this’ was pointing to
-
@sdetweil it’s indeed pointing to my module. Here’s the output:

and the huge LOG ends with the last 2 arguments: null & 2
-
problem is that the sockets are not connected at start time. so the sendSocketNotification is a no-op.
u need wait til the module sends a socket message
the module config is not visible to the node_helper, so the module has to send it over/down…
-
@SopaMaruchan Maybe the below example would help or serve as a guide to see if you may have the send call in the wrong place.
module.exports = NodeHelper.create ({ start: function() { console.log('Starting node_helper for module: ' + this.name) }, getLights: async function(payload) { var url = "http://" + payload.bridgeip + "/api/" + payload.userid + "/" + payload.lightsOrGroups; var response = await fetch(url) if (!response.status == 200) { console.error(`Error retrieving data: ${response.statusCode} ${response.statusText}`) return; } var result = await response.json() this.sendSocketNotification("lightsorgroups", result) },```` -
@mumblebaj he is calling from start:
but sockets not setup yet.
he really needs to wait til the module sends the 1st notification down ( what we use to send config info from module to helper)
-
@sdetweil Ah, hopefully he caught that and changes it.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login
