Node not appearing in palette

I’ve followed the instructions about creating a node, I’m using the docker container for node-red.

I’ve used npm install to install.

In the palette manager I can see the package listed and that it contains a single node.

But for some reason the node doesn’t appear in the actual palette. I’ve made sure the name matches everywhere in code (“sleep-timer“) but no matter what I do I just can’t get it to appear in the palette.

I’ve tried reinstalling the package from the dev folder, restarting the server after making changes but it won’t show!

Are there any gotchas I need to check i an not falling foul off? Might this be a docker specific issue?

What does the logs say both during installation and on startup? Perhaps there are some clues in there?

1 Like

Have you checked the browser JavaScript console for any error messages?

1 Like

Thanks guys: The thought didn’t occur to me.

I’m been using my iPad, but will check the console on my laptop tomorrow.

Thanks for the suggestion! It didn't occur to me to look there, I was looking in the log on the server and nothing was showing.

Turned out I'd missed a comma from the html file, I'd stared at that file by couldn't see it! Now my node is happily appearing!

Can now finish it up properly now!

So it's almost all working, but for the life of me I cannot get the "properties to work".

I have this:

<script type="text/javascript">
	RED.nodes.registerType('sleep-timer',{
		category: 'functions',
		color: '#a6bbcf',
		defaults: {
			defaultPeriod: {value:"60"},
			defaultAdjustment: {value:"15"}
		},
		outputLabels: ["Control", "Timer Decremented", "Timer Set"],
		inputs:1,
		outputs:3,
		icon: "font-awesome/fa-clock-o",
		label: function() {
			return this.name||"sleep-timer";
		}
	});
</script>

<script type="text/html" data-template-name="sleep-timer">
    <div class="form-row">
        <label for="node-input-defaultPeriod"><i class="fa fa-tag"></i> Default Period</label>
        <input type="string" id="node-input-defaultPeriod" placeholder="60">
    </div>
    
    <div class="form-row">
        <label for="node-input-defaultAdjustment"><i class="fa fa-tag"></i> Default Adjustment</label>
        <input type="string" id="node-input-defaultAdjustment" placeholder="15">
    </div>
    
</script>

<script type="text/html" data-help-name="sleep-timer">
	<p>A node that provides TV timer like functionality.</p>
</script>

And in the top of my node, I have:

function SleepTimerNode(config) 
    {
        RED.nodes.createNode(this,config);
        var node = this;

        this.defaultPeriod = config.defaultPeriod
        this.defaultAdjustment = config.defaultAdjustment
        this.timeout = this.defaultPeriod
        this.isRunning = false
        this.timerObject = null

        node.on('input', function(msg) {

But config.defaultPeriod and config.defaultAdjustment are set to undefined when the node is created, regardless of whether I leave them empty in the properties page or fill them in. My assumption is that if they're empty they should use the default value I've provided, but overriding doesn't seem to make any difference either.

I'm obviously doing something very stupid here, but I can't figure out exactly what.

The defaults are only applied when you add a new instance of the node to the workspace. Any existing instance of the node won't have those values retrospectively applied.

In the runtime it is best to assume the values could be undefined and to have sensible defaults applied there as well.

1 Like

Ahh, yes, I just read that and came here to say I'd realised!

Can I read the default value (i.e the default specified in the html file?) so that I don't have to duplicate the value in both the html and js? I have a validator function which I will wrap them up in, but I have to pass in a default and it would be nicer to just pick it up from the html if I can?

No, unfortunately not.

Thank you so much for your help, my node is working perfectly now!

I need to read up on how to submit it now, it’s yet another sleep timer.....but it has the built in behaviour of a TV sleep timer so is ideal to use with tv control nodes!

I have it hooked up to Emby to display a message on the tv and also Sonos where it announces the tv will go to sleep in a minute!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.