MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord
    1. Home
    2. bdeelman
    MagicMirror² v2.25.0 is available! For more information about this release, check out this topic.
    • Profile
    • Following 1
    • Followers 0
    • Topics 1
    • Posts 7
    • Best 2
    • Controversial 0
    • Groups 0

    bdeelman

    @bdeelman

    2
    Reputation
    66
    Profile views
    7
    Posts
    0
    Followers
    1
    Following
    Joined Last Online
    Location Apeldoorn, NL

    bdeelman Unfollow Follow

    Best posts made by bdeelman

    • RE: MMM-RemoteControl or vcgencmd Issue

      @Stroke-0

      A (or my) Rpi4 has two HDMI ports. So you should add also the HDMI port 0 or 1 (or id 2 and id 7). docs

      Status screen:

      vcgencmd display_power -1 2 | grep -q "1" && echo "on" || echo "off"
      vcgencmd display_power -1 7 | grep -q "1" && echo "on" || echo "off"
      

      Regards,
      Bert

      posted in Troubleshooting
      bdeelman
      bdeelman
    • Use of array within all module files

      Hi,

      I convert a CSV file to a JSON array at the node_helper.js file. This array (subscriptions) is needed at several functions at the mmm-sample.js file.

      The array is available at other functions within the node_helper.js I use this.subscriptions = (jsonObj); within the CSVtoJSON function and declare var subscriptions = []; at the top of nodehelper.js and also at the mmm-sample.js.

      How can I achieve this? Do I need the sendSocketNotification functionality to send data back and forth between the files?

      Any help is much appreciated.

      Regards,
      Bert

      posted in Development
      bdeelman
      bdeelman

    Latest posts made by bdeelman

    • RE: MMM-RemoteControl or vcgencmd Issue

      @Stroke-0

      A (or my) Rpi4 has two HDMI ports. So you should add also the HDMI port 0 or 1 (or id 2 and id 7). docs

      Status screen:

      vcgencmd display_power -1 2 | grep -q "1" && echo "on" || echo "off"
      vcgencmd display_power -1 7 | grep -q "1" && echo "on" || echo "off"
      

      Regards,
      Bert

      posted in Troubleshooting
      bdeelman
      bdeelman
    • RE: Use of array within all module files

      @sdetweil I am sorry and lost. 😉

      The sendSocketNotification from node_helper.js

      self.sendSocketNotification('MQTT_PAYLOAD', {
      				topic: topic,
      				value: value,
      				subs: self.subscriptions
      				)};
      

      So if I understand correctly…I should add this.subscriptions = payload; at the receiving function socketNotificationReceived at modulename.js

      socketNotificationReceived: function(notification, payload) {
      	this.subscriptions = payload;
        if (notification === 'MQTT_PAYLOAD') {
      // 
      //
        }
      },
      

      I did that but it is not working. The array is not available at other functions within modulename.js.

      At the node_helper part it is working. this.subscriptions = (jsonObj);and I can use the array at other functions. with

      var self = this;
      var l = self.subscriptions.length; // as an example.
      
      posted in Development
      bdeelman
      bdeelman
    • RE: Use of array within all module files

      @sdetweil Thanks for your reply. Much appreciated!

      I think I need another approach to get the result that I need. The subscriptions array is (must be) part of the this.config. So I add subscriptions: [];to the defaults: at the modulename.js

      The thing now is add the generated JSON (csvtojson) to the this.config. 😃 and I can use this.config as a payload.

      The array is something like this:

      subscriptions = [{
          topic: 'homey/light/keuken/dimmer-fibaro-1/onoff', // MQTT Topic name
          label: 'Licht keuken',
          type: 'device',
          display: { left: 50, top: 50  },
        },
      {
          topic: 'homey/sensor/washok/temp-hum-xiaomi-1/measure-temperature',
          label: 'Washok Temp',
          type: 'label',
          display: { left: 265, top: 0, prefix: "", suffix: "°C", decimals: 0 },
      }
      
      posted in Development
      bdeelman
      bdeelman
    • RE: Use of array within all module files

      @sdetweil can you be more precise? I did not understand you.

      The subscriptions is the generate json array with all kind of information to build an element / divs etc. That array is build at node_helper.js and globally needed within modulename.js.

      As I understand the way of working well…?

      Regards,
      Bert

      posted in Development
      bdeelman
      bdeelman
    • RE: Use of array within all module files

      Hi Sam,

      I take a look at that code. I can read it. 😉 But can’t find the answer.

      This are my thougts. From start() I send

      this.sendSocketNotification('CONFIG', this.config);
      

      The this.config payload is needed at the node_helper.js at two places. One to figure out the csv file and do the MQTT stuff.

      CSVToJSON({ ignoreEmpty: true, trim: true })
      		.fromFile(CSVfile)
      		.then((jsonObj) => {
      			//console.log(jsonObj);
      			this.subscriptions = (jsonObj); //JSON.parse
      			this.setconfig(payload);
      		})
      

      I forward the this.config to the MQTT function. The array subscriptions is available there. At the MQTT function:

      self.sendSocketNotification('MQTT_PAYLOAD', {
      				topic: topic,
      				value: value,
      				subs: self.subscriptions
      				)};
      

      These payloads arrived within the function at the module file. But I can not use the payload outside of that specific function.

      I am not a programmer as you can see…just using reverse engineering and read a lot of configurations. I am almost there, I think.

      Regards,
      Bert

      posted in Development
      bdeelman
      bdeelman
    • Use of array within all module files

      Hi,

      I convert a CSV file to a JSON array at the node_helper.js file. This array (subscriptions) is needed at several functions at the mmm-sample.js file.

      The array is available at other functions within the node_helper.js I use this.subscriptions = (jsonObj); within the CSVtoJSON function and declare var subscriptions = []; at the top of nodehelper.js and also at the mmm-sample.js.

      How can I achieve this? Do I need the sendSocketNotification functionality to send data back and forth between the files?

      Any help is much appreciated.

      Regards,
      Bert

      posted in Development
      bdeelman
      bdeelman