Developing IoT Automation Scenarios (if-then) in a Mobile App

Devices work, but scenarios fail: commands are duplicated, states diverge, and automation runs on its own. We design and implement IoT automation scenarios in a mobile app turnkey — from logic to regulations. Managed automation reduces manual operations and eliminates a class of failures related to desynchronization.

Development and support of all types of mobile applications:

Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Our competencies:

Frequently Asked Questions

Latest works

  • Development of a mobile application for FEEDME
    Development of a mobile application for FEEDME
    971
  • Development of a mobile application for XOOMER
    Development of a mobile application for XOOMER
    868
  • Development of a mobile application for RHL
    Development of a mobile application for RHL
    1288
  • Development of a mobile application for ZIPPY
    Development of a mobile application for ZIPPY
    1143
  • Development of a mobile application for Affhome
    Development of a mobile application for Affhome
    1076
  • Development of a mobile application for the FLAVORS company
    Development of a mobile application for the FLAVORS company
    677

IoT automation scenarios: where logic breaks in the app

An automation scenario is a rule like "if the motion sensor triggers after sunset, turn on the hallway light for 3 minutes." In the app it looks like a couple of toggles, but behind them stands a distributed system: device, gateway, cloud, mobile client.

Automation logic breaks not in the interface but at the junctions between them — and the user sees "the scenario didn't fire," even though each part is individually working.

The first class of failures is device state desync. The app shows "off" because the last confirmation arrived before the relay physically switched, and the next command has already gone into the queue.

If the client doesn't reconcile the actual state with the expected one and doesn't request the current status after a pause, the interface lives in its own reality: the user taps "on," the device is already on, and the command is ignored as a duplicate.

The second is lost commands under unstable connectivity. The mobile client sent a request, the app was backgrounded, the network dropped for half a second — and the command never arrived, while the sender never found out.

This is where idempotency with an operation ID and confirmed redelivery come in: the command is either applied exactly once or returns a clear error instead of silently vanishing.

The third and most insidious is condition conflict. Two scenarios lay claim to the same device: one turns the light on by motion, the other turns it off on a schedule.

Without an explicit priority and a repeat-suppression window, the device starts flickering, and the user loses trust in automation.

We work through such chains at the logic design stage — describing priorities, locks, and behavior on simultaneous triggering, so that a scenario failure is predictable rather than random.

What Managed Automation Delivers: The Effect in Numbers

Managed automation differs from a "checkbox in the app" in that its effect is measurable.

IoT automation scenarios in a mobile app run on top of local rules on the device and server-side rules, and the difference between them is visible precisely in the metrics: response time, the share of lost commands, the number of failures over a long horizon.

Response Time

A local rule like "if the opening sensor triggers — turn on the light" executes on the device or hub itself, without a round trip to the cloud.

This eliminates network latency: the command doesn't wait for a server response and doesn't depend on channel quality at the moment of the event.

In practice, a scenario that previously triggered with a noticeable pause starts executing almost instantly, and behavior remains predictable even when connectivity degrades.

Lost Commands and Stability

The main source of losses is the gap between issuing a command and confirming its delivery. We design the exchange so that every command has an identifier and a confirmation, and a retry on failure doesn't lead to double execution.

This eliminates an entire class of failures: "the scenario triggered twice," "the command went nowhere," "the device was left in an intermediate state." The share of lost commands drops to isolated cases, and they are visible in the logs rather than surfacing as a user complaint.

Eliminated Class of Failures

We separately close out rule conflicts: when two scenarios claim the same device, the priority must be explicit rather than depend on load order.

Plus state monitoring — if a device is unavailable, the scenario doesn't "hang" but transitions to a clear status with a notification. This way, automation reliability stops being a matter of luck: system behavior is reproducible, and failures are localized via the log.

To avoid being unfounded: we rely on proven automation platforms, including Home Assistant, and bring their logic into the mobile interface — the user sees the same rules that execute on the device.

Describe your scenarios — we'll come back with an assessment and a plan where the metrics are fixed before the start.

Scenario execution modes: local, cloud, hybrid

The execution mode determines where the decision to trigger a rule is made: on the device itself or in a cloud service. This affects the trigger latency, the behavior when connectivity is lost, and the amount of logic that can be implemented at all. Below are three options that are realistically chosen between during design.

Option When it fits Limitations
Local execution Simple "sensor → relay" rules that are critical to trigger latency: light, water, access Logic is limited by device resources; no history and no scenarios spanning different nodes
Cloud automation Complex chains involving multiple devices, schedules, notifications, integrations Depends on the communication channel: if the internet goes down, rules do not trigger
Hybrid mode Both fast local reactions and complex logic on top of them are needed Requires rule synchronization and conflict resolution between the layers

