Controlling OpenHAB items from the Gnome desktop

Does anybody have used the guillotine extension with the Gnome Desktop :

https://gitlab.com/ente76/guillotine/

I am trying to use this extension to control a switch (that turns my printer on or off from my Linux desktop).

I wrote the following configuration:

{
    "settings": {
        "loglevel": "warning"
    },
    "menu": [
        {
            "type": "switch",
            "title": "Imprimante HP",
            "start": "curl -X POST --header \"Content-Type: text/plain\" --header \"Accept: application/json\" -d \"ON\" \"http://192.168.1.51:8080/rest/items/ZWaveNode019ZMNHYDSmartPlug_Switch\"",
            "stop": "curl -X POST --header \"Content-Type: text/plain\" --header \"Accept: application/json\" -d \"OFF\" \"http://192.168.1.51:8080/rest/items/ZWaveNode019ZMNHYDSmartPlug_Switch\"",
            "check": "curl -H POST --header \"Content-Type: text/plain\" \"http://192.168.1.51:8080/rest/items/ZWaveNode019ZMNHYDSmartPlug_Switch\" | jq .state | grep ON",
            "icon": "~/.local/share/icons/hp1212.png",
            "interval_s": 2
        },
        {
            "type": "separator"
        },
        {
            "type": "submenu",
            "title": "Guillotine",
            "icon": "guillotine-symbolic",
            "items": [
                {
                    "type": "command",
                    "title": "Configuration",
                    "command": "code .config/guillotine.json",
                    "icon": "preferences-other-symbolic",
                    "killOnDisable": false
                },
                {
                    "type": "command",
                    "title": "Log",
                    "command": "gnome-terminal -e 'journalctl -f GNOME_SHELL_EXTENSION_UUID=guillotine@fopdoodle.net'",
                    "instancing": "singleInstance",
                    "icon": "emblem-documents-symbolic",
                    "killOnDisable": false
                },
                {
                    "type": "command",
                    "title": "Log Gnome Shell",
                    "command": "gnome-terminal -e 'journalctl -f _COMM=gnome-shell' ",
                    "instancing": "singleInstance",
                    "icon": "emblem-documents-symbolic",
                    "killOnDisable": false
                }
            ]
        }
    ]
}

I successfully switch on my printer with the guillotine menu. But I am unable to switch it off. The check command seems not to work either (in the menu the switch appears to be off although it is on).

I tested these commands with the bash shell without any problem, including the returning code for the check.

Any suggestion to make it to work ? Or Is there another solution similar to guillotine that works fine with Gnome ? (version 45)

Well, after debugging the extension, I did not find the problem. I thus created a shell script to check the item status. The following configuration file works fine with my setup:

{
    "settings": {
        "loglevel": "warning"
    },
    "menu": [
        {
            "type": "switch",
            "title": "Imprimante HP",
            "start": "curl -X POST --header \"Content-Type: text/plain\" --header \"Accept: application/json\" -d \"ON\" \"http://192.168.1.51:8080/rest/items/ZWaveNode019ZMNHYDSmartPlug_Switch\"",
            "stop": "curl -X POST --header \"Content-Type: text/plain\" --header \"Accept: application/json\" -d \"OFF\" \"http://192.168.1.51:8080/rest/items/ZWaveNode019ZMNHYDSmartPlug_Switch\"",
            "check": "/home/XXXX/.local/bin/openhab-check-switch-item ZWaveNode019ZMNHYDSmartPlug_Switch",
            "icon": "~/.local/share/icons/hp1212.png",
            "interval_s": 2
        },
        {
            "type": "separator"
        },
        {
            "type": "submenu",
            "title": "Guillotine",
            "icon": "guillotine-symbolic",
            "items": [
                {
                    "type": "command",
                    "title": "Configuration",
                    "command": "code .config/guillotine.json",
                    "icon": "preferences-other-symbolic",
                    "killOnDisable": false
                },
                {
                    "type": "command",
                    "title": "Log",
                    "command": "gnome-terminal -e 'journalctl -f GNOME_SHELL_EXTENSION_UUID=guillotine@fopdoodle.net'",
                    "instancing": "singleInstance",
                    "icon": "emblem-documents-symbolic",
                    "killOnDisable": false
                },
                {
                    "type": "command",
                    "title": "Log Gnome Shell",
                    "command": "gnome-terminal -e 'journalctl -f _COMM=gnome-shell' ",
                    "instancing": "singleInstance",
                    "icon": "emblem-documents-symbolic",
                    "killOnDisable": false
                }
            ]
        }
    ]
}

You need to update XXX by your login name and add the following shell script

~/.local/bin/openhab-check-switch-item

curl -H POST --header "Content-Type: text/plain" "http://192.168.1.51:8080/rest/items/"$1 | jq .state | grep "ON"

And now, it works like a charm…