Using an external JS library in function node, I'm sure it's easy

Further to this post, can someone help me use momentJS in a function node?

Sorry I need a bit of hand holding on this, so if anyone could spell it out for me, that would be most appreciated. Here's what I have done so far:

I have added the following to my .node-red/settings.js file:

functionGlobalContext: {
   moment:require('moment')
},

I have installed moment, although not sure how to install into the same directory as settings.js (I read this was a requirement somewhere). Do I just do this:

cd .node-red
npm install moment

That's what I have done anyway. And in my function node this is what I have:

for (i=msg.payload.length-1;i>0;i--) {
    lastpH = msg.payload[i].pH;
    if (lastpH !== null) {
        lastpHtime = moment().fromNow().msg.payload[i].time
        break
    }
}

As you can see, I'm trying to display a datetime object in the fromNow format, e.g. "3 hours ago".

Do I need to "load" moment into the function at the top of the function as well? Sorry for the basic question.

Only thing you're missing is:

const moment = global.get('moment');

... in the beginning of the function node. Adding values to functionGlobalContext adds them to the same global context you can use to store values runtime (as the name hints). This is mentioned in the function node tutorials.

Thanks. I'm getting

"TypeError: Cannot read property 'fromNow' of undefined"

with the below. Any other ideas? Again sorry this is probably very obvious to others

const moment = global.get('moment')

var lastpH; var lastpHtime
var lastbromine; var lastbrominetime
var lastalkalinity; var lastalkalinitytime



for (i=msg.payload.length-1;i>0;i--) {
    lastpH = msg.payload[i].pH;
    if (lastpH !== null) {
        lastpHtime = moment.fromNow().msg.payload[i].time
        break
    }
}

Did you possibly add the context stuff to the end of settings.js instead of adding into the existing section that should already have been there in the middle of the file?

Otherwise did you restart node-red after editting settings? If you did both of the above and still not working post your settings.js here, and tell us which settings.js you have editted.

Many thanks Colin

  • no I added it to the existing functionGlobalContext section in settings.js
  • yes I restarted NodeRED after editing settings.js

I edited settings.js within the directory /home/mat/.node-red. Might there be another one? I'm running node red as a service in Ubuntu. It looks like this:

mat@automate:~/.node-red$ cat settings.js
/**
 * Copyright JS Foundation and other contributors, http://js.foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 **/

// The `https` setting requires the `fs` module. Uncomment the following
// to make it available:
//var fs = require("fs");

