Skip to Content
Automation Feature

Automation Feature

Beta Feature

The Automations feature is currently in BETA. The database write action is available now, while Telegram notifications and Webhook actions are coming soon.

The PxServ Automation Feature lets you monitor your project data with real-time conditions and automatically run actions when a condition matches (or when it does not). Without writing complex control logic on your device or setting up a separate server, you can create Condition -> When Matched -> Otherwise rules directly from the dashboard.

  • Purpose: monitor project data with conditions and automatically run actions or device commands.
  • Location: Features -> Automations in the project dashboard.
  • How it triggers: with a watched database key (key), a comparison operator (=, !=, >, <, >=, <=), and a threshold value (value).
  • How it runs: executes When Matched actions when the condition is met, and optional Otherwise actions when it is not.

When should you use it?

Automations are ideal when you want to automatically update another database value, switch a relay or fan on/off, or let multiple devices react to each other whenever a sensor reading crosses a limit.

Automations are ideal when:

  • You want to automatically change a fan, pump, or alarm state when temperature, humidity, soil moisture, or water level crosses a limit.
  • You want to adjust threshold values directly from the PxServ dashboard without plugging in a cable and re-uploading code to the device.
  • You want sensor data sent by one device to trigger another device in the same project.
  • You want to turn a system on when a condition matches (When Matched) and automatically turn it back off when readings return to normal (Otherwise).

Use automations carefully when:

  • The watched key in the condition and the key updated by the action are the same, which can cause the automation to re-trigger itself continuously.
  • Numeric comparisons (>, <, >=, <=) are used—values sent from the device should be plain numbers in string format (for example, "24.5").
  • The device controls a critical physical load (such as a high-power heater or water pump); always keep basic safety limits on the device alongside cloud automations.

How does the automation flow work?

An automation rule on PxServ runs through the following steps:

  1. A device or application sends data to the PxServ database (for example, writing "32" to temperature).
  2. PxServ checks the automation rules watching that key.
  3. If the condition is met, the actions under When Matched run.
  4. If the condition is not met and Otherwise actions are defined, those actions run instead.
  5. The updated value (for example, fan_status) is read by devices or applications and applied.

Core Concepts

ConceptDescription
Automation NameThe name that helps you easily recognize the rule in the dashboard (for example, High temperature fan control).
ConditionThe rule that decides when the automation should run (for example, temperature > 30).
Database KeyThe name of the data you want to watch (for example, temperature, humidity, soil_moisture). The dashboard automatically suggests existing keys.
OperatorHow the incoming data is compared against the target value (=, !=, >, <, >=, <=).
When MatchedThe actions that run automatically when the condition is met.
OtherwiseOptional actions that run when the condition is not met (for example, turning the fan off when temperature returns to normal).
Dynamic ValuesLets you automatically use the incoming data’s name ({key}) or current value ({value}) inside an action instead of writing a fixed value.

Supported Operators

You can use the following 6 comparison operators in the condition section:

OperatorDescriptionExample Condition
=Equalsdoor_status = 1
!=Not equalsmode != manual
>Greater thantemperature > 30
<Less thansoil_moisture < 25
>=Greater than or equal tohumidity >= 70
<=Less than or equal tobattery_level <= 15

Action Types

You can add one or more actions to run under When Matched or Otherwise:

Action TypeStatusTarget FieldPayload / Value FieldDescription
Save value to databaseActiveDestination keyValue to saveWrites a fixed or dynamic value to the specified key in the project database.
Send Telegram messageComing soonChat ID / channelTelegram messageSends an automated alert message to the specified Telegram chat or channel.
Call webhookComing soonWebhook URLJSON payloadSends an HTTP request with event data to an external web service.

Using dynamic values ({key} and {value})

When an action runs, you do not have to write a fixed value (1, 0, on) every time. You can also directly insert the name or latest value of the data that triggered the automation:

  • {key}: inserts the name of the data key that triggered the automation.
  • {value}: inserts the current value of the data that triggered the automation.

For example:

  • Destination key: last_alert
  • Value to save: {key} reached critical level: {value}

If the condition is temperature > 30 and a device sends "34.2", the last_alert key is automatically updated to "temperature reached critical level: 34.2".

