Commands are not related to an object on the screen but can get or set global properties or invoke system commands on the device.

Commands can be issued via the Serial commandline, telnet commandline or MQTT.

For MQTT, use the hasp/<nodename>/command topic with payload <keyword> <parameter(s)>

jsonl~

accepted parameters: json formatted lines

Create new objects or update properties of an existing object. When updating an existing object the obj property is not required and will be ignored.

Each line in the jsonl payload defines one object and has to be in the json format. If the payload exceeds the MQTT buffer it will be cut off to fit, don't send too many lines in a single payload, you can always sends another command.

Example:

jsonl {"obj":"btn","id":14,"x":120,"y":1,"w":30,"h":40,"text_font":"2","text":"Test","text_color":"gray","bg_opa":0,"border_width":0}

For more details see Pages and Objects

page~

accepted parameters: [0-12], prev or next

Switches the display to show the objects from a different page and return the page number in state/page.

Calling the page command without a parameter will return the value of the current page in state/page.

clearpage~

accepted parameters: [0-12] or all

Deletes all objects on a given page. If no page number is specified, it clears the current page. Use clearpage all to clear all objects on all pages.

To delete individual objects, you can issue the pxby.delete command.

dim~

accepted parameters: [0-255]

Sets the level of the backlight from 0 to 255, where 0 is off and 255 is full brightness.

Example

dim 127 sets the display to half the brightness.

This can be used in conjunction with the idle events, e.g. to dim the screen after a period of inactivity.

light~

accepted parameters: on/off, true/false, 0/1, yes/no

Switches the backlight on or off, independent of the set dim level. Turning the backlight on will restore the brightness to the previous dim level.

Example

light on Turn the backlight on

dim and light commands will work only if a Backlight GPIO pin is configured to the pin required to control the display backlight.

dim 0 and light 0 both turn off the screen, however, with dim 0 the touching will haven an effect on the objects beneath but not wake the screen, while with light 0 it will only wake the scren but will not affect the objects.

wakeup~

Clears the idle state of the device and publishes a state/idle = OFF status message.

It resets the idle counter as if a touch event occurred on the device. This is helpful e.g. when you want to wake up the display when an external event has occurred, like a PIR motion sensor.

moodlight~

An RGB moodlight can be controlled by configuring 3 GPIO pins as type Mood Red, Mood Green and Mood blue. These leds can then be controlled together using the moodlight command.

moodlight {"state":"off","color":"green"}
moodlight {"state":true,"color":"#ff00e7"}
moodlight {"color":12345}
moodlight {"state":"on","r":255,"g":0,"b":255}

Calling the moodlight command without parameters (or sending an empty payload to the hasp/<nodename>/command/moodlight topic) returns the current state:

    "hasp/<nodename>/state/moodlight" => {"state":"ON","color":{"r":222,"g":161,"b":222}}

The color is returned as individual channels.

output[x]~

where [x] is number of the group (1-14)

accepted parameters: 1 or 0, on or off, true or false

Sets all GPIO's assigned to the group number <x> in Configuration -> GPIO Configuration to "0" or "1".

GUI objects that are assigned to the same group using groupid during object creation will change state accordingly.

System Commands~

calibrate

Start on-screen touch calibration.

You need to issue a soft reboot command to save the new calibration settings. If you do a hard reset of the device, the calibration settings will be lost.

screenshot

Saves a picture of the current screen to the flash filesystem. You can retrieve it via http://<ip-address>/screenshot.bmp. This can be handy for bug reporting or documentation.

The previous screenshot is overwritten.

statusupdate

Reports the status of the MCU. The response will be posted to the state topic. For example:

    "hasp/<platename>/state/statusupdate" => {
        "node":"plate35",
        "idle":"short",
        "version":"0.5.1",
        "uptime":1813,
        "ssid":"network",
        "rssi":-63,
        "ip":"192.168.4.2",
        "heapFree":125820,
        "heapFrag":35,
        "core":"v3.3.5-1-g85c43024c",
        "canUpdate":"false",
        "page":1,
        "numPages":12,
        "tftDriver":"ST7789",
        "tftWidth":240,
        "tftHeight":320
    }

reboot or restart

Saves any changes in the configuration file and reboots the device.

!!! danger "update accepted parameters: [url]

Update the firmware from the url provided. Reboots when update was successful.

factoryreset

Clear the filesystem and EEPROM and reboot the device in its initial state.

Warning

There is no confirmation prompt nor an undo function!

Configuration Settings~

Wi-FI~

ssid

Set network name of the access point to connect to.

pass

Set the optional password for the access point to connect to.

MQTT~

nodename

Set the nodename of the device and mqtt topic for the node to hasp/<nodename>/

mqtthost

Set the IP address or nodename of the mqtt broker.

mqttport

Set the port of the mqtt broker.

mqttuser

Set the optional username for the mqtt broker.

mqttpass

Set the optional password for the mqtt broker.

config/submodule~

You can get or set the configuration of an openHASP submodule in json format. To get the configuration, use the command config/<submodule>. The result will be published to hasp/<nodename>/state/config. Passwords will be omitted from the result.

config/wifi
config/mqtt
config/http
config/mdns
config/hasp {"startdim":255}
config/gui
config/debug {"tele":300}
config/gpio

To update the configuration simply issue the same command config/<submodule> with updated json payload.