Skip to content

samgwd/Tether

Repository files navigation

Tether

A React Native smart home monitoring application that integrates with Tuya-powered IoT devices to provide activity tracking, routine monitoring, and wellness insights for elderly care and independent living.

Tech Stack: React Native 0.73 · Expo 50 · AWS Amplify · TypeScript
Platform: iOS
Licence: GPL v3

Why I Built This

My grandma lives independently over in Ireland, and as she's getting older, our family wanted peace of mind that everything was okay.

I built Tether between 2022-2024 so we could check in on her daily routines and know she's up and about, without needing to call every day or install cameras. The sensors quietly track normal activities like making a cup of tea, moving around the house, or opening the front door. If something seems off, we know to give her a ring.

It's a simple way to stay connected across the miles while respecting her independence.

Overview

Tether enables families and carers to remotely monitor the wellbeing of loved ones through smart home sensors. The app provides real-time activity logs, daily routine tracking, and summarised wellness data—all without intrusive cameras or microphones.

Key Features

  • Activity Monitoring — Real-time logs of sensor activity throughout the home
  • Routine Tracking — Customisable morning and evening routine checklists
  • Activity Graphs — Visual representation of daily activity patterns
  • Sleep Tracking — Monitor sleep duration and overnight activity
  • Wellness Summaries — Daily insights including time outside and bathroom visits
  • Multi-Home Support — Manage multiple properties from a single account
  • Device Management — Easy pairing and configuration of smart devices

Supported Devices

Device Connection Type Description
Motion Sensor Sub-device (Zigbee) Detects movement in rooms
Door Sensor Sub-device (Zigbee) Monitors door open/close events
Smart Plug Wi-Fi Tracks appliance usage
Smart Button Sub-device (Zigbee) Manual routine confirmation
Climate Sensor Wi-Fi Temperature and humidity monitoring
Hub/Gateway Wi-Fi Central hub for Zigbee sub-devices

Screenshots

Home Dashboard Activity Log Morning Routine Devices

Home Dashboard • Activity Log • Morning Routine • Devices

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                        Mobile App                               │
│                   (React Native / Expo)                         │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────────────┐   │
│  │   Screens    │  │  Components  │  │   Native Modules     │   │
│  │              │  │              │  │                      │   │
│  │ • Home       │  │ • Activity   │  │ • TuyaModule (iOS)   │   │
│  │ • Devices    │  │   Graph      │  │                      │   |
│  │ • Health     │  │ • Activity   │  │                      │   │
│  │ • Settings   │  │   Logs       │  │                      │   │
│  │ • Pairing    │  │ • Routine    │  │                      │   │
│  │              │  │   Overview   │  │                      │   │
│  └──────────────┘  └──────────────┘  └──────────────────────┘   │
│                                                                 │
└──────────────────────────────┬──────────────────────────────────┘
                               │
                               ▼
┌─────────────────────────────────────────────────────────────────┐
│                      AWS Amplify Backend                        │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────────────┐   │
│  │   Cognito    │  │ API Gateway  │  │     Lambda           │   │
│  │              │  │              │  │                      │   │
│  │ User Auth    │  │ REST APIs    │  │ • frontendDynamo     │   │
│  │ Email Sign-up│  │              │  │   Functions          │   │
│  │              │  │              │  │ • getDeviceData      │   │
│  └──────────────┘  └──────────────┘  │ • getUserId          │   │
│                                      │ • autoConfirmUser    │   │
│  ┌──────────────┐  ┌──────────────┐  └──────────────────────┘   │
│  │   DynamoDB   │  │      S3      │                             │
│  │              │  │              │                             │
│  │ • TetherData │  │ Profile      │                             │
│  │ • TetherUsers│  │ Pictures     │                             │
│  │              │  │              │                             │
│  └──────────────┘  └──────────────┘                             │
│                                                                 │
└──────────────────────────────┬──────────────────────────────────┘
                               │
                               ▼
┌─────────────────────────────────────────────────────────────────┐
│                     Tuya IoT Cloud                              │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│     Device Data  ◄──────────────────────►  Smart Devices        │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Getting Started

Platform Support

Note: This app has currently only been built and tested for iOS. The React Native codebase is cross-platform, and Android support could be added relatively easily by implementing the equivalent Tuya native module bridge in Java/Kotlin. The Android project structure is already in place.

Prerequisites

  • Node.js >= 18.x
  • npm or yarn
  • Expo CLI (npm install -g expo-cli)
  • Xcode (for iOS development, macOS only)
  • AWS CLI (for Amplify backend)
  • Tuya Developer Account with IoT Core SDK credentials (see Tuya Setup)

Installation

  1. Clone the repository

    git clone https://github.com/your-username/Tether-Tuya-React.git
    cd Tether-Tuya-React
  2. Install dependencies

    npm install
  3. Install iOS pods (macOS only)

    cd ios && pod install && cd ..
  4. Configure environment variables

    Create a .env file in the root directory:

    TUYA_APP_KEY=your_tuya_app_key
    TUYA_APP_SECRET=your_tuya_app_secret
  5. Configure AWS Amplify

    amplify init
    amplify push

    This will create the src/amplifyconfiguration.json file required for AWS services.

