This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
KIP switch panel for Relay control (using GPIO)
#1
Hi!
Have been running OP4 for a while and want to expand functionality to also include Digital switching.  Starting with navigation, anchor and interior lights. 

Initial plan is as follows:
1. Add a page in KIP using widget boolean Control Panel
2. Select a SignalK path for the usage. E.g. update a value to 1 or 0. (this is were my first problem is)
3. The path can also be used by e.g. scripts.  E.g. turn off anchorlight at sunrise. 
3. Configure "actions" in Notifications to listen for changes to the patchs for light
4. "Actions" in Notifications to control GPIO high/low
5. GPIO will control optocouplers 
6. The other side of the octocouplers will have 12v and can control a normal 12v relay (when GPIO activates the optocoupler 12v will run through the OC and activate the relay)
7. Install the 12v relay to override the physical switch in the boat control panel (Bavaria 38AC with panel 201)
8. use the existing LED light next to switch (light up also when controlled from OpernPlotter even if physical switch is not used.)

My problems: 
How to select a path in KIP? I cannot find documentation for how to publish paths that KIP will list ?
What is the best way to set up simple logical sentences as "if anchorlight "on" and sunrise = "now" then turn off anchorlight.  nodeRed?

Have been testing different stuff this weekend, but I struggle to find an elegant way of doing it. Would like to use as most standard OpenPlotter functionality and awoid using PY scrips etc.  I know there are N2K relays (rather expensive) on the marked but why not create them using inexpensive 12v relays and GPIO? Or - should I stop trying to do this in Openplotter, and simply go for HomeAssistant on the OpenPlotter raspberry instead?

Anyone want to point me in the right direction for my winterproject ? Smile
Reply
#2
(2024-10-20, 09:04 PM)sisimonsen Wrote: Hi!
Have been running OP4 for a while and want to expand functionality to also include Digital switching.  Starting with navigation, anchor and interior lights. 

Initial plan is as follows:
1. Add a page in KIP using widget boolean Control Panel
2. Select a SignalK path for the usage. E.g. update a value to 1 or 0. (this is were my first problem is)
3. The path can also be used by e.g. scripts.  E.g. turn off anchorlight at sunrise. 
3. Configure "actions" in Notifications to listen for changes to the patchs for light
4. "Actions" in Notifications to control GPIO high/low
5. GPIO will control optocouplers 
6. The other side of the octocouplers will have 12v and can control a normal 12v relay (when GPIO activates the optocoupler 12v will run through the OC and activate the relay)
7. Install the 12v relay to override the physical switch in the boat control panel (Bavaria 38AC with panel 201)
8. use the existing LED light next to switch (light up also when controlled from OpernPlotter even if physical switch is not used.)

My problems: 
How to select a path in KIP? I cannot find documentation for how to publish paths that KIP will list ?
What is the best way to set up simple logical sentences as "if anchorlight "on" and sunrise = "now" then turn off anchorlight.  nodeRed?

Have been testing different stuff this weekend, but I struggle to find an elegant way of doing it. Would like to use as most standard OpenPlotter functionality and awoid using PY scrips etc.  I know there are N2K relays (rather expensive) on the marked but why not create them using inexpensive 12v relays and GPIO? Or - should I stop trying to do this in Openplotter, and simply go for HomeAssistant on the OpenPlotter raspberry instead?

Anyone want to point me in the right direction for my winterproject ? Smile


I use Node Red with 12v relays. Node red is pretty easy once you get the hang of it & it is very versatile.

I have a quad relay
   

Or there are single relays
   

   
I can turn "things" on or off automatically or from home via RealVNC
Pi5 8GB, NVME SSD 512GB, MacArthur hat, OP4,
Reply
#3
Many thanks for the tip! Quad relay really look like what I need. I also need to dive into the NodeRed world.
Btw, have you also managed to integrate these virtual switches into KIP?
Reply
#4
(2024-10-20, 10:48 PM)sisimonsen Wrote: Many thanks for the tip! Quad relay really look like what I need. I also need to dive into the NodeRed world.
Btw, have you also managed to integrate these virtual switches into KIP?


I haven't tried with KIP .......................yet!!
Pi5 8GB, NVME SSD 512GB, MacArthur hat, OP4,
Reply
#5
(2024-10-21, 12:47 AM)Lazzz Wrote:
(2024-10-20, 10:48 PM)sisimonsen Wrote: Many thanks for the tip! Quad relay really look like what I need. I also need to dive into the NodeRed world.
Btw, have you also managed to integrate these virtual switches into KIP?


I haven't tried with KIP .......................yet!!

Working on a very similar project although somewhat new to Node-Red  Ideally would like to turn my fridge on from a web app and tell it how many hours to stay on before I get to the boat. 

Would you be willing to share a high level description of your programming flow and/or screenshots?
Reply
#6
(2024-10-30, 12:30 AM)Working on a very similar project although somewhat new to Node-Red  Ideally would like to turn my fridge on from a web app and tell it how many hours to stay on before I get to the boat. Wrote: Would you be willing to share a high level description of your programming flow and/or screenshots?

I have sent you a message.

Some screenshots to give you an idea.

   

   

   

   
Pi5 8GB, NVME SSD 512GB, MacArthur hat, OP4,
Reply
#7
(2024-10-30, 12:30 AM)ProdigalSun24 Wrote: Working on a very similar project although somewhat new to Node-Red  Ideally would like to turn my fridge on from a web app and tell it how many hours to stay on before I get to the boat. 

