Witam potrzebuje zautomatyzować podświetlenie tabletu, który służy jako wallpanel do HA.
[
{
"id": "7cb4e1420a0c4077",
"type": "tab",
"label": "Podświetlenie_tabletu",
"disabled": false,
"info": "",
"env": []
},
{
"id": "5e56ab05b656c991",
"type": "inject",
"z": "7cb4e1420a0c4077",
"name": "Co 10 minut",
"props": [
{
"p": "payload"
}
],
"repeat": "600",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{}",
"payloadType": "json",
"x": 140,
"y": 80,
"wires": [
[
"e3e41119e4202f16"
]
]
},
{
"id": "e3e41119e4202f16",
"type": "api-current-state",
"z": "7cb4e1420a0c4077",
"name": "Sprawdź zachód słońca",
"server": "f8e3f945.af0568",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "sun.sun",
"state_type": "str",
"blockInputOverrides": true,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "string",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "entity"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 290,
"y": 240,
"wires": [
[
"b917521123998984"
]
]
},
{
"id": "b917521123998984",
"type": "function",
"z": "7cb4e1420a0c4077",
"name": "Ustaw podświetlenie",
"func": "let brightness = 0;\n\nif (msg.payload === \"below_horizon\") {\n brightness = 0.25;\n} else {\n brightness = 0.5;\n}\n\nmsg.payload =\n `ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null kiosk@192.168.10.106 ` +\n `'sudo -u kiosk DISPLAY=:0 xrandr --output eDP-1 --brightness ${brightness}'`;\n\nnode.warn(\"Komenda wysyłana do exec: \" + msg.payload);\n\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 520,
"y": 80,
"wires": [
[
"5104ecd85c46462d"
]
]
},
{
"id": "5104ecd85c46462d",
"type": "exec",
"z": "7cb4e1420a0c4077",
"command": "/bin/bash",
"addpay": "payload",
"append": "which ssh",
"useSpawn": "false",
"timer": "",
"winHide": false,
"oldrc": false,
"name": "",
"x": 680,
"y": 240,
"wires": [
[],
[],
[]
]
},
{
"id": "f8e3f945.af0568",
"type": "server",
"name": "Home Assistant",
"addon": true
},
{
"id": "7c0b9f6fe3bd533c",
"type": "global-config",
"env": [],
"modules": {
"node-red-contrib-home-assistant-websocket": "0.80.3"
}
}
]
w exec dostaję error126. Komenda ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null kiosk@192.168.10.106 "sudo -u kiosk DISPLAY=:0 xrandr --output eDP-1 --brightness 0.5" z terminala HA działa ok.