Local execution keeps the scenario inside the device: the rule "if there is a leak — close the valve" executes in tens of milliseconds and does not depend on the state of the network.

But such a loop knows nothing about other nodes and does not store history, so it is used only to cover basic offline scenarios.

Cloud automation removes the limits on complexity: conditions across multiple devices, schedules, geofences, notifications. The price for this is trigger latency equal to the time it takes for a command to travel to the service and back, and complete dependence on the channel.

Hybrid mode separates responsibilities: critical rules stay on the device, while complex scenarios go to the cloud. If connectivity is lost, the local loop keeps working, and after it is restored the states are synchronized.

This is the scheme we adopt by default — it provides predictable behavior and does not tie fault tolerance to a single channel.

How we design and implement IoT automation scenarios

Work on IoT automation scenarios begins not with code, but with an inventory of what is already installed at your sites. The mobile app here is a control panel: it sends commands, displays status, and stores rules, but the logic lives on the devices and in the cloud.

Therefore, the first step is to understand which devices and protocols already exist, what they can send and receive, and where a gateway intermediary is needed.

Next, we design the scenario scheme as a state graph: trigger, condition, action, failure handling. This allows us to see conflicts in advance — for example, when two rules simultaneously control the same relay — and avoid encountering them on a live site.

  1. Audit of devices and protocols. We compile a list of equipment, firmware versions, available commands, and telemetry. We record what is controlled directly and what requires an intermediate layer.
  2. Scenario scheme. We describe the rules in an "if — then" format, including conditions based on time, sensors, and the state of other devices. We separately work out priorities and protection against simultaneous triggering.
  3. Rule configuration. We transfer the scheme into the app and cloud engine configuration, bind triggers to real device identifiers, and set up notifications and logging.
  4. Logic verification. We run the scenarios on a test loop: we simulate communication loss, false sensor triggers, and manual intervention. We observe how a rule behaves during network loss and whether the state recovers after a restart.
  5. On-site debugging. We check behavior on real equipment, measure the delay between event and action, and eliminate unnecessary triggers.
  6. Documentation handover. We provide the scenario scheme, regulations for adding new rules, and instructions for diagnosing typical failures.

This sequence closes the main risk — a scenario that works on the test bench and breaks on site. The scheme and regulations remain with you, so your team can add new rules without us.

Configurations, schemas, and regulations: what remains with the customer

The project is delivered not as a demo on a call, but as a set of artifacts that your team can use to evolve the system without us. Below is what is committed to the repository and handed over by acceptance report.

  • Automation scenario configurations — declarative "if — then" rule files: trigger, condition, action, priority, and conflict behavior. They are edited without rebuilding the application and are checked for duplicates and cycles before publication.
  • Device and capability map — a registry of models, supported commands, units of measurement, and constraints. A new device is connected using this map, not by modifying code for each case.
  • Access policies — a role matrix: who creates a scenario, who only runs it, who sees telemetry. Service accounts and key lifetimes are described separately.
  • Rule execution schema — where the condition is evaluated, how loss of connection to a device is handled, and what happens to a deferred action after a restart.
  • Operator instructions — how to enable, pause, and roll back a scenario, how to read the trigger log, and how to distinguish a false trigger from a device failure.
  • Maintenance regulations — the frequency of rule checks, the procedure for decommissioning a device, and the rules for archiving logs and updating the device map.
  • Change log and rollback — versioning of configurations: you can see who changed a rule and when, and there is a return to the previous working version.

The set is self-sufficient: a new engineer is onboarded to the project using it, not through chat history. If you already have some of the artifacts, we will fit into the current format.

Case: eliminating scenario desynchronization in a residential complex

What it was like before the intervention

A residential complex with 340 apartments: IoT automation scenarios (lights in entrances triggered by motion sensors, climate control on a schedule, an "left home" scenario that turns off outlets and water) were written in the app and sent to the gateway as-is.

Scenario desynchronization manifested inconsistently: a rule would trigger on one floor and stay silent on another, and some devices remained in the "on" state after a turn-off command.

The share of successful triggers held at 82%, and every third resident support request was not about broken hardware but about "the scenario didn't work."

What was changed

We moved scenario execution to a server-side queue with idempotent commands: the app stopped being the single source of truth, and each device's state is reconciled against an actual report rather than the last command sent.

We added a scenario run log indicating at which step and why a rule did not apply, plus automatic retry for commands not confirmed by the device.

We separately resolved the conflict of overlapping rules — priority and execution order are now set explicitly rather than by the order of creation in the interface.

What it became

The share of successful triggers grew from 82% to 99.4% on the same device fleet, without replacing hardware.

Recovery time after a gateway failure dropped from several hours of manual walkthroughs to 8 minutes — the queue itself replays unapplied commands when connectivity returns.