module.exports = {
    // the tcp port that the Node-RED web server is listening on
    uiPort: process.env.PORT || 1880,

    // By default, the Node-RED UI accepts connections on all IPv4 interfaces.
    // To listen on all IPv6 addresses, set uiHost to "::",
    // The following property can be used to listen on a specific interface. For
    // example, the following would only allow connections from the local machine.
    //uiHost: "127.0.0.1",

    // Retry time in milliseconds for MQTT connections
    mqttReconnectTime: 15000,

    // Retry time in milliseconds for Serial port connections
    serialReconnectTime: 15000,

    // Retry time in milliseconds for TCP socket connections
    //socketReconnectTime: 10000,

    // Timeout in milliseconds for TCP server socket connections
    //  defaults to no timeout
    //socketTimeout: 120000,

    // Maximum number of messages to wait in queue while attempting to connect to TCP socket
    //  defaults to 1000
    //tcpMsgQueueSize: 2000,

    // Timeout in milliseconds for HTTP request connections
    //  defaults to 120 seconds
    //httpRequestTimeout: 120000,

    // The maximum length, in characters, of any message sent to the debug sidebar tab
    debugMaxLength: 1000,

    // The maximum number of messages nodes will buffer internally as part of their
    // operation. This applies across a range of nodes that operate on message sequences.
    //  defaults to no limit. A value of 0 also means no limit is applied.
    //nodeMaxMessageBufferLength: 0,

    // To disable the option for using local files for storing keys and certificates in the TLS configuration
    //  node, set this to true
    //tlsConfigDisableLocalFiles: true,

    // Colourise the console output of the debug node
    //debugUseColors: true,

    // The file containing the flows. If not set, it defaults to flows_<hostname>.json
    //flowFile: 'flows.json',

    // To enabled pretty-printing of the flow within the flow file, set the following
    //  property to true:
    //flowFilePretty: true,

    // By default, credentials are encrypted in storage using a generated key. To
    // specify your own secret, set the following property.
    // If you want to disable encryption of credentials, set this property to false.
    // Note: once you set this property, do not change it - doing so will prevent
    // node-red from being able to decrypt your existing credentials and they will be
    // lost.
    //credentialSecret: "a-secret-key",

    // By default, all user data is stored in the Node-RED install directory. To
    // use a different location, the following property can be used
    //userDir: '/home/nol/.node-red/',

    // Node-RED scans the `nodes` directory in the install directory to find nodes.
    // The following property can be used to specify an additional directory to scan.
    //nodesDir: '/home/nol/.node-red/nodes',

    // By default, the Node-RED UI is available at http://localhost:1880/
    // The following property can be used to specify a different root path.
    // If set to false, this is disabled.
    //httpAdminRoot: '/admin',

    // Some nodes, such as HTTP In, can be used to listen for incoming http requests.
    // By default, these are served relative to '/'. The following property
    // can be used to specifiy a different root path. If set to false, this is
    // disabled.
    //httpNodeRoot: '/red-nodes',

    // The following property can be used in place of 'httpAdminRoot' and 'httpNodeRoot',
    // to apply the same root to both parts.
    httpRoot: '/red',

    // When httpAdminRoot is used to move the UI to a different root path, the
    // following property can be used to identify a directory of static content
    // that should be served at http://localhost:1880/.
    httpStatic: '/home/mat/.node-red/public',

    // The maximum size of HTTP request that will be accepted by the runtime api.
    // Default: 5mb
    //apiMaxLength: '5mb',

    // If you installed the optional node-red-dashboard you can set it's path
    // relative to httpRoot
    // ui: { path: "dash" },

    // Securing Node-RED
    // -----------------
    // To password protect the Node-RED editor and admin API, the following
    // property can be used. See http://nodered.org/docs/security.html for details.
    adminAuth: {
        type: "credentials",
        users: [{
            username: "",
            password: "",
            permissions: "*"
        }]
    },

    // To password protect the node-defined HTTP endpoints (httpNodeRoot), or
    // the static content (httpStatic), the following properties can be used.
    // The pass field is a bcrypt hash of the password.
    // See http://nodered.org/docs/security.html#generating-the-password-hash
    //httpNodeAuth: {user:"",pass:""},
    //httpStaticAuth: {user:"",pass:""},

    // The following property can be used to enable HTTPS
    // See http://nodejs.org/api/https.html#https_https_createserver_options_requestlistener
    // for details on its contents.
    // See the comment at the top of this file on how to load the `fs` module used by
    // this setting.
    //
    //https: {
    //    key: fs.readFileSync('privatekey.pem'),
    //    cert: fs.readFileSync('certificate.pem')
    //},

    // The following property can be used to cause insecure HTTP connections to
    // be redirected to HTTPS.
    //requireHttps: true

    // The following property can be used to disable the editor. The admin API
    // is not affected by this option. To disable both the editor and the admin
    // API, use either the httpRoot or httpAdminRoot properties
    //disableEditor: false,

    // The following property can be used to configure cross-origin resource sharing
    // in the HTTP nodes.
    // See https://github.com/troygoode/node-cors#configuration-options for
    // details on its contents. The following is a basic permissive set of options:
    //httpNodeCors: {
    //    origin: "*",
    //    methods: "GET,PUT,POST,DELETE"
    //},

    // If you need to set an http proxy please set an environment variable
    // called http_proxy (or HTTP_PROXY) outside of Node-RED in the operating system.
    // For example - http_proxy=http://myproxy.com:8080
    // (Setting it here will have no effect)
    // You may also specify no_proxy (or NO_PROXY) to supply a comma separated
    // list of domains to not proxy, eg - no_proxy=.acme.co,.acme.co.uk

    // The following property can be used to add a custom middleware function
    // in front of all http in nodes. This allows custom authentication to be
    // applied to all http in nodes, or any other sort of common request processing.
    //httpNodeMiddleware: function(req,res,next) {
    //    // Handle/reject the request, or pass it on to the http in node by calling next();
    //    // Optionally skip our rawBodyParser by setting this to true;
    //    //req.skipRawBodyParser = true;
    //    next();
    //},

    // The following property can be used to verify websocket connection attempts.
    // This allows, for example, the HTTP request headers to be checked to ensure
    // they include valid authentication information.
    //webSocketNodeVerifyClient: function(info) {
    //    // 'info' has three properties:
    //    //   - origin : the value in the Origin header
    //    //   - req : the HTTP request
    //    //   - secure : true if req.connection.authorized or req.connection.encrypted is set
    //    //
    //    // The function should return true if the connection should be accepted, false otherwise.
    //    //
    //    // Alternatively, if this function is defined to accept a second argument, callback,
    //    // it can be used to verify the client asynchronously.
    //    // The callback takes three arguments:
    //    //   - result : boolean, whether to accept the connection or not
    //    //   - code : if result is false, the HTTP error status to return
    //    //   - reason: if result is false, the HTTP reason string to return
    //},

    // Anything in this hash is globally available to all functions.
    // It is accessed as context.global.
    // eg:
    //    functionGlobalContext: { os:require('os') }
    // can be accessed in a function block as:
    //    context.global.os

    functionGlobalContext: {
        moment:require('moment')
        // os:require('os'),
        // jfive:require("johnny-five"),
        // j5board:require("johnny-five").Board({repl:false})
    },

    // Context Storage
    // The following property can be used to enable context storage. The configuration
    // provided here will enable file-based context that flushes to disk every 30 seconds.
    // Refer to the documentation for further options: https://nodered.org/docs/api/context/
    //
    contextStorage: {
        default: {
            module:"localfilesystem"
        },
    },

    // The following property can be used to order the categories in the editor
    // palette. If a node's category is not in the list, the category will get
    // added to the end of the palette.
    // If not set, the following default order is used:
    //paletteCategories: ['subflows', 'input', 'output', 'function', 'social', 'mobile', 'storage', 'analysis', 'advanced'],

    // Configure the logging output
    logging: {
        // Only console logging is currently supported
        console: {
            // Level of logging to be recorded. Options are:
            // fatal - only those errors which make the application unusable should be recorded
            // error - record errors which are deemed fatal for a particular request + fatal errors
            // warn - record problems which are non fatal + errors + fatal errors
            // info - record information about the general running of the application + warn + error + fatal errors
            // debug - record information which is more verbose than info + info + warn + error + fatal errors
            // trace - record very detailed logging + debug + info + warn + error + fatal errors
            // off - turn off all logging (doesn't affect metrics or audit)
            level: "debug",
            // Whether or not to include metric events in the log output
            metrics: false,
            // Whether or not to include audit events in the log output
            audit: false
        }
    },

    // Customising the editor
    editorTheme: {
        projects: {
            // To enable the Projects feature, set this value to true
            enabled: false
        }
    },
}

