Shelly plus 1 pm and node-red

Hello everyone,

I have successfully integrated a Shelly plus1 pm into Home Assistant. All values ​​are displayed correctly. I have also added node-red to my home assistant. I now want to ensure that a switching command is executed in node-red when the current current of the shelly is over 1A. The trigger state node is disabled. How can I switch it on?

grafik

Check within the node at the bottom (see my highlight)

image

Hello Mark,

Thank you for the quick reply.

The node is activated.

If I deactivate it, it looks like this

grafik

Is the actual entity disabled?

Settings → Devices & Services → Entities

Yes, the entity is activated. The power consumption is also displayed (at least in Home Assistant) when the connected device is switched on.

Are there any errors in the node-red log:

Settings → Add-ons → Node-Red → Log

I dont think so:

Home Assistant Core: 2024.6.1
 Home Assistant Supervisor: 2024.06.2
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service init-nginx: starting
s6-rc: info: service init-customizations: starting
s6-rc: info: service init-customizations successfully started
s6-rc: info: service init-nodered: starting
s6-rc: info: service init-nginx successfully started

up to date, audited 222 packages in 5s

25 packages are looking for funding
  run `npm fund` for details

10 vulnerabilities (6 moderate, 4 critical)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
npm notice
npm notice New minor version of npm available! 10.7.0 -> 10.8.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.1
npm notice To update run: npm install -g [email protected]
npm notice
s6-rc: info: service init-nodered successfully started
s6-rc: info: service nodered: starting
s6-rc: info: service nodered successfully started
s6-rc: info: service nginx: starting
s6-rc: info: service nginx successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
[17:00:50] INFO: Starting Node-RED...

> start
> node $NODE_OPTIONS node_modules/node-red/red.js --settings /etc/node-red/config.js

30 Jun 17:00:53 - [info] 

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

