Skip to content

[Bug] Missing elements in config after upgrade #4105

Closed

Description

@Tom-Hirschberger

Environment

System Information

  • SYSTEM: manufacturer: Raspberry Pi Foundation; model: Raspberry Pi 5 Model B Rev 1.0; virtual: false; MM: v2.35.0
  • OS: platform: linux; distro: Debian GNU/Linux; release: 12; arch: arm64; kernel: 6.12.75+rpt-rpi-2712
  • VERSIONS: electron: 41.1.0; used node: 22.21.1; installed node: 22.21.1; npm: 10.9.4; pm2: 6.0.14
  • ENV: XDG_SESSION_TYPE: tty; MM_CONFIG_FILE: undefined
    WAYLAND_DISPLAY: undefined; DISPLAY: :0; ELECTRON_ENABLE_GPU: undefined
  • RAM: total: 8059.06 MB; free: 6885.11 MB; used: 1173.95 MB
  • OTHERS: uptime: 931 minutes; timeZone: Europe/Berlin

Which start option are you using?

node --run start

Are you using PM2?

Yes

Module

None

Have you tried disabling other modules?

  • Yes
  • No

Have you searched if someone else has already reported the issue on the forum or in the issues?

  • Yes

What did you do?

Configuration
{
			module: "MMM-ValuesByNotification",
			position: "top_right",
			//header: "Sensors",
			config: {
				debug: true,
				animationSpeed: 0,
				updateInterval: 90,
				valuePositions: "tivu",
				classes: "environment",
				naValue: "na.na",
				valueFormat: "Number(${value}).toFixed(1)",
				transformerFunctions: {
					zisterneAddPercent: (value) => {
						return value+"l ("+(Number(value/1600)*100).toFixed(0)+"%)"
					},
					rountToInt: (value) => {
						try {
							return Math.round(parseFloat(value))
						} catch {
							return value
						}
					},
					toKiloValue: (value) => {
						if(value >= 10000){
							value = Math.round(value/10000)
							return value+"k"
						} else {
							return value
						}
					},
                },
				groups: [
					{
						items: [
							{
								valueTitle: "Dach",
								notification: "KNX_DACH_TEMP",
								reuseCount: 50,
								values: [
									{
										valueIcon: "fxemoji:thermometer",
										valueUnit: "°C",
									},
								]
							},
							{
								notification: "KNX_DACH_LIGHT",
								reuseCount: 1000,
								naValue: "na",
								valueFormat: "{value}",
								valueTransformers: ["rountToInt", "toKiloValue"],
								values: [
									{
										valueIcon: "fa-sun-o",
										valueUnit: "Lux",
									},
								]
							},
						]
					},
					{
						items: [
							{
								valueTitle: "Südseite",
								notification: "TEMPERATURE_C_ESPNORD",
								reuseCount: 4,
								values: [
									{
										valueIcon: "fxemoji:thermometer",
										valueUnit: "°C",
									},
								]
							},
							{
								notification: "HUMIDITY_ESPNORD",
								reuseCount: 4,
								values: [
									{
										valueIcon: "fa fa-tint",
										valueUnit: "%rH",
									},
								]
							},
						]
					},
					{
						items: [
							{
								valueTitle: "Büro",
								notification: "TEMPERATURE_C_ESPBUERO",
								reuseCount: 4,
								values: [
									{
										valueIcon: "fxemoji:thermometer",
										valueUnit: "°C",
									},
								]
							},
							{
								notification: "HUMIDITY_ESPBUERO",
								reuseCount: 4,
								values: [
									{
										valueIcon: "fa fa-tint",
										valueUnit: "%rH",
									},
								]
							},
						]
					},
					{
						items: [
							{
								valueTitle: "Schlafen",
								notification: "KNX_OG_SZ_TEMP",
								reuseCount: 180,
								values: [
									{
										valueIcon: "fxemoji:thermometer",
										valueUnit: "°C",
									},
								]
							},
							{
								notification: "KNX_OG_SZ_TEMP_SET",
								reuseCount: 100000,
								values: [
									{
										naValue: "(na.na",
										valueUnit: "°C)",
										valueIcon: "mdi:home-thermometer",
										valueFormat: "\"(\"+Number(${value}).toFixed(1)"
									},
								]
							},
						]
					},
					{
						items: [
							{
								valueTitle: "Bad",
								notification: "KNX_OG_BAD_TEMP",
								reuseCount: 180,
								values: [
									{
										valueIcon: "fxemoji:thermometer",
										valueUnit: "°C",
									},
								]
							},
							{
								notification: "KNX_OG_BAD_TEMP_SET",
								reuseCount: 100000,
								values: [
									{
										naValue: "(na.na",
										valueUnit: "°C)",
										valueIcon: "mdi:home-thermometer",
										valueFormat: "\"(\"+Number(${value}).toFixed(1)"
									},
								]
							},
						]
					},
					{
						items: [
							{
								valueTitle: "Nähen",
								notification: "KNX_OG_GALERIE_TEMP",
								reuseCount: 180,
								values: [
									{
										valueIcon: "fxemoji:thermometer",
										valueUnit: "°C",
									},
								]
							},
							{
								notification: "KNX_OG_GALERIE_TEMP_SET",
								reuseCount: 100000,
								values: [
									{
										naValue: "(na.na",
										valueUnit: "°C)",
										valueIcon: "mdi:home-thermometer",
										valueFormat: "\"(\"+Number(${value}).toFixed(1)"
									},
								]
							},
						]
					},
					{
						items: [
							{
								valueTitle: "Kinder",
								notification: "KNX_OG_KINDER_TEMP",
								reuseCount: 180,
								values: [
									{
										valueIcon: "fxemoji:thermometer",
										valueUnit: "°C",
									},
								]
							},
							{
								notification: "KNX_OG_KINDER_TEMP_SET",
								reuseCount: 100000,
								values: [
									{
										naValue: "(na.na",
										valueUnit: "°C)",
										valueIcon: "mdi:home-thermometer",
										valueFormat: "\"(\"+Number(${value}).toFixed(1)"
									},
								]
							},
						]
					},
					{
						items: [
							{
								valueTitle: "Wohnzimmer",
								notification: "KNX_EG_WZ_TEMP",
								reuseCount: 180,
								values: [
									{
										valueIcon: "fxemoji:thermometer",
										valueUnit: "°C",
									},
								]
							},
							{
								notification: "KNX_EG_WZ_TEMP_SET",
								reuseCount: 100000,
								values: [
									{
										naValue: "(na.na",
										valueUnit: "°C)",
										valueIcon: "mdi:home-thermometer",
										valueFormat: "\"(\"+Number(${value}).toFixed(1)"
									},
								]
							},
						]
					},
					//ZISTERNE
					{
						valueFormat: "{value}",
						classes: "zisterne",
						items: [
							{
								notification: "ZISTERNE_VALUES",
								reuseCount: 15,
								jsonpath: "rounded",
								naValue: "na",
								values: [
									{
										valueTitle: "Zisterne",
										valuePositions: "ti[v]",
										valueImgIcon: "modules/MMM-ValuesByNotification/icons/wassertank/wassertank-0.svg",
										valueUnit: "l",
										valueTransformers: ["zisterneAddPercent"],
										thresholds: [
											{
												valueImgIcon: "modules/MMM-ValuesByNotification/icons/wassertank/wassertank-100.png",
												type: "gt",
												value: 1550,
											},
											{
												valueImgIcon: "modules/MMM-ValuesByNotification/icons/wassertank/wassertank-90.png",
												type: "gt",
												value: 1395,
											},
											{
												valueImgIcon: "modules/MMM-ValuesByNotification/icons/wassertank/wassertank-80.png",
												type: "gt",
												value: 1240,
											},
											{
												valueImgIcon: "modules/MMM-ValuesByNotification/icons/wassertank/wassertank-70.png",
												type: "gt",
												value: 1085,
											},
											{
												valueImgIcon: "modules/MMM-ValuesByNotification/icons/wassertank/wassertank-60.png",
												type: "gt",
												value: 930,
											},
											{
												valueImgIcon: "modules/MMM-ValuesByNotification/icons/wassertank/wassertank-50.png",
												type: "gt",
												value: 775,
											},
											{
												valueImgIcon: "modules/MMM-ValuesByNotification/icons/wassertank/wassertank-40.png",
												type: "gt",
												value: 620,
											},
											{
												valueImgIcon: "modules/MMM-ValuesByNotification/icons/wassertank/wassertank-30.png",
												type: "gt",
												value: 465,
											},
											{
												valueImgIcon: "modules/MMM-ValuesByNotification/icons/wassertank/wassertank-20.png",
												type: "gt",
												value: 310,
											},
											{
												valueImgIcon: "modules/MMM-ValuesByNotification/icons/wassertank/wassertank-10.png",
												type: "gt",
												value: 155,
											},
										]
									},
								]
							},
						]
					}
				]
			},
			classes: "pageC"
		},