Would you be willing to share a high level description of your programming flow and/or screenshots?

node red would almost certainly work, here's a timer i use to turn off the music playing on clementine on the Pi

Code:
[
    {
        "id": "b40aa325e1421527",
        "type": "inject",
        "z": "926cc4b9fdf71654",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0.2",
        "payloadType": "num",
        "x": 110,
        "y": 620,
        "wires": [
            [
                "f811bdc1ac3ce2e9"
            ]
        ]
    },
    {
        "id": "f811bdc1ac3ce2e9",
        "type": "function",
        "z": "926cc4b9fdf71654",
        "name": "timeout in minutes",
        "func": "msg.timeout = msg.payload * 60;\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 310,
        "y": 620,
        "wires": [
            [
                "cd5544f11bce38f7"
            ]
        ]
    },
    {
        "id": "b2297ed54a6ba7b8",
        "type": "ui_numeric",
        "z": "926cc4b9fdf71654",
        "name": "",
        "label": "Sleep time, minutes.",
        "tooltip": "",
        "group": "d4a061b3.6ae9d",
        "order": 2,
        "width": 0,
        "height": 0,
        "wrap": false,
        "passthru": true,
        "topic": "topic",
        "topicType": "msg",
        "format": "{{value}}",
        "min": 0,
        "max": "60",
        "step": 1,
        "className": "",
        "x": 140,
        "y": 660,
        "wires": [
            [
                "f811bdc1ac3ce2e9"
            ]
        ]
    },
    {
        "id": "fb66b363b8c6b6bf",
        "type": "ui_button",
        "z": "926cc4b9fdf71654",
        "name": "",
        "group": "d4a061b3.6ae9d",
        "order": 4,
        "width": "2",
        "height": "1",
        "passthru": false,
        "label": "Off",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "off",
        "payloadType": "str",
        "topic": "topic",
        "topicType": "msg",
        "x": 290,
        "y": 720,
        "wires": [
            [
                "cd5544f11bce38f7"
            ]
        ]
    },
    {
        "id": "394562b3f17398c3",
        "type": "ui_text",
        "z": "926cc4b9fdf71654",
        "group": "d4a061b3.6ae9d",
        "order": 1,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Time til turn off",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 560,
        "y": 680,
        "wires": []
    },
    {
        "id": "87ecd52b8e335ce1",
        "type": "function",
        "z": "926cc4b9fdf71654",
        "name": "minutesCountdown",
        "func": "var temp = msg.payload;\nvar minutes = parseInt(temp/60);\nvar seconds = temp - minutes*60;\nsecondszero = \"\";\nif (seconds<10){\n    secondszero = \"0\";\n}\n\nmsg.payload = minutes.toString() + \":\" + secondszero + seconds.toString();\nvar newMsg = { payload: minutes};\nnewMsg.topic = \"countdown\";\nreturn [msg, newMsg];",
        "outputs": 2,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 490,
        "y": 720,
        "wires": [
            [
                "394562b3f17398c3"
            ],
            []
        ]
    },
    {
        "id": "0d946ebebad153f2",
        "type": "exec",
        "z": "926cc4b9fdf71654",
        "command": " clementine --stop",
        "addpay": false,
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "winHide": false,
        "oldrc": false,
        "name": "",
        "x": 550,
        "y": 620,
        "wires": [
            [],
            [],
            []
        ]
    },
    {
        "id": "3b7e514dc144c9b0",
        "type": "ui_slider",
        "z": "926cc4b9fdf71654",
        "name": "",
        "label": "Sleep time",
        "tooltip": "",
        "group": "d4a061b3.6ae9d",
        "order": 3,
        "width": 0,
        "height": 0,
        "passthru": true,
        "outs": "end",
        "topic": "topic",
        "topicType": "msg",
        "min": 0,
        "max": "60",
        "step": 1,
        "className": "",
        "x": 130,
        "y": 700,
        "wires": [
            [
                "b2297ed54a6ba7b8"
            ]
        ]
    },
    {
        "id": "9f4419c9990cfc4a",
        "type": "comment",
        "z": "926cc4b9fdf71654",
        "name": "Sleep Timer",
        "info": "",
        "x": 110,
        "y": 580,
        "wires": []
    },
    {
        "id": "cd5544f11bce38f7",
        "type": "mytimeout",
        "z": "926cc4b9fdf71654",
        "name": "",
        "outtopic": "",
        "outsafe": "",
        "outwarning": "",
        "outunsafe": "off",
        "warning": "1",
        "timer": "3",
        "debug": false,
        "ndebug": false,
        "ignoreCase": false,
        "repeat": false,
        "again": false,
        "x": 350,
        "y": 660,
        "wires": [
            [
                "0d946ebebad153f2"
            ],
            [
                "87ecd52b8e335ce1"
            ]
        ]
    },
    {
        "id": "d4a061b3.6ae9d",
        "type": "ui_group",
        "name": "Auto Off",
        "tab": "e93ef2b0.f7b94",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "e93ef2b0.f7b94",
        "type": "ui_tab",
        "name": "Web Radio",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

Paste & play  Smile

You'll likely need to add a few nodes like the timer & maybe dashboard. 

flow -
[Image: QKMRU5H.png]

and the dash
[Image: QKKBJ3l.png]


Many ways to control, you should be able to vnc straight into the Pi desktop with realvnc. 

Or MQTT is another option, send a message to node red from the web. 

Then some way to control the fridge on/off.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)