30 Jun 17:00:53 - [info] Node-RED version: v4.0.1
30 Jun 17:00:53 - [info] Node.js  version: v18.20.3
30 Jun 17:00:53 - [info] Linux 6.6.29-haos x64 LE
30 Jun 17:00:53 - [info] Loading palette nodes
30 Jun 17:00:55 - [info] Node-RED Contrib Theme Collection version: v4.0.1
30 Jun 17:01:07 - [info] Dashboard version 3.6.5 started at /endpoint/ui
30 Jun 17:01:09 - [info] Settings file  : /etc/node-red/config.js
30 Jun 17:01:09 - [info] Context store  : 'default' [module=memory]
30 Jun 17:01:09 - [info] User directory : /config/
30 Jun 17:01:09 - [warn] Projects disabled : editorTheme.projects.enabled=false
30 Jun 17:01:09 - [info] Flows file     : /config/flows.json
30 Jun 17:01:09 - [info] Server now running at http://127.0.0.1:46836/
30 Jun 17:01:09 - [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.
---------------------------------------------------------------------

30 Jun 17:01:09 - [info] Starting flows
[17:01:09] INFO: Starting NGinx...
30 Jun 17:01:09 - [error] [ha-entity-config:9236992af61f2695] Error: Invalid server config
30 Jun 17:01:10 - [info] Started flows
30 Jun 17:01:10 - [info] [server:Home Assistant] Connecting to http://supervisor/core
30 Jun 17:01:10 - [info] [server:Home Assistant] Connected to http://supervisor/core
30 Jun 17:01:14 - [info] [server:Home Assistant] Connecting to http://supervisor/core
30 Jun 17:01:14 - [info] [server:Home Assistant] Connected to http://supervisor/core
30 Jun 17:01:37 - [info] Stopping flows
30 Jun 17:01:37 - [info] [server:Home Assistant] Closing connection to http://supervisor/core
30 Jun 17:01:37 - [info] [server:Home Assistant] Closing connection to http://supervisor/core
30 Jun 17:01:37 - [info] Stopped flows
30 Jun 17:01:37 - [info] Updated flows
30 Jun 17:01:37 - [info] Starting flows
30 Jun 17:01:37 - [error] [ha-entity-config:9236992af61f2695] Error: Invalid server config
30 Jun 17:01:37 - [info] Started flows
30 Jun 17:01:37 - [info] [server:Home Assistant] Connecting to http://supervisor/core
30 Jun 17:01:37 - [info] [server:Home Assistant] Connected to http://supervisor/core
30 Jun 17:01:42 - [info] [server:Home Assistant] Connecting to http://supervisor/core
30 Jun 17:01:42 - [info] [server:Home Assistant] Connected to http://supervisor/core

Are you running the current version of the websocket?

image

I thought I saw @Biscuit starting to reply and waited to see what he said - he is usually right whereas I just poke around looking for something.

I just updated the whole system, even Shelly got an upgrade. Everything is now up to date.

The Node is still disabled.

grafik

Could you open up the Configuration Node panel in the upper right corner of NR and see how many server nodes you have there?

image

do you mean this?

grafik

that was the problem!

I deleted the first server and now the values ​​are also in Node-Red.

Thank you very much for the help!

grafik

1 Like

Command back,

now the node is disabled again…

Just out of curiosity, could you restart Node-Red and see if these errors are gone?

I deleted the faulty nodes.

s6-rc: info: service base-addon-banner: stopping
s6-rc: info: service base-addon-banner successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service base-addon-banner: starting

-----------------------------------------------------------
 Add-on: Node-RED
 Flow-based programming for the Internet of Things
-----------------------------------------------------------
 Add-on version: 18.0.1
 You are running the latest version of this add-on.
 System: Home Assistant OS 12.4  (amd64 / qemux86-64)
 Home Assistant Core: 2024.6.4
 Home Assistant Supervisor: 2024.06.2
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service init-nginx: starting
s6-rc: info: service init-customizations: starting
s6-rc: info: service init-customizations successfully started
s6-rc: info: service init-nodered: starting
s6-rc: info: service init-nginx successfully started

up to date, audited 222 packages in 5s

25 packages are looking for funding
  run `npm fund` for details

10 vulnerabilities (6 moderate, 4 critical)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
npm notice
npm notice New minor version of npm available! 10.7.0 -> 10.8.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.1
npm notice To update run: npm install -g [email protected]
npm notice
s6-rc: info: service init-nodered successfully started
s6-rc: info: service nodered: starting
s6-rc: info: service nodered successfully started
s6-rc: info: service nginx: starting
s6-rc: info: service nginx successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
[20:06:30] INFO: Starting Node-RED...

> start
> node $NODE_OPTIONS node_modules/node-red/red.js --settings /etc/node-red/config.js

30 Jun 20:06:32 - [info] 

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

30 Jun 20:06:32 - [info] Node-RED version: v4.0.1
30 Jun 20:06:32 - [info] Node.js  version: v18.20.3
30 Jun 20:06:32 - [info] Linux 6.6.33-haos x64 LE
30 Jun 20:06:33 - [info] Loading palette nodes
30 Jun 20:06:34 - [info] Node-RED Contrib Theme Collection version: v4.0.1
30 Jun 20:06:43 - [info] Dashboard version 3.6.5 started at /endpoint/ui
30 Jun 20:06:44 - [info] Settings file  : /etc/node-red/config.js
30 Jun 20:06:44 - [info] Context store  : 'default' [module=memory]
30 Jun 20:06:44 - [info] User directory : /config/
30 Jun 20:06:44 - [warn] Projects disabled : editorTheme.projects.enabled=false
30 Jun 20:06:44 - [info] Flows file     : /config/flows.json
30 Jun 20:06:44 - [info] Server now running at http://127.0.0.1:46836/
30 Jun 20:06:44 - [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.
---------------------------------------------------------------------

[20:06:44] INFO: Starting NGinx...
30 Jun 20:06:44 - [info] Starting flows
30 Jun 20:06:45 - [info] Started flows
30 Jun 20:06:45 - [info] [server:Home Assistant] Connecting to http://supervisor/core
30 Jun 20:06:45 - [info] [server:Home Assistant] Connected to http://supervisor/core

I found the error:

in the settings, the deleted entity was still entered under “expose as”. I have now set it to “none” and now it works

grafik

1 Like

@MaxK I wish. The one person who really knows what all of this is doing is Kermit.

I was looking at the logs and the detail:

It kind of says that there are two server:Home Assistant configs starting up and running, and both are Addons connecting back to supervisor/core. As we now know, there were two HA servers, so that would be a likely cause of issues.

The

suggests a problem with an ha entity config node, possibly not being set correctly or not connected back to the HA server node. I note that the node name is a number, and that happens when you edit-create a new entity-config node and don’t give it a name (ie start to create one but abandon it, so it initializes and attaches to the entity node but is not configured). I suspect that, as a user new to Node-RED, there are part-configured entity nodes, entity configuration nodes, and multiple HA servers. Messy.

So, after a long think and some digging, here is what I found.

This is my Node-RED (independent) now running as NR v4.0.1
You will see the new ‘configuration node’ edit style, with the new + button.

Since this is a new sensor node, the Entity Config is ‘none’. It used to be (pre v4) “Add new ha-entity-config…” which was both an invite to use the ‘edit’ button and thereby add a new one, and to say ‘no entity config node selected’. With the new arrangement, the "Add new… " has been replaced with 'none, and the edit button does not work, and you use the + button.

Now, we know the OP was using the Trigger node, so lets look at that one.

As we know, this node looks at Events, and does not create a sensor node. But wait, down at the bottom is ‘Expose as’, which allows you to expose the node as an associated switch so you can turn it on and off.
This is the root cause of the OP’s problem.

You will see that, this is a configuration node edit box, and it also has the new v4 format with the + button, but it also does not have ‘none’ but rather ‘Add new-ha-entity-config…’. Confused? Well I have here NR v4, but my HA instance is still running NR as an addon at v3.1.8, so I wonder if the OP (who shows us that this edit box is ‘none’) has something different in his NR v4 to my NR v4. I defer to Kermit on that one.

So

  • Expose as, with ‘Add new ha-entity-config…’ and click the + button
  • Opens the Add new ha-entity-config node edit box
    • with ‘none’ in the server, which is red as it has to be a valid HA server config node

Now I hit ‘cancel’ and back out, without doing or entering anything.

and it neatly creates a switch:random-number ha-entity-config node that has no setting configuration and will generate an error.

The OP has fixed this by de-selecting the Expose as, ha-entity-config node to ‘none’ but this still leaves a floating ha-entity-config node that should be deleted from the RH configuration window.

I think that explains the error, but raises a question of why does the OP have “none” for this edit box and I have “Add new ha-entity-config…”, and the issue of why does a new ha-entity-config node get created when you click ‘cancel’ from the ‘add new’ window.

Some of these errors take a lot of work!

It shows DISABLED when the input is turned on and you send disabled.

image

Even more interesting.

The OP’s first image posted shows that input is turned off, so he probably has not sent ‘disabled’.

Must be magic