Creating an Automation Step by Step

Follow these steps to create a new automation in the PxServ dashboard:

  1. Open Features -> Automations from your project sidebar.
  2. Click New automation in the top-right corner (or Create automation if you have no rules yet).
  3. Enter a descriptive Automation name (for example, Greenhouse Fan Control).
  4. Under Condition:
    • Database key: enter or select the key you want to monitor (if the key already exists in your database, its Current value is displayed below the input).
    • Operator: choose one of =, !=, >, <, >=, or <=.
    • Value: enter the target threshold value (for example, 30).
  5. Under When Matched:
    • Action: select Save value to database.
    • Destination key: enter the key to update (for example, fan_status).
    • Value to save: enter the value to write (for example, 1).
    • Click + Add action if you want to run additional actions when the same condition matches.
  6. Optionally, under Otherwise, click + Add action to define what should happen when the condition does not match (for example, writing 0 to fan_status).
  7. Click Save automation to activate the rule.
Infinite loop warning

Avoid using the same key for both the watched Database key and the action’s Destination key. For example, writing back to temperature inside a temperature > 20 rule can re-trigger the automation repeatedly. Keep sensor inputs (e.g. temperature) and control outputs (e.g. fan_status) in separate keys.

Example Scenario and Device Code

In the following scenario, an ESP32 sends ambient temperature to the temperature key and reads fan_status to control a fan relay.

1. Dashboard automation rule

  • Automation name: High Temperature Fan Automation
  • Condition: temperature > 28
  • When Matched: Save value to database -> Destination key: fan_status, Value to save: 1
  • Otherwise: Save value to database -> Destination key: fan_status, Value to save: 0

2. Arduino (ESP32 / ESP8266) example code

#include <PxServ.h> #define FAN_RELAY_PIN 5 PxServ client("your_pxserv_project_api_key"); void setup() { Serial.begin(115200); pinMode(FAN_RELAY_PIN, OUTPUT); PxServ::connectWifi("wifi_ssid", "wifi_password"); } void loop() { // 1. Send sensor data to PxServ (monitored by the automation) float currentTemp = 29.4; // Example sensor reading client.setData("temperature", String(currentTemp)); // 2. Read the destination key updated by the automation and drive the relay PxServ::Callback fanState = client.getData("fan_status"); if (fanState.status == 200) { digitalWrite(FAN_RELAY_PIN, fanState.data == "1" ? HIGH : LOW); } delay(5000); }

3. Listening in real time with JavaScript / TypeScript

When an automation updates a destination key, applications connected through Socket.IO or the JavaScript/TypeScript SDK receive the update immediately:

import { io } from "socket.io-client"; const socket = io("https://api.pxserv.net", { auth: { apiKey: process.env.PXSERV_API_KEY, }, }); socket.on("setData", (data) => { if (data.key === "fan_status") { console.log("Automation updated fan status:", data.value); } });

Tips

  • Separate input and output keys: use keys like temperature or humidity for measurement data, and separate keys like fan_status, pump_status, or alarm_status for automation outputs.
  • Use the Otherwise section: if your rule writes 1 when a threshold is exceeded, add an Otherwise action that writes 0 so the state resets automatically when readings return to normal.
  • Send consistent numeric strings: when using numeric operators (>, <, >=, <=), send plain numeric strings without unit symbols ("25.4" instead of "25.4 °C").

Troubleshooting

The automation cannot be saved

  • Make sure the automation name, database key, condition value, and all action target/value fields are filled in. Empty fields prevent saving.

The destination key does not update when the condition matches

  • Verify that the key name sent by the device matches the Database key in the automation (key names are case-sensitive).
  • For numeric comparisons, make sure the published value does not include letters or unit symbols.
  • Check the Automations list to confirm the rule was saved with the expected operator and threshold value.

The device does not apply the updated action value

  • Confirm that the key read by the device (getData("fan_status")) matches the Destination key configured in the automation.
  • Ensure the API key used by the device has read permission.

Short Summary

The PxServ Automation Feature evaluates incoming device data against cloud-side conditions and automatically updates target database keys. With the Condition, When Matched, and Otherwise structure, you can create flexible control scenarios without modifying device code.

Related documentation:

Last updated