Hi everyone,
As a Node-RED beginner, I installed a Shelly 1PM in my motorhome and also integrated it into my Cerbo via Node-RED. The reason for this is that I can activate/deactivate the shore power and measure the power consumption. I can now switch the Shelly on and off via the Shelly app and the Victron app (as long as shore power is available).
However, I now have the problem that when I disconnect the shore power, the Shelly remains available and continues to display the last values, which means that everything is incorrect. Is there a way for the Cerbo to poll the Shelly and remove it when it is unavailable, then integrate it again when it becomes available? Here’s my code:
[
{
“id”: “c6138a722672e3a4”,
“type”: “tab”,
“label”: “Flow 1”,
“disabled”: false,
“info”: “”,
“env”:
},
{
“id”: “fff1e473d2dbd6e8”,
“type”: “shelly-gen2”,
“z”: “c6138a722672e3a4”,
“hostname”: “192.168.1.110”,
“description”: “Shelly 1PM”,
“mode”: “polling”,
“verbose”: false,
“server”: “”,
“outputmode”: “event”,
“uploadretryinterval”: 5000,
“pollinginterval”: 5000,
“pollstatus”: true,
“getstatusoncommand”: true,
“devicetype”: “SNSW-001P16EU”,
“devicetypemustmatchexactly”: true,
“captureblutooth”: false,
“outputs”: 1,
“x”: 570,
“y”: 420,
“wires”: [
[
“c65c333b706a9c30”,
“cb23c2277957bfb3”,
“ea0397b490f2b062”,
“d6ec2b310e1c6653”,
“45b8c5099165ce10”
]
]
},
{
“id”: “c65c333b706a9c30”,
“type”: “function”,
“z”: “c6138a722672e3a4”,
“name”: “Voltage”,
“func”: “msg.payload=(msg.payload.switch0.voltage);\nreturn msg;”,
“outputs”: 1,
“timeout”: 0,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: ,
“x”: 970,
“y”: 320,
“wires”: [
[
“7fa30c780d8b995d”
]
]
},
{
“id”: “cb23c2277957bfb3”,
“type”: “function”,
“z”: “c6138a722672e3a4”,
“name”: “Current”,
“func”: “msg.payload=(msg.payload.switch0.current);\nreturn msg;”,
“outputs”: 1,
“timeout”: 0,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: ,
“x”: 950,
“y”: 420,
“wires”: [
[
“35087ed2a10a86ba”
]
]
},
{
“id”: “ea0397b490f2b062”,
“type”: “function”,
“z”: “c6138a722672e3a4”,
“name”: “Power”,
“func”: “msg.payload=(msg.payload.switch0.apower)\nreturn msg;”,
“outputs”: 1,
“timeout”: 0,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: ,
“x”: 960,
“y”: 520,
“wires”: [
[
“b1a58d25df26d16a”
]
]
},
{
“id”: “7fa30c780d8b995d”,
“type”: “victron-output-custom”,
“z”: “c6138a722672e3a4”,
“service”: “com.victronenergy.grid/100”,
“path”: “/Ac/L1/Voltage”,
“serviceObj”: {
“service”: “com.victronenergy.grid/100”,
“name”: “Shore power (100)”
},
“pathObj”: {
“path”: “/Ac/L1/Voltage”,
“name”: “/Ac/L1/Voltage”,
“type”: “number”,
“value”: 229.6
},
“name”: “Shore power V”,
“onlyChanges”: false,
“roundValues”: “no”,
“rateLimit”: 0,
“outputs”: 0,
“conditionalMode”: false,
“condition1Operator”: “>”,
“condition2Enabled”: false,
“condition2Service”: “”,
“condition2Path”: “”,
“condition2Operator”: “>”,
“logicOperator”: “AND”,
“outputTrue”: “true”,
“outputFalse”: “false”,
“outputOnChange”: false,
“debounce”: 2000,
“x”: 1410,
“y”: 320,
“wires”:
},
{
“id”: “35087ed2a10a86ba”,
“type”: “victron-output-custom”,
“z”: “c6138a722672e3a4”,
“service”: “com.victronenergy.grid/100”,
“path”: “/Ac/L1/Current”,
“serviceObj”: {
“service”: “com.victronenergy.grid/100”,
“name”: “Shore power (100)”
},
“pathObj”: {
“path”: “/Ac/L1/Current”,
“name”: “/Ac/L1/Current”,
“type”: “number”,
“value”: 0.095
},
“name”: “Shore power A”,
“onlyChanges”: false,
“roundValues”: “no”,
“rateLimit”: 0,
“outputs”: 0,
“conditionalMode”: false,
“condition1Operator”: “>”,
“condition2Enabled”: false,
“condition2Service”: “”,
“condition2Path”: “”,
“condition2Operator”: “>”,
“logicOperator”: “AND”,
“outputTrue”: “true”,
“outputFalse”: “false”,
“outputOnChange”: false,
“debounce”: 2000,
“x”: 1410,
“y”: 420,
“wires”:
},
{
“id”: “b1a58d25df26d16a”,
“type”: “victron-output-custom”,
“z”: “c6138a722672e3a4”,
“service”: “com.victronenergy.grid/100”,
“path”: “/Ac/L1/Power”,
“serviceObj”: {
“service”: “com.victronenergy.grid/100”,
“name”: “Shore power (100)”
},
“pathObj”: {
“path”: “/Ac/L1/Power”,
“name”: “/Ac/L1/Power”,
“type”: “number”,
“value”: 3
},
“name”: “Shore power W”,
“onlyChanges”: false,
“roundValues”: “no”,
“rateLimit”: 0,
“outputs”: 0,
“conditionalMode”: false,
“condition1Operator”: “>”,
“condition2Enabled”: false,
“condition2Service”: “”,
“condition2Path”: “”,
“condition2Operator”: “>”,
“logicOperator”: “AND”,
“outputTrue”: “true”,
“outputFalse”: “false”,
“outputOnChange”: false,
“debounce”: 2000,
“x”: 1420,
“y”: 520,
“wires”:
},
{
“id”: “339af066d9f15b2b”,
“type”: “victron-virtual”,
“z”: “c6138a722672e3a4”,
“name”: “Shore power”,
“outputs”: 1,
“device”: “grid”,
“default_values”: true,
“acload_nrofphases”: 1,
“enable_s2support”: false,
“battery_capacity”: 25,
“include_battery_temperature”: false,
“battery_voltage_preset”: “24”,
“battery_voltage_custom”: 24,
“generator_type”: “ac”,
“generator_nrofphases”: 1,
“include_engine_hours”: false,
“include_starter_voltage”: false,
“include_history_energy”: false,
“grid_nrofphases”: 1,
“include_motor_temp”: false,
“include_controller_temp”: false,
“include_coolant_temp”: false,
“include_motor_rpm”: true,
“include_motor_direction”: true,
“position”: 0,
“pvinverter_nrofphases”: 1,
“switch_1_type”: 1,
“switch_1_min”: 0,
“switch_1_max”: “”,
“switch_1_initial”: 0,
“switch_1_label”: “”,
“switch_1_unit”: “”,
“switch_1_step”: 1,
“switch_1_customname”: “”,
“switch_1_group”: “”,
“switch_1_include_measurement”: false,
“switch_1_rgb_color_wheel”: false,
“switch_1_cct_wheel”: false,
“switch_1_rgb_white_dimmer”: false,
“fluid_type”: 0,
“include_tank_battery”: false,
“include_tank_temperature”: false,
“tank_battery_voltage”: 3.3,
“tank_capacity”: 0.2,
“temperature_type”: 2,
“include_humidity”: false,
“include_pressure”: false,
“include_temp_battery”: false,
“temp_battery_voltage”: 3.3,
“x”: 130,
“y”: 200,
“wires”: [
]
},
{
“id”: “d6ec2b310e1c6653”,
“type”: “function”,
“z”: “c6138a722672e3a4”,
“name”: “Energy”,
“func”: “msg.payload=(msg.payload.switch0.aenergy.total) / 1000;\nreturn msg;”,
“outputs”: 1,
“timeout”: 0,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: ,
“x”: 960,
“y”: 620,
“wires”: [
[
“b31e0eae13473b1e”
]
]
},
{
“id”: “45b8c5099165ce10”,
“type”: “debug”,
“z”: “c6138a722672e3a4”,
“name”: “debug 2”,
“active”: false,
“tosidebar”: true,
“console”: false,
“tostatus”: false,
“complete”: “false”,
“statusVal”: “”,
“statusType”: “auto”,
“x”: 760,
“y”: 260,
“wires”:
},
{
“id”: “b31e0eae13473b1e”,
“type”: “victron-output-custom”,
“z”: “c6138a722672e3a4”,
“service”: “com.victronenergy.grid/100”,
“path”: “/Ac/L1/Energy/Forward”,
“serviceObj”: {
“service”: “com.victronenergy.grid/100”,
“name”: “Shore power (100)”
},
“pathObj”: {
“path”: “/Ac/L1/Energy/Forward”,
“name”: “/Ac/L1/Energy/Forward”,
“type”: “number”,
“value”: 17.93982
},
“name”: “Shore power kWh”,
“onlyChanges”: false,
“roundValues”: “no”,
“rateLimit”: 0,
“outputs”: 0,
“conditionalMode”: false,
“condition1Operator”: “>”,
“condition2Enabled”: false,
“condition2Service”: “”,
“condition2Path”: “”,
“condition2Operator”: “>”,
“logicOperator”: “AND”,
“outputTrue”: “true”,
“outputFalse”: “false”,
“outputOnChange”: false,
“debounce”: 2000,
“x”: 1420,
“y”: 620,
“wires”:
},
{
“id”: “3070333cedb95a26”,
“type”: “victron-virtual-switch”,
“z”: “c6138a722672e3a4”,
“name”: “Shore”,
“outputs”: 2,
“switch_1_type”: 1,
“switch_1_initial”: 0,
“switch_1_label”: “”,
“switch_1_customname”: “Shore power”,
“switch_1_group”: “Shelly’s”,
“switch_1_include_measurement”: false,
“switch_1_rgb_color_wheel”: false,
“switch_1_cct_wheel”: false,
“switch_1_rgb_white_dimmer”: false,
“x”: 110,
“y”: 540,
“wires”: [
,
[
“bc7370cc3f4c60b0”,
“957e3f4e6a6134a6”
]
]
},
{
“id”: “bc7370cc3f4c60b0”,
“type”: “debug”,
“z”: “c6138a722672e3a4”,
“name”: “debug 1”,
“active”: false,
“tosidebar”: true,
“console”: false,
“tostatus”: false,
“complete”: “false”,
“statusVal”: “”,
“statusType”: “auto”,
“x”: 300,
“y”: 480,
“wires”:
},
{
“id”: “957e3f4e6a6134a6”,
“type”: “function”,
“z”: “c6138a722672e3a4”,
“name”: “function 1”,
“func”: “if(msg.payload == 1){\n msg.url = “http://192.168.1.110/rpc/Switch.Set?id=0&on=true\”;\n}\nelse {\n msg.url = “http://192.168.1.110/rpc/Switch.Set?id=0&on=false\”;\n}\n\nreturn msg;”,
“outputs”: 1,
“timeout”: 0,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: ,
“x”: 320,
“y”: 580,
“wires”: [
[
“32932baa6238b437”,
“a9ebbf3cb68e7d11”
]
]
},
{
“id”: “32932baa6238b437”,
“type”: “debug”,
“z”: “c6138a722672e3a4”,
“name”: “debug 4”,
“active”: false,
“tosidebar”: true,
“console”: false,
“tostatus”: false,
“complete”: “false”,
“statusVal”: “”,
“statusType”: “auto”,
“x”: 500,
“y”: 520,
“wires”:
},
{
“id”: “a9ebbf3cb68e7d11”,
“type”: “http request”,
“z”: “c6138a722672e3a4”,
“name”: “”,
“method”: “GET”,
“ret”: “txt”,
“paytoqs”: false,
“url”: “”,
“persist”: false,
“insecureHTTPParser”: false,
“authType”: “”,
“senderr”: false,
“headers”: ,
“x”: 530,
“y”: 660,
“wires”: [
[
“52f343d7439835e4”
]
]
},
{
“id”: “52f343d7439835e4”,
“type”: “debug”,
“z”: “c6138a722672e3a4”,
“name”: “debug 3”,
“active”: false,
“tosidebar”: true,
“console”: false,
“tostatus”: false,
“complete”: “false”,
“statusVal”: “”,
“statusType”: “auto”,
“x”: 700,
“y”: 600,
“wires”:
},
{
“id”: “dd982556fd6df3e9”,
“type”: “comment”,
“z”: “c6138a722672e3a4”,
“name”: “”,
“info”: “”,
“x”: 120,
“y”: 80,
“wires”:
},
{
“id”: “e41a6598636e7524”,
“type”: “comment”,
“z”: “c6138a722672e3a4”,
“name”: “”,
“info”: “”,
“x”: 120,
“y”: 140,
“wires”:
},
{
“id”: “7c8354003f1ad7b9”,
“type”: “global-config”,
“env”: ,
“modules”: {
“node-red-contrib-shelly”: “11.10.1”,
“@victronenergy/node-red-contrib-victron”: “1.6.64”
}
}
]
Perhaps there is a way to do this, and someone can help me.
Many thanks,
Wolfgang