That all looks ok. Assuming that node red is running as the user matt, so that is the right .node-red folder. Is the flows file in that folder?

Did you install node-red using the recommended Ubuntu/Debian/Pi script?

Run

node-red-stop
node-red-start

and paste the results here. Use the </> button when pasting it in. Make sure it still fails when started like that.

I don't think I installed node-red using that script, I did it manually as per this youtube vid. I stopped the service and ran node-red as follows and pasted the output below.

  • Yes the problem still happens when I run it that way (you can see the error somewhere in the below!)
  • Also yes the flows file is in that folder.

I'm wondering if moment is working, but my use of fromNow() is not correct (prev post)?

mat@automate:~/.node-red$ sudo service node-red stop
mat@automate:~/.node-red$ node-red
5 Sep 22:37:43 - [info] 

Welcome to Node-RED
===================

5 Sep 22:37:43 - [info] Node-RED version: v1.1.2
5 Sep 22:37:43 - [info] Node.js  version: v8.10.0
5 Sep 22:37:43 - [info] Linux 4.15.0-115-generic x64 LE
5 Sep 22:37:44 - [info] Loading palette nodes
5 Sep 22:37:45 - [debug] Module: node-red-contrib-squeezebox 0.1.1
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-squeezebox
5 Sep 22:37:45 - [debug] Module: node-red-contrib-norelite 2.6.1
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/.node-red-contrib-norelite.DELETE
5 Sep 22:37:45 - [debug] Module: node-red-contrib-alexa-remote2 3.10.4
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-alexa-remote2
5 Sep 22:37:45 - [debug] Module: node-red-contrib-amazon-echo 0.1.9
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-amazon-echo
5 Sep 22:37:45 - [debug] Module: node-red-contrib-bigtimer 2.2.5
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-bigtimer
5 Sep 22:37:45 - [debug] Module: node-red-contrib-cpu 0.0.4
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-cpu
5 Sep 22:37:45 - [debug] Module: node-red-contrib-dsm 0.14.1
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-dsm
5 Sep 22:37:45 - [debug] Module: node-red-contrib-home-assistant-websocket 0.19.5
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-home-assistant-websocket
5 Sep 22:37:45 - [debug] Module: node-red-contrib-httpauth 1.0.12
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-httpauth
5 Sep 22:37:45 - [debug] Module: node-red-contrib-huemagic 2.5.5
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-huemagic
5 Sep 22:37:45 - [debug] Module: node-red-contrib-image-output 0.3.0
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-image-output
5 Sep 22:37:45 - [debug] Module: node-red-contrib-influxdb 0.4.0
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-influxdb
5 Sep 22:37:45 - [debug] Module: node-red-contrib-interval-length 0.0.3
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-interval-length
5 Sep 22:37:45 - [debug] Module: node-red-contrib-moment 3.0.3
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-moment
5 Sep 22:37:45 - [debug] Module: node-red-contrib-mqtt-broker 0.2.4
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-mqtt-broker
5 Sep 22:37:45 - [debug] Module: node-red-contrib-multipart-stream-decoder 0.0.4
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-multipart-stream-decoder
5 Sep 22:37:45 - [debug] Module: node-red-contrib-multipart-stream-encoder 0.0.2
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-multipart-stream-encoder
5 Sep 22:37:45 - [debug] Module: node-red-contrib-mytimeout 3.0.2
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-mytimeout
5 Sep 22:37:45 - [debug] Module: node-red-contrib-nest 0.1.9
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-nest
5 Sep 22:37:45 - [debug] Module: node-red-contrib-netatmo 0.2.0
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-netatmo
5 Sep 22:37:45 - [debug] Module: node-red-contrib-rfxcom 2.6.3
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-rfxcom
5 Sep 22:37:45 - [debug] Module: node-red-contrib-shelly 1.3.1
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-shelly
5 Sep 22:37:45 - [debug] Module: node-red-contrib-alexa-local 0.3.24
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-alexa-local
5 Sep 22:37:45 - [debug] Module: node-red-contrib-stoptimer 0.0.7
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-stoptimer
5 Sep 22:37:45 - [debug] Module: node-red-contrib-telegrambot 8.1.0
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-telegrambot
5 Sep 22:37:45 - [debug] Module: node-red-contrib-timeout 1.1.4
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-timeout
5 Sep 22:37:45 - [debug] Module: node-red-contrib-timeouttrigger 0.0.2
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-timeouttrigger
5 Sep 22:37:45 - [debug] Module: node-red-contrib-ui-led 0.2.3
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-ui-led
5 Sep 22:37:45 - [debug] Module: node-red-contrib-uibuilder 2.0.7
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-uibuilder
5 Sep 22:37:45 - [debug] Module: node-red-contrib-viseo-ffmpeg 0.2.1
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-viseo-ffmpeg
5 Sep 22:37:45 - [debug] Module: node-red-contrib-yale-alarm 0.1.7
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-contrib-yale-alarm
5 Sep 22:37:45 - [debug] Module: node-red-dashboard 2.19.3
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-dashboard
5 Sep 22:37:45 - [debug] Module: node-red-node-base64 0.2.1
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-node-base64
5 Sep 22:37:45 - [debug] Module: node-red-node-darksky 0.1.19
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-node-darksky
5 Sep 22:37:45 - [debug] Module: node-red-node-dropbox 1.0.2
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-node-dropbox
5 Sep 22:37:45 - [debug] Module: node-red-node-email 1.7.4
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-node-email
5 Sep 22:37:45 - [debug] Module: node-red-node-prowl 0.0.9
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-node-prowl
5 Sep 22:37:45 - [debug] Module: node-red-node-pushbullet 0.0.14
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-node-pushbullet
5 Sep 22:37:45 - [debug] Module: node-red-node-pushover 0.0.14
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-node-pushover
5 Sep 22:37:45 - [debug] Module: node-red-node-random 0.1.2
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-node-random
5 Sep 22:37:45 - [debug] Module: node-red-node-serialport 0.6.8
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-node-serialport
5 Sep 22:37:45 - [debug] Module: node-red-node-snmp 0.0.24
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-node-snmp
5 Sep 22:37:45 - [debug] Module: node-red-node-twitter 1.1.5
5 Sep 22:37:45 - [debug]         /home/mat/.node-red/node_modules/node-red-node-twitter
5 Sep 22:37:45 - [debug] Module: node-red-node-rbe 0.2.9
5 Sep 22:37:45 - [debug]         /usr/local/lib/node_modules/node-red/node_modules/node-red-node-rbe
5 Sep 22:37:45 - [debug] Module: node-red-node-tail 0.1.1
5 Sep 22:37:45 - [debug]         /usr/local/lib/node_modules/node-red/node_modules/node-red-node-tail
5 Sep 22:37:48 - [info] +-----------------------------------------------------
5 Sep 22:37:48 - [info] | uibuilder initialised:
5 Sep 22:37:48 - [info] |   root folder: /home/mat/.node-red/uibuilder
5 Sep 22:37:48 - [info] |   version . .: 2.0.7
5 Sep 22:37:48 - [info] |   packages . : vue,bootstrap,bootstrap-vue,socket.io
5 Sep 22:37:48 - [info] +-----------------------------------------------------
Missing ENV var CONFIG_PATH
5 Sep 22:37:49 - [info] Dashboard version 2.19.3 started at /red/ui
5 Sep 22:37:49 - [info] Settings file  : /home/mat/.node-red/settings.js
5 Sep 22:37:49 - [info] HTTP Static    : /home/mat/.node-red/public
5 Sep 22:37:49 - [info] Context store  : 'default' [module=localfilesystem]
5 Sep 22:37:49 - [info] User directory : /home/mat/.node-red
5 Sep 22:37:49 - [warn] Projects disabled : editorTheme.projects.enabled=false
5 Sep 22:37:49 - [info] Flows file     : /home/mat/.node-red/flows_automate.json
5 Sep 22:37:49 - [info] Server now running at http://127.0.0.1:1880/red/
5 Sep 22:37:50 - [debug] loaded flow revision: bb45af768369a75a5b0816d2293cdc70
5 Sep 22:37:50 - [debug] red/runtime/nodes/credentials.load : no user key present
5 Sep 22:37:50 - [debug] red/runtime/nodes/credentials.load : using default key
5 Sep 22:37:50 - [debug] red/runtime/nodes/credentials.load : keyType=system
5 Sep 22:37:50 - [warn] 

---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

5 Sep 22:37:50 - [info] Starting flows
5 Sep 22:37:50 - [debug] red/nodes/flows.start : starting flow : global
5 Sep 22:37:50 - [debug] red/nodes/flows.start : starting flow : fa3892e2.c6cfd
5 Sep 22:37:50 - [debug] red/nodes/flows.start : starting flow : fd75c8e.6e63e38
5 Sep 22:37:50 - [debug] red/nodes/flows.start : starting flow : a09201df.15c79
5 Sep 22:37:50 - [debug] red/nodes/flows.start : starting flow : 53541a30.e1abb4
5 Sep 22:37:50 - [debug] red/nodes/flows.start : starting flow : ccda7ca.4b72e8
5 Sep 22:37:50 - [debug] red/nodes/flows.start : starting flow : 705d403b.f2b8
5 Sep 22:37:50 - [debug] red/nodes/flows.start : starting flow : e0f300f6.435ae
5 Sep 22:37:50 - [debug] red/nodes/flows.start : starting flow : a38201e3.f0e51
5 Sep 22:37:50 - [debug] red/nodes/flows.start : starting flow : d91c856c.90f068
5 Sep 22:37:50 - [debug] red/nodes/flows.start : starting flow : acccd118.a467d
5 Sep 22:37:50 - [debug] red/nodes/flows.start : starting flow : 3d86e78e.17ff28
5 Sep 22:37:50 - [debug] red/nodes/flows.start : starting flow : 373e989f.220948
5 Sep 22:37:50 - [debug] red/nodes/flows.start : starting flow : fe3cc4b6.fad208
5 Sep 22:37:50 - [info] [squeezebox-server:Logitech Media Server] Configuring connection to squeezebox Server at http://10.1.1.34:9000
5 Sep 22:37:50 - [debug] [server:Home Assistant] instantiated node, name: Home Assistant
5 Sep 22:37:50 - [debug] [flow:global] not starting disabled config node : c06a9e07.b696e
5 Sep 22:37:52 - [debug] [flow:53541a30.e1abb4] not starting disabled node : 29ebb609.8cfd4a
5 Sep 22:37:52 - [debug] [flow:53541a30.e1abb4] not starting disabled node : 427a1f06.0edc
5 Sep 22:37:54 - [debug] uibuilder : uibuilder : URL . . . . .  : /red/uibuilder
5 Sep 22:37:54 - [debug] uibuilder : uibuilder : Source files . : /home/mat/.node-red/uibuilder/uibuilder
5 Sep 22:37:58 - [debug] [flow:e0f300f6.435ae] not starting disabled node : 4a609a6b.dc6a04
5 Sep 22:38:00 - [debug] [flow:a38201e3.f0e51] not starting disabled node : 73250662.0740f8
5 Sep 22:38:00 - [error] [prowl:Mat Prowl - Priority 0] No Prowl credentials set.
5 Sep 22:38:00 - [error] [prowl:Mat Prowl - Priority 1] No Prowl credentials set.
5 Sep 22:38:00 - [error] [prowl:Mat Prowl - Priority 2] No Prowl credentials set.
5 Sep 22:38:00 - [error] [prowl:Anna Prowl - Priority 0] No Prowl credentials set.
5 Sep 22:38:00 - [error] [prowl:Anna Prowl - Priority 1] No Prowl credentials set.
5 Sep 22:38:00 - [error] [prowl:Anna Prowl - Priority 2] No Prowl credentials set.
5 Sep 22:38:00 - [error] [prowl:Joe Prowl - Priority 0] No Prowl credentials set.
5 Sep 22:38:00 - [error] [prowl:Joe Prowl - Priority 1] No Prowl credentials set.
5 Sep 22:38:00 - [error] [prowl:Joe Prowl - Priority 2] No Prowl credentials set.
5 Sep 22:38:00 - [error] [prowl:Malakai Prowl - Priority 0] No Prowl credentials set.
5 Sep 22:38:00 - [error] [prowl:Malakai Prowl - Priority 1] No Prowl credentials set.
5 Sep 22:38:00 - [error] [prowl:Malakai Prowl - Priority 2] No Prowl credentials set.
5 Sep 22:38:03 - [info] Started flows
5 Sep 22:38:04 - [warn] [alexa-remote-account:72b0ac81.928084] ENOENT: no such file or directory, open 'alexa_auth'
5 Sep 22:38:04 - [info] [alexa-remote-account:72b0ac81.928084] intialising with the PROXY method and NO saved data...
5 Sep 22:38:04 - [debug] [alexa-remote-account:72b0ac81.928084] Alexa-Remote: starting initialisation:
5 Sep 22:38:04 - [debug] [alexa-remote-account:72b0ac81.928084] Alexa-Remote: {"authMethod":"proxy","initType":"proxy"}
5 Sep 22:38:04 - [debug] [alexa-remote-account:72b0ac81.928084] Alexa-Remote: Use as User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36
5 Sep 22:38:04 - [debug] [alexa-remote-account:72b0ac81.928084] Alexa-Remote: Use as Login-Amazon-URL: amazon.co.uk
5 Sep 22:38:04 - [debug] [alexa-remote-account:72b0ac81.928084] Alexa-Remote: Use as Base-URL: alexa.amazon.co.uk
5 Sep 22:38:04 - [debug] [alexa-remote-account:72b0ac81.928084] Alexa-Remote: No cookie given, generate one
5 Sep 22:38:04 - [debug] [alexa-remote-account:72b0ac81.928084] Alexa-Cookie: Use as Login-Amazon-URL: amazon.co.uk
5 Sep 22:38:04 - [debug] [alexa-remote-account:72b0ac81.928084] Alexa-Cookie: Use as Base-Amazon-URL: amazon.com
5 Sep 22:38:04 - [debug] [alexa-remote-account:72b0ac81.928084] Alexa-Cookie: Use as User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36
5 Sep 22:38:04 - [debug] [alexa-remote-account:72b0ac81.928084] Alexa-Cookie: Use as Accept-Language: en-UK
5 Sep 22:38:04 - [debug] [alexa-remote-account:72b0ac81.928084] Alexa-Cookie: Proxy mode disabled
5 Sep 22:38:04 - [debug] [alexa-remote-account:72b0ac81.928084] Proxy Init: loaded temp data store ass fallback former data
5 Sep 22:38:04 - [debug] [alexa-remote-account:72b0ac81.928084] Proxy Init: reuse frc from former data
5 Sep 22:38:04 - [debug] [alexa-remote-account:72b0ac81.928084] Proxy Init: reuse map-md from former data
5 Sep 22:38:04 - [debug] [alexa-remote-account:72b0ac81.928084] Proxy Init: reuse deviceId from former data
5 Sep 22:38:04 - [debug] [alexa-remote-account:72b0ac81.928084] Alexa-Cookie: Proxy-Server listening on port 3456
5 Sep 22:38:04 - [debug] [alexa-remote-account:72b0ac81.928084] Alexa-Remote: Error from retrieving cookies
5 Sep 22:38:04 - [warn] [alexa-remote-account:72b0ac81.928084] open 10.1.1.37:3456 in your browser
5 Sep 22:38:04 - [rfxcom] on /home/mat/virtualcom0 - Error: No such file or directory, cannot open /home/mat/virtualcom0
5 Sep 22:38:04 - [rfxcom] on /home/mat/virtualcom0 - Cleared command message queue
5 Sep 22:38:04 - [info] [rfx-sensor:/home/mat/virtualcom0 - RFXCom] connect failed: Error: No such file or directory, cannot open /home/mat/virtualcom0
5 Sep 22:38:04 - [info] [mqtt-broker:Mayfield MQTT] Connected to broker: nodered@mqtt://10.1.1.34:1883
5 Sep 22:38:04 - [info] [squeezebox-server:Logitech Media Server] Player Living Room Duet not found!
5 Sep 22:38:09 - [debug] ae477553424dd8 pergola lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] 85cc9528d52b08 site alarm GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] 7fd0ddcbc2a4a4 garden lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] 38f5d0003f943 Pergola Heater GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] 72437f6f58144 living room player GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] 228d3d354f44f2 anne's room GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] 6790b79091b8e8 printer lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] 49b72f2b75688 bedroom player GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] a502537e463cd kitchen lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] 81754f83ff29d both blankets GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] af8e9fa5a4306 Mat's Blanket GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] baac6d4c8c6ba living room projector GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] 2e250132de893e anna's blanket GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] a6bda772159298 alarm GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] 57e261aebc70a xbox GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] a55be24fff2af lounge lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] dfbf4518a48868 bedroom volume GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] 37464b764ac894 malakai's projector GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] a2f5b0a4d281b hallway lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] f5252a86be5218 air con GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] 7aea471fa13248 bedroom lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] 3803f981c7b416 hotbed GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] 3b587c3138e164 living room volume GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] a0ef21098f8b5 living room lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:09 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:10 - [info] [rfx-sensor:/home/mat/virtualcom0 - RFXCom] connecting to /home/mat/virtualcom0
5 Sep 22:38:12 - [debug] 38f5d0003f943 Pergola Heater GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.1.1.34
5 Sep 22:38:12 - [debug] Sending setup.xml to ::ffff:10.1.1.34
5 Sep 22:38:15 - [rfxcom] on /home/mat/virtualcom0 - Sent    : 0D,00,00,00,00,00,00,00,00,00,00,00,00,00
5 Sep 22:38:16 - [rfxcom] on /home/mat/virtualcom0 - Sent    : 0D,00,00,01,02,00,00,00,00,00,00,00,00,00
5 Sep 22:38:19 - [debug] ae477553424dd8 pergola lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] 49b72f2b75688 bedroom player GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] 85cc9528d52b08 site alarm GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] a502537e463cd kitchen lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] 6790b79091b8e8 printer lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] 38f5d0003f943 Pergola Heater GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] 7fd0ddcbc2a4a4 garden lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] 228d3d354f44f2 anne's room GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] 57e261aebc70a xbox GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] 37464b764ac894 malakai's projector GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] a6bda772159298 alarm GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] a2f5b0a4d281b hallway lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] 7aea471fa13248 bedroom lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] 2e250132de893e anna's blanket GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] af8e9fa5a4306 Mat's Blanket GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] 72437f6f58144 living room player GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] a0ef21098f8b5 living room lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] 81754f83ff29d both blankets GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] a55be24fff2af lounge lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] dfbf4518a48868 bedroom volume GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] baac6d4c8c6ba living room projector GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] 3803f981c7b416 hotbed GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] 3b587c3138e164 living room volume GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] f5252a86be5218 air con GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:19 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:20 - [debug] Flushing localfilesystem context scope global
5 Sep 22:38:20 - [debug] Flushing localfilesystem context scope b6f158a2.116b88:fa3892e2.c6cfd
5 Sep 22:38:20 - [debug] Flushing localfilesystem context scope 8bba9d51.f57b48:e0f300f6.435ae
5 Sep 22:38:20 - [debug] Flushing localfilesystem context scope ccda7ca.4b72e8
5 Sep 22:38:29 - [debug] 38f5d0003f943 Pergola Heater GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] ae477553424dd8 pergola lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] 85cc9528d52b08 site alarm GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] 49b72f2b75688 bedroom player GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] 7fd0ddcbc2a4a4 garden lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] 72437f6f58144 living room player GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] 6790b79091b8e8 printer lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] 228d3d354f44f2 anne's room GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] a502537e463cd kitchen lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] 81754f83ff29d both blankets GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] baac6d4c8c6ba living room projector GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] 3b587c3138e164 living room volume GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] 7aea471fa13248 bedroom lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] f5252a86be5218 air con GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] af8e9fa5a4306 Mat's Blanket GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] a6bda772159298 alarm GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] a0ef21098f8b5 living room lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] a55be24fff2af lounge lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] 3803f981c7b416 hotbed GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] dfbf4518a48868 bedroom volume GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] 2e250132de893e anna's blanket GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] 37464b764ac894 malakai's projector GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] 57e261aebc70a xbox GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] a2f5b0a4d281b hallway lights GET /upnp/amazon-ha-bridge/setup.xml ::ffff:10.0.0.111
5 Sep 22:38:29 - [debug] Sending setup.xml to ::ffff:10.0.0.111

In your previous snippet you called moment like a function but not anymore? Calling moment() makes a new instance with the current time stored to it for processing. But with that said, you shouldn't be getting an error it's undefined. If you add node.warn(moment) after the const line, will undefined be printed on your debug sidebar?

I don't remember moment syntax by heart but msg.payload[i].time should likely be inside the parenthesis of fromNow(...)? :slightly_smiling_face:

Hmmm, mine uses var functionName = global.get('ModuleName');

And? :slightly_smiling_face:

I guess what you actually want it
lastpHtime = moment(msg.payload[i].time).fromNow()
but as @ristomatti says that woudn't explain the undefined error.

There is so much in your startup log it is difficult to see the wood for the trees, generally it is better not to enable debug logging unless the normal log doesn't show the problem.

I see you are using an obsolete version of nodejs (8.10.0) which isn't even the last of the 8.x series (the last is 8.17.0 but even that is out of support). The video you followed to install is over two years old, so I suggest you uninstall nodejs and npm and then run the Ubuntu/Debian/Pi script I linked to earlier, in the official node red docs. It should not affect your existing flows (but you do already have a backup of anything important I am sure). Then you will have an up to date set of tools. That may not be the problem, but it will rule out any possible issues there.

2 Likes

I'm not sure if at this point it would yet be necessary to go to lengths suggested by @Colin.

Let's first check something. Go to your $HOME/.node-red dir and start node CLI. On the cli write:

const moment = require('moment');
console.log(moment());

Do you get an error or a date printed? This is just to verify you've successfully installed moment and to the correct place.

If you get it to print ok, then do the equivalent in a NR function node:

const moment = global.get('moment');
node.warn(moment());

...and check the debug tab.

I didn't see anything wrong (related to this) in your settings.js.

1 Like

I don't see the error in the log you posted. Are you sure you are still getting the same error? I would have expected something like "moment.fromNow() is not a function", with the code you posted. Alternatively perhaps you have changed the code again and not posted the latest.

I agree the the nodejs version is probably not the issue here, but it will bite you at some point if you leave it like that.

Hi Colin

I’ll do it again and this time press the inject node that actually causes the error (I had done that when starting node-red manually and it did show the error but maybe that copy paste was from a time I didn’t)

I’ll follow your suggestion and install NR via that script as a first step.

Will post back this afternoon, thanks

Did you try @ristomatti's suggestions to check moment is installed ok?

Hi all, just going through your comments properly (lazy Sunday morning here!)

I tried @ristomatti's suggestions of testing from node command line, and it all worked ok. Then worked back and changed to @Colin's suggestion lastpHtime = moment(msg.payload[i].time).fromNow() and this worked straight away.

Thanks for the really helpful comments to all, it's resolved!

I suspect that you did not get the same error message last time. To check you could put it back as it was and see.
lastpHtime = moment.fromNow().msg.payload[i].time

Yep, exactly right. I get "TypeError: moment.fromNow is not a function" as opposed to "TypeError: Cannot read property 'fromNow' of undefined"

Thanks for spotting that

Does const or var matter here in the global.get()?

It was one obvious difference from the "recipe" I followed to use and external module.