What did you expect to happen?

Maybe the new way to parse the config is the problem. I am not that deep in the core to check what happens during the start.

What actually happened?

Hi and sorry for the big config but i do not want a small detail being responsible for my current problem.

After the update to 2.35 my transformerFunctions do not work anymore.

The idea is to provide transformer functions in config->transformerFunctions which are small javascript functions which then can be called later in values either single or after each other.

Everything works as expected since years but after the upgrade to 2.35 the transformerFunctions are empty ({}) and can not be called later.

I am not sure what is the reason for this and i am very sure that my module is a edge case in the Mirror world.

Additional comments

No response

Participation

  • I am willing to submit a pull request for this change.

Activity

  1. khassel commented on Apr 11, 2026

    @khassel
    Collaborator

    Hi Tom,

    will take a look because I did the rewrite of the config stuff ...

  2. Tom-Hirschberger commented on Apr 11, 2026

    @Tom-Hirschberger
    ContributorAuthor

    Thanks.

    I will try to provide a smaller example to reproduce tomorrow.

    I think other modules like the Calender-Ext ones provide similar mechanisms. Maybe they are affected, too

  3. khassel commented on Apr 11, 2026

    @khassel
    Collaborator

    I did the following with mm v2.34.0

    • added your module
    • added above config
    • added a console.dir of your module config right after config.js is loaded
    • added a console.dir in your node_helper.js after config is retrieved

    This looks like the problem was already there with v2.34.0 ...

    Which mm version was the last one working?

    Can you do the same simple logging on your side to confirm this so far?

    node@4c885cef95a1:~/magicmirror$ node --run server
    [2026-04-11 21:32:45.113] [LOG]   [app] Starting MagicMirror: v2.34.0 
    [2026-04-11 21:32:45.115] [LOG]   [app] Loading config ... 
    [2026-04-11 21:32:45.115] [LOG]   [app] config template file not exists, no envsubst 
    [2026-04-11 21:32:45.191] [INFO]  [check_config] Checking config file /home/node/magicmirror/config/config.js ... 
    [2026-04-11 21:32:45.218] [INFO]  [check_config] Your configuration file doesn't contain syntax errors :) 
    [2026-04-11 21:32:45.218] [INFO]  [check_config] Checking modules structure configuration ... 
    [2026-04-11 21:32:45.232] [INFO]  [check_config] Your modules structure configuration doesn't contain errors :) 
    {
      debug: true,
      configDeepMerge: true,
      animationSpeed: 0,
      updateInterval: 90,
      valuePositions: 'tivu',
      classes: 'environment',
      naValue: 'na.na',
      valueFormat: 'Number(${value}).toFixed(1)',
      transformerFunctions: {
        zisterneAddPercent: [Function: zisterneAddPercent],
        rountToInt: [Function: rountToInt],
        toKiloValue: [Function: toKiloValue]
      },
      groups: [
        { items: [Array] },
        { items: [Array] },
        { items: [Array] },
        { items: [Array] },
        { items: [Array] },
        { items: [Array] },
        { items: [Array] },
        { items: [Array] },
        { valueFormat: '{value}', classes: 'zisterne', items: [Array] }
      ]
    }
    [2026-04-11 21:32:45.236] [LOG]   [app] Loading module helpers ... 
    [2026-04-11 21:32:45.237] [LOG]   [node_helper] Initializing new module helper ... 
    [2026-04-11 21:32:45.237] [LOG]   [node_helper] Module helper loaded: MMM-ValuesByNotification 
    [2026-04-11 21:32:45.237] [LOG]   [app] No helper found for module: clock. 
    [2026-04-11 21:32:45.237] [LOG]   [app] All module helpers loaded. 
    [2026-04-11 21:32:45.239] [LOG]   [server] Starting server on port 8080 ...  
    [2026-04-11 21:32:45.239] [WARN]  [server] You're using a full whitelist configuration to allow for all IPs 
    [2026-04-11 21:32:45.243] [LOG]   [app] Server started ... 
    [2026-04-11 21:32:45.243] [LOG]   [node_helper] Connecting socket for: MMM-ValuesByNotification 
    [2026-04-11 21:32:45.243] [LOG]   [app] Sockets connected & modules started ... 
    [2026-04-11 21:32:45.244] [INFO]  [serveronly] 
    >>>   Ready to go! Please point your browser to: http://0.0.0.0:8080   <<< 
    [2026-04-11 21:32:45.388] [INFO]  [utils] 
    ####  System Information  ####
    - SYSTEM:   manufacturer: Micro Computer (HK) Tech Limited; model: Docker Container; virtual: false; MM: 2.34.0
    - OS:       platform: linux; distro: Debian GNU/Linux; release: 13; arch: x64; kernel: 6.17.0-20-generic
    - VERSIONS: electron: undefined; used node: 25.9.0; installed node: 25.9.0; npm: 11.12.1; pm2: 6.0.14
    - ENV:      XDG_SESSION_TYPE: undefined; MM_CONFIG_FILE: undefined
                WAYLAND_DISPLAY:  wayland-0; DISPLAY: :0; ELECTRON_ENABLE_GPU: undefined
    - RAM:      total: 29854.43 MB; free: 21961.84 MB; used: 7892.59 MB
    - OTHERS:   uptime: 152 minutes; timeZone: UTC 
    {
      debug: true,
      basicElementType: 'span',
      updateInterval: 90,
      reuseCount: 1,
      animationSpeed: 0,
      groupsPositions: 'tie',
      groupPositions: 'tie',
      itemPositions: 'tie',
      valuePositions: 'tivu',
      naValue: 'na.na',
      groupsTitle: null,
      groupTitle: null,
      itemTitle: null,
      valueTitle: null,
      classes: 'environment',
      groupsIcon: null,
      groupIcon: null,
      itemIcon: null,
      valueIcon: null,
      groupsImgIcon: null,
      groupImgIcon: null,
      itemImgIcon: null,
      valueImgIcon: null,
      valueUnit: null,
      valueFormat: 'Number(${value}).toFixed(1)',
      transformerFunctions: {},
      valueTransformers: null,
      formatNaValue: false,
      thresholds: null,
      groups: [
        { items: [Array] },
        { items: [Array] },
        { items: [Array] },
        { items: [Array] },
        { items: [Array] },
        { items: [Array] },
        { items: [Array] },
        { items: [Array] },
        { valueFormat: '{value}', classes: 'zisterne', items: [Array] }
      ],
      notificationPrefix: '',
      profiles: null,
      addClassesRecursive: false,
      letClassesBubbleUp: true,
      reusedClass: 'reused',
      automaticWrapperClassPrefix: 'wrap',
      newlineReplacement: ' ',
      unitSpace: false,
      configDeepMerge: true
    }
  4. Tom-Hirschberger commented on Apr 11, 2026

    @Tom-Hirschberger
    ContributorAuthor

    That's interesting. I am running on 2.34 at the moment and do not have any problems.
    At least things get formatted.

  5. Tom-Hirschberger commented on Apr 11, 2026

    @Tom-Hirschberger
    ContributorAuthor

    I only have my mobile at the moment but will try to provide similar information with 2.34 in my setup tomorrow.

  6. khassel commented on Apr 11, 2026

    @khassel
    Collaborator

    Can you check the /config/ endpoint, e.g. http://localhost:8080/config/ ? For mm v2.34.0 and mm v2.35.0 please.

    The strange thing is that everything of the config is displayed except the one property

    Image
  7. Tom-Hirschberger commented on Apr 12, 2026

    @Tom-Hirschberger
    ContributorAuthor

    Hi again.

    I just tested both config endpoints. Neither in 2.34 nor 2.35 the transformerFunctions are present in the endpoint result.
    But i added:

    //REMOVE_ME
    console.log("---->PRINT TRANSFORMER FUNCTIONS")
    Object.keys(this.config.transformerFunctions).forEach(key => {
      console.log(key, this.config.transformerFunctions[key].toString());
    });
    

    to the start function of my module right after the config is send to the node_helper.js with the socket notification.

    In 2.34 the functions are stored correctly in the object in 2.35 they are missing.

  8. sdetweil commented on Apr 12, 2026

    @sdetweil
    Collaborator

    Looks like requirefromstring() is the culprit

    Image

    In MMM-Config I had to use transformer functions in the JSON parse and stringify to keep the functions (parameter 2)

  9. khassel commented on Apr 12, 2026

    @khassel
    Collaborator

    yes:

    In JavaScript, standard JSON does not support functions.
    If you use JSON.stringify() on an object containing functions,
    those functions will be omitted (if they are object properties)
    or changed to null (if they are in an array).

    will provide a fix

  10. sdetweil commented on Apr 12, 2026

    @sdetweil
    Collaborator

    From mmm-config

    //
    // used by JSON.stringify
    //
    function tohandler(key, value) {
      if (typeof value === "function") {
        return value + ""; // implicitly `toString` it
      }
      return value;
    }
    //
    // used by JSON.parse
    //
    function fromhandler(key, value) {
      if (
        value &&
        typeof value == "string" &&
        (value.startsWith("(") || value.startsWith("function(")) &&
        value.endsWith("}")
      ) {
        return eval("(" + value + ")");
      }
      return value;
    }
    
  11. khassel commented on Apr 12, 2026

    @khassel
    Collaborator

    I think I have a solution for this but before providing a PR to this repo I'm interested if it works on your side @Tom-Hirschberger

    Can you please test if it works when you manually add these changes ? Thanks!

  12. Tom-Hirschberger commented on Apr 12, 2026

    @Tom-Hirschberger
    ContributorAuthor

    Works like a charm.
    My transformers work and i can see them in the config endpoint

  13. added a commit that references this issue on Apr 12, 2026
    d3a3ad9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions