MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. BKeyport
    3. Posts
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    Offline
    • Profile
    • Following 0
    • Followers 2
    • Topics 67
    • Posts 1,318
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Not updating at midnight...

      I think I got it figured out - Based on research elsewhere - if I’m correct: start: function() is only called upon load, correct?

      ASSUMING that’s the case, this seems to work better:

      start: function () {
          function scheduleMidnightUpdate() {
              const now = new Date();
              const nextMidnight = new Date(now);
      
              // Set the time to midnight
              nextMidnight.setHours(24, 0, 0, 0);
      
              // Calculate the time remaining until the next midnight
              const timeUntilMidnight = nextMidnight - now;
      
              // Schedule the updateDom method to be called at midnight
              setTimeout(() => {
                  this.updateDom();
      
                  // Reschedule the update for the next midnight
                  scheduleMidnightUpdate.call(this);
              }, timeUntilMidnight);
          }
      
          // Call the function to start the first schedule
          scheduleMidnightUpdate.call(this);
      },
      

      Now, This seems to work on testing - but it will fail in testing if I change the clock after starting MM.

      Is there anyway y’all can see to improve this, or am I good?

      posted in Troubleshooting
      BKeyportB
      BKeyport
    • RE: Not updating at midnight...

      @MMRIZE @sdetweil

      the reporter posted this to my github:

      I am not a javascript expert, but have some experience in C++ and
      microcontroller programming.
      I have had some problems with other MagicMirror calendar modules not
      updating the day properly and they also seem to implement workarounds and
      have issues with the DOM updating.
      I did a little looking into this and it seems there must be some generic
      issue with the MagicMirror software allowing modules to implement timers
      and date/time functions in realtime.
      

      And Sam - I was telling you that it previously was working and works outside of the MM ecosystem - or at least sets it up to work. that’s what got me pissed off - I had done a slew of debugging and it got down to “have you turned off and on again”

      There’s lots of issues I’ve been having - most of them being internal MM functions, that I tend to work around by native JS code and using remote access via the Web server.

      For example: Logging. Don’t seem to work for me. Gotta log via console, so I pull up the web server and Edge’s dev tools.

      posted in Troubleshooting
      BKeyportB
      BKeyport
    • RE: Not updating at midnight...

      @sdetweil It’s people like you that drive people out of coding. This isn’t fun anymore.

      Is there anyone other than Sam that could explain why this don’t work anymore?

      posted in Troubleshooting
      BKeyportB
      BKeyport
    • RE: Not updating at midnight...

      @sdetweil The problem is that it’s not firing at all - it was working as is… Now it’s not firing, first, last, middle, or any other time.

      posted in Troubleshooting
      BKeyportB
      BKeyport
    • RE: Not updating at midnight...

      I think you see it backwards.

      Look at the reset variable again.

      This line calculates the difference between the current time and midnight of the next day. It does this by creating a new Date object for the next day at 00:00:00.000 (midnight) and subtracting the current time from it.

      The variable timer is then set using the reset variable, so…

      new Date(year, month, nextday, 0, 0, 0, 0).getTime() - date.getTime()

      Assuming it’s currently 6:30pm on August 8th, 2024.

      2024/8/9 0:0:0.0 - 2024/8/8 18:30:0.0
      1723186800 - 1723167000 (Dropping the milliseconds if used)
      = 19800

      then the timer is set using setInterval() to “reset” or 19800 - which would be the next midnight.

      After the first one, it should be calculating so close to midnight, it’s an non-issue.

      posted in Troubleshooting
      BKeyportB
      BKeyport
    • Not updating at midnight...

      I’m having trouble with my module (multimonth) not updating at midnight as expected. It will update on notification as shown, however.

      This used to work - can someone please take a look and see what broke, or if something changed in MagicMirror core that I didn’t pick up on that’s affecting?

      Thanks.

          start: function () {
              date = new Date();
              month = date.getMonth();
              day = date.getDate();
              nextday = day + 1;
              year = date.getFullYear();
              reset = new Date(year, month, nextday, 0, 0, 0, 0).getTime() - date.getTime();
              var timer = setInterval(() => {
                  this.updateDom()
              }, reset)
              this.storedEvents = [];
              this.matchEvents = [];
          },
      
          notificationReceived: function (notification, payload, sender) {
              if (notification === 'CALENDAR_EVENTS') {
                  this.storedEvents = JSON.parse(JSON.stringify(payload))
                  this.updateDom();
              }
          },
      
      posted in Troubleshooting
      BKeyportB
      BKeyport
    • RE: Switchbot API access - MMM-CommandtoNotification

      @sdetweil You might be right - but then again - when you’re already using CommandToNotification for the back end of a module, you might as well continue.

      Even so, the problem still exists - I’m having trouble following the documentation for the API.

      posted in Requests
      BKeyportB
      BKeyport
    • Switchbot API access - MMM-CommandtoNotification

      Folks, I’m not understanding the api at https://github.com/OpenWonderLabs/SwitchBotAPI very well - What I’d like to do is use MMM-CommandtoNotification to get the current tempurature and humidity off my switchbot hub 2, so I can display it on my mirror in another room.

      Could someone help me develop the command/code to do so?

      I flat out think it’s beyond my current ability.

      Thanks!

      posted in Requests
      BKeyportB
      BKeyport
    • RE: Help restyling MMM-ValuesByNotification

      @sdetweil you’re correct. It’s a string. That started fixing it up, just gotta reset a couple of variables I forgot to capture. 😏

      posted in Custom CSS
      BKeyportB
      BKeyport
    • RE: Help restyling MMM-ValuesByNotification

      So, after some more playing around, I’ve come to the determination that the HTML and class setup isn’t good for my use. As a result, I’ve got most of a new module set up for use, however, I’m having issues breaking down the JSON as processed through the notification.

      in short, I’m unable to get the payload on the notification to flow into the array for use. I’ve determined that it’s not flowing through to an array, based on various tests.

      Currently, I have this:

      	notificationReceived: function(notification, payload, sender) {
      		if (notification === 'Weather') {
      			this.storedEvents = JSON.parse(JSON.stringify(payload))
      			this.updateDom();
      
      		}
      	},
      

      Could you provide me something better to strip down the JSON into an array?

      Relevant CommandtoNotification config:

      		{
      						script: "/usr/bin/curl",
      						args: "-X GET -H 'application/json' http://192.168.0.6:80/v1/current_conditions",
      						timeout: 5000,
      						sync: false,
      						notifications: [
      							"Weather",
      						],
      					}
      

      Raw data from command:

      {"data":{"did":"001D0A71573B","ts":1722493593,"conditions":[{"lsid":434637,"data_structure_type":1,"txid":1,"temp": 61.7,"hum":83.1,"dew_point": 56.5,"wet_bulb": 58.3,"heat_index": 62.0,"wind_chill": 61.7,"thw_index": 62.0,"thsw_index":null,"wind_speed_last":0.00,"wind_dir_last":0,"wind_speed_avg_last_1_min":0.00,"wind_dir_scalar_avg_last_1_min":0,"wind_speed_avg_last_2_min":0.00,"wind_dir_scalar_avg_last_2_min":0,"wind_speed_hi_last_2_min":null,"wind_dir_at_hi_speed_last_2_min":null,"wind_speed_avg_last_10_min":0.00,"wind_dir_scalar_avg_last_10_min":226,"wind_speed_hi_last_10_min":1.00,"wind_dir_at_hi_speed_last_10_min":225,"rain_size":1,"rain_rate_last":0,"rain_rate_hi":0,"rainfall_last_15_min":0,"rain_rate_hi_last_15_min":0,"rainfall_last_60_min":0,"rainfall_last_24_hr":0,"rain_storm":0,"rain_storm_start_at":null,"solar_rad":null,"uv_index":null,"rx_state":0,"trans_battery_flag":0,"rainfall_daily":0,"rainfall_monthly":19,"rainfall_year":3902,"rain_storm_last":19,"rain_storm_last_start_at":1722266760,"rain_storm_last_end_at":1722423661},{"lsid":434634,"data_structure_type":4,"temp_in": 82.9,"hum_in":44.5,"dew_point_in": 59.1,"heat_index_in": 82.8},{"lsid":434633,"data_structure_type":3,"bar_sea_level":30.057,"bar_trend": 0.011,"bar_absolute":29.593}]},"error":null}
      

      formatted json:

      {
        "data": {
          "did": "001D0A71573B",
          "ts": 1722493593,
          "conditions": [
            {
              "lsid": 434637,
              "data_structure_type": 1,
              "txid": 1,
              "temp": 61.7,
              "hum": 83.1,
              "dew_point": 56.5,
              "wet_bulb": 58.3,
              "heat_index": 62,
              "wind_chill": 61.7,
              "thw_index": 62,
              "thsw_index": null,
              "wind_speed_last": 0,
              "wind_dir_last": 0,
              "wind_speed_avg_last_1_min": 0,
              "wind_dir_scalar_avg_last_1_min": 0,
              "wind_speed_avg_last_2_min": 0,
              "wind_dir_scalar_avg_last_2_min": 0,
              "wind_speed_hi_last_2_min": null,
              "wind_dir_at_hi_speed_last_2_min": null,
              "wind_speed_avg_last_10_min": 0,
              "wind_dir_scalar_avg_last_10_min": 226,
              "wind_speed_hi_last_10_min": 1,
              "wind_dir_at_hi_speed_last_10_min": 225,
              "rain_size": 1,
              "rain_rate_last": 0,
              "rain_rate_hi": 0,
              "rainfall_last_15_min": 0,
              "rain_rate_hi_last_15_min": 0,
              "rainfall_last_60_min": 0,
              "rainfall_last_24_hr": 0,
              "rain_storm": 0,
              "rain_storm_start_at": null,
              "solar_rad": null,
              "uv_index": null,
              "rx_state": 0,
              "trans_battery_flag": 0,
              "rainfall_daily": 0,
              "rainfall_monthly": 19,
              "rainfall_year": 3902,
              "rain_storm_last": 19,
              "rain_storm_last_start_at": 1722266760,
              "rain_storm_last_end_at": 1722423661
            },
            {
              "lsid": 434634,
              "data_structure_type": 4,
              "temp_in": 82.9,
              "hum_in": 44.5,
              "dew_point_in": 59.1,
              "heat_index_in": 82.8
            },
            {
              "lsid": 434633,
              "data_structure_type": 3,
              "bar_sea_level": 30.057,
              "bar_trend": 0.011,
              "bar_absolute": 29.593
            }
          ]
        },
        "error": null
      }
      

      I already know what the path is to the various array elements (from ValuesByNotification’s config:

      {
      										valueTitle: "Temperature Outdoors",
      										valueUnit: "°",
      										jsonpath: "data.conditions[0].temp",
      										//valueFormat: "Number(${value}).toFixed(2)",
      										//classes: "",
      									},
      

      Should be a path something like this.storedEvents.data.conditions[0].temp

      Thanks!

      posted in Custom CSS
      BKeyportB
      BKeyport
    • RE: Help restyling MMM-ValuesByNotification

      I’ve officially given up.

      I can get it to start to look right outside the magicmirror environment, and even with unsetting everything styled within the ValuesByNotification app, I can’t get it to duplicate within Magic Mirror.

      This is with copying Main.css into a test environment, along with the other modules’ CSS files, and using the output HTML from MagicMirror.

      Works great in test, but the moment I try to make it go live, it’s doing random things.

      I hate CSS. I really do.

      posted in Custom CSS
      BKeyportB
      BKeyport
    • RE: MagicMirror on second Monitor

      @sdetweil Ahh, ok, I thought it was completely dead. Good to know.

      posted in Troubleshooting
      BKeyportB
      BKeyport
    • RE: MagicMirror on second Monitor

      @sdetweil With the displays showing “HDMI-A-1” etc, it’s in Wayland, xrandr doesn’t function under that. This is part of why I suggested going back to X11.

      posted in Troubleshooting
      BKeyportB
      BKeyport
    • RE: MagicMirror on second Monitor

      @Babene1 Please refer to the documentation for MagicMirror. https://docs.magicmirror.builders/configuration/introduction.html#advanced-configuration-and-frequently-asked-how-to-configure-examples

      You may want to also run sudo raspi-config and change back to the x11 desktop environment. there’s some unique issues with the new environment that may not be covered.

      posted in Troubleshooting
      BKeyportB
      BKeyport
    • RE: Help restyling MMM-ValuesByNotification

      @wishmaster270 I think the problem I’m having is figuring out where to place the classes to trigger what I want. Flex to me seems a bit erratic with how to set things.

      posted in Custom CSS
      BKeyportB
      BKeyport
    • RE: Help restyling MMM-ValuesByNotification

      @sdetweil I’m aware of everything you said, the problem is that I can’t get the CSS to cooperate. I can get 'em all to row, all to column (Default), etc, just not anything else.

      Where I’m weakest is CSS, I have a hard time wrapping my head around it.

      posted in Custom CSS
      BKeyportB
      BKeyport
    • RE: Help restyling MMM-ValuesByNotification

      (old) Sample data:

      {"data":{"did":"001D0A71573B","ts":1716603038,"conditions":[{"lsid":434637,"data_structure_type":1,"txid":1,"temp": 56.9,"hum":72.8,"dew_point": 48.3,"wet_bulb": 51.5,"heat_index": 56.2,"wind_chill": 56.9,"thw_index": 56.2,"thsw_index":null,"wind_speed_last":2.00,"wind_dir_last":146,"wind_speed_avg_last_1_min":2.00,"wind_dir_scalar_avg_last_1_min":157,"wind_speed_avg_last_2_min":2.00,"wind_dir_scalar_avg_last_2_min":157,"wind_speed_hi_last_2_min":5.00,"wind_dir_at_hi_speed_last_2_min":169,"wind_speed_avg_last_10_min":1.31,"wind_dir_scalar_avg_last_10_min":180,"wind_speed_hi_last_10_min":5.00,"wind_dir_at_hi_speed_last_10_min":169,"rain_size":1,"rain_rate_last":0,"rain_rate_hi":0,"rainfall_last_15_min":0,"rain_rate_hi_last_15_min":0,"rainfall_last_60_min":0,"rainfall_last_24_hr":7,"rain_storm":7,"rain_storm_start_at":1716576961,"solar_rad":null,"uv_index":null,"rx_state":0,"trans_battery_flag":0,"rainfall_daily":7,"rainfall_monthly":155,"rainfall_year":3713,"rain_storm_last":40,"rain_storm_last_start_at":1716299460,"rain_storm_last_end_at":1716433260},{"lsid":434634,"data_structure_type":4,"temp_in": 83.5,"hum_in":29.5,"dew_point_in": 48.4,"heat_index_in": 81.5},{"lsid":434633,"data_structure_type":3,"bar_sea_level":29.826,"bar_trend":-0.038,"bar_absolute":29.365}]},"error":null}
      
      posted in Custom CSS
      BKeyportB
      BKeyport
    • RE: Help restyling MMM-ValuesByNotification

      of course. Or pause on the sources page. Same effect.

      posted in Custom CSS
      BKeyportB
      BKeyport
    • Help restyling MMM-ValuesByNotification

      I’m wanting to show my values by notification differently, and it’s not cooperating with any css I’m throwing at it.

      Here’s the config - commented to show how I want it to look (adjusted upon rediscovery that some values are calculated, and I’m not gonna bother with that):

      		{
      			module: "MMM-ValuesByNotification", // https://github.com/Tom-Hirschberger/MMM-ValuesByNotification
      			position: "bottom_right",
      			config: {
      				animationSpeed: 0,
      				updateInterval: 15,
      				reuseCount: 99,
      				transformerFunctions: {
      					degToCompass: (num) => {
      						val = ((num/22.5)+.5) | 0;
      						arr = ["N","NNE","NE","ENE","E","ESE", "SE", "SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"];
      						res = arr[(val % 16)];
      						return res;
      					},
      					toDate: (num) => {
      						return new Date(num * 1000).toLocaleString('en-US', { 
      							year: 'numeric', 
      							month: '2-digit', 
      							day: '2-digit', 
      							hour: '2-digit', 
      							minute: '2-digit', 
      							second: '2-digit',
      							hour12: true
      						});
      					},
      					
      				},
      				groups: [
      				//groups should be on row next to each other. 
      				// Values next to titles unless indicated. 
      					{
      						classes: "row",
      						items: [
      							{
      								notification: "Weather",
      								values: [
      									{
      										valueTitle: " ",
      										valueUnit: "°F",
      										jsonpath: "data.conditions[0].temp",
      										valueFormat: "Number(${value}).toFixed(1)",
      										classes: "xlarge",
      									},
      								],
      							},
      						],
      					},
      					// Insert vertical rule here 
      					{
      						classes: "row medium",
      						items: [
      							{
      								notification: "Weather",
      								values: [
      									{
      										valueTitle: "Wind:",
      										valueUnit: "mph",
      										jsonpath: "data.conditions[0].wind_speed_last",
      										valueFormat: "Number(${value}).toFixed(1)",
      										unitSpace: true,
      									},
      									// same line as previous
      									{
      										valueTitle: " ",
      										jsonpath: "data.conditions[0].wind_dir_last",
      										valueTransformers: ["degToCompass"],
      										
      									},
      									// Insert <HR> here 
      									{
      										valueTitle: "Rain:",
      										valueUnit: "in", 
      										unitSpace: true,
      										jsonpath: "data.conditions[0].rainfall_daily",
      										valueFormat: "Number(${value}/100).toFixed(2)",
      									},
      									// same line as previous 
      									{
      										valueTitle: "Yearly Total",
      										valueUnit: "in",
      										unitSpace: true,
      										jsonpath: "data.conditions[0].rainfall_year" ,
      										valueFormat: "Number(${value}/100).toFixed(2)",
      									},
      								],
      							},
      						],
      					},
      					// Insert Vertical Rule here
      					{
      						classes: "row medium",
      						items: [
      							{
      								notification: "Weather",
      								values: [
      									{
      										valueTitle: "Humidity:",
      										valueUnit: "%",
      										jsonpath: "data.conditions[0].hum",
      										valueFormat: "Number(${value}).toFixed(1)",
      									},
      									// same line as previous
      									
      									{
      										valueTitle: "Feels like:",
      										valueUnit: "°F",
      										jsonpath: "data.conditions[0].thw_index",
      										valueFormat: "Number(${value}).toFixed(1)",
      									},
      									// Insert <HR> here
      									{
      										valueTitle: "Barometer",
      										valueUnit: "in Hg",
      										unitSpace: true,
      										jsonpath: "data.conditions[2].bar",
      										valueFormat: "Number(${value}).toFixed(3)",
      									},
      								],
      							},
      						],
      					},
      					// Below others. 
      					{
      						classes: "bottom small",
      						items: [
      							{
      								notification: "Weather",
      								values: [
      									{
      										valueTitle: "Conditions as of:",
      										jsonpath: "data.ts",
      										valueTransformers: ["toDate"],
      										//classes: "",
      									}
      								]
      							},
      						],
      					},
      				],
      			},
      		}, 
      

      Existing CSS modifications - and needs:

      .MMM-ValuesByNotification {
      	border-radius: 0px;
          border-style: none;
          color: black;
          background-color: white;
      }
      
      .MMM-ValuesByNotification .vbn .groupWrapper {
          border-radius: 0px;
          border-style: none;
          color: black;
          background-color: white;
      }
      
      /* vertical rule
      .vertical-rule {
          margin-top: 15px;
          margin-bottom: 15px;
          width: 1px;
          background: #e0e4e7;
          float: left;
          height: 90px;
      }
      */
      posted in Custom CSS
      BKeyportB
      BKeyport
    • RE: Update needed

      @Bungle68 Personally, I’d just start over.

      posted in Troubleshooting
      BKeyportB
      BKeyport
    • 1
    • 2
    • 7
    • 8
    • 9
    • 10
    • 11
    • 65
    • 66
    • 9 / 66