signalk-starlink icon indicating copy to clipboard operation
signalk-starlink copied to clipboard

Feature Request: Add ability to put starlink status over NMEA 2000 as a switch.

Open netgoof opened this issue 7 months ago • 1 comments

I took a copy of your plugin a long while back and added the ability to send the status of the dish as a switch (on/off). That way we could see the status as green/red on our maretron screen. Would you be opposed to adding it to the main branch?

It would be something like below. The code sends it out for switch instance 2. That should probably be configurable.

const SWITCHORDER = 'electrical.switches.bank.2.1.order' const SWITCHSTATE = 'electrical.switches.bank.2.1.state':

function sendState() {
    //send status update 127501
    const pgn = {
        pgn: 127501,
        "Instance": 2
    }

    pgn[`Indicator${1}`] = dishyStatus === "online" ? 'On' : 'Off'

    app.debug('sending pgn %j', pgn)
    app.emit('nmea2000JsonOut', pgn)

    let values;

    values = [
        {
            path: `${SWITCHORDER}`,
            value: 1
        },
        {
            path: `${SWITCHSTATE}`,
            value: dishyStatus === "online" ? 1 : 0
        }
    ];

    app.handleMessage('signalk-starlink', {
        updates: [
            {
                values: values
            }
        ]
    });

}

Maretron

netgoof avatar Jul 15 '24 23:07 netgoof