Resident requests about scenarios fell 6-fold in the first month, and the load on the support service shifted from handling complaints to scheduled checks.

This automation case demonstrated the main point: desynchronization almost always lives in the state model, not in the devices.

How does a local scenario differ from a cloud scenario?

A local scenario runs on the device itself or on a local hub: a rule such as "if the motion sensor triggered — turn on the light" is processed inside the apartment, without going out to the internet.

A cloud scenario lives on a server: the device sends an event to the cloud, the logic triggers there, and the command returns back to the actuator device.

The difference in the event's route determines everything else — response speed, behavior when the connection drops, and how much effort goes into maintenance.

Latency. For a local scenario, the "event → command" cycle fits within tens of milliseconds, because the signal never leaves the premises.

For a cloud scenario, the path is longer: two legs through the internet plus processing on the server — from hundreds of milliseconds to seconds, and this time fluctuates along with the quality of the channel.

For lights and sockets, the difference is imperceptible; for scenarios with leak sensors or door opening sensors, it is fundamental.

Autonomy. Local logic keeps working when the internet drops and when the server is unavailable — the devices are connected directly.

A cloud scenario in such a situation stops triggering entirely: if there is a connection to the server, the rules work; if it disappears, automation comes to a halt. If the site is critical, a local loop becomes mandatory, and the cloud becomes a supplement for complex analytics.

Supporting scenarios. Local rules need to be updated on each device or hub: an edit is replicated across the fleet, and compatibility depends on firmware.

Cloud scenarios are changed in one place and immediately applied to all sites, but they require a stable channel and well-designed state synchronization so that after a reboot a rule does not end up in an incorrect state.

In practice, the working scheme is a hybrid: we keep critical rules locally for the sake of autonomy, and scenario logic and analytics in the cloud for the sake of manageability.

Common technical concerns about IoT automation

The concerns are usually the same: will the logic work on the equipment already in place, won't automation turn into a security hole, will the system withstand the growth in the number of devices, and what happens when the rules have to be changed on the fly. Below are short answers to each point, as we give them at the design stage.

Will the scenarios work on devices that are already installed?

Yes, if the device has a software control interface — open or vendor-specific.

We build a compatibility layer: we bring different models and protocols to a unified device model, so the rule "if the leak sensor triggers — close the valve and send a notification" does not depend on whose valve is installed.

For equipment without software control, we offer a gateway or honestly say that the node cannot be automated.

How secure are automation scenarios?

The rule is executed on the service side, not in the app, so it cannot be swapped from a phone. Access is separated by roles: one user only runs scenarios, another edits and approves them.

Commands to devices are signed, and the log records who changed the logic and when — during an incident investigation, the entire chain is visible.

What happens when there are many times more devices?

The logic is stored declaratively and is not rewritten for each new device — adding a node is an entry in the registry, not a code edit. Execution scales horizontally, and rules are grouped by objects and zones, so the growth of the fleet does not turn into growth of manual work. We separately check that a mass triggering of one rule does not create an avalanche of commands.

How is fault tolerance and logic updating ensured?

Scenarios are versioned: a new version of a rule is published separately, and in case of an error, rollback to the previous one takes minutes. If communication with a device is lost, commands are queued and replayed when it is restored, rather than lost.

Logic updates happen without stopping the app — the user keeps working while the rules migrate to the new version.

Describe your fleet of devices and the processes you want to automate — we will come back with an assessment and a plan for the scenarios.

Let's discuss your automation task

To make the assessment of IoT automation scenarios substantive rather than a rough guess, the first call needs to cover your domain.

Tell us which devices and gateways are already installed at your sites, which channels they use to connect to the network, and what happens when connectivity is lost — the application architecture and the rule execution logic depend on this.

Next, we clarify how you envision the scenarios themselves: which conditions and actions need to be supported, whether schedules, geofences, sensor thresholds, and manual triggers are required.

Separately, we discuss where the logic runs — on the application side, in the cloud, or on the device itself — because this affects trigger latency, offline operation, and the volume of transmitted data.

  • List of devices, protocols, and gateways to integrate with
  • Scenario model: conditions, actions, priorities, rule conflicts
  • Requirements for offline operation and state synchronization after connectivity is restored
  • Roles and permissions: who creates scenarios, who only triggers them, who can view the log
  • Expected implementation timeline and phasing: what is needed for the first launch, what can come later
  • Load constraints: how many devices and scenarios must run simultaneously
  • Logging requirements: which events and errors need to be visible and how long to retain them

Based on the conversation, we prepare a technical specification describing the scenario model, the integration scheme, and a phased work plan. You receive an implementation timeline estimate and an understanding of which risks are addressed at the start and which can be deferred.

Describe your task in any convenient format — we will get back to you with an estimate and a work plan.