From fe9f7e81e980f15b4f2212b071046f1eda96c0c0 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Tue, 5 Jan 2021 22:28:57 +0530 Subject: [PATCH] Add Smart Lights to SmartHome --- src/plugins/SmartHome.js | 17 +++++++++++++++-- src/sample.config.js | 3 ++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/plugins/SmartHome.js b/src/plugins/SmartHome.js index 0e86567..fdc3102 100644 --- a/src/plugins/SmartHome.js +++ b/src/plugins/SmartHome.js @@ -1,8 +1,9 @@ import React, {useState, useEffect} from "react"; import PropTypes from "prop-types"; import { Box, Button } from "grommet"; +import axios from "axios"; -import { CAMERA_URL } from "../config"; +import { CAMERA_URL, LIGHTS_URL } from "../config"; function SmartHome(props) { const [ idx, setIdx ] = useState(0); @@ -10,6 +11,12 @@ function SmartHome(props) { const id = setInterval(() => setIdx(i => i + 1), 20); return () => clearInterval(id); }, []); + function turnOn() { + axios.get(`${LIGHTS_URL}/on`); + } + function turnOff() { + axios.get(`${LIGHTS_URL}/off`); + } return ( + +