-
Notifications
You must be signed in to change notification settings - Fork 15
Home Automation
avanc edited this page Oct 14, 2024
·
3 revisions
As the webui is just interfacing with the device using HTTP POST requests, all functionalities can also be accessed your home automation.
Edit HA configuration.yaml:
rest_command:
set_photos_display:
url: "http://<IP-address>/display"
method: "POST"
content_type: "application/x-www-form-urlencoded"
payload: "action={{ action }}"
and add the following to your automation to turn display on:
action:
- service: rest_command.set_photos_display
data:
action: "on" # activate
or the following to turn display off:
action:
- service: rest_command.set_photos_display
data:
action: "off" # deactivate
For switching the display on and off, photOS expects an HTTP POST request to http://<photos-ip>/display
with the content action=on
and action=off
.
Doing a http request from Node-Red is very simple:
Please note that http-request node does JSON encoding of the payload by default. As photOS requires form data, a special header has to be added.
Below is the flow code:
[
{
"id": "56eeda39.921cb4",
"type": "tab",
"label": "photOS",
"disabled": false,
"info": ""
},
{
"id": "989c41eb.3202e",
"type": "inject",
"z": "56eeda39.921cb4",
"name": "off",
"topic": "",
"payload": "{\"action\":\"off\"}",
"payloadType": "json",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 130,
"y": 120,
"wires": [
[
"3ac57440.0b7b04"
]
]
},
{
"id": "95ee5064.b80798",
"type": "http request",
"z": "56eeda39.921cb4",
"name": "",
"method": "POST",
"ret": "txt",
"url": "http://<photos-ip>/display",
"tls": "",
"x": 530,
"y": 140,
"wires": [
[]
]
},
{
"id": "21aa6236.91b73e",
"type": "inject",
"z": "56eeda39.921cb4",
"name": "on",
"topic": "",
"payload": "{\"action\":\"on\"}",
"payloadType": "json",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 130,
"y": 160,
"wires": [
[
"3ac57440.0b7b04"
]
]
},
{
"id": "3ac57440.0b7b04",
"type": "function",
"z": "56eeda39.921cb4",
"name": "Add necessary header",
"func": "msg.headers = {\n'content-type':'application/x-www-form-urlencoded'\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 320,
"y": 140,
"wires": [
[
"95ee5064.b80798"
]
]
}
]