Running the App

Start the development server:

npm start

Run on iOS:

npm run ios

Note: This app uses native modules for Tuya SDK integration, so it requires a development build rather than Expo Go.

Project Structure

Tether-Tuya-React/
├── amplify/                    # AWS Amplify backend configuration
│   └── backend/
│       ├── api/               # API Gateway definitions
│       ├── auth/              # Cognito configuration
│       ├── function/          # Lambda functions
│       └── storage/           # DynamoDB & S3 configuration
├── android/                    # Android native code
├── assets/
│   ├── fonts/                 # OpenSans font family
│   ├── icons/                 # SVG icons
│   ├── images/                # Device images & diagrams
│   └── logo/                  # App logo
├── ios/                        # iOS native code
│   └── TetherTuyaReact/
│       └── RCTTuyaModule.m    # Tuya native module bridge
├── src/
│   ├── App.tsx                # Main app entry & navigation
│   ├── components/
│   │   ├── ActivityGraph.tsx  # Activity visualisation
│   │   ├── ActivityLogs.tsx   # Event timeline
│   │   ├── ActivitySummary.tsx
│   │   ├── CustomHeader.tsx   # Navigation header
│   │   ├── RoutineOverview.tsx
│   │   ├── RoutineRing.tsx    # Progress indicator
│   │   └── devicePairing/     # Pairing flow components
│   ├── hooks/
│   │   ├── AuthContext.tsx    # Authentication state
│   │   └── useTuyaEvents.ts   # Tuya event handling
│   ├── screens/
│   │   ├── Home.tsx           # Main dashboard
│   │   ├── DeviceList.tsx     # Device management
│   │   ├── Health.tsx         # Wellness insights
│   │   ├── Settings.tsx       # User settings
│   │   ├── PairDevice.tsx     # Device pairing
│   │   ├── CustomiseRoutines.tsx
│   │   └── ...
│   ├── styles/
│   │   └── GlobalStyles.js    # Theme & styling constants
│   └── utils/
│       ├── ApiGateway.ts      # AWS API calls
│       ├── DynamoDBService.ts # Database operations
│       ├── StorageService.ts  # AsyncStorage wrapper
│       └── GeneralUtils.ts    # Helper functions
├── app.json                    # Expo configuration
├── package.json
└── tsconfig.json

AWS Backend Services

Lambda Functions

Function Purpose
frontendDynamoFunctions CRUD operations for users, devices, homes, and activity data
getDeviceData Fetches device data from Tuya API and syncs to DynamoDB
getUserId Resolves user ID from email
autoConfirmUser Cognito trigger for auto-confirming users

DynamoDB Tables

Table Purpose
TetherData Activity logs, device events, and routine data
TetherUsers User profiles and home associations

S3 Buckets

Bucket Purpose
userProfilePictures Stores user/home profile images

Tuya IoT Platform Setup

To use this app, you'll need to create a Tuya developer account and configure an IoT project:

  1. Create a Tuya Developer Account

    • Visit Tuya IoT Platform and sign up for a free account
    • Complete the account verification process
  2. Create a Cloud Project

    • Navigate to CloudDevelopmentCreate Cloud Project
    • Select your data centre region (choose the one closest to your users)
    • Choose Smart Home as the industry
    • Select Custom development method
  3. Subscribe to API Services

    • In your project, go to API ServicesSubscribe
    • Enable the following APIs:
      • IoT Core — Device management and control
      • Smart Home Basic Service — Home and room management
      • Data Dashboard Service — Device data and statistics
  4. Get Your Credentials

    • Go to Project Overview to find your:
      • Access ID (App Key)
      • Access Secret (App Secret)
    • Add these to your .env file
  5. Configure the Mobile SDK

    • Navigate to AppSDK Development
    • Create a new app and configure:
      • Bundle ID (iOS): sam.greenwood.Tether-Tuya
      • Package Name (Android): com.vdsam.TetherTuyaReact
    • Download the security certificate files and place them in the appropriate native directories
  6. Link Your Tuya Devices

    • Ensure your Tuya-compatible devices are linked to your Tuya developer account
    • Devices can be added via the Tuya Smart or Smart Life apps during development

Important: Keep your Access ID and Access Secret confidential. Never commit these to version control.

Native Modules

The app includes a custom native module for iOS to interface with the Tuya SDK:

iOS (RCTTuyaModule.m)

  • User authentication
  • Home management
  • Device pairing
  • Device data fetching

Android

The Android native module has not yet been implemented. The project structure exists in android/app/src/main/java/, and implementing the Tuya SDK bridge would follow a similar pattern to the iOS implementation using the Tuya Android SDK.

Development

Type Checking

npx tsc --noEmit

Linting

npm run lint

Building for Production

iOS:

expo run:ios --configuration Release

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Licence

This project is licensed under the GNU General Public Licence v3.0 — see the LICENCE file for details.

You are free to use, modify, and distribute this software under the terms of the GPL v3. Any derivative works must also be licensed under GPL v3.

Acknowledgements

About

A React Native smart home monitoring application that integrates with Tuya-powered IoT devices to provide activity tracking, routine monitoring, and wellness insights for elderly care and independent living.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors