WiFi/HTTP and WiFi/MQTT control, DoorOpen and DoorSwitch (manual)
|
It is possible to integrate
DoorOpen or
DoorSwitch in any existing automation; you can do this over WiFi, either using HTTP or MQTT.
MQTT is supported by most hubs and / or
Home Assistants and there are pretty much always tricks to use it with those that don't directly support it.
WiFi connection for HTTP <<<
From your device (smartphone, PC, Mac, Linux, microcontroller) you can connect to the internal WiFi generated by DoorOpen / DoorSwitch (therefore without the need for the Internet), or you can connect DoorOpen / DoorSwitch to the home / office / laboratory WiFi in the Settings, as explained in the
quick manual for DoorOpen.
If you connect to the home / work / etc WiFi and use HTTP operation, it may be advisable for convenience to fix the DO / DS IP within the configuration options of your router (typically this can be done in a router menu type DHCP utilites; let's assume it's 192.168.1.4).
WiFi/HTTP commands (c)
The commands can be sent via an HTTP GET request made to:
- or something like http://192.168.1.20/c (if you have connected DoorOpen to your WiFi; the IP that we have exemplified with 192.168.1.20 is assigned by the router, DoorOpen / DoorSwitch writes it at the bottom of all the pages once connected; and if desired, it can be fixed in the configuration options of the your router, so it doesn't change).
You can send commands to DoorOpen / DoorSwitch in the classic format of GET requests (and then using "&" to insert multiple parameters and separate them, and using the classic "URLencode" to handle non-alphanumeric characters).
The available commands are below.
Example: http://wfeasy.com/c?cm=ON1 opens the door
If you use IP, it will be (for example) http://192.168.1.4/c?cm=ON1 and so on.
All this can be tried for example by connecting to the internal WiFi with a PC and writing these things on the browser bar (eg Safari, Chrome, Firefox, Explorer); obviously you can also do it with Mac, Raspberry or other devices ...
Command pw=
If the use of a password is enabled, it must be added to any request, by putting it in pw
Examples:
http://wfeasy.com/c?cm=STATE&pw=a8d7f6k5
it returns status information, but only if the password is a8d7f6k5 - if the pass is not correct, it does nothing.
Command cm=
It allows all actions allowed by MQTT commands, with the same commands (see below)
Example:
http://wfeasy.com/c?cm=STATE
returns the status of
DoorOpen /
DoorSwitch2, which includes the status of the relays (ON / OFF) and the status of the 2 inputs (for limit switches / photocells / infrared etc.) F1 F2, in JSON format (identical to STATE for MQTT)
http://wfeasy.com/c?cm=ON1
turns ON the switch 1.
Home Page commands (d=)
There are also some other basic commands from the Home Page (i.e. without / c):
http://wfeasy.com/?d=3 or http://192.168.1.4/?d=3 it commands opening (or ON) and possibly also closing if it is a garage or gate with a single button Command (where the IP assigned to DoorOpen must be replaced at 192.168.1.4); if closing/OFF is enabled it can be done with d=33
For
DoorSwitch2, for the second relay, you can use d=4 (open/ON/close) and d=34 (off/close)
WiFi connection and MQTT <<<
For MQTT you need an external WiFi connection, it is not enough to connect to the internal WiFi generated by DoorOpen / DoorSwitch, but you must connect to a WiFi that has access to an MQTT Broker; for example, you can connect to the laboratory / home / office WiFi or to the
ControlHUB WiFi if its internal broker is enabled. This is done from the Settings, as explained in the
quick manual for DoorOpen.
In Settings and MQTT you will insert:
- the IP or name of the server where the MQTT Broker runs (if left blank, DoorOpen / DoorSwitch will not use MQTT)
- possibly username and password of the Broker, if needed
DoorOpen / DoorSwitch shows besides the MQTT entry the name of the default topics used for the publication/out and the topic where to receive commands; you can specify a prefix here if you need it (some free brokers require your topics to start with for example yourusername/feeds/ or something like that), otherwise the "prefix" boxes must be left blank.
Then click Save and
DoorOpen/
DoorSwitch will connect, and after a few seconds it will start working in MQTT as well. If the connection is OK it will write OK after the word MQTT; and immediately on the same page it shows the names of the Topics to use to control
DoorOpen/
DoorSwitch and to receive DoorOpen / DoorSwitch messages.
For safety, as already mentioned, since it is about controlling a lock, we suggest using a Broker installed on your device (PC or other; you can download and install and run a Broker program such as Mosquitto even on a simple Windows PC; or you can use the
ControlHUB internal broker) and NOT to use external clouds or external free brokers because if you do that you are potentially putting the opening of your door, garage or gate in the hands of strangers ... Watch out!
However, it can be convenient to use these things if you control a light bulb or less important things with the DoorSwitch ...
Response / Publication Topic
When it responds to commands, or when it means something,
DoorOpen/
DoorSwitch publishes a message on the
do-o-name topic (where Name is the name you gave the device a little further down in the Settings).
A Home Assistant or an automation must listen to this Topic in order to read what
DoorOpen/
DoorSwitch says.
The response / payload is a text, eg. {"ON1"} after Command ON1 has been given (this format with braces is called JSON).
Upon power-up, as soon as it is connected to MQTT,
DoorOpen/
DoorSwitch publishes its Status on this topic (as if it replied to STATE).
Topic for Command / Listening
DoorOpen/
DoorSwitch always listens on topic
do-c-name (where Name is the name you gave your device in Settings). In short, to command it, the hub / assistant / automation (or if you want, you "by hand" through MQTT message sending programs) must publish on this Command Topic a message/payload like these:
ON1 or {"ON1"}
|
opens the door / garage / gate or activates the switch (with pulse or with permanent ON of the relay, depending on what is chosen in the drop-down menu Opening pulse) in DoorSwitch2 this opens the door / garage / gate or operates switch 1
|
OFF1 or {"OFF1"}
|
turns switch 1 off (obviously useless if pulse mode is set)
|
ON2 or {"ON2"}
|
in DoorSwitch2, opens the door / garage / gate or activates switch 2 (with pulse or permanent ON of the relay, depending on what is chosen in the Pulse opening drop-down menu)
|
OFF2 or {"OFF2"}
|
turns switch 2 off (see OFF1)
|
STATE1R or {"STATE1R"}
|
returns the state of relay/switch 1 via the response Topic
|
STATE1F or {"STATE1F"}
|
returns the status of the limit switch 1 / input 1 (where present)
|
STATE2R or {"STATE2R"}
|
returns the state of relay/switch 2 via the response Topic (if available)
|
STATE2F or {"STATE2F"}
|
returns the status of the limit switch 1 / input 1 (where present)
|
STATE or {"STATE"}
|
returns the full Status
|
As is known, for MQTT a local or remote system (accessible via the Internet) is required to act as a Broker.
If you are doing an automation with
DoorOpen/
DoorSwitch you can simplify, and avoid this need by using simple HTTP / Web commands instead of MQTT, explained at the top of the page.
Here are the quick manuals for some other products:
(C) 2022 VisualVision